예제 #1
0
 protected static function tidy($s)
 {
     if ($s === null) {
         return null;
     } else {
         $cleanS = qtype_coderunner_grader::clean($s);
         return qtype_coderunner_grader::snip($cleanS);
     }
 }
예제 #2
0
 /** This grader tests if the expected output matches the actual
  *  output after removing all empty lines and trailing white space,
  *  collapsing all sequences of space or tab characters to a single
  *  space and converting all letters to lower case. [These changes
  *  are of course applied to both expected and actual outputs.]
  * 
  *  As requested by Ulrich Dangel.
  */
 function grade_known_good(&$output, &$testCase)
 {
     $cleanedOutput = qtype_coderunner_grader::clean($output);
     $cleanedExpected = qtype_coderunner_grader::clean($testCase->expected);
     $isCorrect = $this->reduce($cleanedOutput) == $this->reduce($cleanedExpected);
     $awardedMark = $isCorrect ? $testCase->mark : 0.0;
     if (isset($testCase->stdin)) {
         $resultStdin = qtype_coderunner_grader::tidy($testCase->stdin);
     } else {
         $resultStdin = null;
     }
     return new qtype_coderunner_test_result(qtype_coderunner_grader::tidy($testCase->testcode), $testCase->mark, $isCorrect, $awardedMark, qtype_coderunner_grader::snip($cleanedExpected), qtype_coderunner_grader::snip($cleanedOutput), $resultStdin, qtype_coderunner_grader::tidy($testCase->extra));
 }