mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
MDL-24594 Fix some issues with the display of HTML choices.
The most significant issue is that the HTML editor alwasy wraps <p> tags round the input, but that is not appropriate for the choices. It is especially not appropriate because we want to display the choices in a <lable> for accessibility and usability reasons. In valid HTML label can only contain inline elemnts. Therefore, I introduced a make_html_inline method, with a minimal implementation. (It could be improved in future.) Long term, I think the best option would be a new form field type, editorinline, or something like that. That would be a smaller version of TinyMCE that only lets you enter inline elements.
This commit is contained in:
parent
2a6c5c52ee
commit
35c9b65274
8 changed files with 47 additions and 15 deletions
|
@ -751,8 +751,14 @@ class question_type {
|
|||
* Initialise question_definition::answers field.
|
||||
* @param question_definition $question the question_definition we are creating.
|
||||
* @param object $questiondata the question data loaded from the database.
|
||||
* @param bool $forceplaintextanswers most qtypes assume that answers are
|
||||
* FORMAT_PLAIN, and dont use the answerformat DB column (it contains
|
||||
* the default 0 = FORMAT_MOODLE). Therefore, by default this method
|
||||
* ingores answerformat. Pass false here to use answerformat. For example
|
||||
* multichoice does this.
|
||||
*/
|
||||
protected function initialise_question_answers(question_definition $question, $questiondata) {
|
||||
protected function initialise_question_answers(question_definition $question,
|
||||
$questiondata, $forceplaintextanswers = true) {
|
||||
$question->answers = array();
|
||||
if (empty($questiondata->options->answers)) {
|
||||
return;
|
||||
|
@ -760,6 +766,9 @@ class question_type {
|
|||
foreach ($questiondata->options->answers as $a) {
|
||||
$question->answers[$a->id] = new question_answer($a->id, $a->answer,
|
||||
$a->fraction, $a->feedback, $a->feedbackformat);
|
||||
if (!$forceplaintextanswers) {
|
||||
$question->answers[$a->id]->answerformat = $a->answerformat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue