From c0ed73827ff443e79e0eab19d1fb9e9893348dea Mon Sep 17 00:00:00 2001 From: Marcus Green Date: Tue, 24 Oct 2023 18:39:36 +0100 Subject: [PATCH] form fixes --- driprelease_form.php | 12 +++++++----- tests/behat/basic_test.feature | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/driprelease_form.php b/driprelease_form.php index eae2054..26809c6 100644 --- a/driprelease_form.php +++ b/driprelease_form.php @@ -115,11 +115,13 @@ public function definition() { $group[] = $mform->createElement('text', 'sessionlength', get_string('sessionlength', 'tool_driprelease'), ['value' => $driprelease->sessionlength, 'size' => 3]); - $mform->addGroup($group, 'sessiongroup', get_string('sessionlength', 'tool_driprelease') . '  ', '', ' ', false); - $mform->addRule('sessiongroup', null, 'required', null, 'client'); + //$mform->addGroup($group, 'sessiongroup', get_string('sessionlength', 'tool_driprelease') . '  ', '', ' ', []); + $mform->addElement('text', 'sessionlength', get_string('sessionlength','tool_driprelease'),['value' => $driprelease->sessionlength, 'size' => 2]); - $mform->setType('sessiongroup', PARAM_RAW); - $mform->addHelpButton('sessiongroup', 'session', 'tool_driprelease'); + $mform->addRule('sessionlength', null, 'required', null, 'client'); + + $mform->setType('sessionlength', PARAM_RAW); + $mform->addHelpButton('sessionlength', 'session', 'tool_driprelease'); $mform->addElement('text', 'activitiespersession', get_string('activitiespersession', 'tool_driprelease'), ['size' => '3']); $mform->addRule('activitiespersession', null, 'required', null, 'client'); @@ -163,7 +165,7 @@ public function validation($fromform, $tabledata) { $modulecount = count($this->modules); $errors = []; $activitiespersession = $fromform['activitiespersession']; - $sessionlength = $fromform['sessiongroup']['sessionlength']; + $sessionlength = $fromform['sessionlength']; $duration = round(($fromform['schedulefinish'] - $fromform['schedulestart']) / DAYSECS); if ($duration < 1) { diff --git a/tests/behat/basic_test.feature b/tests/behat/basic_test.feature index f21825c..daa4480 100644 --- a/tests/behat/basic_test.feature +++ b/tests/behat/basic_test.feature @@ -58,6 +58,7 @@ Feature: Drip release modifies activity availability And I click on "Edit settings" "link" in the "Quiz1" activity And I expand all fieldsets + And I pause And I set the field "Completion tracking" to "Show activity as complete when conditions are met" And I set the field "completionusegrade" to "1" And I press "Save and return to course" @@ -81,7 +82,7 @@ Feature: Drip release modifies activity availability And I should not see "Session 0" # Check the validation checks for empty fields works - And I set the field "sessiongroup[sessionlength]" to "" + And I set the field "sessionlength" to "" And I should see "You must supply a value here" And I set the field "sessiongroup[sessionlength]" to "1" And I set the field "activitiespersession" to ""