| Línea 22... |
Línea 22... |
| 22 |
* @package qbank_customfields
|
22 |
* @package qbank_customfields
|
| 23 |
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
23 |
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
| 24 |
* @author Matt Porritt <mattp@catalyst-au.net>
|
24 |
* @author Matt Porritt <mattp@catalyst-au.net>
|
| 25 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
25 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
| 26 |
*/
|
26 |
*/
|
| 27 |
class question_handler_test extends \advanced_testcase {
|
27 |
final class question_handler_test extends \advanced_testcase {
|
| Línea 28... |
Línea 28... |
| 28 |
|
28 |
|
| 29 |
/**
|
29 |
/**
|
| 30 |
* Question setup helper method.
|
30 |
* Question setup helper method.
|
| 31 |
*
|
31 |
*
|
| 32 |
* @return int The question id.
|
32 |
* @return int The question id.
|
| 33 |
* @throws coding_exception
|
33 |
* @throws coding_exception
|
| 34 |
*/
|
34 |
*/
|
| 35 |
protected function setup_question(): int {
|
35 |
protected function setup_question(): int {
|
| - |
|
36 |
$course = self::getDataGenerator()->create_course();
|
| 36 |
$category = $this->getDataGenerator()->create_category();
|
37 |
$qbank = self::getDataGenerator()->create_module('qbank', ['course' => $course->id]);
|
| 37 |
$questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
38 |
$questiongenerator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
| 38 |
$context = \context_coursecat::instance($category->id);
|
39 |
$context = \context_module::instance($qbank->cmid);
|
| 39 |
$questioncategory = $questiongenerator->create_question_category(['contextid' => $context->id]);
|
40 |
$questioncategory = $questiongenerator->create_question_category(['contextid' => $context->id]);
|
| 40 |
$questiondata = ['category' => $questioncategory->id, 'idnumber' => 'q1'];
|
41 |
$questiondata = ['category' => $questioncategory->id, 'idnumber' => 'q1'];
|
| Línea 41... |
Línea 42... |
| 41 |
$question = $questiongenerator->create_question('shortanswer', null, $questiondata);
|
42 |
$question = $questiongenerator->create_question('shortanswer', null, $questiondata);
|