| Línea 28... |
Línea 28... |
| 28 |
*
|
28 |
*
|
| 29 |
* @package qtype_ddwtos
|
29 |
* @package qtype_ddwtos
|
| 30 |
* @copyright 2012 The Open University
|
30 |
* @copyright 2012 The Open University
|
| 31 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
31 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
| 32 |
*/
|
32 |
*/
|
| 33 |
class edit_form_test extends \advanced_testcase {
|
33 |
final class edit_form_test extends \advanced_testcase {
|
| 34 |
/**
|
34 |
/**
|
| 35 |
* Helper method.
|
35 |
* Helper method.
|
| 36 |
*
|
36 |
*
|
| 37 |
* @param string $classname the question form class to instantiate.
|
37 |
* @param string $classname the question form class to instantiate.
|
| 38 |
*
|
38 |
*
|
| Línea 42... |
Línea 42... |
| 42 |
*/
|
42 |
*/
|
| 43 |
protected function get_form($classname) {
|
43 |
protected function get_form($classname) {
|
| 44 |
$this->setAdminUser();
|
44 |
$this->setAdminUser();
|
| 45 |
$this->resetAfterTest();
|
45 |
$this->resetAfterTest();
|
| Línea -... |
Línea 46... |
| - |
|
46 |
|
| - |
|
47 |
$course = self::getDataGenerator()->create_course();
|
| 46 |
|
48 |
$qbank = self::getDataGenerator()->create_module('qbank', ['course' => $course->id]);
|
| 47 |
$syscontext = \context_system::instance();
|
49 |
$bankcontext = \context_module::instance($qbank->cmid);
|
| 48 |
$category = question_make_default_categories(array($syscontext));
|
50 |
$category = question_get_default_category($bankcontext->id, true);
|
| 49 |
$fakequestion = new \stdClass();
|
51 |
$fakequestion = new \stdClass();
|
| 50 |
$fakequestion->qtype = 'ddwtos'; // Does not actually matter if this is wrong.
|
52 |
$fakequestion->qtype = 'ddwtos'; // Does not actually matter if this is wrong.
|
| 51 |
$fakequestion->contextid = $syscontext->id;
|
53 |
$fakequestion->contextid = $bankcontext->id;
|
| 52 |
$fakequestion->createdby = 2;
|
54 |
$fakequestion->createdby = 2;
|
| 53 |
$fakequestion->category = $category->id;
|
55 |
$fakequestion->category = $category->id;
|
| 54 |
$fakequestion->questiontext = 'Test [[1]] question [[2]]';
|
56 |
$fakequestion->questiontext = 'Test [[1]] question [[2]]';
|
| 55 |
$fakequestion->options = new \stdClass();
|
57 |
$fakequestion->options = new \stdClass();
|
| Línea 58... |
Línea 60... |
| 58 |
$fakequestion->formoptions->movecontext = null;
|
60 |
$fakequestion->formoptions->movecontext = null;
|
| 59 |
$fakequestion->formoptions->repeatelements = true;
|
61 |
$fakequestion->formoptions->repeatelements = true;
|
| 60 |
$fakequestion->inputs = null;
|
62 |
$fakequestion->inputs = null;
|
| Línea 61... |
Línea 63... |
| 61 |
|
63 |
|
| 62 |
$form = new $classname(new \moodle_url('/'), $fakequestion, $category,
|
64 |
$form = new $classname(new \moodle_url('/'), $fakequestion, $category,
|
| Línea 63... |
Línea 65... |
| 63 |
new \core_question\local\bank\question_edit_contexts($syscontext));
|
65 |
new \core_question\local\bank\question_edit_contexts($bankcontext));
|
| 64 |
|
66 |
|
| Línea 65... |
Línea 67... |
| 65 |
return [$form, $category];
|
67 |
return [$form, $category];
|