diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index f3e0045c5e..45a427999e 100755 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -2440,8 +2440,8 @@ class Exercise while ($row = Database::fetch_array($result)) { $ind = $row['answer']; $values = explode(':', $ind); - $my_answer_id = $values[0]; - $option = $values[1]; + $my_answer_id = isset($values[0]) ? $values[0] : ''; + $option = isset($values[1]) ? $values[1] : ''; $choice[$my_answer_id] = $option; } } @@ -2530,12 +2530,12 @@ class Exercise $ind = $row['answer']; $result = explode(':',$ind); if (isset($result[0])) { - $my_answer_id = $result[0]; - $option = $result[1]; + $my_answer_id = isset($result[0]) ? $result[0] : ''; + $option = isset($result[1]) ? $result[1] : ''; $choice[$my_answer_id] = $option; } } - $studentChoice = $choice[$answerAutoId]; + $studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : ''; if ($answerCorrect == $studentChoice) { //$answerCorrect = 1; diff --git a/main/inc/lib/exercise.lib.php b/main/inc/lib/exercise.lib.php index efbe79be9b..c8b03deb04 100644 --- a/main/inc/lib/exercise.lib.php +++ b/main/inc/lib/exercise.lib.php @@ -3579,6 +3579,12 @@ HTML; $category_was_added_for_this_test = false; if (isset($objQuestionTmp->category) && !empty($objQuestionTmp->category)) { + if (!isset($category_list[$objQuestionTmp->category]['score'])) { + $category_list[$objQuestionTmp->category]['score'] = 0; + } + if (!isset($category_list[$objQuestionTmp->category]['total'])) { + $category_list[$objQuestionTmp->category]['total'] = 0; + } $category_list[$objQuestionTmp->category]['score'] += $my_total_score; $category_list[$objQuestionTmp->category]['total'] += $my_total_weight; $category_was_added_for_this_test = true;