Skip to content

Commit

Permalink
MDL-68597 qtype_essay: switch the form to consistently use hideIf
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Jan 13, 2021
1 parent d9b0da8 commit 6fc462a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions question/type/essay/edit_essay_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ protected function definition_inner($mform) {
$mform->addElement('select', 'responserequired',
get_string('responserequired', 'qtype_essay'), $qtype->response_required_options());
$mform->setDefault('responserequired', 1);
$mform->disabledIf('responserequired', 'responseformat', 'eq', 'noinline');
$mform->hideIf('responserequired', 'responseformat', 'eq', 'noinline');

$mform->addElement('select', 'responsefieldlines',
get_string('responsefieldlines', 'qtype_essay'), $qtype->response_sizes());
$mform->setDefault('responsefieldlines', 15);
$mform->disabledIf('responsefieldlines', 'responseformat', 'eq', 'noinline');
$mform->hideIf('responsefieldlines', 'responseformat', 'eq', 'noinline');

// Create a text box that can be enabled/disabled for max/min word limits options.
$wordlimitoptions = ['size' => '6', 'maxlength' => '6'];
Expand All @@ -64,7 +64,8 @@ protected function definition_inner($mform) {
$mform->addGroup($mingrp, 'mingroup', get_string('minwordlimit', 'qtype_essay'), ' ', false);
$mform->addHelpButton('mingroup', 'minwordlimit', 'qtype_essay');
$mform->disabledIf('minwordlimit', 'minwordenabled', 'notchecked');
$mform->hideIf('mingroup', 'responserequired', '0');
$mform->hideIf('mingroup', 'responserequired', 'eq', '0');
$mform->hideIf('mingroup', 'responseformat', 'eq', 'noinline');

$maxgrp[] = $mform->createElement('text', 'maxwordlimit', '', $wordlimitoptions);
$mform->setType('maxwordlimit', PARAM_INT);
Expand All @@ -73,7 +74,8 @@ protected function definition_inner($mform) {
$mform->addGroup($maxgrp, 'maxgroup', get_string('maxwordlimit', 'qtype_essay'), ' ', false);
$mform->addHelpButton('maxgroup', 'maxwordlimit', 'qtype_essay');
$mform->disabledIf('maxwordlimit', 'maxwordenabled', 'notchecked');
$mform->hideIf('maxgroup', 'responserequired', '0');
$mform->hideIf('maxgroup', 'responserequired', 'eq', '0');
$mform->hideIf('maxgroup', 'responseformat', 'eq', 'noinline');

$mform->addElement('select', 'attachments',
get_string('allowattachments', 'qtype_essay'), $qtype->attachment_options());
Expand All @@ -83,15 +85,15 @@ protected function definition_inner($mform) {
get_string('attachmentsrequired', 'qtype_essay'), $qtype->attachments_required_options());
$mform->setDefault('attachmentsrequired', 0);
$mform->addHelpButton('attachmentsrequired', 'attachmentsrequired', 'qtype_essay');
$mform->disabledIf('attachmentsrequired', 'attachments', 'eq', 0);
$mform->hideIf('attachmentsrequired', 'attachments', 'eq', 0);

$mform->addElement('filetypes', 'filetypeslist', get_string('acceptedfiletypes', 'qtype_essay'));
$mform->addHelpButton('filetypeslist', 'acceptedfiletypes', 'qtype_essay');
$mform->disabledIf('filetypeslist', 'attachments', 'eq', 0);
$mform->hideIf('filetypeslist', 'attachments', 'eq', 0);

$mform->addElement('select', 'maxbytes', get_string('maxbytes', 'qtype_essay'), $qtype->max_file_size_options());
$mform->setDefault('maxbytes', '0');
$mform->disabledIf('maxbytes', 'attachments', 'eq', 0);
$mform->hideIf('maxbytes', 'attachments', 'eq', 0);

$mform->addElement('header', 'responsetemplateheader', get_string('responsetemplateheader', 'qtype_essay'));
$mform->addElement('editor', 'responsetemplate', get_string('responsetemplate', 'qtype_essay'),
Expand Down

0 comments on commit 6fc462a

Please sign in to comment.