Browse Source

Minor - fixing PHP warning.

Julio Montoya 11 years ago
parent
commit
c06c5df11a
1 changed files with 11 additions and 5 deletions
  1. 11 5
      main/coursecopy/classes/CourseRestorer.class.php

+ 11 - 5
main/coursecopy/classes/CourseRestorer.class.php

@@ -1368,11 +1368,17 @@ class CourseRestorer
         // question source_id => category source_id
         if ($this->course->has_resources(RESOURCE_QUIZQUESTION)) {
             // check the category number of each question restored
-            foreach ($resources[RESOURCE_QUIZQUESTION] as $id => $CourseCopyQuestion) {
-                $new_quiz_question_id = $resources[RESOURCE_QUIZQUESTION][$id]->destination_id;
-                $question_category = $CourseCopyQuestion->question_category;
-                if ($question_category > 0) {
-                    Testcategory::add_category_for_question_id($tab_test_category_id_old_new[$question_category], $new_quiz_question_id, $course_id);
+            if (!empty($resources[RESOURCE_QUIZQUESTION])) {
+                foreach ($resources[RESOURCE_QUIZQUESTION] as $id => $CourseCopyQuestion) {
+                    $new_quiz_question_id = $resources[RESOURCE_QUIZQUESTION][$id]->destination_id;
+                    $question_category = $CourseCopyQuestion->question_category;
+                    if ($question_category > 0) {
+                        Testcategory::add_category_for_question_id(
+                            $tab_test_category_id_old_new[$question_category],
+                            $new_quiz_question_id,
+                            $course_id
+                        );
+                    }
                 }
             }
         }