function get_records($filter) { $sort = $this->optional_param('sort', 'timecreated'); $dir = $this->optional_param('dir', 'ASC'); $page = $this->optional_param('page', 0); $perpage = $this->optional_param('perpage', 30); // how many per page $id = $this->required_param('id', PARAM_INT); $items = waitlist::get_students($id, $sort, $dir, $page, $perpage, $filter['namesearch'], $filter['alpha']); $numitems = waitlist::count_records($id, $filter['namesearch'], $filter['alpha']); return array($items, $numitems); }
public function update() { $status = parent::update(); if ($this->moodlecourseid || $this->autocreate) { moodle_attach_class($this->id, $this->moodlecourseid, '', true, true, $this->autocreate); } if (!empty($this->oldmax) && $this->oldmax < $this->maxstudents && waitlist::count_records($this->id) > 0) { for ($i = $this->oldmax; $i < $this->maxstudents; $i++) { $next_student = waitlist::get_next($this->id); if (!empty($next_student)) { $next_student->enrol(); } else { break; } } } $status = $status && field_data::set_for_context_from_datarecord('class', $this); return $status; }
function get_item_display_waitlistsize($column, $class) { require_once elispm::lib('data/waitlist.class.php'); return waitlist::count_records($class->id); }
function get_records($filter) { $sort = $this->optional_param('sort', 'timecreated', PARAM_CLEAN); $dir = $this->optional_param('dir', 'ASC', PARAM_CLEAN); $page = $this->optional_param('page', 0, PARAM_INT); $perpage = $this->optional_param('perpage', 30, PARAM_INT); // how many per page $id = $this->required_param('id', PARAM_INT); if ($sort == 'name') { $sort = 'lastname'; } $items = waitlist::get_students($id, $sort, $dir, $page * $perpage, $perpage, $filter['namesearch'], $filter['alpha']); $numitems = waitlist::count_records($id, $filter['namesearch'], $filter['alpha']); //error_log("waitlistpage::get_records(): count(items) = ". count($items). ", numitems = {$numitems}"); return array($items, $numitems); }
function get_item_display_waitlistsize($column, $class) { require_once CURMAN_DIRLOCATION . '/lib/waitlist.class.php'; return waitlist::count_records($class->id); }
public function save() { $isnew = empty($this->id); parent::save(); if (isset($this->track) && is_array($this->track)) { $param['classid'] = $this->id; $param['courseid'] = $this->courseid; foreach ($this->track as $t) { if (trackassignment::exists(array(new field_filter('classid', $this->id), new field_filter('trackid', $t)))) { continue; } $param['trackid'] = $t; $trackassignobj = new trackassignment($param); $trackassignobj->save(); } } if (isset($this->unlink_attached_course) && isset($this->moodlecourseid)) { // process unlink moodle course id request $return = moodle_detach_class($this->id, $this->moodlecourseid); $this->moodlecourseid = 0; } if ($this->moodlecourseid || $this->autocreate) { moodle_attach_class($this->id, $this->moodlecourseid, '', true, true, $this->autocreate); } if (!$isnew) { if (!empty($this->oldmax) && (!$this->maxstudents || $this->oldmax < $this->maxstudents) && ($waiting = waitlist::count_records($this->id)) > 0) { $start = student_count_records($this->id); $max = $this->maxstudents ? $this->maxstudents : $start + $waiting + 1; //error_log("pmclass.class.php::save() oldmax = {$this->oldmax}, start = {$start}, newmax = {$this->maxstudents}, waiting = {$waiting} ... max = {$max}"); for ($i = $start; $i < $max; $i++) { $next_student = waitlist::get_next($this->id); if (empty($next_student)) { break; } $next_student->enrol(); } } } field_data::set_for_context_from_datarecord(CONTEXT_ELIS_CLASS, $this); }