Skip to content

Commit

Permalink
Removed optional_param
Browse files Browse the repository at this point in the history
-Removed optional_param maxenrollments, instead $choicegroup->maxenrollments is used in the code.
  • Loading branch information
sameer-ah committed Jul 15, 2021
1 parent 266cfb2 commit 3c016d4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions view.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
$action = optional_param('action', '', PARAM_ALPHA);
$userids = optional_param_array('userid', array(), PARAM_INT); // array of attempt ids for delete action
$notify = optional_param('notify', '', PARAM_ALPHA);
$maxenrollments = optional_param('maxenrollments', '', PARAM_INT);

$url = new moodle_url('/mod/choicegroup/view.php', array('id'=>$id));
if ($action !== '') {
Expand Down Expand Up @@ -104,20 +103,19 @@
if ($choicegroup->multipleenrollmentspossible == 1) {
$number_of_groups = optional_param('number_of_groups', '', PARAM_INT);
$enrollmentscount = 0;
$maxenrollments = $choicegroup->maxenrollments;

if($maxenrollments > 0){
if ($choicegroup->maxenrollments > 0) {
for ($i = 0; $i < $number_of_groups; $i++) {
$answer_value = optional_param('answer_' . $i, '', PARAM_INT);
if ($answer_value != '') {
$enrollmentscount++;
}
}
if ($enrollmentscount > $maxenrollments) {
if ($enrollmentscount > $choicegroup->maxenrollments) {
redirect(new moodle_url('/mod/choicegroup/view.php',
array('id' => $cm->id, 'notify' => 'mustchoosemax', 'sesskey' => sesskey(), 'maxenrollments' => $maxenrollments)));
array('id' => $cm->id, 'notify' => 'mustchoosemax', 'sesskey' => sesskey())));
}
}
}

for ($i = 0; $i < $number_of_groups; $i++) {
$answer_value = optional_param('answer_' . $i, '', PARAM_INT);
Expand Down Expand Up @@ -180,7 +178,7 @@
} else if ($notify === 'mustchooseone') {
echo $OUTPUT->notification(get_string('mustchooseone', 'choicegroup'), 'notifyproblem');
} else if ($notify === 'mustchoosemax') {
echo $OUTPUT->notification(get_string('mustchoosemax', 'choicegroup', $maxenrollments), 'notifyproblem');
echo $OUTPUT->notification(get_string('mustchoosemax', 'choicegroup', $choicegroup->maxenrollments), 'notifyproblem');
}
}

Expand Down

0 comments on commit 3c016d4

Please sign in to comment.