Skip to content

Commit

Permalink
catch errors when marking gaps, and when updating correct answer for …
Browse files Browse the repository at this point in the history
…variable replacements

The marking script for gapfill parts now catches errors encountered
while submitting gaps, and ends marking immediately with an error
message.

After submitting a part, any parts which use it in adaptive marking have
their displayed expected answers updated. If there's an error when
computing the error-carried-forward scope (for example, because another
"must be answered" part hasn't been answered yet), silently give up.

fixes #629
  • Loading branch information
christianp committed Aug 5, 2019
1 parent bc266e9 commit 8d0e55b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions locales/en-GB.json
Expand Up @@ -244,6 +244,7 @@
"part.matrix.empty cell": "One or more of the cells in your answer is empty.",
"part.matrix.size mismatch": "The question author hasn't allowed the student to decide the dimensions of their answer, but the correct answer is {{correct_dimensions}} while the answer input is {{input_dimensions}}",
"part.gapfill.feedback header": "<strong>{{name}}</strong>",
"part.gapfill.error marking gap": "Error marking {{name}}: {{-message}}",
"part.extension.not implemented": "Part hasn't implemented the <code>{{name}}</code> method.",
"part.custom.empty setting": "No value given.",
"part.custom.unrecognised input type": "Unrecognised setting type <code>{{input_type}}</code>",
Expand Down
24 changes: 14 additions & 10 deletions marking_scripts/gapfill.jme
Expand Up @@ -28,16 +28,20 @@ gap_order:

gap_feedback (Feedback on each of the gaps):
map(
let(
result, submit_part(gaps[gap_number]["path"],answer),
gap, gaps[gap_number],
name, gap["name"],
noFeedbackIcon, not gap["settings"]["showFeedbackIcon"],
assert(noFeedbackIcon,
assert(name="" or len(gaps)=1,feedback(translate('part.gapfill.feedback header',["name": name])))
);
concat_feedback(filter(x["op"]<>"warning",x,result["feedback"]), if(marks>0,result["marks"]/marks,1), noFeedbackIcon);
result
try(
let(
result, submit_part(gaps[gap_number]["path"],answer),
gap, gaps[gap_number],
name, gap["name"],
noFeedbackIcon, not gap["settings"]["showFeedbackIcon"],
assert(noFeedbackIcon,
assert(name="" or len(gaps)=1,feedback(translate('part.gapfill.feedback header',["name": name])))
);
concat_feedback(filter(x["op"]<>"warning",x,result["feedback"]), if(marks>0,result["marks"]/marks,1), noFeedbackIcon);
result
),
err,
fail(translate("part.gapfill.error marking gap",["name": gaps[gap_number]["name"], "message": err]))
),
[gap_number,answer,index],
zip(gap_order,studentAnswer,list(1..len(gaps)))
Expand Down
7 changes: 5 additions & 2 deletions runtime/scripts/part.js
Expand Up @@ -804,8 +804,11 @@ Part.prototype = /** @lends Numbas.parts.Part.prototype */ {
for(var path in this.errorCarriedForwardBackReferences) {
var p2 = this.question.getPart(path);
if(p2.settings.variableReplacementStrategy=='alwaysreplace') {
var answer = p2.getCorrectAnswer(p2.errorCarriedForwardScope());
p2.display && p2.display.updateCorrectAnswer(answer);
try {
var answer = p2.getCorrectAnswer(p2.errorCarriedForwardScope());
p2.display && p2.display.updateCorrectAnswer(answer);
} catch(e) {
}
}
if(p2.answered) {
p2.pleaseResubmit();
Expand Down

0 comments on commit 8d0e55b

Please sign in to comment.