Skip to content

Commit

Permalink
Matrix: column selection when they are legion #742237
Browse files Browse the repository at this point in the history
  • Loading branch information
mkassaei authored and timhunt committed Nov 29, 2023
1 parent 740ccd3 commit d669c20
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
13 changes: 5 additions & 8 deletions edit_oumatrix_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,9 @@ protected function add_per_row_fields(MoodleQuickForm $mform, string $label) {
protected function get_per_row_fields(MoodleQuickForm $mform, string $label, array &$repeatedoptions): array {
$repeated = [];
$rowoptions = [];
$rowoptions[] = $mform->createElement('text', 'rowname', '', ['size' => 40]);
$repeated[] = $mform->createElement('text', 'rowname', $label, ['size' => 40]);
$mform->setType('rowname', PARAM_RAW);

$rowanswerlistlabel = ($this->inputtype === 'single') ?
get_string('correctanswer', 'qtype_oumatrix') :
get_string('correctanswers', 'qtype_oumatrix');
$rowoptions[] = $mform->createElement('html',
html_writer::tag('span', $rowanswerlistlabel, ['class' => 'pl-3 pr-2']));

// Get the list answer input type (radio buttons or checkboxes).
for ($i = 0; $i < $this->numcolumns; $i++) {
$anslabel = get_string('answerlabelshort', 'qtype_oumatrix', $i + 1);
Expand All @@ -191,7 +185,10 @@ protected function get_per_row_fields(MoodleQuickForm $mform, string $label, arr
$rowoptions[] = $mform->createElement('checkbox', "rowanswers$columnvalue", '', $anslabel);
}
}
$repeated[] = $mform->createElement('group', 'rowoptions', $label, $rowoptions, null, false);
$rowanswerlistlabel = ($this->inputtype === 'single') ?
get_string('correctanswer', 'qtype_oumatrix') :
get_string('correctanswers', 'qtype_oumatrix');
$repeated[] = $mform->createElement('group', 'rowoptions', $rowanswerlistlabel, $rowoptions, null, false);
$repeated[] = $mform->createElement('editor', 'feedback',
get_string('feedback', 'question'), ['rows' => 2], $this->editoroptions);
$repeatedoptions['rowname']['type'] = PARAM_RAW;
Expand Down
12 changes: 3 additions & 9 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
}

/* Editing form. */
body#page-question-type-oumatrix div[id^=fgroup_id_][id*=rowoptions_] {
body#page-question-type-oumatrix div[id^=fitem_id_][id*=rowname_],
body#page-question-type-oumatrix div[id^=fgroup_id_][id*=rowoptions_],
body#page-question-type-oumatrix div[id^=fitem_id_][id*=feedback_] {
background: #eee;
margin-top: 0;
margin-bottom: 0;
padding-bottom: 5px;
padding-top: 5px;
border: 1px solid #bbb;
border-bottom: 0;
}
body#page-question-type-oumatrix label[data-fieldtype=checkbox] {
margin-right: 0.75rem;
Expand All @@ -32,11 +32,5 @@ body#page-question-type-oumatrix div[id^=fgroup_id_][id*=error_rowoptions_] {
border: 0;
}
body#page-question-type-oumatrix div[id^=fitem_id_][id*=feedback_] {
background: #eee;
margin-bottom: 2em;
margin-top: 0;
padding-bottom: 5px;
padding-top: 5px;
border: 1px solid #bbb;
border-top: 0;
}

0 comments on commit d669c20

Please sign in to comment.