Skip to content

Commit

Permalink
Merge branch 'MDL-64906_hideif_mod' of git://github.com/davosmith/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve authored and stronk7 committed Apr 30, 2019
2 parents 36639ba + 298ff4e commit f50b98d
Show file tree
Hide file tree
Showing 19 changed files with 74 additions and 66 deletions.
10 changes: 10 additions & 0 deletions lib/formslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,16 @@ function repeat_elements($elementobjs, $repeats, $options, $repeathiddenname,
$params = array_merge(array($realelementname), $params);
call_user_func_array(array(&$mform, 'disabledIf'), $params);
break;
case 'hideif' :
foreach ($namecloned as $num => $name){
if ($params[0] == $name){
$params[0] = $params[0]."[$i]";
break;
}
}
$params = array_merge(array($realelementname), $params);
call_user_func_array(array(&$mform, 'hideIf'), $params);
break;
case 'rule' :
if (is_string($params)){
$params = array(null, $params, null, 'client');
Expand Down
4 changes: 2 additions & 2 deletions mod/choice/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function definition() {

$repeateloptions = array();
$repeateloptions['limit']['default'] = 0;
$repeateloptions['limit']['disabledif'] = array('limitanswers', 'eq', 0);
$repeateloptions['limit']['hideif'] = array('limitanswers', 'eq', 0);
$repeateloptions['limit']['rule'] = 'numeric';
$repeateloptions['limit']['type'] = PARAM_INT;

Expand Down Expand Up @@ -93,7 +93,7 @@ function definition() {
$mform->addElement('select', 'showresults', get_string("publish", "choice"), $CHOICE_SHOWRESULTS);

$mform->addElement('select', 'publish', get_string("privacy", "choice"), $CHOICE_PUBLISH);
$mform->disabledIf('publish', 'showresults', 'eq', 0);
$mform->hideIf('publish', 'showresults', 'eq', 0);

$mform->addElement('selectyesno', 'showunanswered', get_string("showunanswered", "choice"));

Expand Down
2 changes: 1 addition & 1 deletion mod/data/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function definition() {
$mform->addElement('selectyesno', 'manageapproved', get_string('manageapproved', 'data'));
$mform->addHelpButton('manageapproved', 'manageapproved', 'data');
$mform->setDefault('manageapproved', 1);
$mform->disabledIf('manageapproved', 'approval', 'eq', 0);
$mform->hideIf('manageapproved', 'approval', 'eq', 0);

$mform->addElement('selectyesno', 'comments', get_string('allowcomments', 'data'));

Expand Down
2 changes: 1 addition & 1 deletion mod/feedback/item/feedback_item_form_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function definition() {
'dependvalue',
get_string('dependvalue', 'feedback'),
array('size'=>FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE, 'maxlength'=>255));
$mform->disabledIf('dependvalue', 'dependitem', 'eq', '0');
$mform->hideIf('dependvalue', 'dependitem', 'eq', '0');
} else {
$mform->addElement('hidden', 'dependitem', 0);
$mform->addElement('hidden', 'dependvalue', '');
Expand Down
4 changes: 2 additions & 2 deletions mod/feedback/item/multichoice/multichoice_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public function definition() {
get_string('adjustment', 'feedback').' ',
array(0 => get_string('vertical', 'feedback'),
1 => get_string('horizontal', 'feedback')));
$mform->disabledIf('horizontal', 'subtype', 'eq', 'd');
$mform->hideIf('horizontal', 'subtype', 'eq', 'd');

$mform->addElement('selectyesno',
'hidenoselect',
get_string('hide_no_select_option', 'feedback'));
$mform->disabledIf('hidenoselect', 'subtype', 'ne', 'r');
$mform->hideIf('hidenoselect', 'subtype', 'ne', 'r');

$mform->addElement('selectyesno',
'ignoreempty',
Expand Down
4 changes: 2 additions & 2 deletions mod/feedback/item/multichoicerated/multichoicerated_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ public function definition() {
get_string('adjustment', 'feedback').' ',
array(0 => get_string('vertical', 'feedback'),
1 => get_string('horizontal', 'feedback')));
$mform->disabledIf('horizontal', 'subtype', 'eq', 'd');
$mform->hideIf('horizontal', 'subtype', 'eq', 'd');

$mform->addElement('selectyesno',
'hidenoselect',
get_string('hide_no_select_option', 'feedback'));
$mform->disabledIf('hidenoselect', 'subtype', 'eq', 'd');
$mform->hideIf('hidenoselect', 'subtype', 'eq', 'd');

$mform->addElement('selectyesno',
'ignoreempty',
Expand Down
1 change: 0 additions & 1 deletion mod/feedback/tests/behat/question_types.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Feature: Test creating different types of feedback questions for anonymous feedb
| Question | this is a multiple choice 2 |
| Label | multichoice2 |
| Multiple choice type | Multiple choice - multiple answers |
| Hide the "Not selected" option | Yes |
| Multiple choice values | option d\noption e\noption f |
And I add a "Multiple choice" question to the feedback with:
| Question | this is a multiple choice 3 |
Expand Down
1 change: 0 additions & 1 deletion mod/feedback/tests/behat/question_types_non_anon.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ Feature: Test creating different types of feedback questions for non-anonymous f
| Question | this is a multiple choice 2 |
| Label | multichoice2 |
| Multiple choice type | Multiple choice - multiple answers |
| Hide the "Not selected" option | Yes |
| Multiple choice values | option d\noption e\noption f |
And I add a "Multiple choice" question to the feedback with:
| Question | this is a multiple choice 3 |
Expand Down
6 changes: 3 additions & 3 deletions mod/forum/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function definition() {
$choices[50] = '50';
$mform->addElement('select', 'rssarticles', get_string('rssarticles'), $choices);
$mform->addHelpButton('rssarticles', 'rssarticles', 'forum');
$mform->disabledIf('rssarticles', 'rsstype', 'eq', '0');
$mform->hideIf('rssarticles', 'rsstype', 'eq', '0');
if (isset($CFG->forum_rssarticles)) {
$mform->setDefault('rssarticles', $CFG->forum_rssarticles);
}
Expand Down Expand Up @@ -194,14 +194,14 @@ function definition() {
$mform->setDefault('blockafter', '0');
$mform->addRule('blockafter', null, 'numeric', null, 'client');
$mform->addHelpButton('blockafter', 'blockafter', 'forum');
$mform->disabledIf('blockafter', 'blockperiod', 'eq', 0);
$mform->hideIf('blockafter', 'blockperiod', 'eq', 0);

$mform->addElement('text', 'warnafter', get_string('warnafter', 'forum'));
$mform->setType('warnafter', PARAM_INT);
$mform->setDefault('warnafter', '0');
$mform->addRule('warnafter', null, 'numeric', null, 'client');
$mform->addHelpButton('warnafter', 'warnafter', 'forum');
$mform->disabledIf('warnafter', 'blockperiod', 'eq', 0);
$mform->hideIf('warnafter', 'blockperiod', 'eq', 0);

$coursecontext = context_course::instance($COURSE->id);
plagiarism_get_form_elements_module($mform, $coursecontext, 'mod_forum');
Expand Down
4 changes: 2 additions & 2 deletions mod/glossary/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ function definition() {

$mform->addElement('checkbox', 'casesensitive', get_string('casesensitive', 'glossary'));
$mform->addHelpButton('casesensitive', 'casesensitive', 'glossary');
$mform->disabledIf('casesensitive', 'usedynalink');
$mform->hideIf('casesensitive', 'usedynalink');
$mform->setDefault('casesensitive', $CFG->glossary_casesensitive);

$mform->addElement('checkbox', 'fullmatch', get_string('fullmatch', 'glossary'));
$mform->addHelpButton('fullmatch', 'fullmatch', 'glossary');
$mform->disabledIf('fullmatch', 'usedynalink');
$mform->hideIf('fullmatch', 'usedynalink');
$mform->setDefault('fullmatch', $CFG->glossary_fullmatch);
}

Expand Down
2 changes: 1 addition & 1 deletion mod/glossary/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function definition() {
$choices[50] = '50';
$mform->addElement('select', 'rssarticles', get_string('rssarticles'), $choices);
$mform->addHelpButton('rssarticles', 'rssarticles', 'glossary');
$mform->disabledIf('rssarticles', 'rsstype', 'eq', 0);
$mform->hideIf('rssarticles', 'rsstype', 'eq', 0);
}

//-------------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions mod/lesson/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ function definition() {
$mform->setDefault('password', '');
$mform->setAdvanced('password', $lessonconfig->password_adv);
$mform->setType('password', PARAM_RAW);
$mform->disabledIf('password', 'usepassword', 'eq', 0);
$mform->disabledIf('passwordunmask', 'usepassword', 'eq', 0);
$mform->hideIf('password', 'usepassword', 'eq', 0);
$mform->hideIf('passwordunmask', 'usepassword', 'eq', 0);

// Dependent on.
if ($this->current && isset($this->current->dependency) && $this->current->dependency) {
Expand Down Expand Up @@ -332,7 +332,7 @@ function definition() {
$mform->addHelpButton('usemaxgrade', 'handlingofretakes', 'lesson');
$mform->setDefault('usemaxgrade', $lessonconfig->handlingofretakes);
$mform->setAdvanced('usemaxgrade', $lessonconfig->handlingofretakes_adv);
$mform->disabledIf('usemaxgrade', 'retake', 'eq', '0');
$mform->hideIf('usemaxgrade', 'retake', 'eq', '0');

$numbers = array();
for ($i = 100; $i >= 0; $i--) {
Expand Down
12 changes: 6 additions & 6 deletions mod/lti/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ public function definition() {
$mform->addElement('text', 'toolurl', get_string('launch_url', 'lti'), array('size' => '64'));
$mform->setType('toolurl', PARAM_URL);
$mform->addHelpButton('toolurl', 'launch_url', 'lti');
$mform->disabledIf('toolurl', 'typeid', 'in', $noncontentitemtypes);
$mform->hideIf('toolurl', 'typeid', 'in', $noncontentitemtypes);

$mform->addElement('text', 'securetoolurl', get_string('secure_launch_url', 'lti'), array('size' => '64'));
$mform->setType('securetoolurl', PARAM_URL);
$mform->setAdvanced('securetoolurl');
$mform->addHelpButton('securetoolurl', 'secure_launch_url', 'lti');
$mform->disabledIf('securetoolurl', 'typeid', 'in', $noncontentitemtypes);
$mform->hideIf('securetoolurl', 'typeid', 'in', $noncontentitemtypes);

$mform->addElement('hidden', 'urlmatchedtypeid', '', array( 'id' => 'id_urlmatchedtypeid' ));
$mform->setType('urlmatchedtypeid', PARAM_INT);
Expand All @@ -186,13 +186,13 @@ public function definition() {
$mform->setAdvanced('resourcekey');
$mform->addHelpButton('resourcekey', 'resourcekey', 'lti');
$mform->setForceLtr('resourcekey');
$mform->disabledIf('resourcekey', 'typeid', 'in', $noncontentitemtypes);
$mform->hideIf('resourcekey', 'typeid', 'in', $noncontentitemtypes);

$mform->addElement('passwordunmask', 'password', get_string('password', 'lti'));
$mform->setType('password', PARAM_TEXT);
$mform->setAdvanced('password');
$mform->addHelpButton('password', 'password', 'lti');
$mform->disabledIf('password', 'typeid', 'in', $noncontentitemtypes);
$mform->hideIf('password', 'typeid', 'in', $noncontentitemtypes);

$mform->addElement('textarea', 'instructorcustomparameters', get_string('custom', 'lti'), array('rows' => 4, 'cols' => 60));
$mform->setType('instructorcustomparameters', PARAM_TEXT);
Expand All @@ -204,13 +204,13 @@ public function definition() {
$mform->setType('icon', PARAM_URL);
$mform->setAdvanced('icon');
$mform->addHelpButton('icon', 'icon_url', 'lti');
$mform->disabledIf('icon', 'typeid', 'in', $noncontentitemtypes);
$mform->hideIf('icon', 'typeid', 'in', $noncontentitemtypes);

$mform->addElement('text', 'secureicon', get_string('secure_icon_url', 'lti'), array('size' => '64'));
$mform->setType('secureicon', PARAM_URL);
$mform->setAdvanced('secureicon');
$mform->addHelpButton('secureicon', 'secure_icon_url', 'lti');
$mform->disabledIf('secureicon', 'typeid', 'in', $noncontentitemtypes);
$mform->hideIf('secureicon', 'typeid', 'in', $noncontentitemtypes);

// Add privacy preferences fieldset where users choose whether to send their data.
$mform->addElement('header', 'privacy', get_string('privacy', 'lti'));
Expand Down
4 changes: 2 additions & 2 deletions mod/page/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ function definition() {
if (array_key_exists(RESOURCELIB_DISPLAY_POPUP, $options)) {
$mform->addElement('text', 'popupwidth', get_string('popupwidth', 'page'), array('size'=>3));
if (count($options) > 1) {
$mform->disabledIf('popupwidth', 'display', 'noteq', RESOURCELIB_DISPLAY_POPUP);
$mform->hideIf('popupwidth', 'display', 'noteq', RESOURCELIB_DISPLAY_POPUP);
}
$mform->setType('popupwidth', PARAM_INT);
$mform->setDefault('popupwidth', $config->popupwidth);

$mform->addElement('text', 'popupheight', get_string('popupheight', 'page'), array('size'=>3));
if (count($options) > 1) {
$mform->disabledIf('popupheight', 'display', 'noteq', RESOURCELIB_DISPLAY_POPUP);
$mform->hideIf('popupheight', 'display', 'noteq', RESOURCELIB_DISPLAY_POPUP);
}
$mform->setType('popupheight', PARAM_INT);
$mform->setDefault('popupheight', $config->popupheight);
Expand Down
14 changes: 7 additions & 7 deletions mod/quiz/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected function definition() {
$mform->addHelpButton('graceperiod', 'graceperiod', 'quiz');
$mform->setAdvanced('graceperiod', $quizconfig->graceperiod_adv);
$mform->setDefault('graceperiod', $quizconfig->graceperiod);
$mform->disabledIf('graceperiod', 'overduehandling', 'neq', 'graceperiod');
$mform->hideIf('graceperiod', 'overduehandling', 'neq', 'graceperiod');

// -------------------------------------------------------------------------------
// Grade settings.
Expand Down Expand Up @@ -145,7 +145,7 @@ protected function definition() {
$mform->setAdvanced('grademethod', $quizconfig->grademethod_adv);
$mform->setDefault('grademethod', $quizconfig->grademethod);
if ($this->get_max_attempts_for_any_override() < 2) {
$mform->disabledIf('grademethod', 'attempts', 'eq', 1);
$mform->hideIf('grademethod', 'attempts', 'eq', 1);
}

// -------------------------------------------------------------------------------
Expand Down Expand Up @@ -202,7 +202,7 @@ protected function definition() {
$mform->setDefault('canredoquestions', $quizconfig->canredoquestions);
foreach ($behaviours as $behaviour => $notused) {
if (!question_engine::can_questions_finish_during_the_attempt($behaviour)) {
$mform->disabledIf('canredoquestions', 'preferredbehaviour', 'eq', $behaviour);
$mform->hideIf('canredoquestions', 'preferredbehaviour', 'eq', $behaviour);
}
}

Expand All @@ -213,7 +213,7 @@ protected function definition() {
$mform->setAdvanced('attemptonlast', $quizconfig->attemptonlast_adv);
$mform->setDefault('attemptonlast', $quizconfig->attemptonlast);
if ($this->get_max_attempts_for_any_override() < 2) {
$mform->disabledIf('attemptonlast', 'attempts', 'eq', 1);
$mform->hideIf('attemptonlast', 'attempts', 'eq', 1);
}

// -------------------------------------------------------------------------------
Expand Down Expand Up @@ -308,7 +308,7 @@ protected function definition() {
$mform->setAdvanced('delay1', $quizconfig->delay1_adv);
$mform->setDefault('delay1', $quizconfig->delay1);
if ($this->get_max_attempts_for_any_override() < 2) {
$mform->disabledIf('delay1', 'attempts', 'eq', 1);
$mform->hideIf('delay1', 'attempts', 'eq', 1);
}

$mform->addElement('duration', 'delay2', get_string('delaylater', 'quiz'),
Expand All @@ -317,8 +317,8 @@ protected function definition() {
$mform->setAdvanced('delay2', $quizconfig->delay2_adv);
$mform->setDefault('delay2', $quizconfig->delay2);
if ($this->get_max_attempts_for_any_override() < 3) {
$mform->disabledIf('delay2', 'attempts', 'eq', 1);
$mform->disabledIf('delay2', 'attempts', 'eq', 2);
$mform->hideIf('delay2', 'attempts', 'eq', 1);
$mform->hideIf('delay2', 'attempts', 'eq', 2);
}

// Browser security choices.
Expand Down
12 changes: 6 additions & 6 deletions mod/resource/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ function definition() {
if (array_key_exists(RESOURCELIB_DISPLAY_POPUP, $options)) {
$mform->addElement('text', 'popupwidth', get_string('popupwidth', 'resource'), array('size'=>3));
if (count($options) > 1) {
$mform->disabledIf('popupwidth', 'display', 'noteq', RESOURCELIB_DISPLAY_POPUP);
$mform->hideIf('popupwidth', 'display', 'noteq', RESOURCELIB_DISPLAY_POPUP);
}
$mform->setType('popupwidth', PARAM_INT);
$mform->setDefault('popupwidth', $config->popupwidth);
$mform->setAdvanced('popupwidth', true);

$mform->addElement('text', 'popupheight', get_string('popupheight', 'resource'), array('size'=>3));
if (count($options) > 1) {
$mform->disabledIf('popupheight', 'display', 'noteq', RESOURCELIB_DISPLAY_POPUP);
$mform->hideIf('popupheight', 'display', 'noteq', RESOURCELIB_DISPLAY_POPUP);
}
$mform->setType('popupheight', PARAM_INT);
$mform->setDefault('popupheight', $config->popupheight);
Expand All @@ -127,10 +127,10 @@ function definition() {
array_key_exists(RESOURCELIB_DISPLAY_EMBED, $options) or
array_key_exists(RESOURCELIB_DISPLAY_FRAME, $options)) {
$mform->addElement('checkbox', 'printintro', get_string('printintro', 'resource'));
$mform->disabledIf('printintro', 'display', 'eq', RESOURCELIB_DISPLAY_POPUP);
$mform->disabledIf('printintro', 'display', 'eq', RESOURCELIB_DISPLAY_DOWNLOAD);
$mform->disabledIf('printintro', 'display', 'eq', RESOURCELIB_DISPLAY_OPEN);
$mform->disabledIf('printintro', 'display', 'eq', RESOURCELIB_DISPLAY_NEW);
$mform->hideIf('printintro', 'display', 'eq', RESOURCELIB_DISPLAY_POPUP);
$mform->hideIf('printintro', 'display', 'eq', RESOURCELIB_DISPLAY_DOWNLOAD);
$mform->hideIf('printintro', 'display', 'eq', RESOURCELIB_DISPLAY_OPEN);
$mform->hideIf('printintro', 'display', 'eq', RESOURCELIB_DISPLAY_NEW);
$mform->setDefault('printintro', $config->printintro);
}

Expand Down
Loading

0 comments on commit f50b98d

Please sign in to comment.