afa215d325f54d874997c878a87f416e46c5a59c
[moodle.git] / mod / quiz / upgrade.txt
1 This files describes API changes in the quiz code.
3 === 4.2 ===
5 * The methods in the quiz_settings class which return a URL now all return a moodle_url. Previously
6   some returns a moodle_url and others aa string.
8 * 'firstslotid' value is not used in section_shuffle_updated event anymore.
10 * The quiz has a lot of old classes in lib.php files. These have now been moved into the classes folder,
11   and so are now in namespaces. Because of Moodle's class renaming support, your code should continue
12   working, but output deprecated warnings, so you probably want to update. This should mostly be
13   doable by adding use statements, and a search/replace.
14   - mod_quiz_display_options => mod_quiz\question\display_options
15   - qubaids_for_quiz => mod_quiz\question\qubaids_for_quiz
16   - qubaids_for_quiz_user => mod_quiz\question\qubaids_for_quiz_user - which is deprecated, because
17           it is almost the same as mod_quiz\question\qubaids_for_users_attempts.
18   - mod_quiz_admin_setting_browsersecurity => mod_quiz\admin\browser_security_setting
19   - mod_quiz_admin_setting_grademethod => mod_quiz\admin\grade_method_setting
20   - mod_quiz_admin_setting_overduehandling => mod_quiz\admin\overdue_handling_setting
21   - mod_quiz_admin_review_setting => mod_quiz\admin\review_setting
22   - mod_quiz_admin_setting_user_image => mod_quiz\admin\user_image_setting
23   - mod_quiz_admin_setting_browsersecurity => mod_quiz\admin\browser_security_setting
24   - mod_quiz_admin_setting_grademethod => mod_quiz\admin\grade_method_setting
25   - mod_quiz_admin_setting_overduehandling => mod_quiz\admin\overdue_handling_setting
26   - mod_quiz_admin_review_setting => mod_quiz\admin\review_setting
27   - mod_quiz_admin_setting_user_image => mod_quiz\admin\user_image_setting
28   - mod_quiz\adminpresets\adminpresets_mod_quiz_admin_setting_browsersecurity =>
29             mod_quiz\adminpresets\adminpresets_browser_security_setting
30   - mod_quiz\adminpresets/adminpresets_mod_quiz_admin_setting_grademethod =>
31             mod_quiz\adminpresets\adminpresets_grade_method_setting
32   - mod_quiz\adminpresets\adminpresets_mod_quiz_admin_setting_overduehandling =>
33             mod_quiz\adminpresets\adminpresets_overdue_handling_setting
34   - mod_quiz\adminpresets\adminpresets_mod_quiz_admin_review_setting =>
35             mod_quiz\adminpresets\adminpresets_review_setting
36   - mod_quiz\adminpresets\adminpresets_mod_quiz_admin_setting_user_image =>
37             mod_quiz\adminpresets\adminpresets_user_image_setting
38   - quiz_default_report => mod_quiz\local\reports\report_base
39   - quiz_attempts_report => mod_quiz\local\reports\attempts_report
40   - mod_quiz_attempts_report_form => mod_quiz\local\reports\attempts_report_options_form
41   - mod_quiz_attempts_report_options => mod_quiz\local\reports\attempts_report_options
42   - quiz_attempts_report_table => mod_quiz\local\reports\attempts_report_table
43   - quiz_access_manager => mod_quiz\access_manager
44   - mod_quiz_preflight_check_form => mod_quiz\form\preflight_check_form
45   - quiz_override_form => mod_quiz\form\edit_override_form
46   - quiz_access_rule_base => mod_quiz\local\access_rule_base
47   - quiz_add_random_form => mod_quiz\form\add_random_form
48   - mod_quiz_links_to_other_attempts => mod_quiz\output\links_to_other_attempts
49   - mod_quiz_view_object => mod_quiz\output\view_page
50   - mod_quiz_renderer => mod_quiz\output\renderer
51   - quiz_nav_question_button => mod_quiz\output\navigation_question_button
52   - quiz_nav_section_heading => mod_quiz\output\navigation_section_heading
53   - quiz_nav_panel_base => mod_quiz\output\navigation_panel_base
54   - quiz_attempt_nav_panel => mod_quiz\output\navigation_panel_attempt
55   - quiz_review_nav_panel => mod_quiz\output\navigation_panel_review
56   - quiz_attempt => mod_quiz\quiz_attempt
57   - quiz => mod_quiz\quiz_settings
58   - quizaccess_seb\quiz_settings => quizaccess_seb\seb_quiz_settings
59   - quizaccess_seb\access_manager => quizaccess_seb\seb_access_manager
61 * The following classes have been deprecated:
62   - mod_quiz_overdue_attempt_updater - merged into mod_quiz\task\update_overdue_attempts
63   - moodle_quiz_exception - just use normal moodle_exception
65 * As part of the clean-up, the following files are no longer required, and if you try to
66   include them, you will get a debugging notices telling you not to:
67   - mod/quiz/report/attemptsreport.php
68   - mod/quiz/report/attemptsreport_form.php
69   - mod/quiz/report/attemptsreport_options.php
70   - mod/quiz/report/attemptsreport_table.php
71   - mod/quiz/report/default.php
72   - mod/quiz/accessmanager.php
73   - mod/quiz/accessmanager_form.php
74   - mod/quiz/cronlib.php
75   - mod/quiz/override_form.php
76   - mod/quiz/accessrule/accessrulebase.php
77   - mod/quiz/renderer.php - actually, no debugging ouput for this one because of how renderer factories work.
78   - mod/quiz/attemptlib.php
80 * Various functions related to calculating grades have moved into a new class mod_quiz\grade_calculator.
81   You get that using $quizobj->get_grade_calculator(), then the following old functions have become these new methods.
82   - quiz_update_sumgrades -> recompute_quiz_sumgrades
83   - quiz_update_all_attempt_sumgrades -> recompute_all_attempt_sumgrades
84   - quiz_update_all_final_grades -> recompute_all_final_grades
85   - quiz_set_grade -> update_quiz_maximum_grade
86   - quiz_save_best_grade -> recompute_final_grade
87   - quiz_calculate_best_grade -> [no public direct replacement]
88   - quiz_calculate_best_attempt - [no replacement. It was not used.]
90 * Final deprecation (complete removal) of the following functions which were deprecated long ago:
91   - quiz_groups_member_added_handler - deprecated since 2.6
92   - quiz_groups_member_removed_handler - deprecated since 2.6
93   - quiz_groups_group_deleted_handler - deprecated since 2.6
94   - quiz_groups_members_removed_handler - deprecated since 2.6
95   - The method quiz_settings::confirm_start_attempt_message - deprecated in Moodle 3.1
96   - The field view_page::$startattemptwarning - deprecated in Moodle 3.1
97   - attempts_report::load_relevant_students - deprecated since 3.2
98   - quiz_statistics_graph_get_new_colour - deprecated since 3.2
99   - The file mod/quiz/report/overview/overviewgraph.php - deprecated since 3.2
100   - The file mod/quiz/report/statistics/statistics_graph.php - deprecated since 3.2
101   - quiz_print_overview - deprecated since 3.3
103 * For properties that were previously only declared dynamically, a few classes now include property declarations to support PHP 8.2.
104   The affected classes are:
105    - restore_quiz_activity_structure_step
106    - attempts_report_table
107    - attempts_report
108    - quiz_overview_report (Removing $hasgroupstudents, because the parent attempts_report class has the same variable.)
110 === 4.1 ===
112 * quiz_has_question_use is now deprecated. Use mod_quiz\structure::has_use_capability istead.
115 === 4.0.3, 4.1 ===
117 * If a quiz is sequential the external functions mod_quiz_external::get_attempt_data, mod_quiz_external::get_attempt_summary will not return any data
118 related to out of sequence question except while reviewing the quiz (MDL-75210).
120 === 4.0.2, 4.1 ===
122 * No external code should be calling quiz_overview_report::regrade_attempt because it is an
123   internal method of the quiz_overview plugin. But if you are incorrectly using it, be aware
124   that the API changed slightly. It now returns an array listing any questions which could
125   not be regraded.
126 * New method called get_number_of_unanswered_questions() has been added to mod/quiz/attemptlib.php
127   to get the total number of unanswered questions in the current attempt.
129 === 4.0 ===
131 * The following API methods have a new parameter, $studentisonline, to define whether the student is currently interacting:
132   - process_finish() in mod/quiz/attemptlib.php
133   - quiz_send_confirmation() in mod/quiz/locallib.php
134   - quiz_send_notification_messages() in mod/quiz/locallib.php
135 * The completionpass criteria has been moved to core as 'completionpassgrade'. Refer to completion/upgrade.txt for
136   further information.
137 * New argument quizhasquestions has been added to public methods: view_information in mod/quiz/renderer.php.
138 * The function no_questions_message() in class mod_quiz_renderer is deprecated. There is no replacement.
139 * Related to the Moodle 4.0 question bank changes, the quiz_slots database table.
140   The fields removed are now manage by new core_question tables:
141   - question_references -> Records where a specific question is used.
142   - question_set_references -> Records where groups of questions are used (e.g. random questions).
143 * The quiz_slots_tags database table has been removed entirely, as has the get_slot_tags_for_slot_id() method
144   from mod/quiz/classes/structure.php and the the locallib.php functions quiz_retrieve_slot_tags and
145   quiz_retrieve_slot_tag_ids. This information is now stored in question_set_references
146   and can be accessed in the results of qbank_helper::get_question_structure.
149 === 3.11 ===
151 * External function mod_quiz_external::get_user_best_grade now returns and additional optional field:
152   - gradetopass: The grade to pass the quiz (if set)
155 === 3.10.1 ===
157 * External functions mod_quiz_external::get_attempt_data, mod_quiz_external::get_attempt_summary
158   and mod_quiz_external::get_attempt_review now return a new additional optional field:
159    - settings: Containing the question definition settings for displaying the question in an external system.
161 === 3.10 ===
163 * External functions mod_quiz_external::get_attempt_data, mod_quiz_external::get_attempt_summary
164   and mod_quiz_external::get_attempt_review now return a new additional optional field:
165    - responsefileareas: Containing the user responses to questions file area names including files.
167 === 3.7 ===
169 * Quiz_cron() has been removed. Sub-plugins should implemented scheduled tasks, however legacy cron in subplugins are
170   supported.
172 === 3.6 ===
174 * The following renamed classes have been completely removed:
175   - quiz_question_bank_view (now: mod_quiz\question\bank\custom_view)
176   - question_bank_add_to_quiz_action_column (now: mod_quiz\question\bank\add_action_column)
177   - question_bank_question_name_text_column (now: mod_quiz\question\bank\question_name_text_column)
179 === 3.5 ===
180 * Removed questionbank.ajax.php. Please use the quiz_question_bank fragment instead.
181 * Adding "random" questions to a quiz via quiz_add_quiz_question() has been deprecated. Please use quiz_add_random_questions().
183 === 3.3.2 ===
185 * quiz_refresh_events() Now takes two additional parameters to refine the update to a specific instance. This function
186   now optionally takes the module instance object or ID, and the course module object or ID. Please try to send the full
187   objects instead of the ids to save DB calls.
189 === 3.2 ===
191 * External functions mod_quiz_external::get_attempt_data, mod_quiz_external::get_attempt_summary
192   and mod_quiz_external::get_attempt_review now return additional optional fields:
193    - blockedbyprevious: Whether a question is blocked by the previous question.
195 === 3.1 ===
197 * quiz_attempt::question_print_comment_fields() has been removed. It was broken
198   since at least Moodle 2.0.
200 * quiz::confirm_start_attempt_message and mod_quiz_view_object::$startattemptwarning
201   have been deprecated. This functionality is now entirely handled within the
202   quiz access rule plugins.
204 * The third argument to mod_quiz_renderer::start_attempt_button has been changed
205   from a warning string to a mod_quiz_preflight_check_form.
207 * mod_quiz_renderer::review_next_navigation has a new optional argument. If you
208   have overridden that method, consider updating your code to match.
210 * mod_quiz\output\edit_renderer::start_section_list now takes $structure as an
211   argument. If you have overridden this method (it's hard to believe anyone ever
212   would) you will need to update your renderer.
214 * Several methods relating to preview links/buttons/urls have a new optional
215   argument to make the preview be of a particular variant.
218 === 2.9 ===
220 * There have been changes in classes/output/edit_renderer.php for MDL-40990.
221   + Some methods use to take $structure & $question as the first two arguments.
222     They now take $structure & $slot number. If you need $question, you can get
223     it using $question = $structure->get_question_in_slot($slot);
224   + Some methods used to take $quiz & $question. They now take $structure & $slot
225     number. You can get $question as above. $quiz is $structure->get_quiz().
226   + initialise_editing_javascript has had some redundant arguments removed.
227   Hopefully, with these changes, we will have less need to make other changes in future.
229 * Due to MDL-40992, you should be aware that extra slots can get added to an attempt.
230   You may get slot numbers beyone the end of the original quiz layout, and you
231   may want to call $attemptobj->get_original_slot to find where the question
232   originally came from.
234 * You now need to pass an instance of the mod_quiz_renderer if you call
235   $attemptobj->render_question or $attemptobj->render_question_at_step.
237 * The array values in mod_quiz_links_to_other_attempts may now be either a moodle_url,
238   or renderable (or null). Previously they could only be a moodle_url or null.
240 * The contents of the navigation block is now not just quiz_nav_question_button-s.
241   It can also contain quiz_nav_section_heading-s. If you have overridden
242   mod_quiz_renderer::navigation_panel, then you may need to account for this.
243   This change also has implications for the Edit quiz page.
246 === 2.8 ===
248 * Classes that were defined in various lib files have been moved to the classes
249   folder to take advantage of auto-loading. This has involved renaming them.
250   see the list in mod/quiz/db/renamedclasses.php.
252 * The quiz no longer handles its own \mod_quiz\event\attempt_becameoverdue event,
253   and so the event handler function quiz_attempt_overdue_handler has been deleted.
254   Also, the internal function quiz_send_overdue_message has add the arguments
255   changed. It now takes the $attemptobj object, not separate stdClass objects.
257 * Major changes to the Edit quiz page.
259   The goal of this work was to increase usability, and also clean up the page
260   enough that it will be possible to add new features in future.
262   Display of mod/quiz/edit.php is now entirely generated by
263   mod_quiz\output\edit_renderer. This uses a helper class mod_quiz\structure
264   to provide details of the structure of the quiz, and mod_quiz\repaginate to
265   alter that structure. (Actually, there are still some modification methods on
266   mod_quiz\structure. Expect that to be cleaned up in future.)
268   The new code uses much more ajax, and there are new scripts mod/quiz/edit_rest.php
269   and mod/quiz/repaginate.php to handle this. (Again, don't be surprised if those
270   two scripts get merged in future.) Also questionbank.ajax.php (which may, in
271   future, be made more generic, and moved into the core question bank code.)
273   As a result of this, mod/quiz/editlib.php has gone. (A few remaining functions
274   were moved to locallib.php.)
276   Here is a list of all the old functions or classes that have changed.
277   If you used any of these in custom code, you will need to update your code.
278   (Note that many of these functions should have been considered private internals
279   of the quiz module, and you should not have been using them!)
281   From editlib.php:
282       quiz_remove_slot
283       quiz_delete_empty_page
284       quiz_add_page_break_after_slot    - Use methods of structure or repaginate
285       quiz_update_slot_maxmark          - classes instead.
286       _quiz_move_question
287       quiz_move_question_up
288       quiz_move_question_down
290       quiz_print_question_list
291       quiz_print_pagecontrols
292       quiz_print_singlequestion         - Use methods of edit_renderer instead.
293       quiz_print_randomquestion
294       quiz_print_singlequestion_reordertool
295       quiz_print_randomquestion_reordertool
296       print_random_option_icon
297       quiz_print_grading_form
298       quiz_print_status_bar
300   Moved from editlib.php to locallib.php:
301       quiz_question_tostring - now always returns a string (the only option used).
302                                The $return argument has gone.
304   Old editing JavaScript (e.g. mod/quiz/edit.js) is gone. Replaced with YUI modules.
307 === 2.7.1 ===
309 * The function quiz_fire_attempt_started_event has been removed. This function
310   should not have been used outside the quiz, but if you were using it, you should
311   trigger the event outside this function. Note that the appropriate start event is
312   fired automatically by the quiz_attempt_save_started function.
315 === 2.7 ===
317 * The old quiz.questions database column (comma-separated list of question ids)
318   is gone, and instead the quiz_question_instances table has been renamed to
319   to quiz_slots. Some of the columns of that table have been renamed to match
320   the coding guidelines. Specifically:
321       quiz     -> quizid
322       question -> questionid
323       grade    -> maxmark
324   also there are two new columns:
325       slot     -  numbers the questions in the quiz in order, as on the edit quiz page.
326       page     -  new way to determine which question is on which page.
327   naturally, other parts of the code and APIs have been updated to reflect that
328   change.
330 * The following functions, which were part of the internal workings of the quiz,
331   have been removed.
332       quiz_get_slot_for_question
333       quiz_number_of_questions_in_quiz
334       quiz_repaginate               (there is now a quiz_repaginate_questions with a different API).
335       quiz_add_page_break_at        (see quiz_add_page_break_after_slot)
336       quiz_add_page_break_after     (see quiz_add_page_break_after_slot)
337       quiz_number_of_pages
338       quiz_remove_question          (see quiz_remove_slot)
339       quiz_update_question_instance (see quiz_update_slot_maxmark)
341 * The following internal functions have had their API changed.
342       quiz_delete_empty_page: has had its arguments changed to $quiz and $pagenumber.
343       quiz_has_question_use: now takes $quiz and $slot, not $questionid.
346 === 2.6 ===
348 * As part of improving the page usability and accessibility, we updated the
349   heading levels for quiz module so it has a proper nesting. (MDL-41615)
351 * mod_quiz_renderer::view_best_score has been removed. (It did not do what the
352   name suggested anyway.)
355 === 2.4 ===
357 * mod_quiz_renderer::finish_review_link now requires $attemptobj to be passed in
358   instead of a moodle_url.
361 === Earlier changes ===
363 * Were not documented in this way. Sorry.