Skip to content

Commit 1840b1a

Browse files
committed
re-marking: wait for each question's resume signal
It can take a long time to mark parts with pre-submit tasks, so this makes the remark_session function wait for the 'resume' signal from each question, which is only triggered once all parts have finished submitting.
1 parent 0856848 commit 1840b1a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

numbas_lti/static/resource_remark_iframe.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function remark_session(options) {
116116
options = options || {};
117117
const promise = new Promise((resolve,reject) => {
118118
load_exam().then(exam => {
119-
const pre_submit_promises = [];
119+
const pre_submit_promises = exam.questionList.map(q => q.signals.on('resume'));
120120
exam.questionList.forEach(function(q) {
121121
q.store.saveQuestion(q);
122122
q.allParts().forEach(function(p) {
@@ -132,19 +132,21 @@ function remark_session(options) {
132132
p.submit();
133133
});
134134
}
135-
q.parts.forEach(function(p) {
135+
q.allParts().forEach(function(p) {
136136
if(p.waiting_for_pre_submit) {
137137
pre_submit_promises.push(p.waiting_for_pre_submit);
138138
}
139139
});
140140
});
141141

142142
Promise.all(pre_submit_promises).then(results => {
143-
exam.store.saveExam(exam);
143+
setTimeout(() => {
144+
exam.store.saveExam(exam);
144145

145-
reset(exam);
146+
reset(exam);
146147

147-
resolve({success: true});
148+
resolve({success: true});
149+
}, 100);
148150
});
149151
}).catch(err=>{
150152
resolve({success: false, error: err});

0 commit comments

Comments
 (0)