Browse Source

fix up some phpdoc stuff.

MOODLE_32_STABLE
Dan Marsden 8 years ago
parent
commit
c55d38af16
  1. 4
      attendance.php
  2. 3
      db/install.php
  3. 2
      db/services.php
  4. 6
      db/upgrade.php
  5. 7
      db/upgradelib.php
  6. 121
      locallib.php
  7. 112
      sessions.php
  8. 19
      student_attendance_form.php
  9. 21
      tempmerge_form.php
  10. 9
      tests/generator/lib.php

4
attendance.php

@ -17,8 +17,8 @@
/** /**
* Prints attendance info for particular user * Prints attendance info for particular user
* *
* @package mod * @package mod_attendance
* @subpackage attendance * @copyright 2014 Dan Marsden
* @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
*/ */

3
db/install.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();
/** /**
* post installation hook for adding data. * post installation hook for adding data.
@ -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();
/** /**
* Post installation procedure * Post installation procedure
*/ */

2
db/services.php

@ -17,7 +17,7 @@
/** /**
* Web service local plugin attendance external functions and service definitions. * Web service local plugin attendance external functions and service definitions.
* *
* @package localwsattendance * @package mod_attendance
* @copyright 2015 Caio Bressan Doneda * @copyright 2015 Caio Bressan Doneda
* @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
*/ */

6
db/upgrade.php

