MDL-73975 course: Remove course_search_form template
[moodle.git] / question / engine / upgrade.txt
bloba2369dea035fa8654a6755e588b211d7c47357aa
1 This files describes API changes for the core question engine.
3 === 4.4 ===
5 * The method question_usage_by_activity::add_question_in_place_of_other has been made more flexible.
6   There is a new argument $keepoldquestionattempt. That defaults to true, which behaves the same as
7   the old API, but if you pass false, then the newly added question_attempt completely replaces the
8   existing one in-place.
10 === 4.2 ===
12 * A `$questionidentifier` property has been added to `\question_display_options` to enable question type plugins to associate the
13 question number to the question that is being rendered. This can be used to improve the accessibility of rendered
14 questions and can be especially be helpful for screen reader users as adding the question number on the answer field(s) labels
15 will allow them to distinguish between answer fields as they navigate through a quiz.
16 * Question type plugins can use \question_display_options::add_question_identifier_to_label() to add the question number to the
17 label of the answer field(s) of the question that is being rendered. The question number may be redundant when displayed, so the
18 function allows for it to be enclosed within an sr-only container.
20 === 4.0 ===
21 1) A new optional parameter $extraselect has been added as a part of load_questions_usages_where_question_in_state()
22    method in question/engine/datalib.php, anything passed here will be added to the SELECT list, use this to return extra data.
24 === 3.9 ===
26 1) In the past, whenever a question_usage_by_activity was loaded from the database,
27    the apply_attempt_state was immediately called on every question, whether the
28    results of doing that were ever used, or not.
30    Now we have changed the code flow, so that apply_attempt_state is only called
31    when some data or processing is requested (e.g. analysing a response or rendering
32    the question) which requires the question to be fully initialised. This is MDL-67183.
34    This change should be completely invisible with everything handled by the question
35    engine. If you don't change your code, it should continue to work.
37    However, to get the full advantage of this change, you should review your code,
38    and look at every call to get_question or get_behaviour (on a question_attempt or
39    question_usage_by_activity). The problem with these methods is that the question engine
40    cannot know what you are planning to do with the question once you have got it.
41    Therefore, they have to assume that apply_attempt_state must be called - which can be expensive.
42    If you know that you don't need that (because, for example, you are just going to
43    look at ->id or ->questiontext or something simple) then you should pass
44    false to these functions, to get the possible performance benefit.
45    In addition, there is a new method $qa->get_question_id() to handle that case more simply.
47    Note that you don't have worry about this in places like the renderer for your question
48    type, because by the time you are in the renderer, the question will already have been
49    initialised.
52 === 3.7 ===
54 1) When a question is rendered, the outer div of the question has an id="q123"
55    added. Unfortunately, this id was not actually unique, leading to bugs like
56    MDL-52572. Therefore, we have had to change it. The id used now is what
57    is returned by the new method $qa->get_outer_question_div_unique_id().
58    The old code that you need to search for and replace with a call to this
59    method is "'q' . $qa->get_slot()"
61    Note, the new method has also been added to Moodle 3.5.6 and 3.6.4, but
62    returning the old id. This is to help question types that want to support
63    multiple Moodle versions.
65 === 3.1, 3.0.3, 2.9.5 ===
67 1) The field question_display_options::$extrainfocontent is now displayed in the
68    outcomes (yellow) div by default. It used to be in the info div. If you have
69    overriden the question renderer, you may need to make a corresponding change.
72 === 3.0, 2.9.2, 2.8.8 ===
74 1) The extra internal PARAM constant question_attempt::PARAM_MARK should no
75    longer be used. (It should not have been used outside the core of the
76    question system). See MDL-51090 if you want more explanation.
79 === 2.9 ===
81 1) Some new methods on the question_usage class (and corresponding methods on
82    question_attempt, question_attempt_step, question_usage_observer, ... requried
83    to implement them, but almost certainly you should only be calling the
84    question_usage methods from your code.
86    * question_usage::add_question_in_place_of_other($slot, $question, $maxmark = null)
88      This creates a new questoin_attempt in place of an existing one, moving the
89      existing question_attempt to the end of the usage, in a new slot number.
90      The new slot number is returned. The goal is to replace the old attempt, but
91      not lose the old data.
93    * question_usage::set_question_max_mark($slot, $maxmark)
95      Sets the max mark for one question in this usage. Previously, you could
96      only change this using the bulk operation question_usage::set_max_mark_in_attempts;
98    * question_usage::set_question_attempt_metadata($slot, $name, $value);
99      question_usage::get_question_attempt_metadata($slot, $name);
101      You can now record metadata, that is, values stored by name, against
102      question_attempts. The question engine ignores this data (other than storing
103      and loading it) but you may find it useful in your code.
105    To see examples of where these are used, look at the chagnes from MDL-40992.
107 2) New fields in question_display_options, ->extrainfocontent and ->extrahistorycontent.
108    These default to blank, but can be used to inject extra content into those parts
109    of the question display. If you have overridden the methods in
110    core_question_renderer that use these fields, you may need to update your renderer.
113 === 2.6 ===
115 1) The method question_behaviour::is_manual_grade_in_range and move and become
116    question_engine::is_manual_grade_in_range.
118 2) The arguments to core_question_renderer::mark_summary changed from
119    ($qa, $options) to ($qa, $behaviouroutput, $options). If you have overridden
120    that method you will need to update your code.
122 3) Heading level for number(), add_part_heading() and respond_history()
123    has been lowered by one level. These changes are part of improving the page
124    accessibility and making heading to have proper nesting. (MDL-41615)
126 === Earlier changes ===
128 * Were not documented in this way. Sorry.