Skip to content

Commit 5a7c881

Browse files
authored
Edit question popup, Speed Mode exit to course, disable Speed Mode button double clicking, non-scoring questions
2 parents 68af3fe + 8be9487 commit 5a7c881

File tree

5 files changed

+137
-31
lines changed

5 files changed

+137
-31
lines changed

admin/editor.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ <h1>Questions</h1>
119119
<label>As</label>
120120
</div>
121121
<div square hidden-spacer></div>
122+
<div square hidden-spacer></div>
122123
</div>
123124
</div>
124125
<div class="button-grid inputs">

admin/upload.html

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666

6767
button#paste,
6868
button#submit,
69+
button#next,
6970
button#exit,
7071
button#add-answers,
7172
button#remove-answers,
@@ -96,6 +97,7 @@
9697

9798
button#paste:hover,
9899
button#submit:hover,
100+
button#next:hover,
99101
button#exit:hover,
100102
button#add-answers:hover,
101103
button#remove-answers:hover,
@@ -116,6 +118,7 @@
116118
margin-top: 0.5em;
117119
}
118120

121+
button#next,
119122
button#exit {
120123
display: none;
121124
margin-top: 0.5em;
@@ -252,27 +255,31 @@
252255
const loader = uploader.querySelector('#loader');
253256
if (loader) loader.classList.remove('active');
254257
};
255-
async function exit() {
258+
async function next() {
256259
window.opener.postMessage('uploadSuccess', window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : ''));
257260
setTimeout(() => {
258261
window.close();
259262
}, 500);
260263
};
264+
async function exit() {
265+
window.opener.postMessage('exitToCourse', window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : ''));
266+
setTimeout(() => {
267+
window.close();
268+
}, 500);
269+
};
261270
function createUploader(event = null, number = null) {
262271
const isMultiple = document.querySelector('.uploader') && originalWindowWidth && originalWindowHeight && originalWindowY && originalWindowX;
263272
if (isMultiple) {
264273
window.resizeTo(originalWindowWidth, originalWindowHeight);
265274
window.moveTo(originalWindowX, originalWindowY);
266-
};
267-
if (isMultiple) {
268275
startingQuestionId++;
269276
startingQuestion = (number || startingQuestion).replace(/(\d+)([a-z]*)$/, (match, num, suffix) => {
270277
return !suffix ? (parseInt(num, 10) + 1).toString() : ((suffix === 'z') ? ((parseInt(num, 10) + 1) + 'a') : (num + String.fromCharCode(suffix.charCodeAt(0) + 1)));
271278
});
272279
}
280+
window.opener.postMessage(`${startingQuestionId};+;${startingQuestion}`, window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : ''));
273281
const uploaderQuestionId = startingQuestionId;
274282
const uploaderQuestion = startingQuestion;
275-
window.opener.postMessage(`${startingQuestionId}+${startingQuestion}`, window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : ''));
276283
var uploader = document.createElement('div');
277284
uploader.id = uploaderQuestionId;
278285
uploader.classList.add('uploader');
@@ -309,11 +316,12 @@
309316
<div class="description"></div>
310317
${isMultiple ? '' : `${allowMultiple ? '<div id="submit-exit" class="input-group row">' : ''}
311318
<button id="submit">Create</button>
312-
<button id="exit">Close & Next Question</button>
319+
<button id="next">Next Question</button>
320+
<button id="exit">Exit</button>
313321
${allowMultiple ? '</div>' : ''}`}
314322
`;
315323
document.querySelector('.uploaders').appendChild(uploader);
316-
uploader.querySelector('[data-question-number]').focus();
324+
uploader.querySelector('[data-question-number]').select();
317325
const inputElement = uploader.querySelector('input[type="file"]');
318326
const questionElement = uploader.querySelector('input[type="file"]');
319327
const pond = FilePond.create(inputElement, {
@@ -369,6 +377,7 @@
369377
uploader.querySelectorAll('.input-group').forEach(e => e.remove());
370378
uploader.querySelector('.description').remove();
371379
uploader.querySelector('#submit').remove();
380+
uploader.querySelector('#next').remove();
372381
uploader.querySelector('#exit').remove();
373382
} else {
374383
var textareaContainer = uploader.querySelector('.description')
@@ -612,6 +621,7 @@
612621
uploader.querySelector('#copy')?.addEventListener('click', () => {
613622
createUploader(null, uploader.querySelector('[data-question-number]').value || uploaderQuestion);
614623
});
624+
uploader.querySelector('#next')?.addEventListener('click', next);
615625
uploader.querySelector('#exit')?.addEventListener('click', exit);
616626
uploader.querySelector('#remove')?.addEventListener('click', () => {
617627
if (confirm('Are you sure you want to remove this question? If it has unsaved data, all will be deleted.')) uploader.remove();
@@ -628,6 +638,9 @@
628638
});
629639
};
630640
async function submitAllUploaders() {
641+
document.querySelector('#submit').disabled = true;
642+
document.querySelector('#next').disabled = true;
643+
document.querySelector('#exit').disabled = true;
631644
var submitSuccess = true;
632645
document.querySelector('#submit').innerText = 'Submitting';
633646
for (const { uploader, pond, quill, uploaderQuestionId, uploaderQuestion } of uploaders) {
@@ -659,21 +672,26 @@
659672
if (data.error) submitSuccess = false;
660673
});
661674
};
675+
document.querySelector('#submit').disabled = false;
676+
document.querySelector('#next').disabled = false;
677+
document.querySelector('#exit').disabled = false;
662678
if (submitSuccess) {
663679
document.querySelector('#submit').innerText = 'Success';
664680
document.querySelector('#submit').classList.add('success');
681+
document.querySelector('#next').style.display = 'block';
665682
document.querySelector('#exit').style.display = 'block';
666683
setTimeout(() => {
667684
document.querySelector('#submit').innerText = 'Save';
668685
document.querySelector('#submit').classList.remove('success');
669686
}, 2000);
670687
} else {
671-
document.querySelector('#exit').classList.add('error');
688+
document.querySelector('#submit').classList.add('error');
672689
setTimeout(() => {
673-
document.querySelector('#exit').classList.remove('error');
690+
document.querySelector('#submit').classList.remove('error');
674691
}, 2000);
675692
alert(data.error);
676693
};
694+
window.opener.postMessage('uploadSuccess', window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : ''));
677695
}
678696
window.onload = createUploader;
679697
</script>

0 commit comments

Comments
 (0)