Closed
Description
Grader programs are currently concatenated to the end of student's programs. We should also allow for programs to be prepended to student programs. The most obvious use cases are for assessments where certain functional abstractions are already provided for the student.
For example, if the student is asked to write a function cube
to find the cube of a power, and is already given a square
function, the old style of append-only grader may sometimes run into a runtime error, if the student calls their function.
// STUDENT'S
function cube(x) {
return square(x) * x;
}
display(cube(3))l // the student left this in to test
// GRADER APPEND
const square = x => x * x;
function __test() {
return cube(5) === 125 ? 1 : 0;
}
__test();
With prepended program snippets, we avoid this problem altogether.
// GRADER PREPEND
const square = x => x * x;
// STUDENT'S
function cube(x) {
return square(x) * x;
}
display(cube(3))l // the student left this in to test
// GRADER APPEND
function __test() {
return cube(5) === 125 ? 1 : 0;
}
__test();
In other words, this is simpler a 'set-up' mechanism, without the need to manipulate the GLOBAL or EXTERNAL nodes of assessment XML files.