Skip to content

Commit b716ac0

Browse files
committed
Display: Remove redundant inline styles and attributes for radio buttons in multiple-answer exercises #7378
1 parent 2431daf commit b716ac0

2 files changed

Lines changed: 7 additions & 19 deletions

File tree

public/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ public function createAnswersForm($form)
6262

6363
$form->addHeader(get_lang('Answers'));
6464

65-
// Force native radios visibility even if global CSS resets form controls.
66-
$choiceInputAttrs = [
67-
'class' => 'h-4 w-4 cursor-pointer',
68-
'style' => 'appearance:auto;-webkit-appearance:auto;',
69-
];
70-
7165
// Determine if options exist already (edit) or not (first creation).
7266
$hasOptions = false;
7367
if (!empty($this->id)) {
@@ -161,8 +155,8 @@ public function createAnswersForm($form)
161155
$trueValue = $hasOptions ? (int) $tfIids[1] : 1;
162156
$falseValue = $hasOptions ? (int) $tfIids[2] : 2;
163157

164-
$form->addElement('radio', 'correct['.$i.']', null, null, $trueValue, $choiceInputAttrs);
165-
$form->addElement('radio', 'correct['.$i.']', null, null, $falseValue, $choiceInputAttrs);
158+
$form->addElement('radio', 'correct['.$i.']', null, null, $trueValue);
159+
$form->addElement('radio', 'correct['.$i.']', null, null, $falseValue);
166160

167161
$form->addHtmlEditor(
168162
'answer['.$i.']',

public/main/exercise/multiple_answer_true_false.class.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ public function createAnswersForm($form)
8080
// Can be more options in the future
8181
$optionData = Question::readQuestionOption($this->id, $course_id);
8282

83-
// Safe input attrs (force visibility even if global CSS sets appearance:none)
84-
$choiceInputAttrs = [
85-
'class' => 'h-4 w-4 cursor-pointer',
86-
'style' => 'appearance:auto;-webkit-appearance:auto;',
87-
];
88-
8983
for ($i = 1; $i <= $nb_answers; $i++) {
9084
$form->addHtml('<tr>');
9185

@@ -139,7 +133,7 @@ public function createAnswersForm($form)
139133
foreach ($optionData as $data) {
140134
$value = (int) ($data['iid'] ?? 0);
141135
if ($value > 0) {
142-
$form->addElement('radio', 'correct['.$i.']', null, null, $value, $choiceInputAttrs);
136+
$form->addElement('radio', 'correct['.$i.']', null, null, $value);
143137
$count++;
144138
}
145139
if ($count >= 2) {
@@ -148,13 +142,13 @@ public function createAnswersForm($form)
148142
}
149143
} else {
150144
// Fallback
151-
$form->addElement('radio', 'correct['.$i.']', null, null, 1, $choiceInputAttrs);
152-
$form->addElement('radio', 'correct['.$i.']', null, null, 2, $choiceInputAttrs);
145+
$form->addElement('radio', 'correct['.$i.']', null, null, 1);
146+
$form->addElement('radio', 'correct['.$i.']', null, null, 2);
153147
}
154148
} else {
155149
// New question: positions 1/2 are mapped to the real option iids on save
156-
$form->addElement('radio', 'correct['.$i.']', null, null, 1, $choiceInputAttrs);
157-
$form->addElement('radio', 'correct['.$i.']', null, null, 2, $choiceInputAttrs);
150+
$form->addElement('radio', 'correct['.$i.']', null, null, 1);
151+
$form->addElement('radio', 'correct['.$i.']', null, null, 2);
158152

159153
$defaults['answer['.$i.']'] = '';
160154
$defaults['comment['.$i.']'] = '';

0 commit comments

Comments
 (0)