Browse Source

more phpdoc changes.

MOODLE_33_STABLE
Dan Marsden 8 years ago
parent
commit
67869631e0
  1. 7
      add_form.php
  2. 30
      classes/attendance_webservices_handler.php
  3. 10
      classes/calendar_helpers.php
  4. 7
      classes/manage_page_params.php
  5. 52
      classes/page_with_filter_controls.php
  6. 12
      classes/preferences_page_params.php
  7. 16
      classes/report_page_params.php
  8. 140
      classes/structure.php
  9. 25
      classes/take_page_params.php
  10. 16
      classes/view_page_params.php
  11. 6
      export_form.php
  12. 21
      temp_form.php
  13. 10
      tempusers.php

7
add_form.php

@ -242,6 +242,13 @@ class mod_attendance_add_form extends moodleform {
return $errors; return $errors;
} }
/**
* Check weekdays function.
* @param int $sessiondate
* @param int $sessionenddate
* @param int $sdays
* @return bool
*/
private function checkweekdays($sessiondate, $sessionenddate, $sdays) { private function checkweekdays($sessiondate, $sessionenddate, $sdays) {
$found = false; $found = false;

30
classes/attendance_webservices_handler.php

@ -13,6 +13,7 @@
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* Web Services for Attendance plugin. * Web Services for Attendance plugin.
* *
@ -28,10 +29,17 @@ require_once(dirname(__FILE__).'/structure.php');
require_once(dirname(__FILE__).'/../../../lib/sessionlib.php'); require_once(dirname(__FILE__).'/../../../lib/sessionlib.php');
require_once(dirname(__FILE__).'/../../../lib/datalib.php'); require_once(dirname(__FILE__).'/../../../lib/datalib.php');
/**
* Class attendance_handler
* @copyright 2015 Caio Bressan Doneda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class attendance_handler { class attendance_handler {
/** /**
* For this user, this method searches in all the courses that this user has permission to take attendance, * For this user, this method searches in all the courses that this user has permission to take attendance,
* looking for today sessions and returns the courses with the sessions. * looking for today sessions and returns the courses with the sessions.
* @param int $userid
* @return array
*/ */
public static function get_courses_with_today_sessions($userid) { public static function get_courses_with_today_sessions($userid) {
$usercourses = enrol_get_users_courses($userid); $usercourses = enrol_get_users_courses($userid);
@ -69,6 +77,12 @@ class attendance_handler {
return self::prepare_data($coursessessions); return self::prepare_data($coursessessions);
} }
/**
* Prepare data.
*
* @param array $coursessessions
* @return array
*/
private static function prepare_data($coursessessions) { private static function prepare_data($coursessessions) {
$courses = array(); $courses = array();
@ -82,8 +96,11 @@ class attendance_handler {
return $courses; return $courses;
} }
/* /**
** For this session, returns all the necessary data to take an attendance * For this session, returns all the necessary data to take an attendance.
*
* @param int $sessionid
* @return mixed
*/ */
public static function get_session($sessionid) { public static function get_session($sessionid) {
global $DB; global $DB;
@ -103,6 +120,15 @@ class attendance_handler {
return $session; return $session;
} }
/**
* Update user status
*
* @param int $sessionid
* @param int $studentid
* @param int $takenbyid
* @param int $statusid
* @param int $statusset
*/
public static function update_user_status($sessionid, $studentid, $takenbyid, $statusid, $statusset) { public static function update_user_status($sessionid, $studentid, $takenbyid, $statusid, $statusset) {
global $DB; global $DB;

10
classes/calendar_helpers.php

@ -64,7 +64,7 @@ function attendance_create_calendar_event(&$session) {
/** /**
* Create multiple calendar events based on sessions data. * Create multiple calendar events based on sessions data.
* *
* @param array %sessionsids array of sessions ids * @param array $sessionsids array of sessions ids
*/ */
function attendance_create_calendar_events($sessionsids) { function attendance_create_calendar_events($sessionsids) {
global $DB; global $DB;
@ -81,9 +81,9 @@ function attendance_create_calendar_events($sessionsids) {
/** /**
* Update calendar event duration and date * Update calendar event duration and date
* *
* @param $caleventid int calendar event id * @param int $caleventid calendar event id
* @param $timeduration int duration of the event * @param int $timeduration duration of the event
* @param $timestart int start time of the event * @param int $timestart start time of the event
* @return bool result of updating * @return bool result of updating
*/ */
function attendance_update_calendar_event($caleventid, $timeduration, $timestart) { function attendance_update_calendar_event($caleventid, $timeduration, $timestart) {
@ -103,7 +103,7 @@ function attendance_update_calendar_event($caleventid, $timeduration, $timestart
/** /**
* Delete calendar events for sessions * Delete calendar events for sessions
* *
* @param array %sessionsids array of sessions ids * @param array $sessionsids array of sessions ids
* @return bool result of updating * @return bool result of updating
*/ */
function attendance_delete_calendar_events($sessionsids) { function attendance_delete_calendar_events($sessionsids) {

7
classes/manage_page_params.php

@ -30,10 +30,17 @@ defined('MOODLE_INTERNAL') || die();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class mod_attendance_manage_page_params extends mod_attendance_page_with_filter_controls { class mod_attendance_manage_page_params extends mod_attendance_page_with_filter_controls {
/**
* mod_attendance_manage_page_params constructor.
*/
public function __construct() { public function __construct() {
$this->selectortype = mod_attendance_page_with_filter_controls::SELECTOR_SESS_TYPE; $this->selectortype = mod_attendance_page_with_filter_controls::SELECTOR_SESS_TYPE;
} }
/**
* Get page params.
* @return array
*/
public function get_significant_params() { public function get_significant_params() {
return array(); return array();
} }

52
classes/page_with_filter_controls.php

@ -24,18 +24,28 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
/** /**
* base filter controls class - overridden by different views where needed. * Base filter controls class - overridden by different views where needed.
* *
* @copyright 2016 Dan Marsden http://danmarsden.com * @copyright 2016 Dan Marsden http://danmarsden.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class mod_attendance_page_with_filter_controls { class mod_attendance_page_with_filter_controls {
/** No filter. */
const SELECTOR_NONE = 1; const SELECTOR_NONE = 1;
/** Filter by group. */
const SELECTOR_GROUP = 2; const SELECTOR_GROUP = 2;
/** Filter by session type. */
const SELECTOR_SESS_TYPE = 3; const SELECTOR_SESS_TYPE = 3;
/** Common. */
const SESSTYPE_COMMON = 0; const SESSTYPE_COMMON = 0;
/** All. */
const SESSTYPE_ALL = -1; const SESSTYPE_ALL = -1;
/** No value. */
const SESSTYPE_NO_VALUE = -2; const SESSTYPE_NO_VALUE = -2;
/** @var int current view mode */ /** @var int current view mode */
@ -50,16 +60,26 @@ class mod_attendance_page_with_filter_controls {
/** @var int end date of displayed date range */ /** @var int end date of displayed date range */
public $enddate; public $enddate;
/** @var int type. */
public $selectortype = self::SELECTOR_NONE; public $selectortype = self::SELECTOR_NONE;
/** @var int default view. */
protected $defaultview = ATT_VIEW_WEEKS; protected $defaultview = ATT_VIEW_WEEKS;
/** @var stdClass course module record. */
private $cm; private $cm;
/** @var array */
private $sessgroupslist; private $sessgroupslist;
/** @var int */
private $sesstype; private $sesstype;
/**
* initialise stuff.
*
* @param stdClass $cm
*/
public function init($cm) { public function init($cm) {
$this->cm = $cm; $this->cm = $cm;
$this->init_view(); $this->init_view();
@ -67,6 +87,9 @@ class mod_attendance_page_with_filter_controls {
$this->init_start_end_date(); $this->init_start_end_date();
} }
/**
* Initialise the view.
*/
private function init_view() { private function init_view() {
global $SESSION; global $SESSION;
@ -79,6 +102,9 @@ class mod_attendance_page_with_filter_controls {
} }
} }
/**
* Initialise the current date.
*/
private function init_curdate() { private function init_curdate() {
global $SESSION; global $SESSION;
@ -91,6 +117,9 @@ class mod_attendance_page_with_filter_controls {
} }
} }
/**
* Initialise the end date.
*/
public function init_start_end_date() { public function init_start_end_date() {
global $CFG; global $CFG;
@ -132,6 +161,9 @@ class mod_attendance_page_with_filter_controls {
} }
} }
/**
* Calculate the session group list type.
*/
private function calc_sessgroupslist_sesstype() { private function calc_sessgroupslist_sesstype() {
global $SESSION; global $SESSION;
@ -180,6 +212,9 @@ class mod_attendance_page_with_filter_controls {
} }
} }
/**
* Calculate the session group list
*/
private function calc_sessgroupslist() { private function calc_sessgroupslist() {
global $USER, $PAGE; global $USER, $PAGE;
@ -207,6 +242,11 @@ class mod_attendance_page_with_filter_controls {
} }
} }
/**
* Return the session groups.
*
* @return array
*/
public function get_sess_groups_list() { public function get_sess_groups_list() {
if (is_null($this->sessgroupslist)) { if (is_null($this->sessgroupslist)) {
$this->calc_sessgroupslist_sesstype(); $this->calc_sessgroupslist_sesstype();
@ -215,6 +255,11 @@ class mod_attendance_page_with_filter_controls {
return $this->sessgroupslist; return $this->sessgroupslist;
} }
/**
* Get the current session type.
*
* @return int
*/
public function get_current_sesstype() { public function get_current_sesstype() {
if (is_null($this->sesstype)) { if (is_null($this->sesstype)) {
$this->calc_sessgroupslist_sesstype(); $this->calc_sessgroupslist_sesstype();
@ -223,6 +268,11 @@ class mod_attendance_page_with_filter_controls {
return $this->sesstype; return $this->sesstype;
} }
/**
* Set the current session type.
*
* @param int $sesstype
*/
public function set_current_sesstype($sesstype) { public function set_current_sesstype($sesstype) {
$this->sesstype = $sesstype; $this->sesstype = $sesstype;
} }

12
classes/preferences_page_params.php

@ -30,19 +30,31 @@ defined('MOODLE_INTERNAL') || die();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class mod_attendance_preferences_page_params { class mod_attendance_preferences_page_params {
/** Add */
const ACTION_ADD = 1; const ACTION_ADD = 1;
/** Delete */
const ACTION_DELETE = 2; const ACTION_DELETE = 2;
/** Hide */
const ACTION_HIDE = 3; const ACTION_HIDE = 3;
/** Show */
const ACTION_SHOW = 4; const ACTION_SHOW = 4;
/** Save */
const ACTION_SAVE = 5; const ACTION_SAVE = 5;
/** @var int view mode of taking attendance page*/ /** @var int view mode of taking attendance page*/
public $action; public $action;
/** @var int */
public $statusid; public $statusid;
/** @var array */
public $statusset; public $statusset;
/**
* Get params for this page.
*
* @return array
*/
public function get_significant_params() { public function get_significant_params() {
$params = array(); $params = array();

16
classes/report_page_params.php

@ -30,15 +30,27 @@ defined('MOODLE_INTERNAL') || die();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class mod_attendance_report_page_params extends mod_attendance_page_with_filter_controls { class mod_attendance_report_page_params extends mod_attendance_page_with_filter_controls {
/** @var int */
public $group; public $group;
/** @var int */
public $sort; public $sort;
/** @var int */
public $showsessiondetails; public $showsessiondetails;
/** @var int */
public $sessiondetailspos; public $sessiondetailspos;
/**
* mod_attendance_report_page_params constructor.
*/
public function __construct() { public function __construct() {
$this->selectortype = self::SELECTOR_GROUP; $this->selectortype = self::SELECTOR_GROUP;
} }
/**
* Initialise params.
*
* @param stdClass $cm
*/
public function init($cm) { public function init($cm) {
parent::init($cm); parent::init($cm);
@ -50,6 +62,10 @@ class mod_attendance_report_page_params extends mod_attendance_page_with_filter_
} }
} }
/**
* Get params for this page.
* @return array
*/
public function get_significant_params() { public function get_significant_params() {
$params = array(); $params = array();

140
classes/structure.php

@ -32,7 +32,9 @@ require_once(dirname(__FILE__) . '/calendar_helpers.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class mod_attendance_structure { class mod_attendance_structure {
/** Common sessions */
const SESSION_COMMON = 0; const SESSION_COMMON = 0;
/** Group sessions */
const SESSION_GROUP = 1; const SESSION_GROUP = 1;
/** @var stdclass course module record */ /** @var stdclass course module record */
@ -62,23 +64,27 @@ class mod_attendance_structure {
/** @var int format of the intro (see above) */ /** @var int format of the intro (see above) */
public $introformat; public $introformat;
/** current page parameters */ /** @var array current page parameters */
public $pageparams; public $pageparams;
/** @var string subnets (IP range) for student self selection. */
public $subnet; public $subnet;
/** Define if session details should be shown in reports */ /** @var int Define if session details should be shown in reports */
public $showsessiondetails; public $showsessiondetails;
/** Position for the session detail columns related to summary columns.*/ /** @var int Position for the session detail columns related to summary columns.*/
public $sessiondetailspos; public $sessiondetailspos;
/** @var int groupmode */
private $groupmode; private $groupmode;
/** @var array */
private $statuses; private $statuses;
private $allstatuses; // Cache list of all statuses (not just one used by current session). /** @var array Cache list of all statuses (not just one used by current session). */
private $allstatuses;
// Array by sessionid. /** @var array of sessionid. */
private $sessioninfo = array(); private $sessioninfo = array();
/** /**
@ -91,8 +97,9 @@ class mod_attendance_structure {
* @param stdClass $cm Course module record as returned by {@link get_coursemodule_from_id()} * @param stdClass $cm Course module record as returned by {@link get_coursemodule_from_id()}
* @param stdClass $course Course record from {course} table * @param stdClass $course Course record from {course} table
* @param stdClass $context The context of the workshop instance * @param stdClass $context The context of the workshop instance
* @param stdClass $pageparams
*/ */
public function __construct(stdclass $dbrecord, stdclass $cm, stdclass $course, stdclass $context=null, $pageparams=null) { public function __construct(stdClass $dbrecord, stdClass $cm, stdClass $course, stdClass $context=null, $pageparams=null) {
global $DB; global $DB;
foreach ($dbrecord as $field => $value) { foreach ($dbrecord as $field => $value) {
@ -120,6 +127,11 @@ class mod_attendance_structure {
} }
} }
/**
* Get group mode.
*
* @return int
*/
public function get_group_mode() { public function get_group_mode() {
if (is_null($this->groupmode)) { if (is_null($this->groupmode)) {
$this->groupmode = groups_get_activity_groupmode($this->cm, $this->course); $this->groupmode = groups_get_activity_groupmode($this->cm, $this->course);
@ -179,7 +191,7 @@ class mod_attendance_structure {
* Returns today sessions suitable for copying attendance log * Returns today sessions suitable for copying attendance log
* *
* Fetches data from {attendance_sessions} * Fetches data from {attendance_sessions}
* * @param stdClass $sess
* @return array of records or an empty array * @return array of records or an empty array
*/ */
public function get_today_sessions_for_copy($sess) { public function get_today_sessions_for_copy($sess) {
@ -237,6 +249,11 @@ class mod_attendance_structure {
return $DB->get_records_select('attendance_sessions', $where, $params); return $DB->get_records_select('attendance_sessions', $where, $params);
} }
/**
* Get filtered sessions.
*
* @return array
*/
public function get_filtered_sessions() { public function get_filtered_sessions() {
global $DB; global $DB;
@ -273,6 +290,8 @@ class mod_attendance_structure {
} }
/** /**
* Get manage url.
* @param array $params
* @return moodle_url of manage.php for attendance instance * @return moodle_url of manage.php for attendance instance
*/ */
public function url_manage($params=array()) { public function url_manage($params=array()) {
@ -281,6 +300,7 @@ class mod_attendance_structure {
} }
/** /**
* Get manage temp users url.
* @param array $params optional * @param array $params optional
* @return moodle_url of tempusers.php for attendance instance * @return moodle_url of tempusers.php for attendance instance
*/ */
@ -290,6 +310,8 @@ class mod_attendance_structure {
} }
/** /**
* Get temp delete url.
*
* @param array $params optional * @param array $params optional
* @return moodle_url of tempdelete.php for attendance instance * @return moodle_url of tempdelete.php for attendance instance
*/ */
@ -299,6 +321,8 @@ class mod_attendance_structure {
} }
/** /**
* Get temp edit url.
*
* @param array $params optional * @param array $params optional
* @return moodle_url of tempedit.php for attendance instance * @return moodle_url of tempedit.php for attendance instance
*/ */
@ -308,6 +332,8 @@ class mod_attendance_structure {
} }
/** /**
* Get temp merge url
*
* @param array $params optional * @param array $params optional
* @return moodle_url of tempedit.php for attendance instance * @return moodle_url of tempedit.php for attendance instance
*/ */
@ -317,6 +343,8 @@ class mod_attendance_structure {
} }
/** /**
* Get url for sessions.
* @param array $params
* @return moodle_url of sessions.php for attendance instance * @return moodle_url of sessions.php for attendance instance
*/ */
public function url_sessions($params=array()) { public function url_sessions($params=array()) {
@ -325,6 +353,8 @@ class mod_attendance_structure {
} }
/** /**
* Get url for report.
* @param array $params
* @return moodle_url of report.php for attendance instance * @return moodle_url of report.php for attendance instance
*/ */
public function url_report($params=array()) { public function url_report($params=array()) {
@ -333,6 +363,8 @@ class mod_attendance_structure {
} }
/** /**
* Get url for export.
*
* @return moodle_url of export.php for attendance instance * @return moodle_url of export.php for attendance instance
*/ */
public function url_export() { public function url_export() {
@ -341,6 +373,8 @@ class mod_attendance_structure {
} }
/** /**
* Get preferences url
* @param array $params
* @return moodle_url of attsettings.php for attendance instance * @return moodle_url of attsettings.php for attendance instance
*/ */
public function url_preferences($params=array()) { public function url_preferences($params=array()) {
@ -353,6 +387,8 @@ class mod_attendance_structure {
} }
/** /**
* Get take url.
* @param array $params
* @return moodle_url of attendances.php for attendance instance * @return moodle_url of attendances.php for attendance instance
*/ */
public function url_take($params=array()) { public function url_take($params=array()) {
@ -360,11 +396,21 @@ class mod_attendance_structure {
return new moodle_url('/mod/attendance/take.php', $params); return new moodle_url('/mod/attendance/take.php', $params);
} }
/**
* Get view url.
* @param array $params
* @return moodle_url
*/
public function url_view($params=array()) { public function url_view($params=array()) {
$params = array_merge(array('id' => $this->cm->id), $params); $params = array_merge(array('id' => $this->cm->id), $params);
return new moodle_url('/mod/attendance/view.php', $params); return new moodle_url('/mod/attendance/view.php', $params);
} }
/**
* Add sessions.
*
* @param array $sessions
*/
public function add_sessions($sessions) { public function add_sessions($sessions) {
global $DB; global $DB;
@ -402,6 +448,12 @@ class mod_attendance_structure {
} }
} }
/**
* Update session from form.
*
* @param stdClass $formdata
* @param int $sessionid
*/
public function update_session_from_form_data($formdata, $sessionid) { public function update_session_from_form_data($formdata, $sessionid) {
global $DB; global $DB;
@ -449,7 +501,7 @@ class mod_attendance_structure {
/** /**
* Used to record attendance submitted by the student. * Used to record attendance submitted by the student.
* *
* @param type $mformdata * @param stdClass $mformdata
* @return boolean * @return boolean
*/ */
public function take_from_student($mformdata) { public function take_from_student($mformdata) {
@ -506,6 +558,11 @@ class mod_attendance_structure {
return true; return true;
} }
/**
* Take attendance from form data.
*
* @param stdClass $formdata
*/
public function take_from_form_data($formdata) { public function take_from_form_data($formdata) {
global $DB, $USER; global $DB, $USER;
// TODO: WARNING - $formdata is unclean - comes from direct $_POST - ideally needs a rewrite but we do some cleaning below. // TODO: WARNING - $formdata is unclean - comes from direct $_POST - ideally needs a rewrite but we do some cleaning below.
@ -592,7 +649,11 @@ class mod_attendance_structure {
} }
/** /**
* MDL-27591 made this method obsolete. * Get users with enrolment status (Feature request MDL-27591)
*
* @param int $groupid
* @param int $page
* @return array
*/ */
public function get_users($groupid = 0, $page = 1) { public function get_users($groupid = 0, $page = 1) {
global $DB, $CFG; global $DB, $CFG;
@ -687,7 +748,12 @@ class mod_attendance_structure {
return $users; return $users;
} }
// Convert a tempuser record into a user object. /**
* Convert a tempuser record into a user object.
*
* @param stdClass $tempuser
* @return object
*/
protected static function tempuser_to_user($tempuser) { protected static function tempuser_to_user($tempuser) {
$ret = (object)array( $ret = (object)array(
'id' => $tempuser->studentid, 'id' => $tempuser->studentid,
@ -708,6 +774,12 @@ class mod_attendance_structure {
return $ret; return $ret;
} }
/**
* Get user and include extra info.
*
* @param int $userid
* @return mixed|object
*/
public function get_user($userid) { public function get_user($userid) {
global $DB; global $DB;
@ -749,6 +821,13 @@ class mod_attendance_structure {
return $user; return $user;
} }
/**
* Get possible statuses.
*
* @param bool $onlyvisible
* @param bool $allsets
* @return array
*/
public function get_statuses($onlyvisible = true, $allsets = false) { public function get_statuses($onlyvisible = true, $allsets = false) {
if (!isset($this->statuses)) { if (!isset($this->statuses)) {
// Get the statuses for the current set only. // Get the statuses for the current set only.
@ -770,6 +849,11 @@ class mod_attendance_structure {
return $this->statuses; return $this->statuses;
} }
/**
* Get session info.
* @param int $sessionid
* @return mixed
*/
public function get_session_info($sessionid) { public function get_session_info($sessionid) {
global $DB; global $DB;
@ -785,6 +869,12 @@ class mod_attendance_structure {
return $this->sessioninfo[$sessionid]; return $this->sessioninfo[$sessionid];
} }
/**
* Get sessions info
*
* @param array $sessionids
* @return array
*/
public function get_sessions_info($sessionids) { public function get_sessions_info($sessionids) {
global $DB; global $DB;
@ -803,16 +893,31 @@ class mod_attendance_structure {
return $sessions; return $sessions;
} }
/**
* Get log.
*
* @param int $sessionid
* @return array
*/
public function get_session_log($sessionid) { public function get_session_log($sessionid) {
global $DB; global $DB;
return $DB->get_records('attendance_log', array('sessionid' => $sessionid), '', 'studentid,statusid,remarks,id'); return $DB->get_records('attendance_log', array('sessionid' => $sessionid), '', 'studentid,statusid,remarks,id');
} }
/**
* Update user grade.
* @param array $userids
*/
public function update_users_grade($userids) { public function update_users_grade($userids) {
attendance_update_users_grade($this, $userids); attendance_update_users_grade($this, $userids);
} }
/**
* Get filtered log.
* @param int $userid
* @return array
*/
public function get_user_filtered_sessions_log($userid) { public function get_user_filtered_sessions_log($userid) {
global $DB; global $DB;
@ -857,6 +962,11 @@ class mod_attendance_structure {
return $sessions; return $sessions;
} }
/**
* Get filtered log extended.
* @param int $userid
* @return array
*/
public function get_user_filtered_sessions_log_extended($userid) { public function get_user_filtered_sessions_log_extended($userid) {
global $DB; global $DB;
// All taked sessions (including previous groups). // All taked sessions (including previous groups).
@ -937,6 +1047,10 @@ class mod_attendance_structure {
return $sessions; return $sessions;
} }
/**
* Delete sessions.
* @param array $sessionsids
*/
public function delete_sessions($sessionsids) { public function delete_sessions($sessionsids) {
global $DB; global $DB;
if (attendance_existing_calendar_events_ids($sessionsids)) { if (attendance_existing_calendar_events_ids($sessionsids)) {
@ -954,6 +1068,12 @@ class mod_attendance_structure {
$event->trigger(); $event->trigger();
} }
/**
* Update duration.
*
* @param array $sessionsids
* @param int $duration
*/
public function update_sessions_duration($sessionsids, $duration) { public function update_sessions_duration($sessionsids, $duration) {
global $DB; global $DB;

25
classes/take_page_params.php

@ -13,7 +13,6 @@
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
/** /**
* Class definition for mod_attendance_take_page_params * Class definition for mod_attendance_take_page_params
@ -23,6 +22,8 @@ defined('MOODLE_INTERNAL') || die();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
defined('MOODLE_INTERNAL') || die();
/** /**
* contains functions/constants used by take attendance page. * contains functions/constants used by take attendance page.
* *
@ -30,22 +31,34 @@ defined('MOODLE_INTERNAL') || die();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class mod_attendance_take_page_params { class mod_attendance_take_page_params {
/** Sorted list. */
const SORTED_LIST = 1; const SORTED_LIST = 1;
/** Sorted grid. */
const SORTED_GRID = 2; const SORTED_GRID = 2;
/** Default view */
const DEFAULT_VIEW_MODE = self::SORTED_LIST; const DEFAULT_VIEW_MODE = self::SORTED_LIST;
/** @var int */
public $sessionid; public $sessionid;
/** @var int */
public $grouptype; public $grouptype;
/** @var int */
public $group; public $group;
/** @var int */
public $sort; public $sort;
/** @var int */
public $copyfrom; public $copyfrom;
/** @var int view mode of taking attendance page*/ /** @var int view mode of taking attendance page*/
public $viewmode; public $viewmode;
/** @var int */
public $gridcols; public $gridcols;
/**
* Initialize params.
*/
public function init() { public function init() {
if (!isset($this->group)) { if (!isset($this->group)) {
$this->group = 0; $this->group = 0;
@ -57,6 +70,9 @@ class mod_attendance_take_page_params {
$this->init_gridcols(); $this->init_gridcols();
} }
/**
* Initialise view mode params.
*/
private function init_view_mode() { private function init_view_mode() {
if (isset($this->viewmode)) { if (isset($this->viewmode)) {
set_user_preference("attendance_take_view_mode", $this->viewmode); set_user_preference("attendance_take_view_mode", $this->viewmode);
@ -65,6 +81,9 @@ class mod_attendance_take_page_params {
} }
} }
/**
* Initilise grid columns.
*/
private function init_gridcols() { private function init_gridcols() {
if (isset($this->gridcols)) { if (isset($this->gridcols)) {
set_user_preference("attendance_gridcolumns", $this->gridcols); set_user_preference("attendance_gridcolumns", $this->gridcols);
@ -73,6 +92,10 @@ class mod_attendance_take_page_params {
} }
} }
/**
* Get main page params.
* @return array
*/
public function get_significant_params() { public function get_significant_params() {
$params = array(); $params = array();

16
classes/view_page_params.php

@ -13,7 +13,6 @@
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
/** /**
* Class definition for mod_attendance_view_page_params * Class definition for mod_attendance_view_page_params
@ -23,6 +22,8 @@ defined('MOODLE_INTERNAL') || die();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
defined('MOODLE_INTERNAL') || die();
/** /**
* contains functions/constants used by attendance view page. * contains functions/constants used by attendance view page.
* *
@ -30,17 +31,30 @@ defined('MOODLE_INTERNAL') || die();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class mod_attendance_view_page_params extends mod_attendance_page_with_filter_controls { class mod_attendance_view_page_params extends mod_attendance_page_with_filter_controls {
/** Only This course */
const MODE_THIS_COURSE = 0; const MODE_THIS_COURSE = 0;
/** All courses */
const MODE_ALL_COURSES = 1; const MODE_ALL_COURSES = 1;
/** @var int */
public $studentid; public $studentid;
/** @var string */
public $mode; public $mode;
/**
* mod_attendance_view_page_params constructor.
*/
public function __construct() { public function __construct() {
$this->defaultview = ATT_VIEW_MONTHS; $this->defaultview = ATT_VIEW_MONTHS;
} }
/**
* Get params for url.
*
* @return array
*/
public function get_significant_params() { public function get_significant_params() {
$params = array(); $params = array();

6
export_form.php

@ -137,6 +137,12 @@ class mod_attendance_export_form extends moodleform {
$mform->addElement('hidden', 'id', $cm->id); $mform->addElement('hidden', 'id', $cm->id);
} }
/**
* Validate form.
* @param array $data
* @param array $files
* @return array
*/
public function validation($data, $files) { public function validation($data, $files) {
$errors = parent::validation($data, $files); $errors = parent::validation($data, $files);

21
temp_form.php

@ -27,9 +27,16 @@ defined('MOODLE_INTERNAL') || die();
global $CFG; global $CFG;
require_once($CFG->libdir.'/formslib.php'); require_once($CFG->libdir.'/formslib.php');
/**
* Class temp_form
* @copyright 2013 Davo Smith, Synergy Learning
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class temp_form extends moodleform { class temp_form extends moodleform {
/**
* Define form.
*/
public function definition() { public function definition() {
$mform = $this->_form; $mform = $this->_form;
$mform->addElement('hidden', 'id', 0); $mform->addElement('hidden', 'id', 0);
@ -49,11 +56,21 @@ class temp_form extends moodleform {
$mform->closeHeaderBefore('submit'); $mform->closeHeaderBefore('submit');
} }
/**
* Do stuff to form after creation.
*/
public function definition_after_data() { public function definition_after_data() {
$mform = $this->_form; $mform = $this->_form;
$mform->applyFilter('tname', 'trim'); $mform->applyFilter('tname', 'trim');
} }
/**
* Form validation.
*
* @param array $data
* @param array $files
* @return array
*/
public function validation($data, $files) { public function validation($data, $files) {
$errors = parent::validation($data, $files); $errors = parent::validation($data, $files);
@ -63,6 +80,4 @@ class temp_form extends moodleform {
return $errors; return $errors;
} }
} }

10
tempusers.php

@ -89,12 +89,18 @@ $tempusers = $DB->get_records('attendance_tempusers', array('courseid' => $cours
echo '<div>'; echo '<div>';
echo '<p style="margin-left:10%;">'.get_string('tempuserslist', 'attendance').'</p>'; echo '<p style="margin-left:10%;">'.get_string('tempuserslist', 'attendance').'</p>';
if ($tempusers) { if ($tempusers) {
print_tempusers($tempusers, $att); attendance_print_tempusers($tempusers, $att);
} }
echo '</div>'; echo '</div>';
echo $output->footer($course); echo $output->footer($course);
function print_tempusers($tempusers, mod_attendance_structure $att) { /**
* Print list of users.
*
* @param stdClass $tempusers
* @param mod_attendance_structure $att
*/
function attendance_print_tempusers($tempusers, mod_attendance_structure $att) {
echo '<p></p>'; echo '<p></p>';
echo '<table border="1" bordercolor="#EEEEEE" style="background-color:#fff" cellpadding="2" align="center"'. echo '<table border="1" bordercolor="#EEEEEE" style="background-color:#fff" cellpadding="2" align="center"'.
'width="80%" summary="'.get_string('temptable', 'attendance').'"><tr>'; 'width="80%" summary="'.get_string('temptable', 'attendance').'"><tr>';

Loading…
Cancel
Save