Skip to content

Commit

Permalink
MDL-70374 qtype_multichoice: code cleanup
Browse files Browse the repository at this point in the history
* Remove some obsoliete CSS.
* Put the CSS in a more logical order.
* Rename some variables in the renderer, for more clarity.
  • Loading branch information
timhunt committed Dec 18, 2020
1 parent 4d23573 commit add7eba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
10 changes: 5 additions & 5 deletions question/type/multichoice/renderer.php
Expand Up @@ -104,16 +104,16 @@ public function formulation_and_controls(question_attempt $qa,
));
}

$questionnumber = '';
$choicenumber = '';
if ($question->answernumbering !== 'none') {
$questionnumber = html_writer::span(
$choicenumber = html_writer::span(
$this->number_in_style($value, $question->answernumbering), 'answernumber');
}
$answertext = $question->format_text($ans->answer, $ans->answerformat, $qa, 'question', 'answer', $ansid);
$questionanswer = html_writer::div($answertext, 'flex-fill ml-1');
$choicetext = $question->format_text($ans->answer, $ans->answerformat, $qa, 'question', 'answer', $ansid);
$choice = html_writer::div($choicetext, 'flex-fill ml-1');

$radiobuttons[] = $hidden . html_writer::empty_tag('input', $inputattributes) .
html_writer::div($questionnumber . $questionanswer, 'd-flex w-100', [
html_writer::div($choicenumber . $choice, 'd-flex w-100', [
'id' => $inputattributes['id'] . '_label',
'data-region' => 'answer-label',
]);
Expand Down
21 changes: 6 additions & 15 deletions question/type/multichoice/styles.css
@@ -1,25 +1,10 @@
.que.multichoice .answer .specificfeedback {
display: inline;
padding: 0 0.7em;
background: #fff3bf;
}

.que.multichoice .answer div.r0,
.que.multichoice .answer div.r1 {
display: flex;
margin: 0.25rem 0;
align-items: flex-start;
}

.que.multichoice .answer div.r0 label,
.que.multichoice .answer div.r1 label,
.que.multichoice .answer div.r0 div.specificfeedback,
.que.multichoice .answer div.r1 div.specificfeedback {
/* In Chrome and IE, the text-indent above is applied to any embedded table
cells or <li>s, which screws up the intended layout. This fixes it again. */
text-indent: 0;
}

.que.multichoice .answer div.r0 input,
.que.multichoice .answer div.r1 input {
margin: 0.3rem 0.5rem;
Expand All @@ -30,6 +15,12 @@
min-width: 1.5em;
}

.que.multichoice .answer .specificfeedback {
display: inline;
padding: 0 0.7em;
background: #fff3bf;
}

/* Editing form. */
body#page-question-type-multichoice div[id^=fitem_id_][id*=answer_] {
background: #eee;
Expand Down

0 comments on commit add7eba

Please sign in to comment.