Browse Source

Move forms into auto-loaded classes folder.

nwp90-nwp90-allsessionsreport
Dan Marsden 4 years ago
parent
commit
ea8acbabb1
  1. 6
      attendance.php
  2. 11
      classes/form/addsession.php
  3. 11
      classes/form/addwarning.php
  4. 9
      classes/form/duration.php
  5. 5
      classes/form/export.php
  6. 10
      classes/form/studentattendance.php
  7. 9
      classes/form/tempmerge.php
  8. 11
      classes/form/tempuser.php
  9. 8
      classes/form/tempuseredit.php
  10. 7
      classes/form/updatesession.php
  11. 4
      export.php
  12. 10
      sessions.php
  13. 6
      tempedit.php
  14. 6
      tempmerge.php
  15. 5
      tempusers.php
  16. 2
      warnings.php

6
attendance.php

@ -24,7 +24,7 @@
require_once(dirname(__FILE__).'/../../config.php'); require_once(dirname(__FILE__).'/../../config.php');
require_once(dirname(__FILE__).'/locallib.php'); require_once(dirname(__FILE__).'/locallib.php');
require_once(dirname(__FILE__).'/student_attendance_form.php'); require_once($CFG->libdir.'/formslib.php');
$pageparams = new mod_attendance_sessions_page_params(); $pageparams = new mod_attendance_sessions_page_params();
@ -156,11 +156,11 @@ $PAGE->set_url($att->url_sessions());
// Create the form. // Create the form.
if ($attforsession->rotateqrcode == 1) { if ($attforsession->rotateqrcode == 1) {
$mform = new mod_attendance_student_attendance_form(null, $mform = new mod_attendance\form\studentattendance(null,
array('course' => $course, 'cm' => $cm, 'modcontext' => $PAGE->context, 'session' => $attforsession, array('course' => $course, 'cm' => $cm, 'modcontext' => $PAGE->context, 'session' => $attforsession,
'attendance' => $att, 'password' => $attforsession->studentpassword)); 'attendance' => $att, 'password' => $attforsession->studentpassword));
} else { } else {
$mform = new mod_attendance_student_attendance_form(null, $mform = new mod_attendance\form\studentattendance(null,
array('course' => $course, 'cm' => $cm, 'modcontext' => $PAGE->context, 'session' => $attforsession, array('course' => $course, 'cm' => $cm, 'modcontext' => $PAGE->context, 'session' => $attforsession,
'attendance' => $att, 'password' => $qrpass)); 'attendance' => $att, 'password' => $qrpass));
} }

11
add_form.php → classes/form/addsession.php

