|
16 | 16 |
|
17 | 17 | namespace filter_embedquestion;
|
18 | 18 |
|
19 |
| -use core_external\external_api; |
20 |
| -use core_external\external_description; |
21 |
| -use core_external\external_function_parameters; |
22 |
| -use core_external\external_multiple_structure; |
23 |
| -use core_external\external_single_structure; |
24 |
| -use core_external\external_value; |
| 19 | +defined('MOODLE_INTERNAL') || die(); |
| 20 | + |
| 21 | +global $CFG; |
| 22 | +require_once($CFG->libdir . '/externallib.php'); |
25 | 23 |
|
26 | 24 | /**
|
27 | 25 | * External API for AJAX calls.
|
|
30 | 28 | * @copyright 2018 The Open University
|
31 | 29 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
32 | 30 | */
|
33 |
| -class external extends external_api { |
| 31 | +class external extends \external_api { |
34 | 32 | /**
|
35 | 33 | * Returns parameter types for get_status function.
|
36 | 34 | *
|
37 |
| - * @return external_function_parameters Parameters |
| 35 | + * @return \external_function_parameters Parameters |
38 | 36 | */
|
39 |
| - public static function get_sharable_question_choices_parameters(): external_function_parameters { |
40 |
| - return new external_function_parameters([ |
41 |
| - 'courseid' => new external_value(PARAM_INT, 'Course id.'), |
42 |
| - 'categoryidnumber' => new external_value(PARAM_RAW, 'Idnumber of the question category.'), |
| 37 | + public static function get_sharable_question_choices_parameters(): \external_function_parameters { |
| 38 | + return new \external_function_parameters([ |
| 39 | + 'courseid' => new \external_value(PARAM_INT, 'Course id.'), |
| 40 | + 'categoryidnumber' => new \external_value(PARAM_RAW, 'Idnumber of the question category.'), |
43 | 41 | ]);
|
44 | 42 | }
|
45 | 43 |
|
46 | 44 | /**
|
47 | 45 | * Returns result type for get_status function.
|
48 | 46 | *
|
49 |
| - * @return external_description Result type |
| 47 | + * @return \external_description Result type |
50 | 48 | */
|
51 |
| - public static function get_sharable_question_choices_returns(): external_description { |
52 |
| - return new external_multiple_structure( |
53 |
| - new external_single_structure([ |
54 |
| - 'value' => new external_value(PARAM_RAW, 'Choice value to return from the form.'), |
55 |
| - 'label' => new external_value(PARAM_RAW, 'Choice name, to display to users.'), |
| 49 | + public static function get_sharable_question_choices_returns(): \external_description { |
| 50 | + return new \external_multiple_structure( |
| 51 | + new \external_single_structure([ |
| 52 | + 'value' => new \external_value(PARAM_RAW, 'Choice value to return from the form.'), |
| 53 | + 'label' => new \external_value(PARAM_RAW, 'Choice name, to display to users.'), |
56 | 54 | ]));
|
57 | 55 | }
|
58 | 56 |
|
@@ -107,52 +105,52 @@ public static function get_sharable_question_choices(int $courseid, string $cate
|
107 | 105 | /**
|
108 | 106 | * Returns parameter types for get_embed_code function.
|
109 | 107 | *
|
110 |
| - * @return external_function_parameters Parameters |
| 108 | + * @return \external_function_parameters Parameters |
111 | 109 | */
|
112 |
| - public static function get_embed_code_parameters(): external_function_parameters { |
| 110 | + public static function get_embed_code_parameters(): \external_function_parameters { |
113 | 111 | // We can't use things like PARAM_INT for things like variant, because it is
|
114 | 112 | // and int of '' for not set.
|
115 |
| - return new external_function_parameters([ |
116 |
| - 'courseid' => new external_value(PARAM_INT, |
| 113 | + return new \external_function_parameters([ |
| 114 | + 'courseid' => new \external_value(PARAM_INT, |
117 | 115 | 'Course id.'),
|
118 |
| - 'categoryidnumber' => new external_value(PARAM_RAW, |
| 116 | + 'categoryidnumber' => new \external_value(PARAM_RAW, |
119 | 117 | 'Id number of the question category.'),
|
120 |
| - 'questionidnumber' => new external_value(PARAM_RAW, |
| 118 | + 'questionidnumber' => new \external_value(PARAM_RAW, |
121 | 119 | 'Id number of the question.'),
|
122 |
| - 'iframedescription' => new external_value(PARAM_TEXT, |
| 120 | + 'iframedescription' => new \external_value(PARAM_TEXT, |
123 | 121 | 'Iframe description.'),
|
124 |
| - 'behaviour' => new external_value(PARAM_RAW, |
| 122 | + 'behaviour' => new \external_value(PARAM_RAW, |
125 | 123 | 'Question behaviour.'),
|
126 |
| - 'maxmark' => new external_value(PARAM_RAW_TRIMMED, |
| 124 | + 'maxmark' => new \external_value(PARAM_RAW_TRIMMED, |
127 | 125 | 'Question maximum mark (float or "").'),
|
128 |
| - 'variant' => new external_value(PARAM_RAW_TRIMMED, |
| 126 | + 'variant' => new \external_value(PARAM_RAW_TRIMMED, |
129 | 127 | 'Question variant (int or "").'),
|
130 |
| - 'correctness' => new external_value(PARAM_RAW_TRIMMED, |
| 128 | + 'correctness' => new \external_value(PARAM_RAW_TRIMMED, |
131 | 129 | 'Whether to show question correctness (1/0/"") for show, hide or default.'),
|
132 |
| - 'marks' => new external_value(PARAM_RAW_TRIMMED, |
| 130 | + 'marks' => new \external_value(PARAM_RAW_TRIMMED, |
133 | 131 | 'Wheter to show mark information (0/1/2/"") for hide, show max only, show mark and max or default.'),
|
134 |
| - 'markdp' => new external_value(PARAM_RAW_TRIMMED, |
| 132 | + 'markdp' => new \external_value(PARAM_RAW_TRIMMED, |
135 | 133 | 'Decimal places to use when outputting grades.'),
|
136 |
| - 'feedback' => new external_value(PARAM_RAW_TRIMMED, |
| 134 | + 'feedback' => new \external_value(PARAM_RAW_TRIMMED, |
137 | 135 | 'Whether to show specific feedback (1/0/"") for show, hide or default.'),
|
138 |
| - 'generalfeedback' => new external_value(PARAM_RAW_TRIMMED, |
| 136 | + 'generalfeedback' => new \external_value(PARAM_RAW_TRIMMED, |
139 | 137 | 'Whether to show general feedback (1/0/"") for show, hide or default.'),
|
140 |
| - 'rightanswer' => new external_value(PARAM_RAW_TRIMMED, |
| 138 | + 'rightanswer' => new \external_value(PARAM_RAW_TRIMMED, |
141 | 139 | 'Whether to show the automatically generated right answer display (1/0/"") for show, hide or default.'),
|
142 |
| - 'history' => new external_value(PARAM_RAW_TRIMMED, |
| 140 | + 'history' => new \external_value(PARAM_RAW_TRIMMED, |
143 | 141 | 'Whether to show the response history (1/0/"") for show, hide or default.'),
|
144 |
| - 'forcedlanguage' => new external_value(PARAM_LANG, |
| 142 | + 'forcedlanguage' => new \external_value(PARAM_LANG, |
145 | 143 | 'Whether to force the UI language of the question. Lang code or empty string.'),
|
146 | 144 | ]);
|
147 | 145 | }
|
148 | 146 |
|
149 | 147 | /**
|
150 | 148 | * Returns result type for for get_embed_code function.
|
151 | 149 | *
|
152 |
| - * @return external_description Result type |
| 150 | + * @return \external_description Result type |
153 | 151 | */
|
154 |
| - public static function get_embed_code_returns(): external_description { |
155 |
| - return new external_value(PARAM_RAW, 'Embed code to show this question with those options.'); |
| 152 | + public static function get_embed_code_returns(): \external_description { |
| 153 | + return new \external_value(PARAM_RAW, 'Embed code to show this question with those options.'); |
156 | 154 | }
|
157 | 155 |
|
158 | 156 | /**
|
|
0 commit comments