1 This files describes API changes for code that uses the question API.
5 1) Previously, the questionbank api classes were coupled in one place. Now the classes
6 are divided in two different parts, base classes and feature classes. All the base
7 classes are moved classes/local/bank and all the feature classes will be moved to
8 the plugin for that feature.
10 2) submit_tags_form and associated external services for question tag, tags_form in question/type,
11 core_question_output_fragment_tags_form method in lib is deprecated and moved to the tagquestion plugin.
13 3) Function question_get_export_single_question_url() in questionlib has been deprecated
14 and moved to qbank_exporttoxml plugin, the new location is:
15 qbank_exporttoxml\helper::question_get_export_single_question_url().
17 4) The following methods are deprecated in previewlib and moved to the previewquestion plugin:
18 restart_preview(), question_preview_form_url(), question_preview_action_url(),
19 question_preview_question_pluginfile()
20 The following classes are deprecated in previewlib and moves the previewquestion plugin:
21 question_preview_options, preview_options_form.
23 5) submit_tags_form and associated external services for question tag, tags_form in question/type,
24 core_question_output_fragment_tags_form method in lib is deprecated and moved to the tagquestion plugin.
26 6) Function question_get_export_single_question_url() in questionlib has been deprecated
27 and moved to qbank_exporttoxml plugin, the new location is:
28 qbank_exporttoxml\exporttoxml_helper::question_get_export_single_question_url().
30 7) The following classes are deleted and available in the new location:
31 'core_question\bank\action_column_base' => 'core_question\local\bank\action_column_base',
32 'core_question\bank\checkbox_column' => 'core_question\local\bank\checkbox_column',
33 'core_question\bank\column_base' => 'core_question\local\bank\column_base',
34 'core_question\bank\edit_menu_column' => 'core_question\local\bank\edit_menu_column',
35 'core_question\bank\menu_action_column_base' => 'core_question\local\bank\menu_action_column_base',
36 'core_question\bank\menuable_action' => 'core_question\local\bank\menuable_action',
37 'core_question\bank\random_question_loader' => 'core_question\local\bank\random_question_loader',
38 'core_question\bank\row_base' => 'core_question\local\bank\row_base',
39 'core_question\bank\view' => 'core_question\local\bank\view',
40 'core_question\bank\copy_action_column' => 'qbank_editquestion\copy_action_column',
41 'core_question\bank\edit_action_column' => 'qbank_editquestion\edit_action_column',
42 'core_question\bank\creator_name_column' => 'qbank_viewcreator\creator_name_column',
43 'core_question\bank\modifier_name_column' => 'qbank_viewcreator\modifier_name_column',
44 'core_question\bank\question_name_column' => 'qbank_viewquestionname\viewquestionname_column_helper',
45 'core_question\bank\question_name_idnumber_tags_column' => 'qbank_viewquestionname\question_name_idnumber_tags_column',
46 'core_question\bank\delete_action_column' => 'qbank_deletequestion\delete_action_column',
47 'core_question\bank\export_xml_action_column' => 'qbank_exporttoxml\export_xml_action_column',
48 'core_question\bank\preview_action_column' => 'qbank_previewquestion\preview_action_column',
49 'core_question\bank\question_text_row' => 'qbank_viewquestiontext\question_text_row',
50 'core_question\bank\question_type_column' => 'qbank_viewquestiontype\question_type_column',
51 'core_question\bank\tags_action_column' => 'qbank_tagquestion\tags_action_column',
52 'core_question\form\tags' => '\qbank_tagquestion\form\tags_form',
53 'core_question\output\qbank_chooser' => 'qbank_editquestion\qbank_chooser',
54 'core_question\output\qbank_chooser_item' => 'qbank_editquestion\qbank_chooser_item',
56 8) The following classes are deprecated and moved to a new location. These are marked for final deprecation on 4.4:
57 'question_category_list' => 'qbank_managecategories\question_category_list',
58 'question_category_list_item' => 'qbank_managecategories\question_category_list_item',
59 'question_category_object' => 'qbank_managecategories\question_category_object',
60 'question_category_edit_form' => 'qbank_managecategories\form\category_form',
61 'question_export_form' => 'qbank_exportquestions\form\export_form',
62 'question_import_form' => 'qbank_importquestions\form\question_import_form',
63 'question_move_form' => 'qbank_managecategories\form\question_move_form',
64 'preview_options_form' => 'qbank_previewquestion\form\preview_options_form',
65 'question_preview_options' => 'qbank_previewquestion\output\question_preview_options',
66 'category_form' => 'qbank_managecategories\form\category_form',
67 'export_form' => 'qbank_exportquestions\form\export_form'.
69 9) The following functions are deprecated and moved to the new location:
70 question_preview_question_pluginfile() => qbank_previewquestion\helper::question_preview_question_pluginfile(),
71 question_preview_action_url() => qbank_previewquestion\helper::question_preview_action_url(),
72 question_preview_form_url() => qbank_previewquestion\helper::question_preview_form_url(),
73 restart_preview() => qbank_previewquestion\helper::restart_preview(),
74 core_question_output_fragment_tags_form() => /question/bank/qbank_tagquestion/lib.php.
76 10)The qbank api now allows bulk actions from qbank plugins. Its possible to implement a qbank plugin and pass the bulk
77 bulk action object from the plugin feature using the get_bulk_actions(). The base class for this feature is bulk_action_base.
78 The following methods are deprecated as a part of bulk actions ui implementation and its no more required to call these methods
79 anymore as the api is now self sufficient, calling the api will fetch all the features:
80 process_actions(), process_actions_needing_ui().
84 1) For years, the ..._questions_in_use callback has been the right way for plugins to
85 tell the core question system if questions are required. Previously this callback
86 only worked in mods. Now it works in all plugins.
88 At the same time, if you are still relying on the legacy ..._question_list_instances
89 callback for this, you will now get a debugging warning telling you to upgrade.
91 2) Previously, the functions question_delete_activity, question_delete_course and
92 question_delete_course_category would echo output. This was not correct behaviour for
93 a low-level API function. Now, they no longer output. Related to this, the helper
94 function they use, question_delete_context, now always returns an empty array.
96 This probably won't acutally cause you any problems. However, you may previously
97 have had to add expectOutputRegex calls to your unit tests to avoid warnings about
98 risky tests. If you have done that, those tests will now fail until you delete that expectation.
103 If you have customised the display of the question bank (using $CFG->questionbankcolumns)
104 then be aware that the default configuration has changed, and you may wish to make
105 equivalent changes in your customised version. The old column question_name_column
106 has been replaced by question_name_idnumber_tags_column. The old question_name_column
107 still exists, so it is safe to continue using it.
109 There is a new question bank column edit_menu_column which displays all actions
110 in a drop-down menu, instead of as separate icons. This is now used by default.
111 Specifically, it gathers all other columns which implement the new interface
112 menuable_action. If you have made a custom subclasses of action_column_base,
113 you probably want to implement the new interface. If your column is a simple action,
114 the easiest way to do this will be to subclass menu_action_column_base. If your action
115 is more complex, and does not follow the simple pattern that menu_action_column_base
116 uses, then you will need to implement menuable_action yourself. The commit for
117 MDL-66816 updates all the core action columns. Looking at that change should make
118 it clearly the changes you need to make to your columns.
123 The code for the is_valid_number function that was duplicated in the
124 qtype_numerical and qtype_multianswer plugins in the qtype_numerical_edit_form
125 and qtype_multianswer_edit_form classes has been moved to a static function
126 in the qtype_numerical class of the qtype_numerical plugin.
128 The exportprocess function of the qformat_default class doesn't output a blank line
129 if the result of the writequestion function is null. This permit to qformat plugins
130 to ignore some questions without the need to overwrite this function.
132 * The question_preview_cron() has been deleted. Please use \core\task\question_cron_task::execute().
133 * The question_usage_statistics_cron() has been deleted. Please use \core\task\question_cron_task::execute().
134 * The method question_bank::cron() has been deleted, please use question related scheduled tasks.
138 1) The question format exportprocess function now adds a
139 $checkcapabilities boolean to allow questions to be exported in
140 certain circumstances.
144 1) The following renderers have been deprecated in favour of the renderable
145 core_question\output\qbank_chooser and associated render_* method.
147 * qbank_chooser_types
148 * qbank_chooser_qtype
149 * qbank_chooser_title
153 1) The argument $requirecourseid was removed from question_edit_setup() and
154 is no longer respected. The behaviour was found to be buggy and now throws
155 debugging notices if passed.
159 1) Some functions in questionlib.php which were deprecated in the past have now
163 * question_list_instances
165 * question_category_isused
166 * save_question_options
167 * question_get_real_state
170 * question_rewrite_questiontext_preview_urls
171 * question_send_questiontext_file
172 * question_pluginfile no longer falls back to using the old
173 {$previewcomponent}_questiontext_preview_pluginfile callback if the new
174 {$previewcomponent}_question_preview_pluginfile callback is missing.
179 1) This is just a warning that some methods of the question_engine_data_mapper
180 class have changed. All these methods are ones that you should not have been
181 calling directly from your code, so this should not cause any problems.
182 The changed methods are:
183 * insert_question_attempt
185 * update_question_attempt_step
190 1) Changes to class question_bank_view:
192 Filters, including $recurse and $showhidden, are now implemented as
193 pluggable \core_question\bank\search\condition classes.
195 Therefore $recurse and $showhidden are no longer passed to the following functions:
196 protected function display_options [deprecated, use display_options_form()]
197 protected function build_query_sql [deprecated, use build_query()]
199 protected function display_category_form() is deprecated. Use \core_question\bank\search\category_condition
201 protected function display_category_form_checkbox deprecated use html_writer::checkbox and separate JavaScript
203 To add filters, local plugins can now implement the function local_[pluginname]_get_question_bank_search_conditions,
205 2) To make columns available to question_bank_view, plugins can extend core_question\bank\column_base.
206 Users may choose to display additional columns by setting $CFG->questionbankcolumns to a comma-delimited list of columns.
208 3) The subsort separator has changed from _ to - in order to distinuguish subsorts vs frankenstyle component separators.
210 4) Because of the move to autoloading, $knowncolumntypes and known_field_types() are no longer used.
212 5) question_bank_column_base and it's derived classes have been namespaced to core_question\bank\column_base.
217 1) Modules using the question bank MUST now declare their use of it with the xxx_supports()
218 flag FEATURE_USES_QUESTIONS. question_module_uses_questions() should be used to determine
219 if a module uses questions.
221 2) It is sometimes necessary to display bits of question content without having
222 and attempt (question_usage) in progress. Two examples of this are the option
223 in the question bank to display the questiontext, and in the quiz statistics
224 report, where it displays the question text above the report.
226 Previously, this display was done using a special method that only worked for
227 the question text, but which would not work for other parts of the question.
228 That old mechanism has been deprecated, and there is a new method that you
231 To display the question, replace calls to question_rewrite_questiontext_preview_urls
232 with calls to question_rewrite_question_preview_urls. Because the new function
233 is more flexibile, you have to pass more arguments.
235 To perform the necessary permission checks when the file is downloaded, you need
236 to implement the callback [component name]_question_preview_pluginfile.
237 (Previously you implemented [component name]_questiontext_preview_pluginfile.)
238 quiz_statistics_question_preview_pluginfile is an example of what to do.
240 question_send_questiontext_file has been deprecated. It is no longer necessary.
242 To ensure you are no longer using or defining any deprecated functions,
243 search for the regular expression:
244 question_rewrite_questiontext_preview_urls|_questiontext_preview_pluginfile|question_send_questiontext_file
246 3) The argument list for core_question_renderer::mark_summary has changed.
247 Please update your calls. (The most likely scenario for this is if you have
248 overridden core_question_renderer::info in your own renderer.) You need to
250 - $this->mark_summary($qa, $options);
251 + $this->mark_summary($qa, $behaviouroutput, $options);