Skip to content

Commit

Permalink
adaptive marking: show the "part must be answered" warning in the war…
Browse files Browse the repository at this point in the history
…nings box

When a part depends on a previous part that must be answered, an error
message is shown in the part feedback area.
This commit makes it so that the message is also shown in the part's
warnings box next to the input widget, where students expect to see
warnings.

fixes #1068
  • Loading branch information
christianp committed Dec 14, 2023
1 parent dd182bc commit d7a3650
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion runtime/scripts/part.js
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,7 @@ if(res) { \
}
}
}
result.warnings.push(e.message);
} else {
try{
this.error(e.message,{},e);
Expand Down Expand Up @@ -1574,7 +1575,7 @@ if(res) { \
new_variables[vr.variable] = p2.studentAnswerAsJME();
replaced.push(vr.variable);
} else if(vr.must_go_first) {
throw(new Numbas.Error("part.marking.variable replacement part not answered",{part:p2.name}));
throw(new Numbas.Error("part.marking.variable replacement part not answered", {part: p2.name}));
}
}
var scope = Numbas.jme.variables.remakeVariables(this.question.variablesTodo, new_variables, this.getScope());
Expand Down
3 changes: 3 additions & 0 deletions themes/default/files/scripts/part-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,9 @@ Numbas.queueScript('part-display',['display-util', 'display-base','util','jme'],
*/
setWarnings: function(warnings) {
this.warnings(warnings.map(function(warning){return {message: warning+''}}));
if(warnings.length) {
this.showWarnings();
}
},
/** Remove all previously displayed warnings.
*
Expand Down

0 comments on commit d7a3650

Please sign in to comment.