Skip to content

Commit

Permalink
Minor updates, removing useless bits and pieces.
Browse files Browse the repository at this point in the history
  • Loading branch information
mckeownp committed Feb 29, 2024
1 parent 16b36e3 commit 51fc87a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 18 deletions.
2 changes: 0 additions & 2 deletions classes/jobrunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ class qtype_coderunner_jobrunner {
* this is a run triggered by the student clicking the Precheck button.
* @param string $answerlanguage will be the empty string except for multilanguage questions,
* when it is the language selected in the language drop-down menu.
* @param boolean $validating Set to true if this is a validate on grading. Otherwise the
* validate on save uses the qid of the last version.
* @return qtype_coderunner_combinator_grader_outcome $testoutcome that contains the outcome
* of the grading.
*/
Expand Down
3 changes: 1 addition & 2 deletions edit_coderunner_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -1630,8 +1630,7 @@ private function validate_sample_answer() {
}
[$mark, $state, $cachedata] = $this->formquestion->grade_response(
$response,
false, // Not a precheck.
false // Don't use cache as it the old question id is used and would give old outcome.
false // Not a precheck.
);
} catch (Exception $e) {
return $e->getMessage();
Expand Down
2 changes: 1 addition & 1 deletion question.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
use qtype_coderunner\constants;
use qtype_coderunner\coderunner_files;

/**
/**
* Represents a 'CodeRunner' question.
*/

Expand Down
11 changes: 4 additions & 7 deletions tests/grader_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ public function test_regex_grader() {
pass
EOCODE;
$response = ['answer' => $code];
// Moodle's test helper question uses an id of zero so turn off cache!
// Note: Moodle's test helper question always uses an id of zero!
$result = $q->grade_response(
$response,
false, // Not a precheck.
false // Here usecache is set to false.
);
[$mark, $grade, $cache] = $result;
$testoutcome = unserialize($cache['_testoutcome']); // For debugging test.
Expand Down Expand Up @@ -99,12 +98,11 @@ public function test_nearequality_grader_right_answer() {
pass
EOCODE;
$response = ['answer' => $code];
// Moodle's test helper question uses an id of zero so turn off cache!
// Note: Moodle's test helper question always uses an id of zero!
$result = $q->grade_response(
$response,
false, // Not a precheck.
false // Here usecache is set to false.
);
);
[$mark, $grade, $cache] = $result;
$testoutcome = unserialize($cache['_testoutcome']); // For debugging test.
$this->assertEquals(1, $mark);
Expand Down Expand Up @@ -135,11 +133,10 @@ public function test_nearequality_grader_wrong_answer() {
pass
EOCODE;
$response = ['answer' => $code];
// Moodle's test helper question uses an id of zero so turn off cache!
// Note: Moodle's test helper question always uses an id of zero!
$result = $q->grade_response(
$response,
false, // Not a precheck.
false // Here usecache is set to false.
);
[$mark, $grade, $cache] = $result;
$testoutcome = unserialize($cache['_testoutcome']); // For debugging test.
Expand Down
10 changes: 4 additions & 6 deletions tests/template_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,18 @@ public function test_grading_template() {
$q->allornothing = false;
$code = "def sqr(n): return n * n\n";
$response = ['answer' => $code];
// Don't use cache as qid of zero is reused with different question!
// Note: qid of zero is reused with different question!
$result = $q->grade_response(
$response,
false, // Not a precheck.
false // Here usecache is set to false.
false // Not a precheck.
);
[$mark, $grade, $cache] = $result;
$this->assertTrue(abs($mark - 24.0 / 31.0) < 0.000001);
$q->allornothing = true;
// Don't use cache as qid of zero is reused with different question!
// Note: qid of zero is reused with different question!
$result = $q->grade_response(
$response,
false, // Not a precheck.
false // Here usecache is set to false.
false // Not a precheck.
);
[$mark, $grade, $cache] = $result;
$this->assertTrue($mark == 0.0);
Expand Down

0 comments on commit 51fc87a

Please sign in to comment.