@ -15,16 +15,21 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* This file contains the forms to add * This file contains the forms to add session.
* *
* @package mod_attendance * @package mod_attendance
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com> * @copyright 2011 Artem Andreev <andreev.artem@gmail.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
*/ */
namespace mod_attendance\form;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/formslib.php'); use moodleform;
use mod_attendance_structure;
use DateTime;
use DateInterval;
use DatePeriod;
/** /**
* class for displaying add form. * class for displaying add form.
@ -32,7 +37,7 @@ require_once($CFG->libdir.'/formslib.php');
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com> * @copyright 2011 Artem Andreev <andreev.artem@gmail.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_add_form extends moodleform { class addsession extends moodleform {
/** /**
* Called to define this moodle form * Called to define this moodle form

11
classes/add_warning_form.php → classes/form/addwarning.php

@ -15,23 +15,28 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* Contains class mod_attendance_add_warning_form * Contains class addwarning
* *
* @package mod_attendance * @package mod_attendance
* @copyright 2017 Dan Marsden * @copyright 2017 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
*/ */
namespace mod_attendance\form;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
use moodleform;
use context_course;
/** /**
* Class mod_attendance_add_warning_form * Class addwarning
* *
* @package mod_attendance * @package mod_attendance
* @copyright 2017 Dan Marsden * @copyright 2017 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
*/ */
class mod_attendance_add_warning_form extends moodleform { class addwarning extends moodleform {
/** /**
* Form definition * Form definition
*/ */

9
duration_form.php → classes/form/duration.php

@ -22,8 +22,11 @@
* @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
*/ */
namespace mod_attendance\form;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/formslib.php');
use moodleform;
/** /**
* class for displaying duration form. * class for displaying duration form.
@ -31,7 +34,7 @@ require_once($CFG->libdir.'/formslib.php');
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com> * @copyright 2011 Artem Andreev <andreev.artem@gmail.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_duration_form extends moodleform { class duration extends moodleform {
/** /**
* Called to define this moodle form * Called to define this moodle form
@ -62,7 +65,7 @@ class mod_attendance_duration_form extends moodleform {
$mform->setType('ids', PARAM_ALPHANUMEXT); $mform->setType('ids', PARAM_ALPHANUMEXT);
$mform->addElement('hidden', 'id', $cm->id); $mform->addElement('hidden', 'id', $cm->id);
$mform->setType('id', PARAM_INT); $mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'action', mod_attendance_sessions_page_params::ACTION_CHANGE_DURATION); $mform->addElement('hidden', 'action', \mod_attendance_sessions_page_params::ACTION_CHANGE_DURATION);
$mform->setType('action', PARAM_INT); $mform->setType('action', PARAM_INT);
$mform->setDefaults(array('durtime' => array('hours' => 0, 'minutes' => 0))); $mform->setDefaults(array('durtime' => array('hours' => 0, 'minutes' => 0)));

5
export_form.php → classes/form/export.php

@ -22,8 +22,9 @@
* @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
*/ */
namespace mod_attendance\form;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/formslib.php');
/** /**
* class for displaying export form. * class for displaying export form.
@ -31,7 +32,7 @@ require_once($CFG->libdir.'/formslib.php');
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com> * @copyright 2011 Artem Andreev <andreev.artem@gmail.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_export_form extends moodleform { class export extends \moodleform {
/** /**
* Called to define this moodle form * Called to define this moodle form

10
student_attendance_form.php → classes/form/studentattendance.php

@ -21,17 +21,17 @@
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com> * @copyright 2011 Artem Andreev <andreev.artem@gmail.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
*/ */
namespace mod_attendance\form;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/formslib.php');
/** /**
* Class mod_attendance_student_attendance_form * Class studentattendance
* *
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com> * @copyright 2011 Artem Andreev <andreev.artem@gmail.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_student_attendance_form extends moodleform { class studentattendance extends \moodleform {
/** /**
* Called to define this moodle form * Called to define this moodle form
* *
@ -89,11 +89,11 @@ class mod_attendance_student_attendance_form extends moodleform {
// Create radio buttons for setting the attendance status. // Create radio buttons for setting the attendance status.
$radioarray = array(); $radioarray = array();
foreach ($statuses as $status) { foreach ($statuses as $status) {
$name = html_writer::span($status->description, 'statusdesc'); $name = \html_writer::span($status->description, 'statusdesc');
$radioarray[] =& $mform->createElement('radio', 'status', '', $name, $status->id, array()); $radioarray[] =& $mform->createElement('radio', 'status', '', $name, $status->id, array());
} }
if ($disabledduetotime) { if ($disabledduetotime) {
$warning = html_writer::span(get_string('somedisabledstatus', 'attendance'), 'somedisabledstatus'); $warning = \html_writer::span(get_string('somedisabledstatus', 'attendance'), 'somedisabledstatus');
$radioarray[] =& $mform->createElement('static', '', '', $warning); $radioarray[] =& $mform->createElement('static', '', '', $warning);
} }
// Add the radio buttons as a control with the user's name in front. // Add the radio buttons as a control with the user's name in front.

9
tempmerge_form.php → classes/form/tempmerge.php

@ -22,10 +22,9 @@
* @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(); namespace mod_attendance\form;
global $CFG; defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/formslib.php');
/** /**
* Temp merge form class. * Temp merge form class.
@ -34,7 +33,7 @@ require_once($CFG->libdir.'/formslib.php');
* @copyright 2013 Davo Smith, Synergy Learning * @copyright 2013 Davo Smith, Synergy Learning
* @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 tempmerge_form extends moodleform { class tempmerge extends \moodleform {
/** /**
* Called to define this moodle form * Called to define this moodle form
* *
@ -43,7 +42,7 @@ class tempmerge_form extends moodleform {
public function definition() { public function definition() {
global $COURSE; global $COURSE;
$context = context_course::instance($COURSE->id); $context = \context_course::instance($COURSE->id);
$namefields = get_all_user_name_fields(true, 'u'); $namefields = get_all_user_name_fields(true, 'u');
$students = get_enrolled_users($context, 'mod/attendance:canbelisted', 0, 'u.id,'.$namefields.',u.email', $students = get_enrolled_users($context, 'mod/attendance:canbelisted', 0, 'u.id,'.$namefields.',u.email',
'u.lastname, u.firstname', 0, 0, true); 'u.lastname, u.firstname', 0, 0, true);

11
temp_form.php → classes/form/tempuser.php

@ -22,17 +22,16 @@
* @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(); namespace mod_attendance\form;
global $CFG; defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/formslib.php');
/** /**
* Class temp_form * Class tempuser
* @copyright 2013 Davo Smith, Synergy Learning * @copyright 2013 Davo Smith, Synergy Learning
* @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 temp_form extends moodleform { class tempuser extends \moodleform {
/** /**
* Define form. * Define form.
*/ */
@ -74,7 +73,7 @@ class temp_form extends moodleform {
public function validation($data, $files) { public function validation($data, $files) {
$errors = parent::validation($data, $files); $errors = parent::validation($data, $files);
if ($err = mod_attendance_structure::check_existing_email($data['temail'])) { if ($err = \mod_attendance_structure::check_existing_email($data['temail'])) {
$errors['temail'] = $err; $errors['temail'] = $err;
} }

8
tempedit_form.php → classes/form/tempuseredit.php

@ -21,19 +21,17 @@
* @copyright 2013 Davo Smith, Synergy Learning * @copyright 2013 Davo Smith, Synergy Learning
* @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
*/ */
namespace mod_attendance\form;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->libdir.'/formslib.php');
/** /**
* class for displaying tempedit form. * class for displaying tempedit form.
* *
* @copyright 2013 Davo Smith, Synergy Learning * @copyright 2013 Davo Smith, Synergy Learning
* @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 tempedit_form extends moodleform { class tempuseredit extends \moodleform {
/** /**
* Called to define this moodle form * Called to define this moodle form
@ -83,7 +81,7 @@ class tempedit_form extends moodleform {
public function validation($data, $files) { public function validation($data, $files) {
$errors = parent::validation($data, $files); $errors = parent::validation($data, $files);
if ($err = mod_attendance_structure::check_existing_email($data['temail'], $data['userid'])) { if ($err = \mod_attendance_structure::check_existing_email($data['temail'], $data['userid'])) {
$errors['temail'] = $err; $errors['temail'] = $err;
} }
return $errors; return $errors;

7
update_form.php → classes/form/updatesession.php

@ -22,16 +22,17 @@
* @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
*/ */
namespace mod_attendance\form;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/formslib.php');
/** /**
* class for displaying update form. * class for displaying update session form.
* *
* @copyright 2011 Artem Andreev <andreev.artem@gmail.com> * @copyright 2011 Artem Andreev <andreev.artem@gmail.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_update_form extends moodleform { class updatesession extends \moodleform {
/** /**
* Called to define this moodle form * Called to define this moodle form

4
export.php

@ -26,9 +26,9 @@ define('NO_OUTPUT_BUFFERING', true);
require_once(dirname(__FILE__).'/../../config.php'); require_once(dirname(__FILE__).'/../../config.php');
require_once(dirname(__FILE__).'/locallib.php'); require_once(dirname(__FILE__).'/locallib.php');
require_once(dirname(__FILE__).'/export_form.php');
require_once(dirname(__FILE__).'/renderables.php'); require_once(dirname(__FILE__).'/renderables.php');
require_once(dirname(__FILE__).'/renderhelpers.php'); require_once(dirname(__FILE__).'/renderhelpers.php');
require_once($CFG->libdir.'/formslib.php');
$id = required_param('id', PARAM_INT); $id = required_param('id', PARAM_INT);
@ -51,7 +51,7 @@ $PAGE->set_cacheable(true);
$PAGE->navbar->add(get_string('export', 'attendance')); $PAGE->navbar->add(get_string('export', 'attendance'));
$formparams = array('course' => $course, 'cm' => $cm, 'modcontext' => $context); $formparams = array('course' => $course, 'cm' => $cm, 'modcontext' => $context);
$mform = new mod_attendance_export_form($att->url_export(), $formparams); $mform = new mod_attendance\form\export($att->url_export(), $formparams);
if ($formdata = $mform->get_data()) { if ($formdata = $mform->get_data()) {

10
sessions.php

@ -24,9 +24,7 @@
require_once(dirname(__FILE__).'/../../config.php'); require_once(dirname(__FILE__).'/../../config.php');
require_once(dirname(__FILE__).'/locallib.php'); require_once(dirname(__FILE__).'/locallib.php');
require_once(dirname(__FILE__).'/add_form.php'); require_once($CFG->dirroot.'/lib/formslib.php');
require_once(dirname(__FILE__).'/update_form.php');
require_once(dirname(__FILE__).'/duration_form.php');
$pageparams = new mod_attendance_sessions_page_params(); $pageparams = new mod_attendance_sessions_page_params();
@ -67,7 +65,7 @@ $formparams = array('course' => $course, 'cm' => $cm, 'modcontext' => $context,
switch ($att->pageparams->action) { switch ($att->pageparams->action) {
case mod_attendance_sessions_page_params::ACTION_ADD: case mod_attendance_sessions_page_params::ACTION_ADD:
$url = $att->url_sessions(array('action' => mod_attendance_sessions_page_params::ACTION_ADD)); $url = $att->url_sessions(array('action' => mod_attendance_sessions_page_params::ACTION_ADD));
$mform = new mod_attendance_add_form($url, $formparams); $mform = new \mod_attendance\form\addsession($url, $formparams);
if ($mform->is_cancelled()) { if ($mform->is_cancelled()) {
redirect($att->url_manage()); redirect($att->url_manage());
@ -93,7 +91,7 @@ switch ($att->pageparams->action) {
$url = $att->url_sessions(array('action' => mod_attendance_sessions_page_params::ACTION_UPDATE, 'sessionid' => $sessionid)); $url = $att->url_sessions(array('action' => mod_attendance_sessions_page_params::ACTION_UPDATE, 'sessionid' => $sessionid));
$formparams['sessionid'] = $sessionid; $formparams['sessionid'] = $sessionid;
$mform = new mod_attendance_update_form($url, $formparams); $mform = new \mod_attendance\form\updatesession($url, $formparams);
if ($mform->is_cancelled()) { if ($mform->is_cancelled()) {
redirect($att->url_manage()); redirect($att->url_manage());
@ -179,7 +177,7 @@ switch ($att->pageparams->action) {
$url = $att->url_sessions(array('action' => mod_attendance_sessions_page_params::ACTION_CHANGE_DURATION)); $url = $att->url_sessions(array('action' => mod_attendance_sessions_page_params::ACTION_CHANGE_DURATION));
$formparams['ids'] = $slist; $formparams['ids'] = $slist;
$mform = new mod_attendance_duration_form($url, $formparams); $mform = new mod_attendance\form\duration($url, $formparams);
if ($mform->is_cancelled()) { if ($mform->is_cancelled()) {
redirect($att->url_manage()); redirect($att->url_manage());

6
tempedit.php

@ -23,10 +23,8 @@
*/ */
require_once(dirname(__FILE__).'/../../config.php'); require_once(dirname(__FILE__).'/../../config.php');
require_once($CFG->libdir.'/formslib.php');
global $CFG, $DB, $PAGE, $OUTPUT;
require_once($CFG->dirroot.'/mod/attendance/locallib.php'); require_once($CFG->dirroot.'/mod/attendance/locallib.php');
require_once($CFG->dirroot.'/mod/attendance/tempedit_form.php');
$id = required_param('id', PARAM_INT); $id = required_param('id', PARAM_INT);
$userid = required_param('userid', PARAM_INT); $userid = required_param('userid', PARAM_INT);
@ -90,7 +88,7 @@ $formdata->tname = $tempuser->fullname;
$formdata->userid = $tempuser->id; $formdata->userid = $tempuser->id;
$formdata->temail = $tempuser->email; $formdata->temail = $tempuser->email;
$mform = new tempedit_form(); $mform = new \mod_attendance\form\tempuseredit();
$mform->set_data($formdata); $mform->set_data($formdata);
if ($mform->is_cancelled()) { if ($mform->is_cancelled()) {

6
tempmerge.php

@ -23,10 +23,8 @@
*/ */
require_once(dirname(__FILE__).'/../../config.php'); require_once(dirname(__FILE__).'/../../config.php');
require_once($CFG->libdir.'/formslib.php');
global $CFG, $DB, $PAGE, $OUTPUT;
require_once($CFG->dirroot.'/mod/attendance/locallib.php'); require_once($CFG->dirroot.'/mod/attendance/locallib.php');
require_once($CFG->dirroot.'/mod/attendance/tempmerge_form.php');
$id = required_param('id', PARAM_INT); $id = required_param('id', PARAM_INT);
$userid = required_param('userid', PARAM_INT); $userid = required_param('userid', PARAM_INT);
@ -55,7 +53,7 @@ $formdata = (object)array(
$custom = array( $custom = array(
'description' => format_string($tempuser->fullname).' ('.format_string($tempuser->email).')', 'description' => format_string($tempuser->fullname).' ('.format_string($tempuser->email).')',
); );
$mform = new tempmerge_form(null, $custom); $mform = new mod_attendance\form\tempmerge(null, $custom);
$mform->set_data($formdata); $mform->set_data($formdata);
if ($mform->is_cancelled()) { if ($mform->is_cancelled()) {

5
tempusers.php

@ -23,9 +23,8 @@
*/ */
require_once(dirname(__FILE__).'/../../config.php'); require_once(dirname(__FILE__).'/../../config.php');
global $CFG, $DB, $OUTPUT, $PAGE, $COURSE; require_once($CFG->libdir.'/formslib.php');
require_once($CFG->dirroot.'/mod/attendance/locallib.php'); require_once($CFG->dirroot.'/mod/attendance/locallib.php');
require_once($CFG->dirroot.'/mod/attendance/temp_form.php');
$id = required_param('id', PARAM_INT); $id = required_param('id', PARAM_INT);
@ -52,7 +51,7 @@ $tabs = new attendance_tabs($att, attendance_tabs::TAB_TEMPORARYUSERS);
$formdata = (object)array( $formdata = (object)array(
'id' => $cm->id, 'id' => $cm->id,
); );
$mform = new temp_form(); $mform = new mod_attendance\form\tempuser();
$mform->set_data($formdata); $mform->set_data($formdata);
if ($data = $mform->get_data()) { if ($data = $mform->get_data()) {

2
warnings.php

@ -70,7 +70,7 @@ if (empty($id)) {
} }
$mform = new mod_attendance_add_warning_form($url, array('notid' => $notid, 'id' => $id)); $mform = new mod_attendance\form\addwarning($url, array('notid' => $notid, 'id' => $id));
if ($data = $mform->get_data()) { if ($data = $mform->get_data()) {
if (empty($data->notid)) { if (empty($data->notid)) {

Loading…
Cancel
Save