diff --git a/edit_coderunner_form.php b/edit_coderunner_form.php index 7f6f1978..30f81d52 100644 --- a/edit_coderunner_form.php +++ b/edit_coderunner_form.php @@ -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(); } diff --git a/question.php b/question.php index b6d6e141..3fb0d8a8 100644 --- a/question.php +++ b/question.php @@ -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"); } @@ -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'])) {