Not all questions have grades/fractions. Added check.

This commit is contained in:
thepurpleblob
2006-03-23 11:12:54 +00:00
parent d118d06afc
commit 2d52056f79
+15 -13
View File
@@ -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)