| Línea 28... |
Línea 28... |
| 28 |
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
28 |
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
| 29 |
* @author Safat Shahin <safatshahin@catalyst-au.net>
|
29 |
* @author Safat Shahin <safatshahin@catalyst-au.net>
|
| 30 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
30 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
| 31 |
* @coversDefaultClass \qbank_exporttoxml\helper
|
31 |
* @coversDefaultClass \qbank_exporttoxml\helper
|
| 32 |
*/
|
32 |
*/
|
| 33 |
class helper_test extends \advanced_testcase {
|
33 |
final class helper_test extends \advanced_testcase {
|
| Línea 34... |
Línea 34... |
| 34 |
|
34 |
|
| 35 |
/**
|
35 |
/**
|
| 36 |
* Test the export single question url.
|
36 |
* Test the export single question url.
|
| 37 |
*
|
37 |
*
|
| Línea 41... |
Línea 41... |
| 41 |
$this->resetAfterTest();
|
41 |
$this->resetAfterTest();
|
| 42 |
$generator = $this->getDataGenerator();
|
42 |
$generator = $this->getDataGenerator();
|
| Línea 43... |
Línea 43... |
| 43 |
|
43 |
|
| 44 |
// Create a course and an activity.
|
44 |
// Create a course and an activity.
|
| - |
|
45 |
$course = $generator->create_course();
|
| - |
|
46 |
$qbank = self::getDataGenerator()->create_module('qbank', ['course' => $course->id]);
|
| 45 |
$course = $generator->create_course();
|
47 |
$qbankcontext = \context_module::instance($qbank->cmid);
|
| Línea 46... |
Línea 48... |
| 46 |
$quiz = $generator->create_module('quiz', ['course' => $course->id]);
|
48 |
$quiz = $generator->create_module('quiz', ['course' => $course->id]);
|
| 47 |
|
49 |
|
| 48 |
// Create a question in each place.
|
50 |
// Create a question in each place.
|
| 49 |
$questiongenerator = $generator->get_plugin_generator('core_question');
|
51 |
$questiongenerator = $generator->get_plugin_generator('core_question');
|
| 50 |
$courseqcat = $questiongenerator->create_question_category(['contextid' => context_course::instance($course->id)->id]);
|
52 |
$qbankqcat = $questiongenerator->create_question_category(['contextid' => $qbankcontext->id]);
|
| 51 |
$courseq = $questiongenerator->create_question('truefalse', null, ['category' => $courseqcat->id]);
|
53 |
$qbankq = $questiongenerator->create_question('truefalse', null, ['category' => $qbankqcat->id]);
|
| 52 |
$quizqcat = $questiongenerator->create_question_category(['contextid' => context_module::instance($quiz->cmid)->id]);
|
- |
|
| 53 |
$quizq = $questiongenerator->create_question('truefalse', null, ['category' => $quizqcat->id]);
|
- |
|
| Línea 54... |
Línea 54... |
| 54 |
$systemqcat = $questiongenerator->create_question_category();
|
54 |
$quizqcat = $questiongenerator->create_question_category(['contextid' => context_module::instance($quiz->cmid)->id]);
|
| 55 |
$systemq = $questiongenerator->create_question('truefalse', null, ['category' => $systemqcat->id]);
|
55 |
$quizq = $questiongenerator->create_question('truefalse', null, ['category' => $quizqcat->id]);
|
| 56 |
|
56 |
|
| 57 |
// Verify some URLs.
|
57 |
// Verify some URLs.
|
| 58 |
$this->assertEquals(new moodle_url('/question/bank/exporttoxml/exportone.php',
|
58 |
$this->assertEquals(new moodle_url('/question/bank/exporttoxml/exportone.php',
|
| Línea 59... |
Línea 59... |
| 59 |
['id' => $courseq->id, 'courseid' => $course->id, 'sesskey' => sesskey()]),
|
59 |
['id' => $qbankq->id, 'cmid' => $qbank->cmid, 'sesskey' => sesskey()]),
|
| 60 |
helper::question_get_export_single_question_url(
|
60 |
helper::question_get_export_single_question_url(
|
| 61 |
question_bank::load_question_data($courseq->id)));
|
61 |
question_bank::load_question_data($qbankq->id)));
|
| 62 |
|
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',
|
63 |
$this->assertEquals(new moodle_url('/question/bank/exporttoxml/exportone.php',
|
| Línea 69... |
Línea 64... |
| 69 |
['id' => $systemq->id, 'courseid' => SITEID, 'sesskey' => sesskey()]),
|
64 |
['id' => $quizq->id, 'cmid' => $quiz->cmid, 'sesskey' => sesskey()]),
|