Skip to content

Commit

Permalink
form fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusgreen committed Oct 24, 2023
1 parent 59c0c2b commit c0ed738
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 7 additions & 5 deletions driprelease_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion tests/behat/basic_test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 ""
Expand Down

0 comments on commit c0ed738

Please sign in to comment.