Skip to content
Permalink
Browse files

error while doing adaptive marking just causes 'incorrect'

I had a question which used adaptive marking to replace a parameter for
an algorithm. Certain values of parameters are inconsistent with the
algorithm's assumptions, so using them causes an error.
I should be catching those invalid values and giving better feedback,
but if I don't, Numbas shouldn't just die.
Showing the error message to the student isn't helpful - it's often
something inscrutable, like "list index error".

So now, if an error occurs while marking a part with "always replace
variables", the following happens:

* the part is marked incorrect.
* the student is told "This part could not be marked using your answers
  to previous parts", as a sort of hint that something further up is
  incorrect (they might've lost marks, but if the referenced part has
  zero credit that won't be the case)
* the error message is logged to the console, where the question author
  can find it
  • Loading branch information...
christianp committed Nov 1, 2018
1 parent 4a48c4f commit 75a24d59c607cfa62a4cff72e6e39928c1c1e327
Showing with 19 additions and 17 deletions.
  1. +1 −1 locales/en-GB.json
  2. +18 −16 runtime/scripts/part.js
@@ -161,7 +161,7 @@
"part.marking.correct": "Your answer is correct.",
"part.marking.uncaught error": "Error when marking {{part}}: {{-message}}",
"part.marking.error in marking script": "There was an error in this part's marking algorithm. Please report this. {{-message}}",
"part.marking.no result": "This part could not be marked.",
"part.marking.no result after replacement": "This part could not be marked using your answers to previous parts.",
"part.marking.missing required note": "The marking algorithm does not define the note <code>{{note}}</code>",
"marking.apply.not a list": "The first argument to <code>apply</code> must be a list, and isn't",
"marking.apply marking script.script not found": "Marking script <code>{{name}}</code> not found",
@@ -647,28 +647,30 @@ Part.prototype = /** @lends Numbas.parts.Part.prototype */ {
if(this.settings.variableReplacementStrategy=='alwaysreplace' || try_replacement) {
try {
var scope = this.errorCarriedForwardScope();
var result_replacement = this.markAgainstScope(scope,existing_feedback);
if(!(result_original) || (result_replacement.answered && result_replacement.credit>result_original.credit)) {
result = result_replacement;
result.finalised_result.states.splice(0,0,{op: Numbas.marking.FeedbackOps.FEEDBACK, message: R('part.marking.used variable replacements')});
result.markingFeedback.splice(0,0,{op: 'comment', message: R('part.marking.used variable replacements')});
}
} catch(e) {
if(!result) {
this.giveWarning(e.originalMessage);
this.answered = false;
throw(e);
try{
this.error(e.message);
} catch(pe) {
console.error(pe.message);
}
}
var result_replacement = this.markAgainstScope(scope,existing_feedback);
if(!(result_original) || (result_replacement.answered && result_replacement.credit>result_original.credit)) {
result = result_replacement;
result.finalised_result.states.splice(0,0,{op: Numbas.marking.FeedbackOps.FEEDBACK, message: R('part.marking.used variable replacements')});
result.markingFeedback.splice(0,0,{op: 'comment', message: R('part.marking.used variable replacements')});
}
}
if(!result) {
this.error('part.marking.no result');
this.setCredit(0,R('part.marking.no result after replacement'));
this.answered = true;
} else {
this.setWarnings(result.warnings);
this.markingFeedback = result.markingFeedback;
this.finalised_result = result.finalised_result;
this.credit = result.credit;
this.answered = result.answered;
}
this.setWarnings(result.warnings);
this.markingFeedback = result.markingFeedback;
this.finalised_result = result.finalised_result;
this.credit = result.credit;
this.answered = result.answered;
} catch(e) {
throw(new Numbas.Error('part.marking.uncaught error',{part:util.nicePartName(this.path),message:e.message}));
}

0 comments on commit 75a24d5

Please sign in to comment.
You can’t perform that action at this time.