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