Browse Source

Adjust take_from_form_data function to allow better re-use.

MOODLE_36_STABLE
Dan Marsden 6 years ago
parent
commit
484b1f6ae1
  1. 22
      classes/structure.php
  2. 22
      take.php

22
classes/structure.php

@ -735,28 +735,6 @@ class mod_attendance_structure {
$event->add_record_snapshot('course_modules', $this->cm); $event->add_record_snapshot('course_modules', $this->cm);
$event->add_record_snapshot('attendance_sessions', $session); $event->add_record_snapshot('attendance_sessions', $session);
$event->trigger(); $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'));
} }
/** /**

22
take.php

@ -61,6 +61,28 @@ if (!empty($pageparams->grouptype) && !array_key_exists($pageparams->grouptype,
if (($formdata = data_submitted()) && confirm_sesskey()) { if (($formdata = data_submitted()) && confirm_sesskey()) {
$att->take_from_form_data($formdata); $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()); $PAGE->set_url($att->url_take());

Loading…
Cancel
Save