| [ Index ] |
PHP Cross Reference of Moodle 310 |
[Summary view] [Print] [Text view]
1 This files describes API changes for the core question engine. 2 3 === 3.9 === 4 5 1) In the past, whenever a question_usage_by_activity was loaded from the database, 6 the apply_attempt_state was immediately called on every question, whether the 7 results of doing that were ever used, or not. 8 9 Now we have changed the code flow, so that apply_attempt_state is only called 10 when some data or processing is requested (e.g. analysing a response or rendering 11 the question) which requires the question to be fully initialised. This is MDL-67183. 12 13 This change should be completely invisible with everything handled by the question 14 engine. If you don't change your code, it should continue to work. 15 16 However, to get the full advantage of this change, you should review your code, 17 and look at every call to get_question or get_behaviour (on a question_attempt or 18 question_usage_by_activity). The problem with these methods is that the question engine 19 cannot know what you are planning to do with the question once you have got it. 20 Therefore, they have to assume that apply_attempt_state must be called - which can be expensive. 21 If you know that you don't need that (because, for example, you are just going to 22 look at ->id or ->questiontext or something simple) then you should pass 23 false to these functions, to get the possible performance benefit. 24 In addition, there is a new method $qa->get_question_id() to handle that case more simply. 25 26 Note that you don't have worry about this in places like the renderer for your question 27 type, because by the time you are in the renderer, the question will already have been 28 initialised. 29 30 31 === 3.7 === 32 33 1) When a question is rendered, the outer div of the question has an id="q123" 34 added. Unfortunately, this id was not actually unique, leading to bugs like 35 MDL-52572. Therefore, we have had to change it. The id used now is what 36 is returned by the new method $qa->get_outer_question_div_unique_id(). 37 The old code that you need to search for and replace with a call to this 38 method is "'q' . $qa->get_slot()" 39 40 Note, the new method has also been added to Moodle 3.5.6 and 3.6.4, but 41 returning the old id. This is to help question types that want to support 42 multiple Moodle versions. 43 44 === 3.1, 3.0.3, 2.9.5 === 45 46 1) The field question_display_options::$extrainfocontent is now displayed in the 47 outcomes (yellow) div by default. It used to be in the info div. If you have 48 overriden the question renderer, you may need to make a corresponding change. 49 50 51 === 3.0, 2.9.2, 2.8.8 === 52 53 1) The extra internal PARAM constant question_attempt::PARAM_MARK should no 54 longer be used. (It should not have been used outside the core of the 55 question system). See MDL-51090 if you want more explanation. 56 57 58 === 2.9 === 59 60 1) Some new methods on the question_usage class (and corresponding methods on 61 question_attempt, question_attempt_step, question_usage_observer, ... requried 62 to implement them, but almost certainly you should only be calling the 63 question_usage methods from your code. 64 65 * question_usage::add_question_in_place_of_other($slot, $question, $maxmark = null) 66 67 This creates a new questoin_attempt in place of an existing one, moving the 68 existing question_attempt to the end of the usage, in a new slot number. 69 The new slot number is returned. The goal is to replace the old attempt, but 70 not lose the old data. 71 72 * question_usage::set_question_max_mark($slot, $maxmark) 73 74 Sets the max mark for one question in this usage. Previously, you could 75 only change this using the bulk operation question_usage::set_max_mark_in_attempts; 76 77 * question_usage::set_question_attempt_metadata($slot, $name, $value); 78 question_usage::get_question_attempt_metadata($slot, $name); 79 80 You can now record metadata, that is, values stored by name, against 81 question_attempts. The question engine ignores this data (other than storing 82 and loading it) but you may find it useful in your code. 83 84 To see examples of where these are used, look at the chagnes from MDL-40992. 85 86 2) New fields in question_display_options, ->extrainfocontent and ->extrahistorycontent. 87 These default to blank, but can be used to inject extra content into those parts 88 of the question display. If you have overridden the methods in 89 core_question_renderer that use these fields, you may need to update your renderer. 90 91 92 === 2.6 === 93 94 1) The method question_behaviour::is_manual_grade_in_range and move and become 95 question_engine::is_manual_grade_in_range. 96 97 2) The arguments to core_question_renderer::mark_summary changed from 98 ($qa, $options) to ($qa, $behaviouroutput, $options). If you have overridden 99 that method you will need to update your code. 100 101 3) Heading level for number(), add_part_heading() and respond_history() 102 has been lowered by one level. These changes are part of improving the page 103 accessibility and making heading to have proper nesting. (MDL-41615) 104 105 === Earlier changes === 106 107 * Were not documented in this way. Sorry.
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 22 11:59:49 2025 | Cross-referenced by PHPXref 0.7.1 |