Browse Source

Avoiding fatal error if object is not set

Julio Montoya 13 years ago
parent
commit
98fa0a75ef
1 changed files with 16 additions and 14 deletions
  1. 16 14
      main/exercice/exercise_submit.php

+ 16 - 14
main/exercice/exercise_submit.php

@@ -593,20 +593,22 @@ if (!empty ($error)) {
             $i++;
             $objQuestionTmp = Question::read($questionId);
             // for sequential exercises
-            if ($exerciseType == ONE_PER_PAGE) {
-                // if it is not the right question, goes to the next loop iteration
-                if ($questionNum != $i) {
-                    continue;
-                } else {                    
-                    if ($objQuestionTmp->selectType() == HOT_SPOT || $objQuestionTmp->selectType() == HOT_SPOT_DELINEATION) {
-                        $number_of_hotspot_questions++;
-                    }
-                    break;
-                }
-            } else {
-                if ($objQuestionTmp->selectType() == HOT_SPOT || $objQuestionTmp->selectType() == HOT_SPOT_DELINEATION) {
-                    $number_of_hotspot_questions++;
-                }
+            if (!empty($objQuestionTmp)) {
+	            if ($exerciseType == ONE_PER_PAGE) {
+	                // if it is not the right question, goes to the next loop iteration
+	                if ($questionNum != $i) {
+	                    continue;
+	                } else {                    
+	                    if ($objQuestionTmp->selectType() == HOT_SPOT || $objQuestionTmp->selectType() == HOT_SPOT_DELINEATION) {
+	                        $number_of_hotspot_questions++;
+	                    }
+	                    break;
+	                }
+	            } else {
+	                if ($objQuestionTmp->selectType() == HOT_SPOT || $objQuestionTmp->selectType() == HOT_SPOT_DELINEATION) {
+	                    $number_of_hotspot_questions++;
+	                }
+	            }
             }
         }
     }