2 quiz tests are creating forms with text editors manually - they need to ensure a valid
$PAGE->url is set so they don't trigger debugging warnings from $PAGE->url magic method
called by Atto.
For users with edit permissions, but not add permissions, it was
impossible to save the editing form. The validation assuemd this value
was present, but it was not. Other code checks this field too, so I
added it rather than changing the validation and all the other uses.
For questions set to 'One answer only', the 'Clear incorrect responses'
and 'Show the number of correct responses' hint options make not sense,
and are not used. Hence we disableIf them.
In order to do this in a sane way, I cleaned up a lot of old mess,
inclduing:
1. Previously, qtype_calcuated used ->answeres when importing, and
->answer when saving the form. This was crazy, so I fixed it, and
stripped out the code that made the alternative variable name work.
2. Similarly, it could handle ->answer being either an array, such as
you would get form the HTML editor, or a simple string, which is what
you get form the form. I simplified that too.
3. Finally, I made import use a transaction around saving each
question, so we don't get half questions in the database when an error
occurs.
Some time ago, it when from using '0' for no-subcategories to blank.
Change to properly define '0' or '1', update old questions, and make
sure to fix newly restored questions.
question_type::save_question_answers function added, supporting
saving answers and extra answer fields. It can be called from
save_question_options function for the questions, using
question_answers table. Special functions created for overloading
so that every question could tune it to it's own form.
Shortanswer qtype save_question_options() converted as a proof of
concept and for testing purposes.
Now question_edit_form can load extra answer fields. If a question
type need to do something more complex for particular field, it
can overload added functions without duplicating other code.
Extra answer data may be optional, saving DB space - i.e. not every row in
question_answers will have respective row in extra answers table. Current
implementation of question_type::get_question_options() won't return such
answers at all. This commit fix that, changing join type for db query.
Also fixed coding style violation in the variable name in get_question_options.
The sequence of questions that made up a quiz used to be stored as a
comma-separated list in quiz.questions. Now the same information is
stored in the rows in the quiz_slots table. This is not just 'better' in
a database design sense, but it allows for the future changes we will
need as we enhance the quiz in the MDL-40987 epic.
Having changed the database structure, all the rest of the code needs to
be changed to account for it, and that is done here.
Note that there are not many unit tests for the changed bit. That is
because as part of MDL-40987 we will be changing the code further, and
we will add unit tests then.
This data should all have been upgraded when moving to Moodle 2.1. It
was only kept as a back-up, and now, after 3 years have past, we can
clean it up.
Added XML import/export
Different randomsamatch qtypes in the same quiz can now pick the same
shortanswer question.
Images are not preserved if shortanswer question is deleted after being
used in a randomsamatch attempt.