Skip to content

Commit

Permalink
Testcases marked as Precheck Only were not being validating on save.
Browse files Browse the repository at this point in the history
  • Loading branch information
trampgeek committed Mar 21, 2024
1 parent bf8a4d1 commit 260736a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion edit_coderunner_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,7 @@ private function validate_sample_answer() {
if ($error) {
return $error;
}
[$mark, , $cachedata] = $this->formquestion->grade_response($response);
[$mark, , $cachedata] = $this->formquestion->grade_response($response, false, true);
} catch (Exception $e) {
return $e->getMessage();
}
Expand Down
10 changes: 8 additions & 2 deletions question.php
Original file line number Diff line number Diff line change
Expand Up @@ -818,13 +818,15 @@ public function display_feedback() {
* the history of prior submissions.
* @param bool $isprecheck true iff this grading is occurring because the
* student clicked the precheck button
* @param bool $isvalidationrun true iff this is a validation run when saving
* a question.
* @return 3-element array of the mark (0 - 1), the question_state (
* gradedright, gradedwrong, gradedpartial, invalid) and the full
* qtype_coderunner_testing_outcome object to be cached. The invalid
* state is used when a sandbox error occurs.
* @throws coding_exception
*/
public function grade_response(array $response, bool $isprecheck = false) {
public function grade_response(array $response, bool $isprecheck = false, $isvalidationrun = false) {
if ($isprecheck && empty($this->precheck)) {
throw new coding_exception("Unexpected precheck");
}
Expand All @@ -847,7 +849,11 @@ public function grade_response(array $response, bool $isprecheck = false) {
// filenames and values being file contents.
$code = $response['answer'];
$attachments = $this->get_attached_files($response);
$testcases = $this->filter_testcases($isprecheck, $this->precheck);
if ($isvalidationrun) {
$testcases = $this->testcases;
} else {
$testcases = $this->filter_testcases($isprecheck, $this->precheck);
}
$runner = new qtype_coderunner_jobrunner();
$this->stepinfo = self::step_info($response);
if (isset($response['graderstate'])) {
Expand Down

0 comments on commit 260736a

Please sign in to comment.