fix up some phpdoc stuff.
authorDan Marsden <dan@danmarsden.com>
Mon, 1 May 2017 02:56:21 +0000 (14:56 +1200)
committerDan Marsden <dan@danmarsden.com>
Mon, 1 May 2017 02:56:21 +0000 (14:56 +1200)
attendance.php
db/install.php
db/services.php
db/upgrade.php
db/upgradelib.php
locallib.php
sessions.php
student_attendance_form.php
tempmerge_form.php
tests/generator/lib.php

index 92f8e2e..091628a 100644 (file)
@@ -17,8 +17,8 @@
 /**
  * Prints attendance info for particular user
  *
- * @package    mod
- * @subpackage attendance
+ * @package   mod_attendance
+ * @copyright  2014 Dan Marsden
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
index 5a5ae48..4bcb19a 100644 (file)
@@ -13,7 +13,6 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-defined('MOODLE_INTERNAL') || die();
 
 /**
  * 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
  */
 
+defined('MOODLE_INTERNAL') || die();
+
 /**
  * Post installation procedure
  */
index ffbabdb..274f023 100644 (file)
@@ -17,7 +17,7 @@
 /**
  * Web service local plugin attendance external functions and service definitions.
  *
- * @package    localwsattendance
+ * @package    mod_attendance
  * @copyright  2015 Caio Bressan Doneda
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
index 71690f4..89388a8 100644 (file)
@@ -14,9 +14,6 @@
 // You should have received a copy of the GNU General Public License
 // 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.
  *
@@ -25,6 +22,9 @@ require_once(dirname(__FILE__) . '/upgradelib.php');
  * @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
  * @param int $oldversion The old version of the attendance module
index 1b12984..e2ba9ca 100644 (file)
@@ -14,8 +14,6 @@
 // You should have received a copy of the GNU General Public License
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
-defined('MOODLE_INTERNAL') || die();
-
 /**
  * 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
  */
 
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Function to help upgrade old attendance records and create calendar events.
+ */
 function attendance_upgrade_create_calendar_events() {
     global $DB;
 
index d3265bf..660687b 100644 (file)
@@ -480,4 +480,123 @@ function attendance_exporttocsv($data, $filename) {
     foreach ($data->table as $row) {
         echo implode("\t", $row)."\n";
     }
-}
\ No newline at end of file
+}
+
+/**
+ * @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;
+        }
+    }
+}
index 836dc50..61369b8 100644 (file)
@@ -73,7 +73,7 @@ switch ($att->pageparams->action) {
         }
 
         if ($formdata = $mform->get_data()) {
-            $sessions = construct_sessions_data_for_add($formdata);
+            $sessions = attendance_construct_sessions_data_for_add($formdata);
             $att->add_sessions($sessions);
             if (count($sessions) == 1) {
                 $message = get_string('sessiongenerated', 'attendance');
@@ -222,112 +222,4 @@ echo $output->render($tabs);
 
 $mform->display();
 
-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;
-        }
-    }
-}
+echo $OUTPUT->footer();
\ No newline at end of file
index 56b7986..888507f 100644 (file)
 // You should have received a copy of the GNU General Public License
 // 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();
 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 {
+    /**
+     * Called to define this moodle form
+     *
+     * @return void
+     */
     public function definition() {
         global $USER;
 
index c5e5510..d25c4f8 100644 (file)
 // You should have received a copy of the GNU General Public License
 // 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();
 
 global $CFG;
 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 {
-
+    /**
+     * Called to define this moodle form
+     *
+     * @return void
+     */
     public function definition() {
         global $COURSE;
 
index 4c1d7cb..7a3dfb8 100644 (file)
 
 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 {
 
     /**