MDL-61514 Quiz: Fix restore error
authorShamim Rezaie <shamim@moodle.com>
Wed, 21 Mar 2018 22:50:00 +0000 (09:50 +1100)
committerShamim Rezaie <shamim@moodle.com>
Wed, 21 Mar 2018 22:57:35 +0000 (09:57 +1100)
Include mod/quiz/locallib.php to fix the restore error.

mod/quiz/backup/moodle2/restore_quiz_stepslib.php
mod/quiz/tests/tags_test.php

index 5f76fa5..13da05f 100644 (file)
@@ -251,7 +251,7 @@ class restore_quiz_activity_structure_step extends restore_questions_activity_st
     }
 
     protected function process_quiz_question_instance($data) {
-        global $DB;
+        global $CFG, $DB;
 
         $data = (object)$data;
 
@@ -302,6 +302,8 @@ class restore_quiz_activity_structure_step extends restore_questions_activity_st
         }
 
         if (isset($data->tags)) {
+            require_once($CFG->dirroot . '/mod/quiz/locallib.php');
+
             $tags = quiz_extract_random_question_tags($data->tags, $this->task->is_samesite());
             $data->tags = quiz_build_random_question_tag_json($tags);
         }
index c5fbbcd..161e07b 100644 (file)
@@ -23,8 +23,6 @@
  */
 
 defined('MOODLE_INTERNAL') || die();
-global $CFG;
-require_once($CFG->dirroot . '/mod/quiz/locallib.php');
 
 /**
  * Class mod_quiz_tags_testcase