From: thepurpleblob Date: Thu, 23 Mar 2006 11:12:54 +0000 (+0000) Subject: Not all questions have grades/fractions. Added check. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=2d52056f79945db0ca2ac1d3a486174d28320f6b;p=moodle.git Not all questions have grades/fractions. Added check. --- diff --git a/question/format.php b/question/format.php index e6b235439d..8af4a93f48 100644 --- a/question/format.php +++ b/question/format.php @@ -69,23 +69,25 @@ class qformat_default { // check for answer grades validity (must match fixed list of grades) $fractions = $question->fraction; - $answersvalid = true; // in case they are! - foreach ($fractions as $key => $fraction) { - $newfraction = match_grade_options($gradeoptionsfull, $fraction, $matchgrades); - if ($newfraction===false) { - $answersvalid = false; + if (!empty($fractions)) { + $answersvalid = true; // in case they are! + foreach ($fractions as $key => $fraction) { + $newfraction = match_grade_options($gradeoptionsfull, $fraction, $matchgrades); + if ($newfraction===false) { + $answersvalid = false; + } + else { + $fractions[$key] = $newfraction; + } + } + if (!$answersvalid) { + notify( get_string('matcherror','quiz') ); + continue; } else { - $fractions[$key] = $newfraction; + $question->fraction = $fractions; } } - if (!$answersvalid) { - notify( get_string('matcherror','quiz') ); - continue; - } - else { - $question->fraction = $fractions; - } $question->category = $this->category->id; $question->stamp = make_unique_id_code(); // Set the unique code (not to be changed)