Browse Source

phpdoc stuff.

MOODLE_33_STABLE
Dan Marsden 8 years ago
parent
commit
e584a48448
  1. 57
      externallib.php
  2. 37
      locallib.php
  3. 300
      renderables.php
  4. 14
      tests/attendance_webservices_test.php

57
externallib.php

@ -26,17 +26,36 @@ defined('MOODLE_INTERNAL') || die;
require_once("$CFG->libdir/externallib.php"); require_once("$CFG->libdir/externallib.php");
require_once(dirname(__FILE__).'/classes/attendance_webservices_handler.php'); require_once(dirname(__FILE__).'/classes/attendance_webservices_handler.php');
/**
* Class mod_wsattendance_external
* @copyright 2015 Caio Bressan Doneda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_wsattendance_external extends external_api { class mod_wsattendance_external extends external_api {
/**
* Get parameter list.
* @return external_function_parameters
*/
public static function get_courses_with_today_sessions_parameters() { public static function get_courses_with_today_sessions_parameters() {
return new external_function_parameters ( return new external_function_parameters (
array('userid' => new external_value(PARAM_INT, 'User id.', VALUE_DEFAULT, 0))); array('userid' => new external_value(PARAM_INT, 'User id.', VALUE_DEFAULT, 0)));
} }
/**
* Get list of courses with active sessions for today.
* @param int $userid
* @return array
*/
public static function get_courses_with_today_sessions($userid) { public static function get_courses_with_today_sessions($userid) {
return attendance_handler::get_courses_with_today_sessions($userid); return attendance_handler::get_courses_with_today_sessions($userid);
} }
/**
* Get structure of an attendance session.
*
* @return array
*/
private static function get_session_structure() { private static function get_session_structure() {
$session = array('id' => new external_value(PARAM_INT, 'Session id.'), $session = array('id' => new external_value(PARAM_INT, 'Session id.'),
'attendanceid' => new external_value(PARAM_INT, 'Attendance id.'), 'attendanceid' => new external_value(PARAM_INT, 'Attendance id.'),
@ -54,6 +73,10 @@ class mod_wsattendance_external extends external_api {
return $session; return $session;
} }
/**
* Show structure of return.
* @return external_multiple_structure
*/
public static function get_courses_with_today_sessions_returns() { public static function get_courses_with_today_sessions_returns() {
$todaysessions = self::get_session_structure(); $todaysessions = self::get_session_structure();
@ -69,15 +92,31 @@ class mod_wsattendance_external extends external_api {
return new external_multiple_structure(new external_single_structure(($courses))); return new external_multiple_structure(new external_single_structure(($courses)));
} }
/**
* Get session params.
*
* @return external_function_parameters
*/
public static function get_session_parameters() { public static function get_session_parameters() {
return new external_function_parameters ( return new external_function_parameters (
array('sessionid' => new external_value(PARAM_INT, 'session id'))); array('sessionid' => new external_value(PARAM_INT, 'session id')));
} }
/**
* Get session.
*
* @param int $sessionid
* @return mixed
*/
public static function get_session($sessionid) { public static function get_session($sessionid) {
return attendance_handler::get_session($sessionid); return attendance_handler::get_session($sessionid);
} }
/**
* Show return values of get_session.
*
* @return external_single_structure
*/
public static function get_session_returns() { public static function get_session_returns() {
$statuses = array('id' => new external_value(PARAM_INT, 'Status id.'), $statuses = array('id' => new external_value(PARAM_INT, 'Status id.'),
'attendanceid' => new external_value(PARAM_INT, 'Attendance id.'), 'attendanceid' => new external_value(PARAM_INT, 'Attendance id.'),
@ -106,6 +145,11 @@ class mod_wsattendance_external extends external_api {
return new external_single_structure($session); return new external_single_structure($session);
} }
/**
* Update user status params.
*
* @return external_function_parameters
*/
public static function update_user_status_parameters() { public static function update_user_status_parameters() {
return new external_function_parameters( return new external_function_parameters(
array('sessionid' => new external_value(PARAM_INT, 'Session id'), array('sessionid' => new external_value(PARAM_INT, 'Session id'),
@ -115,10 +159,23 @@ class mod_wsattendance_external extends external_api {
'statusset' => new external_value(PARAM_TEXT, 'Status set of session'))); 'statusset' => new external_value(PARAM_TEXT, 'Status set of 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) {
return attendance_handler::update_user_status($sessionid, $studentid, $takenbyid, $statusid, $statusset); return attendance_handler::update_user_status($sessionid, $studentid, $takenbyid, $statusid, $statusset);
} }
/**
* Show return values.
* @return external_value
*/
public static function update_user_status_returns() { public static function update_user_status_returns() {
return new external_value(PARAM_TEXT, 'Http code'); return new external_value(PARAM_TEXT, 'Http code');
} }

37
locallib.php

@ -39,6 +39,14 @@ define('ATT_SORT_DEFAULT', 0);
define('ATT_SORT_LASTNAME', 1); define('ATT_SORT_LASTNAME', 1);
define('ATT_SORT_FIRSTNAME', 2); define('ATT_SORT_FIRSTNAME', 2);
/**
* Get statuses,
*
* @param int $attid
* @param bool $onlyvisible
* @param int $statusset
* @return array
*/
function attendance_get_statuses($attid, $onlyvisible=true, $statusset = -1) { function attendance_get_statuses($attid, $onlyvisible=true, $statusset = -1) {
global $DB; global $DB;
@ -90,6 +98,12 @@ function attendance_get_setname($attid, $statusset, $includevalues = true) {
return $statusname; return $statusname;
} }
/**
* Get users courses and the relevant attendances.
*
* @param int $userid
* @return array
*/
function attendance_get_user_courses_attendances($userid) { function attendance_get_user_courses_attendances($userid) {
global $DB; global $DB;
@ -181,7 +195,7 @@ function attendance_get_max_statusset($attendanceid) {
/** /**
* Returns the maxpoints for each statusset * Returns the maxpoints for each statusset
* *
* @param array statuses * @param array $statuses
* @return array * @return array
*/ */
function attendance_get_statusset_maxpoints($statuses) { function attendance_get_statusset_maxpoints($statuses) {
@ -197,7 +211,7 @@ function attendance_get_statusset_maxpoints($statuses) {
/** /**
* Update user grades * Update user grades
* *
* @param mixed mod_attendance_structure|stdClass $attendance * @param mod_attendance_structure|stdClass $attendance
* @param array $userids * @param array $userids
*/ */
function attendance_update_users_grade($attendance, $userids=array()) { function attendance_update_users_grade($attendance, $userids=array()) {
@ -247,6 +261,11 @@ function attendance_update_users_grade($attendance, $userids=array()) {
* @param string $acronym * @param string $acronym
* @param string $description * @param string $description
* @param int $grade * @param int $grade
* @param int $attendanceid
* @param int $setnumber
* @param stdClass $context
* @param stdClass $cm
* @return bool
*/ */
function attendance_add_status($acronym, $description, $grade, $attendanceid, $setnumber = 0, $context = null, $cm = null) { function attendance_add_status($acronym, $description, $grade, $attendanceid, $setnumber = 0, $context = null, $cm = null) {
global $DB; global $DB;
@ -284,6 +303,8 @@ function attendance_add_status($acronym, $description, $grade, $attendanceid, $s
* Remove a status variable from an attendance instance * Remove a status variable from an attendance instance
* *
* @param stdClass $status * @param stdClass $status
* @param stdClass $context
* @param stdClass $cm
*/ */
function attendance_remove_status($status, $context = null, $cm = null) { function attendance_remove_status($status, $context = null, $cm = null) {
global $DB; global $DB;
@ -313,6 +334,9 @@ function attendance_remove_status($status, $context = null, $cm = null) {
* @param string $description * @param string $description
* @param int $grade * @param int $grade
* @param bool $visible * @param bool $visible
* @param stdClass $context
* @param stdClass $cm
* @return array
*/ */
function attendance_update_status($status, $acronym, $description, $grade, $visible, $context = null, $cm = null) { function attendance_update_status($status, $acronym, $description, $grade, $visible, $context = null, $cm = null) {
global $DB; global $DB;
@ -483,7 +507,8 @@ function attendance_exporttocsv($data, $filename) {
} }
/** /**
* @param $formdata moodleform - attendance form. * Get session data for form.
* @param stdClass $formdata moodleform - attendance form.
* @return array. * @return array.
*/ */
function attendance_construct_sessions_data_for_add($formdata) { function attendance_construct_sessions_data_for_add($formdata) {
@ -583,9 +608,9 @@ function attendance_construct_sessions_data_for_add($formdata) {
/** /**
* Helper function for attendance_construct_sessions_data_for_add(). * Helper function for attendance_construct_sessions_data_for_add().
* *
* @param $formdata * @param stdClass $formdata
* @param $sessions * @param stdClass $sessions
* @param $sess * @param stdClass $sess
*/ */
function attendance_fill_groupid($formdata, &$sessions, $sess) { function attendance_fill_groupid($formdata, &$sessions, $sess) {
if ($formdata->sessiontype == mod_attendance_structure::SESSION_COMMON) { if ($formdata->sessiontype == mod_attendance_structure::SESSION_COMMON) {

300
renderables.php

@ -37,24 +37,32 @@ require_once(dirname(__FILE__).'/locallib.php');
* *
*/ */
class attendance_tabs implements renderable { class attendance_tabs implements renderable {
/** Sessions tab */
const TAB_SESSIONS = 1; const TAB_SESSIONS = 1;
/** Add tab */
const TAB_ADD = 2; const TAB_ADD = 2;
/** Rerort tab */
const TAB_REPORT = 3; const TAB_REPORT = 3;
/** Export tab */
const TAB_EXPORT = 4; const TAB_EXPORT = 4;
/** Preferences tab */
const TAB_PREFERENCES = 5; const TAB_PREFERENCES = 5;
/** Temp users tab */
const TAB_TEMPORARYUSERS = 6; // Tab for managing temporary users. const TAB_TEMPORARYUSERS = 6; // Tab for managing temporary users.
/** Update tab */
const TAB_UPDATE = 7; const TAB_UPDATE = 7;
/** @var int current tab */
public $currenttab; public $currenttab;
/** @var attendance */ /** @var stdClass attendance */
private $att; private $att;
/** /**
* Prepare info about sessions for attendance taking into account view parameters. * Prepare info about sessions for attendance taking into account view parameters.
* *
* @param attendance $att instance * @param mod_attendance_structure $att
* @param $currenttab - one of attendance_tabs constants * @param int $currenttab - one of attendance_tabs constants
*/ */
public function __construct(mod_attendance_structure $att, $currenttab=null) { public function __construct(mod_attendance_structure $att, $currenttab=null) {
$this->att = $att; $this->att = $att;
@ -113,25 +121,38 @@ class attendance_tabs implements renderable {
} }
} }
/**
* Class attendance_filter_controls
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class attendance_filter_controls implements renderable { class attendance_filter_controls implements renderable {
/** @var int current view mode */ /** @var int current view mode */
public $pageparams; public $pageparams;
/** @var stdclass */
public $cm; public $cm;
/** @var int */
public $curdate; public $curdate;
/** @var int */
public $prevcur; public $prevcur;
/** @var int */
public $nextcur; public $nextcur;
/** @var string */
public $curdatetxt; public $curdatetxt;
/** @var boolean */
public $reportcontrol; public $reportcontrol;
/** @var string */
private $urlpath; private $urlpath;
/** @var array */
private $urlparams; private $urlparams;
/** @var mod_attendance_structure */
public $att; public $att;
/**
* attendance_filter_controls constructor.
* @param mod_attendance_structure $att
* @param bool $report
*/
public function __construct(mod_attendance_structure $att, $report = false) { public function __construct(mod_attendance_structure $att, $report = false) {
global $PAGE; global $PAGE;
@ -179,30 +200,57 @@ class attendance_filter_controls implements renderable {
$this->att = $att; $this->att = $att;
} }
/**
* Helper function for url.
*
* @param array $params
* @return moodle_url
*/
public function url($params=array()) { public function url($params=array()) {
$params = array_merge($this->urlparams, $params); $params = array_merge($this->urlparams, $params);
return new moodle_url($this->urlpath, $params); return new moodle_url($this->urlpath, $params);
} }
/**
* Helper function for url path.
* @return string
*/
public function url_path() { public function url_path() {
return $this->urlpath; return $this->urlpath;
} }
/**
* Helper function for url_params.
* @param array $params
* @return array
*/
public function url_params($params=array()) { public function url_params($params=array()) {
$params = array_merge($this->urlparams, $params); $params = array_merge($this->urlparams, $params);
return $params; return $params;
} }
/**
* Return groupmode.
* @return int
*/
public function get_group_mode() { public function get_group_mode() {
return $this->att->get_group_mode(); return $this->att->get_group_mode();
} }
/**
* Return groupslist.
* @return mixed
*/
public function get_sess_groups_list() { public function get_sess_groups_list() {
return $this->att->pageparams->get_sess_groups_list(); return $this->att->pageparams->get_sess_groups_list();
} }
/**
* Get current session type.
* @return mixed
*/
public function get_current_sesstype() { public function get_current_sesstype() {
return $this->att->pageparams->get_current_sesstype(); return $this->att->pageparams->get_current_sesstype();
} }
@ -220,17 +268,17 @@ class attendance_manage_data implements renderable {
/** @var int number of hidden sessions (sessions before $course->startdate)*/ /** @var int number of hidden sessions (sessions before $course->startdate)*/
public $hiddensessionscount; public $hiddensessionscount;
/** @var array */
public $groups; public $groups;
/** @var int */
public $hiddensesscount; public $hiddensesscount;
/** @var attendance */ /** @var mod_attendance_structure */
public $att; public $att;
/** /**
* Prepare info about attendance sessions taking into account view parameters. * Prepare info about attendance sessions taking into account view parameters.
* *
* @param attendance $att instance * @param mod_attendance_structure $att instance
*/ */
public function __construct(mod_attendance_structure $att) { public function __construct(mod_attendance_structure $att) {
@ -243,40 +291,64 @@ class attendance_manage_data implements renderable {
$this->att = $att; $this->att = $att;
} }
/**
* Helper function to return urls.
* @param int $sessionid
* @param int $grouptype
* @return mixed
*/
public function url_take($sessionid, $grouptype) { public function url_take($sessionid, $grouptype) {
return url_helpers::url_take($this->att, $sessionid, $grouptype); return url_helpers::url_take($this->att, $sessionid, $grouptype);
} }
/** /**
* Must be called without or with both parameters * Must be called without or with both parameters
*
* @param int $sessionid
* @param null $action
* @return mixed
*/ */
public function url_sessions($sessionid=null, $action=null) { public function url_sessions($sessionid=null, $action=null) {
return url_helpers::url_sessions($this->att, $sessionid, $action); return url_helpers::url_sessions($this->att, $sessionid, $action);
} }
} }
/**
* class take data.
*
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class attendance_take_data implements renderable { class attendance_take_data implements renderable {
/** @var array */
public $users; public $users;
/** @var array|null|stdClass */
public $pageparams; public $pageparams;
/** @var int */
public $groupmode; public $groupmode;
/** @var stdclass */
public $cm; public $cm;
/** @var array */
public $statuses; public $statuses;
/** @var mixed */
public $sessioninfo; public $sessioninfo;
/** @var array */
public $sessionlog; public $sessionlog;
/** @var array */
public $sessions4copy; public $sessions4copy;
/** @var bool */
public $updatemode; public $updatemode;
/** @var string */
private $urlpath; private $urlpath;
/** @var array */
private $urlparams; private $urlparams;
/** @var mod_attendance_structure */
public $att; public $att;
/**
* attendance_take_data constructor.
* @param mod_attendance_structure $att
*/
public function __construct(mod_attendance_structure $att) { public function __construct(mod_attendance_structure $att) {
if ($att->pageparams->grouptype) { if ($att->pageparams->grouptype) {
$this->users = $att->get_users($att->pageparams->grouptype, $att->pageparams->page); $this->users = $att->get_users($att->pageparams->grouptype, $att->pageparams->page);
@ -314,6 +386,12 @@ class attendance_take_data implements renderable {
$this->att = $att; $this->att = $att;
} }
/**
* Url function
* @param array $params
* @param array $excludeparams
* @return moodle_url
*/
public function url($params=array(), $excludeparams=array()) { public function url($params=array(), $excludeparams=array()) {
$params = array_merge($this->urlparams, $params); $params = array_merge($this->urlparams, $params);
@ -324,35 +402,57 @@ class attendance_take_data implements renderable {
return new moodle_url($this->urlpath, $params); return new moodle_url($this->urlpath, $params);
} }
/**
* Url view helper.
* @param array $params
* @return mixed
*/
public function url_view($params=array()) { public function url_view($params=array()) {
return url_helpers::url_view($this->att, $params); return url_helpers::url_view($this->att, $params);
} }
/**
* Url path helper.
* @return string
*/
public function url_path() { public function url_path() {
return $this->urlpath; return $this->urlpath;
} }
} }
/**
* Class user data.
*
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class attendance_user_data implements renderable { class attendance_user_data implements renderable {
/** @var mixed|object */
public $user; public $user;
/** @var array|null|stdClass */
public $pageparams; public $pageparams;
/** @var array */
public $statuses; public $statuses;
/** @var array */
public $summary; public $summary;
/** @var attendance_filter_controls */
public $filtercontrols; public $filtercontrols;
/** @var array */
public $sessionslog; public $sessionslog;
/** @var array */
public $groups; public $groups;
/** @var array */
public $coursesatts; public $coursesatts;
/** @var string */
private $urlpath; private $urlpath;
/** @var array */
private $urlparams; private $urlparams;
/**
* attendance_user_data constructor.
* @param mod_attendance_structure $att
* @param int $userid
*/
public function __construct(mod_attendance_structure $att, $userid) { public function __construct(mod_attendance_structure $att, $userid) {
$this->user = $att->get_user($userid); $this->user = $att->get_user($userid);
@ -389,32 +489,47 @@ class attendance_user_data implements renderable {
$this->urlparams = $params; $this->urlparams = $params;
} }
/**
* url helper.
* @return moodle_url
*/
public function url() { public function url() {
return new moodle_url($this->urlpath, $this->urlparams); return new moodle_url($this->urlpath, $this->urlparams);
} }
} }
/**
* Class report data.
*
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class attendance_report_data implements renderable { class attendance_report_data implements renderable {
/** @var array|null|stdClass */
public $pageparams; public $pageparams;
/** @var array */
public $users; public $users;
/** @var array */
public $groups; public $groups;
/** @var array */
public $sessions; public $sessions;
/** @var array */
public $statuses; public $statuses;
// Includes disablrd/deleted statuses. /** @var array includes disablrd/deleted statuses. */
public $allstatuses; public $allstatuses;
/** @var array */
public $usersgroups = array(); public $usersgroups = array();
/** @var array */
public $sessionslog = array(); public $sessionslog = array();
/** @var array|mod_attendance_summary */
public $summary = array(); public $summary = array();
/** @var mod_attendance_structure */
public $att; public $att;
/**
* attendance_report_data constructor.
* @param mod_attendance_structure $att
*/
public function __construct(mod_attendance_structure $att) { public function __construct(mod_attendance_structure $att) {
$currenttime = time(); $currenttime = time();
if ($att->pageparams->view == ATT_VIEW_NOTPRESENT) { if ($att->pageparams->view == ATT_VIEW_NOTPRESENT) {
@ -463,14 +578,30 @@ class attendance_report_data implements renderable {
$this->att = $att; $this->att = $att;
} }
/**
* url take helper.
* @param int $sessionid
* @param int $grouptype
* @return mixed
*/
public function url_take($sessionid, $grouptype) { public function url_take($sessionid, $grouptype) {
return url_helpers::url_take($this->att, $sessionid, $grouptype); return url_helpers::url_take($this->att, $sessionid, $grouptype);
} }
/**
* url view helper.
* @param array $params
* @return mixed
*/
public function url_view($params=array()) { public function url_view($params=array()) {
return url_helpers::url_view($this->att, $params); return url_helpers::url_view($this->att, $params);
} }
/**
* url helper.
* @param array $params
* @return moodle_url
*/
public function url($params=array()) { public function url($params=array()) {
$params = array_merge($params, $this->pageparams->get_significant_params()); $params = array_merge($params, $this->pageparams->get_significant_params());
@ -479,13 +610,25 @@ class attendance_report_data implements renderable {
} }
/**
* Class preferences data.
*
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class attendance_preferences_data implements renderable { class attendance_preferences_data implements renderable {
/** @var array */
public $statuses; public $statuses;
/** @var mod_attendance_structure */
private $att; private $att;
/** @var array */
public $errors; public $errors;
/**
* attendance_preferences_data constructor.
* @param mod_attendance_structure $att
* @param array $errors
*/
public function __construct(mod_attendance_structure $att, $errors) { public function __construct(mod_attendance_structure $att, $errors) {
$this->statuses = $att->get_statuses(false); $this->statuses = $att->get_statuses(false);
$this->errors = $errors; $this->errors = $errors;
@ -497,6 +640,12 @@ class attendance_preferences_data implements renderable {
$this->att = $att; $this->att = $att;
} }
/**
* url helper function
* @param array $params
* @param bool $significantparams
* @return moodle_url
*/
public function url($params=array(), $significantparams=true) { public function url($params=array(), $significantparams=true) {
if ($significantparams) { if ($significantparams) {
$params = array_merge($this->att->pageparams->get_significant_params(), $params); $params = array_merge($this->att->pageparams->get_significant_params(), $params);
@ -506,32 +655,65 @@ class attendance_preferences_data implements renderable {
} }
} }
/**
* Default status set
*
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class attendance_default_statusset implements renderable { class attendance_default_statusset implements renderable {
/** @var array */
public $statuses; public $statuses;
/** @var array */
public $errors; public $errors;
/**
* attendance_default_statusset constructor.
* @param array $statuses
* @param array $errors
*/
public function __construct($statuses, $errors) { public function __construct($statuses, $errors) {
$this->statuses = $statuses; $this->statuses = $statuses;
$this->errors = $errors; $this->errors = $errors;
} }
/**
* url helper.
* @param stdClass $params
* @return moodle_url
*/
public function url($params) { public function url($params) {
return new moodle_url('/mod/attendance/defaultstatus.php', $params); return new moodle_url('/mod/attendance/defaultstatus.php', $params);
} }
} }
// Output a selector to change between status sets. /**
* Output a selector to change between status sets.
*
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class attendance_set_selector implements renderable { class attendance_set_selector implements renderable {
/** @var int */
public $maxstatusset; public $maxstatusset;
/** @var mod_attendance_structure */
private $att; private $att;
/**
* attendance_set_selector constructor.
* @param mod_attendance_structure $att
* @param int $maxstatusset
*/
public function __construct(mod_attendance_structure $att, $maxstatusset) { public function __construct(mod_attendance_structure $att, $maxstatusset) {
$this->att = $att; $this->att = $att;
$this->maxstatusset = $maxstatusset; $this->maxstatusset = $maxstatusset;
} }
/**
* url helper
* @param array $statusset
* @return moodle_url
*/
public function url($statusset) { public function url($statusset) {
$params = array(); $params = array();
$params['statusset'] = $statusset; $params['statusset'] = $statusset;
@ -539,6 +721,10 @@ class attendance_set_selector implements renderable {
return $this->att->url_preferences($params); return $this->att->url_preferences($params);
} }
/**
* get current statusset.
* @return int
*/
public function get_current_statusset() { public function get_current_statusset() {
if (isset($this->att->pageparams->statusset)) { if (isset($this->att->pageparams->statusset)) {
return $this->att->pageparams->statusset; return $this->att->pageparams->statusset;
@ -546,12 +732,30 @@ class attendance_set_selector implements renderable {
return 0; return 0;
} }
/**
* get statusset name.
* @param int $statusset
* @return string
*/
public function get_status_name($statusset) { public function get_status_name($statusset) {
return attendance_get_setname($this->att->id, $statusset, true); return attendance_get_setname($this->att->id, $statusset, true);
} }
} }
/**
* Url helpers
*
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class url_helpers { class url_helpers {
/**
* Url take.
* @param stdClass $att
* @param int $sessionid
* @param int $grouptype
* @return mixed
*/
public static function url_take($att, $sessionid, $grouptype) { public static function url_take($att, $sessionid, $grouptype) {
$params = array('sessionid' => $sessionid); $params = array('sessionid' => $sessionid);
if (isset($grouptype)) { if (isset($grouptype)) {
@ -563,6 +767,10 @@ class url_helpers {
/** /**
* Must be called without or with both parameters * Must be called without or with both parameters
* @param stdClass $att
* @param null $sessionid
* @param null $action
* @return mixed
*/ */
public static function url_sessions($att, $sessionid=null, $action=null) { public static function url_sessions($att, $sessionid=null, $action=null) {
if (isset($sessionid) && isset($action)) { if (isset($sessionid) && isset($action)) {
@ -574,6 +782,12 @@ class url_helpers {
return $att->url_sessions($params); return $att->url_sessions($params);
} }
/**
* Url view helper.
* @param stdClass $att
* @param array $params
* @return mixed
*/
public static function url_view($att, $params=array()) { public static function url_view($att, $params=array()) {
return $att->url_view($params); return $att->url_view($params);
} }

14
tests/attendance_webservices_test.php

@ -31,14 +31,26 @@ global $CFG;
require_once($CFG->dirroot . '/mod/attendance/classes/attendance_webservices_handler.php'); require_once($CFG->dirroot . '/mod/attendance/classes/attendance_webservices_handler.php');
require_once($CFG->dirroot . '/mod/attendance/classes/structure.php'); require_once($CFG->dirroot . '/mod/attendance/classes/structure.php');
/** This class contains the test cases for the functions in attendance_webservices_handler.php. */ /**
* This class contains the test cases for the functions in attendance_webservices_handler.php.
* @copyright 2015 Caio Bressan Doneda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class attendance_webservices_tests extends advanced_testcase { class attendance_webservices_tests extends advanced_testcase {
/** @var coursecat */
protected $category; protected $category;
/** @var stdClass */
protected $course; protected $course;
/** @var stdClass */
protected $attendance; protected $attendance;
/** @var stdClass */
protected $teacher; protected $teacher;
/** @var array */
protected $sessions; protected $sessions;
/**
* Setup class.
*/
public function setUp() { public function setUp() {
global $DB; global $DB;

Loading…
Cancel
Save