@ -14,9 +14,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();
require_once(dirname(__FILE__) . '/upgradelib.php');
/** /**
* upgrade processes for this module. * upgrade processes for this module.
* *
@ -25,6 +22,9 @@ require_once(dirname(__FILE__) . '/upgradelib.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
*/ */
defined('MOODLE_INTERNAL') || die();
require_once(dirname(__FILE__) . '/upgradelib.php');
/** /**
* upgrade this attendance instance - this function could be skipped but it will be needed later * upgrade this attendance instance - this function could be skipped but it will be needed later
* @param int $oldversion The old version of the attendance module * @param int $oldversion The old version of the attendance module

7
db/upgradelib.php

@ -14,8 +14,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();
/** /**
* Helper functions to keep upgrade.php clean. * Helper functions to keep upgrade.php clean.
* *
@ -24,6 +22,11 @@ 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();
/**
* Function to help upgrade old attendance records and create calendar events.
*/
function attendance_upgrade_create_calendar_events() { function attendance_upgrade_create_calendar_events() {
global $DB; global $DB;

121
locallib.php

@ -480,4 +480,123 @@ function attendance_exporttocsv($data, $filename) {
foreach ($data->table as $row) { foreach ($data->table as $row) {
echo implode("\t", $row)."\n"; echo implode("\t", $row)."\n";
} }
} }
/**
* @param $formdata moodleform - attendance form.
* @return array.
*/
function attendance_construct_sessions_data_for_add($formdata) {
global $CFG;
$sesstarttime = $formdata->sestime['starthour'] * HOURSECS + $formdata->sestime['startminute'] * MINSECS;
$sesendtime = $formdata->sestime['endhour'] * HOURSECS + $formdata->sestime['endminute'] * MINSECS;
$sessiondate = $formdata->sessiondate + $sesstarttime;
$duration = $sesendtime - $sesstarttime;
$now = time();
if (empty(get_config('attendance', 'studentscanmark'))) {
$formdata->studentscanmark = 0;
}
$sessions = array();
if (isset($formdata->addmultiply)) {
$startdate = $sessiondate;
$enddate = $formdata->sessionenddate + DAYSECS; // Because enddate in 0:0am.
if ($enddate < $startdate) {
return null;
}
// Getting first day of week.
$sdate = $startdate;
$dinfo = usergetdate($sdate);
if ($CFG->calendar_startwday === '0') { // Week start from sunday.
$startweek = $startdate - $dinfo['wday'] * DAYSECS; // Call new variable.
} else {
$wday = $dinfo['wday'] === 0 ? 7 : $dinfo['wday'];
$startweek = $startdate - ($wday - 1) * DAYSECS;
}
$wdaydesc = array(0 => 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
while ($sdate < $enddate) {
if ($sdate < $startweek + WEEKSECS) {
$dinfo = usergetdate($sdate);
if (isset($formdata->sdays) && array_key_exists($wdaydesc[$dinfo['wday']], $formdata->sdays)) {
$sess = new stdClass();
$sess->sessdate = make_timestamp($dinfo['year'], $dinfo['mon'], $dinfo['mday'],
$formdata->sestime['starthour'], $formdata->sestime['startminute']);
$sess->duration = $duration;
$sess->descriptionitemid = $formdata->sdescription['itemid'];
$sess->description = $formdata->sdescription['text'];
$sess->descriptionformat = $formdata->sdescription['format'];
$sess->timemodified = $now;
if (isset($formdata->studentscanmark)) { // Students will be able to mark their own attendance.
$sess->studentscanmark = 1;
if (!empty($formdata->randompassword)) {
$sess->studentpassword = attendance_random_string();
} else {
$sess->studentpassword = $formdata->studentpassword;
}
} else {
$sess->studentpassword = '';
}
$sess->statusset = $formdata->statusset;
attendance_fill_groupid($formdata, $sessions, $sess);
}
$sdate += DAYSECS;
} else {
$startweek += WEEKSECS * $formdata->period;
$sdate = $startweek;
}
}
} else {
$sess = new stdClass();
$sess->sessdate = $sessiondate;
$sess->duration = $duration;
$sess->descriptionitemid = $formdata->sdescription['itemid'];
$sess->description = $formdata->sdescription['text'];
$sess->descriptionformat = $formdata->sdescription['format'];
$sess->timemodified = $now;
$sess->studentscanmark = 0;
$sess->studentpassword = '';
if (isset($formdata->studentscanmark) && !empty($formdata->studentscanmark)) {
// Students will be able to mark their own attendance.
$sess->studentscanmark = 1;
if (!empty($formdata->randompassword)) {
$sess->studentpassword = attendance_random_string();
} else {
$sess->studentpassword = $formdata->studentpassword;
}
}
$sess->statusset = $formdata->statusset;
attendance_fill_groupid($formdata, $sessions, $sess);
}
return $sessions;
}
/**
* Helper function for attendance_construct_sessions_data_for_add().
*
* @param $formdata
* @param $sessions
* @param $sess
*/
function attendance_fill_groupid($formdata, &$sessions, $sess) {
if ($formdata->sessiontype == mod_attendance_structure::SESSION_COMMON) {
$sess = clone $sess;
$sess->groupid = 0;
$sessions[] = $sess;
} else {
foreach ($formdata->groups as $groupid) {
$sess = clone $sess;
$sess->groupid = $groupid;
$sessions[] = $sess;
}
}
}

112
sessions.php

@ -73,7 +73,7 @@ switch ($att->pageparams->action) {
} }
if ($formdata = $mform->get_data()) { if ($formdata = $mform->get_data()) {
$sessions = construct_sessions_data_for_add($formdata); $sessions = attendance_construct_sessions_data_for_add($formdata);
$att->add_sessions($sessions); $att->add_sessions($sessions);
if (count($sessions) == 1) { if (count($sessions) == 1) {
$message = get_string('sessiongenerated', 'attendance'); $message = get_string('sessiongenerated', 'attendance');
@ -222,112 +222,4 @@ echo $output->render($tabs);
$mform->display(); $mform->display();
echo $OUTPUT->footer(); echo $OUTPUT->footer();
function construct_sessions_data_for_add($formdata) {
global $CFG;
$sesstarttime = $formdata->sestime['starthour'] * HOURSECS + $formdata->sestime['startminute'] * MINSECS;
$sesendtime = $formdata->sestime['endhour'] * HOURSECS + $formdata->sestime['endminute'] * MINSECS;
$sessiondate = $formdata->sessiondate + $sesstarttime;
$duration = $sesendtime - $sesstarttime;
$now = time();
if (empty(get_config('attendance', 'studentscanmark'))) {
$formdata->studentscanmark = 0;
}
$sessions = array();
if (isset($formdata->addmultiply)) {
$startdate = $sessiondate;
$enddate = $formdata->sessionenddate + DAYSECS; // Because enddate in 0:0am.
if ($enddate < $startdate) {
return null;
}
// Getting first day of week.
$sdate = $startdate;
$dinfo = usergetdate($sdate);
if ($CFG->calendar_startwday === '0') { // Week start from sunday.
$startweek = $startdate - $dinfo['wday'] * DAYSECS; // Call new variable.
} else {
$wday = $dinfo['wday'] === 0 ? 7 : $dinfo['wday'];
$startweek = $startdate - ($wday - 1) * DAYSECS;
}
$wdaydesc = array(0 => 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
while ($sdate < $enddate) {
if ($sdate < $startweek + WEEKSECS) {
$dinfo = usergetdate($sdate);
if (isset($formdata->sdays) && array_key_exists($wdaydesc[$dinfo['wday']], $formdata->sdays)) {
$sess = new stdClass();
$sess->sessdate = make_timestamp($dinfo['year'], $dinfo['mon'], $dinfo['mday'],
$formdata->sestime['starthour'], $formdata->sestime['startminute']);
$sess->duration = $duration;
$sess->descriptionitemid = $formdata->sdescription['itemid'];
$sess->description = $formdata->sdescription['text'];
$sess->descriptionformat = $formdata->sdescription['format'];
$sess->timemodified = $now;
if (isset($formdata->studentscanmark)) { // Students will be able to mark their own attendance.
$sess->studentscanmark = 1;
if (!empty($formdata->randompassword)) {
$sess->studentpassword = attendance_random_string();
} else {
$sess->studentpassword = $formdata->studentpassword;
}
} else {
$sess->studentpassword = '';
}
$sess->statusset = $formdata->statusset;
fill_groupid($formdata, $sessions, $sess);
}
$sdate += DAYSECS;
} else {
$startweek += WEEKSECS * $formdata->period;
$sdate = $startweek;
}
}
} else {
$sess = new stdClass();
$sess->sessdate = $sessiondate;
$sess->duration = $duration;
$sess->descriptionitemid = $formdata->sdescription['itemid'];
$sess->description = $formdata->sdescription['text'];
$sess->descriptionformat = $formdata->sdescription['format'];
$sess->timemodified = $now;
$sess->studentscanmark = 0;
$sess->studentpassword = '';
if (isset($formdata->studentscanmark) && !empty($formdata->studentscanmark)) {
// Students will be able to mark their own attendance.
$sess->studentscanmark = 1;
if (!empty($formdata->randompassword)) {
$sess->studentpassword = attendance_random_string();
} else {
$sess->studentpassword = $formdata->studentpassword;
}
}
$sess->statusset = $formdata->statusset;
fill_groupid($formdata, $sessions, $sess);
}
return $sessions;
}
function fill_groupid($formdata, &$sessions, $sess) {
if ($formdata->sessiontype == mod_attendance_structure::SESSION_COMMON) {
$sess = clone $sess;
$sess->groupid = 0;
$sessions[] = $sess;
} else {
foreach ($formdata->groups as $groupid) {
$sess = clone $sess;
$sess->groupid = $groupid;
$sessions[] = $sess;
}
}
}

19
student_attendance_form.php

@ -14,10 +14,29 @@
// 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/>.
/**
* Student form class.
*
* @package mod_attendance
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/formslib.php'); require_once($CFG->libdir.'/formslib.php');
/**
* Class mod_attendance_student_attendance_form
*
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_attendance_student_attendance_form extends moodleform { class mod_attendance_student_attendance_form extends moodleform {
/**
* Called to define this moodle form
*
* @return void
*/
public function definition() { public function definition() {
global $USER; global $USER;

21
tempmerge_form.php

@ -14,13 +14,32 @@
// 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/>.
/**
* Temp merge form class.
*
* @package mod_attendance
* @copyright 2013 Davo Smith, Synergy Learning
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
global $CFG; global $CFG;
require_once($CFG->libdir.'/formslib.php'); require_once($CFG->libdir.'/formslib.php');
/**
* Temp merge form class.
*
* @package mod_attendance
* @copyright 2013 Davo Smith, Synergy Learning
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tempmerge_form extends moodleform { class tempmerge_form extends moodleform {
/**
* Called to define this moodle form
*
* @return void
*/
public function definition() { public function definition() {
global $COURSE; global $COURSE;

9
tests/generator/lib.php

@ -25,7 +25,14 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
/**
* mod_attendance data generator
*
* @package mod_attendance
* @category test
* @copyright 2013 Davo Smith, Synergy Learning
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_attendance_generator extends testing_module_generator { class mod_attendance_generator extends testing_module_generator {
/** /**

Loading…
Cancel
Save