Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 139... Línea 139...
139
        $rc = new restore_controller($backupid, $newcourseid,
139
        $rc = new restore_controller($backupid, $newcourseid,
140
                backup::INTERACTIVE_NO, backup::MODE_GENERAL, $USER->id,
140
                backup::INTERACTIVE_NO, backup::MODE_GENERAL, $USER->id,
141
                backup::TARGET_NEW_COURSE);
141
                backup::TARGET_NEW_COURSE);
142
        $thrown = null;
142
        $thrown = null;
143
        try {
143
        try {
144
            $this->assertTrue($rc->execute_precheck());
144
            $rc->execute_precheck();
145
            $rc->execute_plan();
145
            $rc->execute_plan();
146
            $rc->destroy();
146
            $rc->destroy();
147
        } catch (Exception $e) {
147
        } catch (Exception $e) {
148
            $thrown = $e;
148
            $thrown = $e;
149
            // Because of the PHPUnit exception behaviour in this situation, we
149
            // Because of the PHPUnit exception behaviour in this situation, we
Línea 153... Línea 153...
153
                    $thrown->getFile() . ':' . $thrown->getLine(). "]\n\n";
153
                    $thrown->getFile() . ':' . $thrown->getLine(). "]\n\n";
154
        }
154
        }
Línea 155... Línea 155...
155
 
155
 
Línea -... Línea 156...
-
 
156
        $this->assertNull($thrown);
-
 
157
 
-
 
158
        // Backup contained a question category in a deprecated context.
-
 
159
        $results = $rc->get_precheck_results();
-
 
160
        $this->assertCount(1, $results['warnings']);
156
        $this->assertNull($thrown);
161
        $this->assertStringStartsWith('The questions category', $results['warnings'][0]);
157
 
162
 
158
        // Get information about the resulting course and check that it is set
163
        // Get information about the resulting course and check that it is set
159
        // up correctly.
164
        // up correctly.
160
        $modinfo = get_fast_modinfo($newcourseid);
165
        $modinfo = get_fast_modinfo($newcourseid);
Línea 1038... Línea 1043...
1038
                    'Test fullname', 'Test shortname', $categoryid);
1043
                    'Test fullname', 'Test shortname', $categoryid);
1039
            $rc = new restore_controller($backupid, $newcourseid,
1044
            $rc = new restore_controller($backupid, $newcourseid,
1040
                    backup::INTERACTIVE_NO, backup::MODE_GENERAL, $USER->id,
1045
                    backup::INTERACTIVE_NO, backup::MODE_GENERAL, $USER->id,
1041
                    backup::TARGET_NEW_COURSE);
1046
                    backup::TARGET_NEW_COURSE);
Línea 1042... Línea 1047...
1042
 
1047
 
1043
            $this->assertTrue($rc->execute_precheck());
1048
            $rc->execute_precheck();
1044
            $rc->execute_plan();
1049
            $rc->execute_plan();
Línea -... Línea 1050...
-
 
1050
            $rc->destroy();
-
 
1051
 
-
 
1052
            // Backup contained question category(s) in a deprecated context.
-
 
1053
            $expectedwarnings = $backupid === 'question_category_34_format' ? 1 : 2;
-
 
1054
            $results = $rc->get_precheck_results();
-
 
1055
            $this->assertCount($expectedwarnings, $results['warnings']);
-
 
1056
            for ($i = 0; $i < $expectedwarnings; $i++) {
-
 
1057
                $this->assertStringStartsWith('The questions category', $results['warnings'][$i]);
1045
            $rc->destroy();
1058
            }
1046
 
1059
 
1047
            // Get information about the resulting course and check that it is set up correctly.
1060
            // Get information about the resulting course and check that it is set up correctly.
-
 
1061
            $modinfo = get_fast_modinfo($newcourseid);
-
 
1062
            $quizzes = array_values($modinfo->get_instances_of('quiz'));
-
 
1063
            $qbanks = $modinfo->get_instances_of('qbank');
1048
            $modinfo = get_fast_modinfo($newcourseid);
1064
            $this->assertCount(1, $qbanks);
Línea 1049... Línea 1065...
1049
            $quizzes = array_values($modinfo->get_instances_of('quiz'));
1065
            $qbank = reset($qbanks);
1050
            $contexts = $quizzes[0]->context->get_parent_contexts(true);
1066
            $contexts = $quizzes[0]->context->get_parent_contexts(true);
1051
 
1067
 
Línea 1052... Línea 1068...
1052
            $topcategorycount = [];
1068
            $topcategorycount = [];
1053
            foreach ($contexts as $context) {
1069
            foreach ($contexts as $context) {
-
 
1070
                $cats = $DB->get_records('question_categories', array('contextid' => $context->id), 'parent', 'id, name, parent');
-
 
1071
 
-
 
1072
                // Make sure all question categories that were inside the backup file were restored correctly.
-
 
1073
                if ($context->contextlevel == CONTEXT_COURSE) {
-
 
1074
                    // Course context categories are deprecated and now get transferred to a qbank instance on the course
1054
                $cats = $DB->get_records('question_categories', array('contextid' => $context->id), 'parent', 'id, name, parent');
1075
                    // at point of restore.
1055
 
1076
                    $cats = $DB->get_records('question_categories',
1056
                // Make sure all question categories that were inside the backup file were restored correctly.
1077
                        ['contextid' => $qbank->context->id], 'parent', 'id, name, parent'
1057
                if ($context->contextlevel == CONTEXT_COURSE) {
1078
                    );