diff --git a/classes/structure.php b/classes/structure.php index 782defa..74b99b2 100644 --- a/classes/structure.php +++ b/classes/structure.php @@ -735,28 +735,6 @@ class mod_attendance_structure { $event->add_record_snapshot('course_modules', $this->cm); $event->add_record_snapshot('attendance_sessions', $session); $event->trigger(); - - $group = 0; - if ($this->pageparams->grouptype != self::SESSION_COMMON) { - $group = $this->pageparams->grouptype; - } else { - if ($this->pageparams->group) { - $group = $this->pageparams->group; - } - } - - $totalusers = count_enrolled_users(context_module::instance($this->cm->id), 'mod/attendance:canbelisted', $group); - $usersperpage = $this->pageparams->perpage; - - if (!empty($this->pageparams->page) && $this->pageparams->page && $totalusers && $usersperpage) { - $numberofpages = ceil($totalusers / $usersperpage); - if ($this->pageparams->page < $numberofpages) { - $params['page'] = $this->pageparams->page + 1; - redirect($this->url_take($params), get_string('moreattendance', 'attendance')); - } - } - - redirect($this->url_manage(), get_string('attendancesuccess', 'attendance')); } /** diff --git a/take.php b/take.php index 8355f3a..2fcb686 100644 --- a/take.php +++ b/take.php @@ -61,6 +61,28 @@ if (!empty($pageparams->grouptype) && !array_key_exists($pageparams->grouptype, if (($formdata = data_submitted()) && confirm_sesskey()) { $att->take_from_form_data($formdata); + + $group = 0; + if ($att->pageparams->grouptype != mod_attendance_structure::SESSION_COMMON) { + $group = $att->pageparams->grouptype; + } else { + if ($att->pageparams->group) { + $group = $att->pageparams->group; + } + } + + $totalusers = count_enrolled_users(context_module::instance($cm->id), 'mod/attendance:canbelisted', $group); + $usersperpage = $att->pageparams->perpage; + + if (!empty($att->pageparams->page) && $att->pageparams->page && $totalusers && $usersperpage) { + $numberofpages = ceil($totalusers / $usersperpage); + if ($att->pageparams->page < $numberofpages) { + $params['page'] = $att->pageparams->page + 1; + redirect($att->url_take($params), get_string('moreattendance', 'attendance')); + } + } + + redirect($att->url_manage(), get_string('attendancesuccess', 'attendance')); } $PAGE->set_url($att->url_take());