See Release Notes
Long Term Support Release
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 namespace qbank_exporttoxml; 18 19 use context_course; 20 use context_module; 21 use moodle_url; 22 use question_bank; 23 24 /** 25 * Class helper unit tests. 26 * 27 * @package qbank_exporttoxml 28 * @copyright 2021 Catalyst IT Australia Pty Ltd 29 * @author Safat Shahin <safatshahin@catalyst-au.net> 30 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 31 * @coversDefaultClass \qbank_exporttoxml\helper 32 */ 33 class helper_test extends \advanced_testcase { 34 35 /** 36 * Test the export single question url. 37 * 38 * @covers ::question_get_export_single_question_url 39 */ 40 public function test_question_get_export_single_question_url() { 41 $this->resetAfterTest(); 42 $generator = $this->getDataGenerator(); 43 44 // Create a course and an activity. 45 $course = $generator->create_course(); 46 $quiz = $generator->create_module('quiz', ['course' => $course->id]); 47 48 // Create a question in each place. 49 $questiongenerator = $generator->get_plugin_generator('core_question'); 50 $courseqcat = $questiongenerator->create_question_category(['contextid' => context_course::instance($course->id)->id]); 51 $courseq = $questiongenerator->create_question('truefalse', null, ['category' => $courseqcat->id]); 52 $quizqcat = $questiongenerator->create_question_category(['contextid' => context_module::instance($quiz->cmid)->id]); 53 $quizq = $questiongenerator->create_question('truefalse', null, ['category' => $quizqcat->id]); 54 $systemqcat = $questiongenerator->create_question_category(); 55 $systemq = $questiongenerator->create_question('truefalse', null, ['category' => $systemqcat->id]); 56 57 // Verify some URLs. 58 $this->assertEquals(new moodle_url('/question/bank/exporttoxml/exportone.php', 59 ['id' => $courseq->id, 'courseid' => $course->id, 'sesskey' => sesskey()]), 60 helper::question_get_export_single_question_url( 61 question_bank::load_question_data($courseq->id))); 62 63 $this->assertEquals(new moodle_url('/question/bank/exporttoxml/exportone.php', 64 ['id' => $quizq->id, 'cmid' => $quiz->cmid, 'sesskey' => sesskey()]), 65 helper::question_get_export_single_question_url( 66 question_bank::load_question($quizq->id))); 67 68 $this->assertEquals(new moodle_url('/question/bank/exporttoxml/exportone.php', 69 ['id' => $systemq->id, 'courseid' => SITEID, 'sesskey' => sesskey()]), 70 helper::question_get_export_single_question_url( 71 question_bank::load_question($systemq->id))); 72 } 73 74 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body