Skip to content

Commit

Permalink
Fixed the calculated question editing wizard temporarily for Moodle 1…
Browse files Browse the repository at this point in the history
….5 until Julian gets his new version ready.
  • Loading branch information
gustav_delius committed Jun 5, 2005
1 parent db7f11c commit 85a6b27
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions mod/quiz/questiontypes/calculated/questiontype.php
Expand Up @@ -368,7 +368,8 @@ function comment_on_datasetitems($question, $data, $number) {
}

// Get answers
$answers = $question->options->answers;
// the next line is hacked to get rid of the PHP notice until this gets fixed properly
$answers = (isset($question->options->answers)) ? $question->options->answers : null;
$stranswers = get_string('answer', 'quiz');
$strmin = get_string('min', 'quiz');
$strmax = get_string('max', 'quiz');
Expand All @@ -378,26 +379,28 @@ function comment_on_datasetitems($question, $data, $number) {
$state->responses = array();
$state->options = new stdClass;
$virtualqtype = $this->get_virtual_qtype();
foreach ($answers as $answer) {
$calculated = quiz_qtype_calculated_calculate_answer(
$answer->answer, $data, $answer->tolerance,
$answer->tolerancetype, $answer->correctanswerlength,
$answer->correctanswerformat, $unit);
$state->responses[''] = $calculated->answer;
$virtualqtype->get_tolerance_interval($question, $state);
$calculated->min = $state->options->min;
$calculated->max = $state->options->max;
if ($calculated->min === '') {
// This should mean that something is wrong
$errors .= " -$calculated->answer";
$stranswers .= $delimiter;
} else {
$stranswers .= $delimiter.$calculated->answer;
if ($answers) {
foreach ($answers as $answer) {
$calculated = quiz_qtype_calculated_calculate_answer(
$answer->answer, $data, $answer->tolerance,
$answer->tolerancetype, $answer->correctanswerlength,
$answer->correctanswerformat, $unit);
$state->responses[''] = $calculated->answer;
$virtualqtype->get_tolerance_interval($question, $state);
$calculated->min = $state->options->min;
$calculated->max = $state->options->max;
if ($calculated->min === '') {
// This should mean that something is wrong
$errors .= " -$calculated->answer";
$stranswers .= $delimiter;
} else {
$stranswers .= $delimiter.$calculated->answer;
}
$strmin .= $delimiter.$calculated->min;
$strmax .= $delimiter.$calculated->max;

$delimiter = ', ';
}
$strmin .= $delimiter.$calculated->min;
$strmax .= $delimiter.$calculated->max;

$delimiter = ', ';
}
return "$stranswers<br/>$strmin<br/>$strmax<br/>$errors";
}
Expand Down

0 comments on commit 85a6b27

Please sign in to comment.