From: moodler Date: Thu, 12 Jun 2003 03:01:56 +0000 (+0000) Subject: Extensions for grades and comments from Thomas Robb. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=34c84a186ce0d781a60efb48dd32d8e47be21a75;p=moodle.git Extensions for grades and comments from Thomas Robb. --- diff --git a/mod/quiz/format/missingword.php b/mod/quiz/format/missingword.php index 1a24dd5da7..f35d378115 100644 --- a/mod/quiz/format/missingword.php +++ b/mod/quiz/format/missingword.php @@ -1,4 +1,6 @@ qtype = MULTICHOICE; + #$answers = swapshuffle($answers); foreach ($answers as $key => $answer) { $answer = trim($answer); + + // Tom's addition starts here + $answeight = 0; + if (strspn($answer,"1234567890%") > 0){ + //Make sure that the percent sign is the last in the span + if (strpos($answer,"%") == strspn($answer,"1234567890%")) { + $answeight0 = substr($answer,0,strspn($answer,"1234567890%")); + $answeight = round(($answeight0/100),2); + $answer = substr($answer,(strspn($answer,"1234567890%"))); + } + } + if ($answer[0] == "="){ + $answeight = 1; + } + //remove the protective underscore for leading numbers in answers + if ($answer[0] == "_"){ + $answer = substr($answer, 1); + } + $answer = trim($answer); + + if (strpos($answer,"#") > 0){ + $hashpos = strpos($answer,"#"); + $comment = addslashes(substr(($answer),$hashpos+1)); + $answer = substr($answer,0,$hashpos); + } else { + $comment = ""; + } + // End of Tom's addition + if ($answer[0] == "=") { - $question->fraction[$key] = 1; +# $question->fraction[$key] = 1; + $question->fraction[$key] = $answeight; $answer = substr($answer, 1); } else { - $question->fraction[$key] = 0; +# $question->fraction[$key] = 0; + $question->fraction[$key] = $answeight; } $question->answer[$key] = addslashes($answer); - $question->feedback[$key] = ""; + $question->feedback[$key] = $comment; } $question->defaultgrade = 1; @@ -110,7 +152,6 @@ class quiz_file_format extends quiz_default_format { return $question; } } - } ?>