From 8a1d4654e9a407c1316518bcc21147178ef7eae0 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Thu, 4 Jul 2013 09:38:47 +1200 Subject: [PATCH] rename attforblock module to attendance - also includes upgrade script to rename old attforblock tables. --- README.md | 2 +- add_form.php | 58 ++-- ...backup_attforblock_activity_task.class.php | 22 +- .../backup_attforblock_settingslib.php | 2 +- .../moodle2/backup_attforblock_stepslib.php | 20 +- ...estore_attforblock_activity_task.class.php | 18 +- .../moodle2/restore_attforblock_stepslib.php | 50 +-- calendar.js | 10 +- db/access.php | 18 +- db/install.php | 8 +- db/install.xml | 8 +- db/upgrade.php | 300 +----------------- duration_form.php | 10 +- export.php | 26 +- export_form.php | 20 +- index.php | 4 +- lang/en/{attforblock.php => attendance.php} | 21 +- lib.php | 192 +++++------ locallib.php | 138 ++++---- manage.php | 24 +- mod_form.php | 8 +- module.js | 6 +- preferences.php | 32 +- renderables.php | 58 ++-- renderer.php | 190 +++++------ renderhelpers.php | 36 +-- report.php | 24 +- sessions.php | 50 +-- styles.css | 62 ++-- take.php | 20 +- update_form.php | 20 +- version.php | 12 +- view.php | 14 +- 33 files changed, 612 insertions(+), 871 deletions(-) rename lang/en/{attforblock.php => attendance.php} (90%) diff --git a/README.md b/README.md index d338e60..e249f7d 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,6 @@ INSTALLATION ========== The attendance module follows standard installation procedure. -1. Create folder /mod/attforblock. +1. Create folder /mod/attendance. 2. Extract files from folder inside archive to created folder. 3. Visit page Home ► Site administration ► Notifications to complete installation. \ No newline at end of file diff --git a/add_form.php b/add_form.php index cf8ddb4..197af86 100644 --- a/add_form.php +++ b/add_form.php @@ -24,7 +24,7 @@ require_once($CFG->libdir.'/formslib.php'); -class mod_attforblock_add_form extends moodleform { +class mod_attendance_add_form extends moodleform { public function definition() { @@ -35,31 +35,31 @@ class mod_attforblock_add_form extends moodleform { $cm = $this->_customdata['cm']; $modcontext = $this->_customdata['modcontext']; - $mform->addElement('header', 'general', get_string('addsession', 'attforblock')); + $mform->addElement('header', 'general', get_string('addsession', 'attendance')); $groupmode = groups_get_activity_groupmode($cm); switch ($groupmode) { case NOGROUPS: - $mform->addElement('static', 'sessiontypedescription', get_string('sessiontype', 'attforblock'), - get_string('commonsession', 'attforblock')); - $mform->addHelpButton('sessiontypedescription', 'sessiontype', 'attforblock'); - $mform->addElement('hidden', 'sessiontype', attforblock::SESSION_COMMON); + $mform->addElement('static', 'sessiontypedescription', get_string('sessiontype', 'attendance'), + get_string('commonsession', 'attendance')); + $mform->addHelpButton('sessiontypedescription', 'sessiontype', 'attendance'); + $mform->addElement('hidden', 'sessiontype', attendance::SESSION_COMMON); break; case SEPARATEGROUPS: - $mform->addElement('static', 'sessiontypedescription', get_string('sessiontype', 'attforblock'), - get_string('groupsession', 'attforblock')); - $mform->addHelpButton('sessiontypedescription', 'sessiontype', 'attforblock'); - $mform->addElement('hidden', 'sessiontype', attforblock::SESSION_GROUP); + $mform->addElement('static', 'sessiontypedescription', get_string('sessiontype', 'attendance'), + get_string('groupsession', 'attendance')); + $mform->addHelpButton('sessiontypedescription', 'sessiontype', 'attendance'); + $mform->addElement('hidden', 'sessiontype', attendance::SESSION_GROUP); break; case VISIBLEGROUPS: $radio=array(); $radio[] = &$mform->createElement('radio', 'sessiontype', '', - get_string('commonsession', 'attforblock'), attforblock::SESSION_COMMON); + get_string('commonsession', 'attendance'), attendance::SESSION_COMMON); $radio[] = &$mform->createElement('radio', 'sessiontype', '', - get_string('groupsession', 'attforblock'), attforblock::SESSION_GROUP); - $mform->addGroup($radio, 'sessiontype', get_string('sessiontype', 'attforblock'), ' ', false); - $mform->addHelpButton('sessiontype', 'sessiontype', 'attforblock'); - $mform->setDefault('sessiontype', attforblock::SESSION_COMMON); + get_string('groupsession', 'attendance'), attendance::SESSION_GROUP); + $mform->addGroup($radio, 'sessiontype', get_string('sessiontype', 'attendance'), ' ', false); + $mform->addHelpButton('sessiontype', 'sessiontype', 'attendance'); + $mform->setDefault('sessiontype', attendance::SESSION_COMMON); break; } if ($groupmode == SEPARATEGROUPS or $groupmode == VISIBLEGROUPS) { @@ -75,21 +75,21 @@ class mod_attforblock_add_form extends moodleform { } $select = &$mform->addElement('select', 'groups', get_string('groups', 'group'), $selectgroups); $select->setMultiple(true); - $mform->disabledIf('groups', 'sessiontype', 'neq', attforblock::SESSION_GROUP); + $mform->disabledIf('groups', 'sessiontype', 'neq', attendance::SESSION_GROUP); } else { $mform->updateElementAttr($radio, array('disabled'=>'disabled')); $mform->addElement('static', 'groups', get_string('groups', 'group'), - get_string('nogroups', 'attforblock')); + get_string('nogroups', 'attendance')); if ($groupmode == SEPARATEGROUPS) { return; } } } - $mform->addElement('checkbox', 'addmultiply', '', get_string('createmultiplesessions', 'attforblock')); - $mform->addHelpButton('addmultiply', 'createmultiplesessions', 'attforblock'); + $mform->addElement('checkbox', 'addmultiply', '', get_string('createmultiplesessions', 'attendance')); + $mform->addHelpButton('addmultiply', 'createmultiplesessions', 'attendance'); - $mform->addElement('date_time_selector', 'sessiondate', get_string('sessiondate', 'attforblock')); + $mform->addElement('date_time_selector', 'sessiondate', get_string('sessiondate', 'attendance')); for ($i=0; $i<=23; $i++) { $hours[$i] = sprintf("%02d", $i); @@ -100,9 +100,9 @@ class mod_attforblock_add_form extends moodleform { $durtime = array(); $durtime[] =& $mform->createElement('select', 'hours', get_string('hour', 'form'), $hours, false, true); $durtime[] =& $mform->createElement('select', 'minutes', get_string('minute', 'form'), $minutes, false, true); - $mform->addGroup($durtime, 'durtime', get_string('duration', 'attforblock'), array(' '), true); + $mform->addGroup($durtime, 'durtime', get_string('duration', 'attendance'), array(' '), true); - $mform->addElement('date_selector', 'sessionenddate', get_string('sessionenddate', 'attforblock')); + $mform->addElement('date_selector', 'sessionenddate', get_string('sessionenddate', 'attendance')); $mform->disabledIf('sessionenddate', 'addmultiply', 'notchecked'); $sdays = array(); @@ -118,29 +118,29 @@ class mod_attforblock_add_form extends moodleform { if ($CFG->calendar_startwday !== '0') { // Week start from sunday. $sdays[] =& $mform->createElement('checkbox', 'Sun', '', get_string('sunday', 'calendar')); } - $mform->addGroup($sdays, 'sdays', get_string('sessiondays', 'attforblock'), array(' '), true); + $mform->addGroup($sdays, 'sdays', get_string('sessiondays', 'attendance'), array(' '), true); $mform->disabledIf('sdays', 'addmultiply', 'notchecked'); $period = array(1=>1, 2, 3, 4, 5, 6, 7, 8); $periodgroup = array(); $periodgroup[] =& $mform->createElement('select', 'period', '', $period, false, true); - $periodgroup[] =& $mform->createElement('static', 'perioddesc', '', get_string('week', 'attforblock')); - $mform->addGroup($periodgroup, 'periodgroup', get_string('period', 'attforblock'), array(' '), false); + $periodgroup[] =& $mform->createElement('static', 'perioddesc', '', get_string('week', 'attendance')); + $mform->addGroup($periodgroup, 'periodgroup', get_string('period', 'attendance'), array(' '), false); $mform->disabledIf('periodgroup', 'addmultiply', 'notchecked'); - $mform->addElement('editor', 'sdescription', get_string('description', 'attforblock'), + $mform->addElement('editor', 'sdescription', get_string('description', 'attendance'), null, array('maxfiles'=>EDITOR_UNLIMITED_FILES, 'noclean'=>true, 'context'=>$modcontext)); $mform->setType('sdescription', PARAM_RAW); - $submit_string = get_string('addsession', 'attforblock'); + $submit_string = get_string('addsession', 'attendance'); $this->add_action_buttons(false, $submit_string); } public function validation($data, $files) { $errors = parent::validation($data, $files); - if ($data['sessiontype'] == attforblock::SESSION_GROUP and empty($data['groups'])) { - $errors['groups'] = get_string('errorgroupsnotselected', 'attforblock'); + if ($data['sessiontype'] == attendance::SESSION_GROUP and empty($data['groups'])) { + $errors['groups'] = get_string('errorgroupsnotselected', 'attendance'); } return $errors; } diff --git a/backup/moodle2/backup_attforblock_activity_task.class.php b/backup/moodle2/backup_attforblock_activity_task.class.php index 55237d0..b7c2094 100644 --- a/backup/moodle2/backup_attforblock_activity_task.class.php +++ b/backup/moodle2/backup_attforblock_activity_task.class.php @@ -15,23 +15,23 @@ // along with Moodle. If not, see . /** - * Class {@link backup_attforblock_activity_task} definition + * Class {@link backup_attendance_activity_task} definition * * @package mod - * @subpackage attforblock + * @subpackage attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); -require_once($CFG->dirroot . '/mod/attforblock/backup/moodle2/backup_attforblock_settingslib.php'); -require_once($CFG->dirroot . '/mod/attforblock/backup/moodle2/backup_attforblock_stepslib.php'); +require_once($CFG->dirroot . '/mod/attendance/backup/moodle2/backup_attendance_settingslib.php'); +require_once($CFG->dirroot . '/mod/attendance/backup/moodle2/backup_attendance_stepslib.php'); /** - * Provides all the settings and steps to perform one complete backup of attforblock activity + * Provides all the settings and steps to perform one complete backup of attendance activity */ -class backup_attforblock_activity_task extends backup_activity_task { +class backup_attendance_activity_task extends backup_activity_task { /** * Define (add) particular settings this activity can have @@ -43,7 +43,7 @@ class backup_attforblock_activity_task extends backup_activity_task { * Define (add) particular steps this activity can have */ protected function define_my_steps() { - $this->add_step(new backup_attforblock_activity_structure_step('attforblock_structure', 'attforblock.xml')); + $this->add_step(new backup_attendance_activity_structure_step('attendance_structure', 'attendance.xml')); } /** @@ -55,12 +55,12 @@ class backup_attforblock_activity_task extends backup_activity_task { $base = preg_quote($CFG->wwwroot, "/"); - // Link to attforblock view by moduleid. - $search = "/(" . $base . "\/mod\/attforblock\/view.php\?id\=)([0-9]+)/"; + // Link to attendance view by moduleid. + $search = "/(" . $base . "\/mod\/attendance\/view.php\?id\=)([0-9]+)/"; $content= preg_replace($search, '$@ATTFORBLOCKVIEWBYID*$2@$', $content); - // Link to attforblock view by moduleid and studentid. - $search = "/(" . $base . "\/mod\/attforblock\/view.php\?id\=)([0-9]+)\&studentid\=([0-9]+)/"; + // Link to attendance view by moduleid and studentid. + $search = "/(" . $base . "\/mod\/attendance\/view.php\?id\=)([0-9]+)\&studentid\=([0-9]+)/"; $content= preg_replace($search, '$@ATTFORBLOCKVIEWBYIDSTUD*$2*$3@$', $content); return $content; diff --git a/backup/moodle2/backup_attforblock_settingslib.php b/backup/moodle2/backup_attforblock_settingslib.php index fbfb7c2..26cb3ba 100644 --- a/backup/moodle2/backup_attforblock_settingslib.php +++ b/backup/moodle2/backup_attforblock_settingslib.php @@ -16,7 +16,7 @@ /** * @package mod - * @subpackage attforblock + * @subpackage attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/backup/moodle2/backup_attforblock_stepslib.php b/backup/moodle2/backup_attforblock_stepslib.php index 1e34b48..c09ac38 100644 --- a/backup/moodle2/backup_attforblock_stepslib.php +++ b/backup/moodle2/backup_attforblock_stepslib.php @@ -15,10 +15,10 @@ // along with Moodle. If not, see . /** - * Defines all the backup steps that will be used by {@link backup_attforblock_activity_task} + * Defines all the backup steps that will be used by {@link backup_attendance_activity_task} * * @package mod - * @subpackage attforblock + * @subpackage attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -26,9 +26,9 @@ defined('MOODLE_INTERNAL') || die(); /** - * Defines the complete attforblock structure for backup, with file and id annotations + * Defines the complete attendance structure for backup, with file and id annotations */ -class backup_attforblock_activity_structure_step extends backup_activity_structure_step { +class backup_attendance_activity_structure_step extends backup_activity_structure_step { protected function define_structure() { @@ -36,7 +36,7 @@ class backup_attforblock_activity_structure_step extends backup_activity_structu $userinfo = $this->get_setting_value('userinfo'); // XML nodes declaration - non-user data. - $attforblock = new backup_nested_element('attforblock', array('id'), array( + $attendance = new backup_nested_element('attendance', array('id'), array( 'name', 'grade')); $statuses = new backup_nested_element('statuses'); @@ -55,10 +55,10 @@ class backup_attforblock_activity_structure_step extends backup_activity_structu 'timetaken', 'takenby', 'remarks')); // Build the tree in the order needed for restore. - $attforblock->add_child($statuses); + $attendance->add_child($statuses); $statuses->add_child($status); - $attforblock->add_child($sessions); + $attendance->add_child($sessions); $sessions->add_child($session); $session->add_child($logs); @@ -66,7 +66,7 @@ class backup_attforblock_activity_structure_step extends backup_activity_structu // Data sources - non-user data. - $attforblock->set_source_table('attforblock', array('id' => backup::VAR_ACTIVITYID)); + $attendance->set_source_table('attendance', array('id' => backup::VAR_ACTIVITYID)); $status->set_source_table('attendance_statuses', array('attendanceid' => backup::VAR_PARENTID)); @@ -84,9 +84,9 @@ class backup_attforblock_activity_structure_step extends backup_activity_structu $log->annotate_ids('user', 'takenby'); // File annotations. - $session->annotate_files('mod_attforblock', 'session', 'id'); + $session->annotate_files('mod_attendance', 'session', 'id'); // Return the root element (workshop), wrapped into standard activity structure. - return $this->prepare_activity_structure($attforblock); + return $this->prepare_activity_structure($attendance); } } diff --git a/backup/moodle2/restore_attforblock_activity_task.class.php b/backup/moodle2/restore_attforblock_activity_task.class.php index 800d730..972e10f 100644 --- a/backup/moodle2/restore_attforblock_activity_task.class.php +++ b/backup/moodle2/restore_attforblock_activity_task.class.php @@ -16,20 +16,20 @@ /** * @package mod - * @subpackage attforblock + * @subpackage attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); -require_once($CFG->dirroot . '/mod/attforblock/backup/moodle2/restore_attforblock_stepslib.php'); +require_once($CFG->dirroot . '/mod/attendance/backup/moodle2/restore_attendance_stepslib.php'); /** - * attforblock restore task that provides all the settings and steps to perform one + * attendance restore task that provides all the settings and steps to perform one * complete restore of the activity */ -class restore_attforblock_activity_task extends restore_activity_task { +class restore_attendance_activity_task extends restore_activity_task { /** * Define (add) particular settings this activity can have @@ -41,7 +41,7 @@ class restore_attforblock_activity_task extends restore_activity_task { * Define (add) particular steps this activity can have */ protected function define_my_steps() { - $this->add_step(new restore_attforblock_activity_structure_step('attforblock_structure', 'attforblock.xml')); + $this->add_step(new restore_attendance_activity_structure_step('attendance_structure', 'attendance.xml')); } /** @@ -52,7 +52,7 @@ class restore_attforblock_activity_task extends restore_activity_task { $contents = array(); $contents[] = new restore_decode_content('attendance_sessions', - array('description'), 'attforblock_session'); + array('description'), 'attendance_session'); return $contents; } @@ -65,9 +65,9 @@ class restore_attforblock_activity_task extends restore_activity_task { $rules = array(); $rules[] = new restore_decode_rule('ATTFORBLOCKVIEWBYID', - '/mod/attforblock/view.php?id=$1', 'course_module'); + '/mod/attendance/view.php?id=$1', 'course_module'); $rules[] = new restore_decode_rule('ATTFORBLOCKVIEWBYIDSTUD', - '/mod/attforblock/view.php?id=$1&studentid=$2', array('course_module', 'user')); + '/mod/attendance/view.php?id=$1&studentid=$2', array('course_module', 'user')); return $rules; @@ -76,7 +76,7 @@ class restore_attforblock_activity_task extends restore_activity_task { /** * Define the restore log rules that will be applied * by the {@link restore_logs_processor} when restoring - * attforblock logs. It must return one array + * attendance logs. It must return one array * of {@link restore_log_rule} objects */ static public function define_restore_log_rules() { diff --git a/backup/moodle2/restore_attforblock_stepslib.php b/backup/moodle2/restore_attforblock_stepslib.php index 252987f..2a9c461 100644 --- a/backup/moodle2/restore_attforblock_stepslib.php +++ b/backup/moodle2/restore_attforblock_stepslib.php @@ -16,7 +16,7 @@ /** * @package mod - * @subpackage attforblock + * @subpackage attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -24,13 +24,13 @@ defined('MOODLE_INTERNAL') || die(); /** - * Define all the restore steps that will be used by the restore_attforblock_activity_task + * Define all the restore steps that will be used by the restore_attendance_activity_task */ /** - * Structure step to restore one attforblock activity + * Structure step to restore one attendance activity */ -class restore_attforblock_activity_structure_step extends restore_activity_structure_step { +class restore_attendance_activity_structure_step extends restore_activity_structure_step { protected function define_structure() { @@ -39,13 +39,13 @@ class restore_attforblock_activity_structure_step extends restore_activity_struc $userinfo = $this->get_setting_value('userinfo'); // Are we including userinfo? // XML interesting paths - non-user data. - $paths[] = new restore_path_element('attforblock', '/activity/attforblock'); + $paths[] = new restore_path_element('attendance', '/activity/attendance'); - $paths[] = new restore_path_element('attforblock_status', - '/activity/attforblock/statuses/status'); + $paths[] = new restore_path_element('attendance_status', + '/activity/attendance/statuses/status'); - $paths[] = new restore_path_element('attforblock_session', - '/activity/attforblock/sessions/session'); + $paths[] = new restore_path_element('attendance_session', + '/activity/attendance/sessions/session'); // End here if no-user data has been selected. if (!$userinfo) { @@ -53,45 +53,45 @@ class restore_attforblock_activity_structure_step extends restore_activity_struc } // XML interesting paths - user data. - $paths[] = new restore_path_element('attforblock_log', - '/activity/attforblock/sessions/session/logs/log'); + $paths[] = new restore_path_element('attendance_log', + '/activity/attendance/sessions/session/logs/log'); // Return the paths wrapped into standard activity structure. return $this->prepare_activity_structure($paths); } - protected function process_attforblock($data) { + protected function process_attendance($data) { global $DB; $data = (object)$data; $oldid = $data->id; $data->course = $this->get_courseid(); - // Insert the attforblock record. - $newitemid = $DB->insert_record('attforblock', $data); + // Insert the attendance record. + $newitemid = $DB->insert_record('attendance', $data); // Immediately after inserting "activity" record, call this. $this->apply_activity_instance($newitemid); } - protected function process_attforblock_status($data) { + protected function process_attendance_status($data) { global $DB; $data = (object)$data; $oldid = $data->id; - $data->attendanceid = $this->get_new_parentid('attforblock'); + $data->attendanceid = $this->get_new_parentid('attendance'); $newitemid = $DB->insert_record('attendance_statuses', $data); - $this->set_mapping('attforblock_status', $oldid, $newitemid); + $this->set_mapping('attendance_status', $oldid, $newitemid); } - protected function process_attforblock_session($data) { + protected function process_attendance_session($data) { global $DB; $data = (object)$data; $oldid = $data->id; - $data->attendanceid = $this->get_new_parentid('attforblock'); + $data->attendanceid = $this->get_new_parentid('attendance'); $data->groupid = $this->get_mappingid('group', $data->groupid); $data->sessdate = $this->apply_date_offset($data->sessdate); $data->lasttaken = $this->apply_date_offset($data->lasttaken); @@ -99,21 +99,21 @@ class restore_attforblock_activity_structure_step extends restore_activity_struc $data->timemodified = $this->apply_date_offset($data->timemodified); $newitemid = $DB->insert_record('attendance_sessions', $data); - $this->set_mapping('attforblock_session', $oldid, $newitemid, true); + $this->set_mapping('attendance_session', $oldid, $newitemid, true); } - protected function process_attforblock_log($data) { + protected function process_attendance_log($data) { global $DB; $data = (object)$data; $oldid = $data->id; - $data->sessionid = $this->get_mappingid('attforblock_session', $data->sessionid); + $data->sessionid = $this->get_mappingid('attendance_session', $data->sessionid); $data->studentid = $this->get_mappingid('user', $data->studentid); - $data->statusid = $this->get_mappingid('attforblock_status', $data->statusid); + $data->statusid = $this->get_mappingid('attendance_status', $data->statusid); $statusset = explode(',', $data->statusset); foreach ($statusset as $st) { - $st = $this->get_mappingid('attforblock_status', $st); + $st = $this->get_mappingid('attendance_status', $st); } $data->statusset = implode(',', $statusset); $data->timetaken = $this->apply_date_offset($data->timetaken); @@ -123,6 +123,6 @@ class restore_attforblock_activity_structure_step extends restore_activity_struc } protected function after_execute() { - $this->add_related_files('mod_attforblock', 'session', 'attforblock_session'); + $this->add_related_files('mod_attendance', 'session', 'attendance_session'); } } diff --git a/calendar.js b/calendar.js index 828d195..b57ebc1 100644 --- a/calendar.js +++ b/calendar.js @@ -37,7 +37,7 @@ YUI().use('yui2-container', 'yui2-calendar', function(Y) { dialog = new YAHOO.widget.Dialog("attcalendarcontainer", { visible:false, context:["show", "tl", "bl"], - buttons:[{text: M.str.attforblock.caltoday, handler: resetHandler, isDefault:true}, {text: M.str.attforblock.calclose, handler: closeHandler}], + buttons:[{text: M.str.attendance.caltoday, handler: resetHandler, isDefault:true}, {text: M.str.attendance.calclose, handler: closeHandler}], draggable:false, close:false }); @@ -63,10 +63,10 @@ YUI().use('yui2-container', 'yui2-calendar', function(Y) { hide_blank_weeks:true // Enable, to demonstrate how we handle changing height, using changeContent }); - calendar.cfg.setProperty("start_weekday", M.attforblock.cal_start_weekday); - calendar.cfg.setProperty("MONTHS_LONG", M.attforblock.cal_months); - calendar.cfg.setProperty("WEEKDAYS_SHORT", M.attforblock.cal_week_days); - calendar.select(new Date(M.attforblock.cal_cur_date*1000)); + calendar.cfg.setProperty("start_weekday", M.attendance.cal_start_weekday); + calendar.cfg.setProperty("MONTHS_LONG", M.attendance.cal_months); + calendar.cfg.setProperty("WEEKDAYS_SHORT", M.attendance.cal_week_days); + calendar.select(new Date(M.attendance.cal_cur_date*1000)); calendar.render(); calendar.selectEvent.subscribe(function() { diff --git a/db/access.php b/db/access.php index 99ea17b..02bbba3 100644 --- a/db/access.php +++ b/db/access.php @@ -47,7 +47,7 @@ $capabilities = array( - 'mod/attforblock:view' => array( + 'mod/attendance:view' => array( 'captype' => 'read', 'contextlevel' => CONTEXT_MODULE, 'archetypes' => array( @@ -58,7 +58,7 @@ $capabilities = array( ) ), - 'mod/attforblock:addinstance' => array( + 'mod/attendance:addinstance' => array( 'riskbitmask' => RISK_XSS, 'captype' => 'write', 'contextlevel' => CONTEXT_COURSE, @@ -69,7 +69,7 @@ $capabilities = array( 'clonepermissionsfrom' => 'moodle/course:manageactivities' ), - 'mod/attforblock:viewreports' => array( + 'mod/attendance:viewreports' => array( 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_MODULE, @@ -80,7 +80,7 @@ $capabilities = array( ) ), - 'mod/attforblock:takeattendances' => array( + 'mod/attendance:takeattendances' => array( 'riskbitmask' => RISK_DATALOSS, 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, @@ -91,7 +91,7 @@ $capabilities = array( ) ), - 'mod/attforblock:changeattendances' => array( + 'mod/attendance:changeattendances' => array( 'riskbitmask' => RISK_DATALOSS, 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, @@ -102,7 +102,7 @@ $capabilities = array( ) ), - 'mod/attforblock:manageattendances' => array( + 'mod/attendance:manageattendances' => array( 'riskbitmask' => RISK_CONFIG, 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, @@ -112,7 +112,7 @@ $capabilities = array( ) ), - 'mod/attforblock:changepreferences' => array( + 'mod/attendance:changepreferences' => array( 'riskbitmask' => RISK_CONFIG, 'captype' => 'write', 'contextlevel' => CONTEXT_MODULE, @@ -122,7 +122,7 @@ $capabilities = array( ) ), - 'mod/attforblock:export' => array( + 'mod/attendance:export' => array( 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_MODULE, @@ -133,7 +133,7 @@ $capabilities = array( ), - 'mod/attforblock:canbelisted' => array( + 'mod/attendance:canbelisted' => array( 'riskbitmask' => RISK_PERSONAL, 'captype' => 'read', 'contextlevel' => CONTEXT_MODULE, diff --git a/db/install.php b/db/install.php index b523186..b6c668e 100644 --- a/db/install.php +++ b/db/install.php @@ -20,7 +20,7 @@ * lib.php/modulename_install() post installation hook and partially defaults.php * * @package mod - * @subpackage attforblock + * @subpackage attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -28,7 +28,7 @@ /** * Post installation procedure */ -function xmldb_attforblock_install() { +function xmldb_attendance_install() { global $DB; $result = true; @@ -36,8 +36,8 @@ function xmldb_attforblock_install() { foreach ($arr as $k => $v) { $rec = new stdClass; $rec->attendanceid = 0; - $rec->acronym = get_string($k.'acronym', 'attforblock'); - $rec->description = get_string($k.'full', 'attforblock'); + $rec->acronym = get_string($k.'acronym', 'attendance'); + $rec->description = get_string($k.'full', 'attendance'); $rec->grade = $v; $rec->visible = 1; $rec->deleted = 0; diff --git a/db/install.xml b/db/install.xml index 195512e..63b8777 100644 --- a/db/install.xml +++ b/db/install.xml @@ -1,10 +1,10 @@ - - +
@@ -12,13 +12,13 @@ - +
- +
diff --git a/db/upgrade.php b/db/upgrade.php index 7b1c11e..9a48c77 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -15,309 +15,15 @@ // along with Moodle. If not, see . // This file keeps track of upgrades to -// the attforblock module. +// the attendance module. -function xmldb_attforblock_upgrade($oldversion=0) { +function xmldb_attendance_upgrade($oldversion=0) { global $CFG, $THEME, $DB; $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes. $result = true; - if ($oldversion < 2008021904) { // New version in version.php. - global $USER; - if ($sessions = $DB->get_records('attendance_sessions', array('takenby'=> 0))) { - foreach ($sessions as $sess) { - if ($DB->count_records('attendance_log', array('attsid'=> $sess->id)) > 0) { - $sess->takenby = $USER->id; - $sess->timetaken = $sess->timemodified ? $sess->timemodified : time(); - $sess->description = addslashes($sess->description); - $result = $DB->update_record('attendance_sessions', $sess) and $result; - } - } - } - upgrade_mod_savepoint(true, 2008021904, 'attforblock'); - } - - if ($oldversion < 2008102401) { - - $table = new xmldb_table('attforblock'); - - $field = new xmldb_field('grade'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '100', 'name'); - $dbman->add_field($table, $field); - - $table = new xmldb_table('attendance_sessions'); - - $field = new xmldb_field('courseid'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'id'); - $dbman->change_field_unsigned($table, $field); - - $field = new xmldb_field('sessdate'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'creator'); - $dbman->change_field_unsigned($table, $field); - - $field = new xmldb_field('duration'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'sessdate'); - $dbman->add_field($table, $field); - - $field = new xmldb_field('timetaken'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'takenby'); - $dbman->change_field_unsigned($table, $field); - $dbman->rename_field($table, $field, 'lasttaken'); - - $field = new xmldb_field('takenby'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'lasttaken'); - $dbman->change_field_unsigned($table, $field); - $dbman->rename_field($table, $field, 'lasttakenby'); - - $field = new xmldb_field('timemodified'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'lasttaken'); - $dbman->change_field_unsigned($table, $field); - - $table = new xmldb_table('attendance_log'); - - $field = new xmldb_field('attsid'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'id'); - $dbman->change_field_unsigned($table, $field); - - $field = new xmldb_field('studentid'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'attsid'); - $dbman->change_field_unsigned($table, $field); - - $field = new xmldb_field('statusid'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'status'); - $dbman->add_field($table, $field); - - $field = new xmldb_field('statusset'); - $field->set_attributes(XMLDB_TYPE_CHAR, '100', null, null, null, null, 'statusid'); - $dbman->add_field($table, $field); - - $field = new xmldb_field('timetaken'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'statusid'); - $dbman->add_field($table, $field); - - $field = new xmldb_field('takenby'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'timetaken'); - $dbman->add_field($table, $field); - - // Indexes. - $index = new xmldb_index('statusid'); - $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('statusid')); - $dbman->add_index($table, $index); - - $index = new xmldb_index('attsid'); - $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('attsid')); - $dbman->drop_index($table, $index); - - $field = new xmldb_field('attsid'); // Rename field. - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'id'); - $dbman->rename_field($table, $field, 'sessionid'); - - $index = new xmldb_index('sessionid'); - $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('sessionid')); - $dbman->add_index($table, $index); - - $table = new xmldb_table('attendance_settings'); - - $field = new xmldb_field('courseid'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'id'); - $dbman->change_field_unsigned($table, $field); - - $field = new xmldb_field('visible'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'grade'); - $dbman->add_field($table, $field); - - $field = new xmldb_field('deleted'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'visible'); - $dbman->add_field($table, $field); - - // Indexes. - $index = new xmldb_index('visible'); - $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('visible')); - $dbman->add_index($table, $index); - - $index = new xmldb_index('deleted'); - $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('deleted')); - $dbman->add_index($table, $index); - - $dbman->rename_table($table, 'attendance_statuses'); - - upgrade_mod_savepoint(true, 2008102401, 'attforblock'); - } - - if ($oldversion < 2008102406) { - - if ($courses = $DB->get_records_sql("SELECT courseid FROM {attendance_sessions} GROUP BY courseid")) { - foreach ($courses as $c) { - // Adding own status for course (now it must have own). - if (!$DB->count_records('attendance_statuses', array( 'courseid'=> $c->courseid))) { - $statuses = $DB->get_records('attendance_statuses', array('courseid'=> 0)); - foreach ($statuses as $stat) { - $rec = $stat; - $rec->courseid = $c->courseid; - $DB->insert_record('attendance_statuses', $rec); - } - } - $statuses = $DB->get_records('attendance_statuses', array('courseid'=> $c->courseid)); - $statlist = implode(',', array_keys($statuses)); - $sess = $DB->get_records_select_menu('attendance_sessions', - "courseid = ? AND lasttakenby > 0", array($c->courseid)); - $sesslist = implode(',', array_keys($sess)); - foreach ($statuses as $stat) { - execute("UPDATE {attendance_log} - SET statusid = {$stat->id}, statusset = '$statlist' - WHERE sessionid IN ($sesslist) AND status = '$stat->status'"); - } - $sessions = $DB->get_records_list('attendance_sessions', array('id'=> $sesslist)); - foreach ($sessions as $sess) { - execute("UPDATE {attendance_log} - SET timetaken = {$sess->lasttaken}, - takenby = {$sess->lasttakenby} - WHERE sessionid = {$sess->id}"); - } - - } - } - upgrade_mod_savepoint(true, 2008102406, 'attforblock'); - } - - if ($oldversion < 2008102409) { - $table = new xmldb_table('attendance_statuses'); - - $field = new xmldb_field('status'); - $dbman->drop_field($table, $field); - - $index = new xmldb_index('status'); - $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('status')); - $dbman->drop_index($table, $index); - - $table = new xmldb_table('attendance_log'); - - $field = new xmldb_field('status'); - $dbman->drop_field($table, $field); - - $index = new xmldb_index('status'); - $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('status')); - $dbman->drop_index($table, $index); - - $table = new xmldb_table('attendance_sessions'); - - $field = new xmldb_field('creator'); - $dbman->drop_field($table, $field); - upgrade_mod_savepoint(true, 2008102409, 'attforblock'); - } - - if ($oldversion < 2010070900) { - $table = new xmldb_table('attendance_sessions'); - - $field = new xmldb_field('groupid'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'courseid'); - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - $index = new xmldb_index('groupid'); - $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('groupid')); - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - upgrade_mod_savepoint(true, 2010070900, 'attforblock'); - } - - if ($oldversion < 2010123003) { - - $table = new xmldb_table('attendance_sessions'); - - $field = new xmldb_field('attendanceid'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'groupid'); - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - $index = new xmldb_index('attendanceid'); - $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('attendanceid')); - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - $sql = "UPDATE {attendance_sessions} AS ses - JOIN {attforblock} AS att - ON (ses.courseid = att.course) - SET ses.attendanceid=att.id"; - $DB->execute($sql); - - $table = new xmldb_table('attendance_statuses'); - - $field = new xmldb_field('attendanceid'); - $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'courseid'); - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - $index = new xmldb_index('attendanceid'); - $index->set_attributes(XMLDB_INDEX_NOTUNIQUE, array('attendanceid')); - if (!$dbman->index_exists($table, $index)) { - $dbman->add_index($table, $index); - } - - $sql = "UPDATE {attendance_statuses} AS sta - JOIN {attforblock} as att - ON (sta.courseid = att.course) - SET sta.attendanceid = att.id"; - $DB->execute($sql); - - upgrade_mod_savepoint(true, 2010123003, 'attforblock'); - } - - if ($oldversion < 2011061800) { - $table = new xmldb_table('attendance_sessions'); - - $field = new xmldb_field('description'); - $field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'timemodified'); - $dbman->change_field_type($table, $field); - - $field = new xmldb_field('descriptionformat', XMLDB_TYPE_INTEGER, '4', - XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'description'); - - if (!$dbman->field_exists($table, $field)) { - $dbman->add_field($table, $field); - } - - // Conditionally migrate to html format in intro. - if ($CFG->texteditors !== 'textarea') { - $rs = $DB->get_recordset('attendance_sessions', array('descriptionformat' => FORMAT_MOODLE), - '', 'id,description,descriptionformat'); - foreach ($rs as $s) { - $s->description = text_to_html($s->description, false, false, true); - $s->descriptionformat = FORMAT_HTML; - $DB->update_record('attendance_sessions', $s); - upgrade_set_timeout(); - } - $rs->close(); - } - - // Now we can create more than one attendances per course - // thus sessions and statuses belongs to attendance - // so we don't need courseid fields in attendance_sessions and attendance_statuses. - $index = new xmldb_index('courseid', XMLDB_INDEX_NOTUNIQUE, array('courseid')); - if ($dbman->index_exists($table, $index)) { - $dbman->drop_index($table, $index); - } - $field = new xmldb_field('courseid'); - if ($dbman->field_exists($table, $field)) { - $dbman->drop_field($table, $field); - } - - $table = new xmldb_table('attendance_statuses'); - if ($dbman->index_exists($table, $index)) { - $dbman->drop_index($table, $index); - } - if ($dbman->field_exists($table, $field)) { - $dbman->drop_field($table, $field); - } - - upgrade_mod_savepoint(true, 2011061800, 'attforblock'); - } + // UPGRADES from attforblock are only supported for sites that are running attforblock version 2012120700 return $result; } diff --git a/duration_form.php b/duration_form.php index 7947fef..b8ab908 100644 --- a/duration_form.php +++ b/duration_form.php @@ -24,7 +24,7 @@ require_once($CFG->libdir.'/formslib.php'); -class mod_attforblock_duration_form extends moodleform { +class mod_attendance_duration_form extends moodleform { public function definition() { @@ -36,8 +36,8 @@ class mod_attforblock_duration_form extends moodleform { $modcontext = $this->_customdata['modcontext']; $ids = $this->_customdata['ids']; - $mform->addElement('header', 'general', get_string('changeduration', 'attforblock')); - $mform->addElement('static', 'count', get_string('countofselected', 'attforblock'), count(explode('_', $ids))); + $mform->addElement('header', 'general', get_string('changeduration', 'attendance')); + $mform->addElement('static', 'count', get_string('countofselected', 'attendance'), count(explode('_', $ids))); for ($i=0; $i<=23; $i++) { $hours[$i] = sprintf("%02d", $i); @@ -47,7 +47,7 @@ class mod_attforblock_duration_form extends moodleform { } $durselect[] =& $mform->createElement('select', 'hours', '', $hours); $durselect[] =& $mform->createElement('select', 'minutes', '', $minutes, false, true); - $mform->addGroup($durselect, 'durtime', get_string('newduration', 'attforblock'), array(' '), true); + $mform->addGroup($durselect, 'durtime', get_string('newduration', 'attendance'), array(' '), true); $mform->addElement('hidden', 'ids', $ids); $mform->addElement('hidden', 'id', $cm->id); @@ -55,7 +55,7 @@ class mod_attforblock_duration_form extends moodleform { $mform->setDefaults(array('durtime' => array('hours'=>0, 'minutes'=>0))); - $submit_string = get_string('update', 'attforblock'); + $submit_string = get_string('update', 'attendance'); $this->add_action_buttons(true, $submit_string); } diff --git a/export.php b/export.php index 86c5d4f..57d7ebc 100644 --- a/export.php +++ b/export.php @@ -30,13 +30,13 @@ require_once(dirname(__FILE__).'/renderhelpers.php'); $id = required_param('id', PARAM_INT); -$cm = get_coursemodule_from_id('attforblock', $id, 0, false, MUST_EXIST); +$cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attforblock', array('id' => $cm->instance), '*', MUST_EXIST); +$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); require_login($course, true, $cm); -$att = new attforblock($att, $cm, $course, $PAGE->context); +$att = new attendance($att, $cm, $course, $PAGE->context); $att->perm->require_export_capability(); @@ -44,11 +44,11 @@ $PAGE->set_url($att->url_export()); $PAGE->set_title($course->shortname. ": ".$att->name); $PAGE->set_heading($course->fullname); $PAGE->set_cacheable(true); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attforblock')); +$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attendance')); $PAGE->navbar->add(get_string('export', 'quiz')); $formparams = array('course' => $course, 'cm' => $cm, 'modcontext' => $PAGE->context); -$mform = new mod_attforblock_export_form($att->url_export(), $formparams); +$mform = new mod_attendance_export_form($att->url_export(), $formparams); if ($mform->is_submitted()) { $formdata = $mform->get_data(); @@ -71,7 +71,7 @@ if ($mform->is_submitted()) { } $att->pageparams = $pageparams; - $reportdata = new attforblock_report_data($att); + $reportdata = new attendance_report_data($att); if ($reportdata->users) { $filename = clean_filename($course->shortname.'_Attendances_'.userdate(time(), '%Y%m%d-%H%M')); @@ -82,7 +82,7 @@ if ($mform->is_submitted()) { $data->group = $group ? $group->name : get_string('allparticipants'); if (isset($formdata->ident['id'])) { - $data->tabhead[] = get_string('studentid', 'attforblock'); + $data->tabhead[] = get_string('studentid', 'attendance'); } if (isset($formdata->ident['uname'])) { $data->tabhead[] = get_string('username'); @@ -93,13 +93,13 @@ if ($mform->is_submitted()) { if (count($reportdata->sessions) > 0) { foreach ($reportdata->sessions as $sess) { - $text = userdate($sess->sessdate, get_string('strftimedmyhm', 'attforblock')); + $text = userdate($sess->sessdate, get_string('strftimedmyhm', 'attendance')); $text .= ' '; - $text .= $sess->groupid ? $reportdata->groups[$sess->groupid]->name : get_string('commonsession', 'attforblock'); + $text .= $sess->groupid ? $reportdata->groups[$sess->groupid]->name : get_string('commonsession', 'attendance'); $data->tabhead[] = $text; } } else { - print_error('sessionsnotfound', 'attforblock', $att->url_manage()); + print_error('sessionsnotfound', 'attendance', $att->url_manage()); } if ($reportdata->gradable) { $data->tabhead[] = get_string('grade'); @@ -135,10 +135,10 @@ if ($mform->is_submitted()) { } } -$output = $PAGE->get_renderer('mod_attforblock'); -$tabs = new attforblock_tabs($att, attforblock_tabs::TAB_EXPORT); +$output = $PAGE->get_renderer('mod_attendance'); +$tabs = new attendance_tabs($att, attendance_tabs::TAB_EXPORT); echo $output->header(); -echo $output->heading(get_string('attendanceforthecourse', 'attforblock').' :: ' .$course->fullname); +echo $output->heading(get_string('attendanceforthecourse', 'attendance').' :: ' .$course->fullname); echo $output->render($tabs); $mform->display(); diff --git a/export_form.php b/export_form.php index abcf6d3..e9eee31 100644 --- a/export_form.php +++ b/export_form.php @@ -24,7 +24,7 @@ require_once($CFG->libdir.'/formslib.php'); -class mod_attforblock_export_form extends moodleform { +class mod_attendance_export_form extends moodleform { public function definition() { @@ -50,24 +50,24 @@ class mod_attforblock_export_form extends moodleform { $mform->addElement('select', 'group', get_string('group'), $grouplist); $ident = array(); - $ident[] =& $mform->createElement('checkbox', 'id', '', get_string('studentid', 'attforblock')); + $ident[] =& $mform->createElement('checkbox', 'id', '', get_string('studentid', 'attendance')); $ident[] =& $mform->createElement('checkbox', 'uname', '', get_string('username')); - $mform->addGroup($ident, 'ident', get_string('identifyby', 'attforblock'), array('
'), true); + $mform->addGroup($ident, 'ident', get_string('identifyby', 'attendance'), array('
'), true); $mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true)); - $mform->addElement('checkbox', 'includeallsessions', get_string('includeall', 'attforblock'), get_string('yes')); + $mform->addElement('checkbox', 'includeallsessions', get_string('includeall', 'attendance'), get_string('yes')); $mform->setDefault('includeallsessions', true); - $mform->addElement('checkbox', 'includenottaken', get_string('includenottaken', 'attforblock'), get_string('yes')); - $mform->addElement('date_selector', 'sessionstartdate', get_string('startofperiod', 'attforblock')); + $mform->addElement('checkbox', 'includenottaken', get_string('includenottaken', 'attendance'), get_string('yes')); + $mform->addElement('date_selector', 'sessionstartdate', get_string('startofperiod', 'attendance')); $mform->setDefault('sessionstartdate', $course->startdate); $mform->disabledIf('sessionstartdate', 'includeallsessions', 'checked'); - $mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod', 'attforblock')); + $mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod', 'attendance')); $mform->disabledIf('sessionenddate', 'includeallsessions', 'checked'); $mform->addElement('select', 'format', get_string('format'), - array('excel' => get_string('downloadexcel', 'attforblock'), - 'ooo' => get_string('downloadooo', 'attforblock'), - 'text' => get_string('downloadtext', 'attforblock') + array('excel' => get_string('downloadexcel', 'attendance'), + 'ooo' => get_string('downloadooo', 'attendance'), + 'text' => get_string('downloadtext', 'attendance') )); $submit_string = get_string('ok'); diff --git a/index.php b/index.php index bc78f6c..dcb421c 100644 --- a/index.php +++ b/index.php @@ -30,8 +30,8 @@ $course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST); require_login($course); // TODO: check if this is correct behaviour - other modules list all the instances of the module in the course. -if ($att = array_pop(get_all_instances_in_course('attforblock', $course, null, true))) { +if ($att = array_pop(get_all_instances_in_course('attendance', $course, null, true))) { redirect("view.php?id=$att->coursemodule"); } else { - print_error('notfound', 'attforblock'); + print_error('notfound', 'attendance'); } diff --git a/lang/en/attforblock.php b/lang/en/attendance.php similarity index 90% rename from lang/en/attforblock.php rename to lang/en/attendance.php index e59929d..86b6496 100644 --- a/lang/en/attforblock.php +++ b/lang/en/attendance.php @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -$string['attforblock:addinstance'] = 'Add a new attendance activity'; +$string['attendance:addinstance'] = 'Add a new attendance activity'; $string['Aacronym'] = 'A'; $string['Afull'] = 'Absent'; $string['Eacronym'] = 'E'; @@ -38,14 +38,15 @@ $string['attendancepercent'] = 'Attendance percent'; $string['attendancereport'] = 'Attendance report'; $string['attendancesuccess'] = 'Attendance has been successfully taken'; $string['attendanceupdated'] = 'Attendance successfully updated'; -$string['attforblock:canbelisted'] = 'Appears in the roster'; -$string['attforblock:changepreferences'] = 'Changing Preferences'; -$string['attforblock:changeattendances'] = 'Changing Attendances'; -$string['attforblock:export'] = 'Export Reports'; -$string['attforblock:manageattendances'] = 'Manage Attendances'; -$string['attforblock:takeattendances'] = 'Taking Attendances'; -$string['attforblock:view'] = 'Viewing Attendances'; -$string['attforblock:viewreports'] = 'Viewing Reports'; +$string['attendance:canbelisted'] = 'Appears in the roster'; +$string['attendance:changepreferences'] = 'Changing Preferences'; +$string['attendance:changeattendances'] = 'Changing Attendances'; +$string['attendance:export'] = 'Export Reports'; +$string['attendance:manageattendances'] = 'Manage Attendances'; +$string['attendance:takeattendances'] = 'Taking Attendances'; +$string['attendance:view'] = 'Viewing Attendances'; +$string['attendance:viewreports'] = 'Viewing Reports'; +$string['attforblockdirstillexists'] = 'old mod/attforblock directory still exists - you must delete this directory on your server before running this upgrade.'; $string['attrecords'] = 'Attendances records'; $string['calclose'] = 'Close'; $string['calmonths'] = 'January,February,March,April,May,June,July,August,September,October,November,December'; @@ -131,6 +132,7 @@ $string['nosessiondayselected'] = 'No Session day selected'; $string['nosessionexists'] = 'No Session exists for this course'; $string['nosessionsselected'] = 'No sessions selected'; $string['notfound'] = 'Attendance activity not found in this course!'; +$string['noupgradefromthisversion'] = 'The Attendance module cannot upgrade from the version of attforblock you have installed. - please delete attforblock or upgrade it to the latest version before isntalling the new attendance module'; $string['olddate'] = 'Old date'; $string['period'] = 'Frequency'; $string['pluginname'] = 'Attendance'; @@ -184,6 +186,7 @@ $string['strftimeshortdate'] = '%d.%m.%Y'; $string['studentid'] = 'Student ID'; $string['takeattendance'] = 'Take attendance'; $string['thiscourse'] = 'This course'; +$string['tablerenamefailed'] = 'Rename of old attforblock table to attendance failed'; $string['update'] = 'Update'; $string['variable'] = 'variable'; $string['variablesupdated'] = 'Variables successfully updated'; diff --git a/lib.php b/lib.php index 90ddb59..56691db 100644 --- a/lib.php +++ b/lib.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Library of functions and constants for module attforblock + * Library of functions and constants for module attendance * * @package mod_attendance * @copyright 2011 Artem Andreev @@ -29,7 +29,7 @@ * @param string $feature FEATURE_xx constant for requested feature * @return mixed true if the feature is supported, null if unknown */ -function attforblock_supports($feature) { +function attendance_supports($feature) { switch($feature) { case FEATURE_GRADE_HAS_GRADE: return true; @@ -66,41 +66,41 @@ function att_add_default_statuses($attid) { } } -function attforblock_add_instance($attforblock) { +function attendance_add_instance($attendance) { global $DB; - $attforblock->timemodified = time(); + $attendance->timemodified = time(); - $attforblock->id = $DB->insert_record('attforblock', $attforblock); + $attendance->id = $DB->insert_record('attendance', $attendance); - att_add_default_statuses($attforblock->id); + att_add_default_statuses($attendance->id); - attforblock_grade_item_update($attforblock); - // attforblock_update_grades($attforblock); - return $attforblock->id; + attendance_grade_item_update($attendance); + // attendance_update_grades($attendance); + return $attendance->id; } -function attforblock_update_instance($attforblock) { +function attendance_update_instance($attendance) { global $DB; - $attforblock->timemodified = time(); - $attforblock->id = $attforblock->instance; + $attendance->timemodified = time(); + $attendance->id = $attendance->instance; - if (! $DB->update_record('attforblock', $attforblock)) { + if (! $DB->update_record('attendance', $attendance)) { return false; } - attforblock_grade_item_update($attforblock); + attendance_grade_item_update($attendance); return true; } -function attforblock_delete_instance($id) { +function attendance_delete_instance($id) { global $DB; - if (! $attforblock = $DB->get_record('attforblock', array('id'=> $id))) { + if (! $attendance = $DB->get_record('attendance', array('id'=> $id))) { return false; } @@ -110,17 +110,17 @@ function attforblock_delete_instance($id) { } $DB->delete_records('attendance_statuses', array('attendanceid'=> $id)); - $DB->delete_records('attforblock', array('id'=> $id)); + $DB->delete_records('attendance', array('id'=> $id)); - attforblock_grade_item_delete($attforblock); + attendance_grade_item_delete($attendance); return true; } -function attforblock_delete_course($course, $feedback=true) { +function attendance_delete_course($course, $feedback=true) { global $DB; - $attids = array_keys($DB->get_records('attforblock', array('course'=> $course->id), '', 'id')); + $attids = array_keys($DB->get_records('attendance', array('course'=> $course->id), '', 'id')); $sessids = array_keys($DB->get_records_list('attendance_sessions', 'attendanceid', $attids, '', 'id')); if ($sessids) { $DB->delete_records_list('attendance_log', 'sessionid', $sessids); @@ -129,7 +129,7 @@ function attforblock_delete_course($course, $feedback=true) { $DB->delete_records_list('attendance_statuses', 'attendanceid', $attids); $DB->delete_records_list('attendance_sessions', 'attendanceid', $attids); } - $DB->delete_records('attforblock', array('course'=> $course->id)); + $DB->delete_records('attendance', array('course'=> $course->id)); return true; } @@ -138,17 +138,17 @@ function attforblock_delete_course($course, $feedback=true) { * Called by course/reset.php * @param $mform form passed by reference */ -function attforblock_reset_course_form_definition(&$mform) { - $mform->addElement('header', 'attendanceheader', get_string('modulename', 'attforblock')); +function attendance_reset_course_form_definition(&$mform) { + $mform->addElement('header', 'attendanceheader', get_string('modulename', 'attendance')); - $mform->addElement('static', 'description', get_string('description', 'attforblock'), - get_string('resetdescription', 'attforblock')); - $mform->addElement('checkbox', 'reset_attendance_log', get_string('deletelogs', 'attforblock')); + $mform->addElement('static', 'description', get_string('description', 'attendance'), + get_string('resetdescription', 'attendance')); + $mform->addElement('checkbox', 'reset_attendance_log', get_string('deletelogs', 'attendance')); - $mform->addElement('checkbox', 'reset_attendance_sessions', get_string('deletesessions', 'attforblock')); + $mform->addElement('checkbox', 'reset_attendance_sessions', get_string('deletesessions', 'attendance')); $mform->disabledIf('reset_attendance_sessions', 'reset_attendance_log', 'notchecked'); - $mform->addElement('checkbox', 'reset_attendance_statuses', get_string('resetstatuses', 'attforblock')); + $mform->addElement('checkbox', 'reset_attendance_statuses', get_string('resetstatuses', 'attendance')); $mform->setAdvanced('reset_attendance_statuses'); $mform->disabledIf('reset_attendance_statuses', 'reset_attendance_log', 'notchecked'); } @@ -156,16 +156,16 @@ function attforblock_reset_course_form_definition(&$mform) { /** * Course reset form defaults. */ -function attforblock_reset_course_form_defaults($course) { +function attendance_reset_course_form_defaults($course) { return array('reset_attendance_log'=>0, 'reset_attendance_statuses'=>0, 'reset_attendance_sessions'=>0); } -function attforblock_reset_userdata($data) { +function attendance_reset_userdata($data) { global $DB; $status = array(); - $attids = array_keys($DB->get_records('attforblock', array('course'=> $data->courseid), '', 'id')); + $attids = array_keys($DB->get_records('attendance', array('course'=> $data->courseid), '', 'id')); if (!empty($data->reset_attendance_log)) { $sess = $DB->get_records_list('attendance_sessions', 'attendanceid', $attids, '', 'id'); @@ -176,8 +176,8 @@ function attforblock_reset_userdata($data) { $DB->set_field_select('attendance_sessions', 'lasttaken', 0, "attendanceid $sql", $params); $status[] = array( - 'component' => get_string('modulenameplural', 'attforblock'), - 'item' => get_string('attendancedata', 'attforblock'), + 'component' => get_string('modulenameplural', 'attendance'), + 'item' => get_string('attendancedata', 'attendance'), 'error' => false ); } @@ -190,8 +190,8 @@ function attforblock_reset_userdata($data) { } $status[] = array( - 'component' => get_string('modulenameplural', 'attforblock'), - 'item' => get_string('sessions', 'attforblock'), + 'component' => get_string('modulenameplural', 'attendance'), + 'item' => get_string('sessions', 'attendance'), 'error' => false ); } @@ -200,8 +200,8 @@ function attforblock_reset_userdata($data) { $DB->delete_records_list('attendance_sessions', 'attendanceid', $attids); $status[] = array( - 'component' => get_string('modulenameplural', 'attforblock'), - 'item' => get_string('statuses', 'attforblock'), + 'component' => get_string('modulenameplural', 'attendance'), + 'item' => get_string('statuses', 'attendance'), 'error' => false ); } @@ -215,13 +215,13 @@ function attforblock_reset_userdata($data) { * $return->time = the time they did it * $return->info = a short text description */ -function attforblock_user_outline($course, $user, $mod, $attforblock) { +function attendance_user_outline($course, $user, $mod, $attendance) { global $CFG; require_once(dirname(__FILE__).'/locallib.php'); require_once($CFG->libdir.'/gradelib.php'); - $grades = grade_get_grades($course->id, 'mod', 'attforblock', $attforblock->id, $user->id); + $grades = grade_get_grades($course->id, 'mod', 'attendance', $attendance->id, $user->id); $result = new stdClass(); if (!empty($grades->items[0]->grades)) { @@ -230,11 +230,11 @@ function attforblock_user_outline($course, $user, $mod, $attforblock) { } else { $result->time = 0; } - if (has_capability('mod/attforblock:canbelisted', $mod->context, $user->id)) { - $statuses = att_get_statuses($attforblock->id); - $grade = att_get_user_grade(att_get_user_statuses_stat($attforblock->id, $course->startdate, + if (has_capability('mod/attendance:canbelisted', $mod->context, $user->id)) { + $statuses = att_get_statuses($attendance->id); + $grade = att_get_user_grade(att_get_user_statuses_stat($attendance->id, $course->startdate, $user->id), $statuses); - $maxgrade = att_get_user_max_grade(att_get_user_taken_sessions_count($attforblock->id, $course->startdate, + $maxgrade = att_get_user_max_grade(att_get_user_taken_sessions_count($attendance->id, $course->startdate, $user->id), $statuses); $result->info = $grade.' / '.$maxgrade; @@ -247,37 +247,37 @@ function attforblock_user_outline($course, $user, $mod, $attforblock) { * a given particular instance of this module, for user activity reports. * */ -function attforblock_user_complete($course, $user, $mod, $attforblock) { +function attendance_user_complete($course, $user, $mod, $attendance) { global $CFG; require_once(dirname(__FILE__).'/renderhelpers.php'); require_once($CFG->libdir.'/gradelib.php'); - if (has_capability('mod/attforblock:canbelisted', $mod->context, $user->id)) { - echo construct_full_user_stat_html_table($attforblock, $course, $user); + if (has_capability('mod/attendance:canbelisted', $mod->context, $user->id)) { + echo construct_full_user_stat_html_table($attendance, $course, $user); } } -function attforblock_print_recent_activity($course, $isteacher, $timestart) { +function attendance_print_recent_activity($course, $isteacher, $timestart) { return false; } -function attforblock_cron () { +function attendance_cron () { return true; } /** * Return grade for given user or all users. * - * @param int $attforblockid id of attforblock + * @param int $attendanceid id of attendance * @param int $userid optional user id, 0 means all users * @return array array of grades, false if none */ -/*function attforblock_get_user_grades($attforblock, $userid=0) { +/*function attendance_get_user_grades($attendance, $userid=0) { global $CFG, $DB; require_once('_locallib.php'); - if (! $course = $DB->get_record('course', array('id'=> $attforblock->course))) { + if (! $course = $DB->get_record('course', array('id'=> $attendance->course))) { error("Course is misconfigured"); } @@ -285,13 +285,13 @@ function attforblock_cron () { if ($userid) { $result = array(); $result[$userid]->userid = $userid; - $result[$userid]->rawgrade = $attforblock->grade * get_percent($userid, $course, $attforblock) / 100; + $result[$userid]->rawgrade = $attendance->grade * get_percent($userid, $course, $attendance) / 100; } else { if ($students = get_course_students($course->id)) { $result = array(); foreach ($students as $student) { $result[$student->id]->userid = $student->id; - $result[$student->id]->rawgrade = $attforblock->grade * get_percent($student->id, $course, $attforblock) / 100; + $result[$student->id]->rawgrade = $attendance->grade * get_percent($student->id, $course, $attendance) / 100; } } } @@ -302,37 +302,37 @@ function attforblock_cron () { /** * Update grades by firing grade_updated event * - * @param object $attforblock null means all attforblocks + * @param object $attendance null means all attendances * @param int $userid specific user only, 0 mean all */ -/*function attforblock_update_grades($attforblock=null, $userid=0, $nullifnone=true) { +/*function attendance_update_grades($attendance=null, $userid=0, $nullifnone=true) { global $CFG, $DB; if (!function_exists('grade_update')) { //workaround for buggy PHP versions require_once($CFG->libdir.'/gradelib.php'); } - if ($attforblock != null) { - if ($grades = attforblock_get_user_grades($attforblock, $userid)) { + if ($attendance != null) { + if ($grades = attendance_get_user_grades($attendance, $userid)) { foreach($grades as $k=>$v) { if ($v->rawgrade == -1) { $grades[$k]->rawgrade = null; } } - attforblock_grade_item_update($attforblock, $grades); + attendance_grade_item_update($attendance, $grades); } else { - attforblock_grade_item_update($attforblock); + attendance_grade_item_update($attendance); } } else { $sql = "SELECT a.*, cm.idnumber as cmidnumber, a.course as courseid - FROM {attforblock} a, {course_modules} cm, {modules} m - WHERE m.name='attforblock' AND m.id=cm.module AND cm.instance=a.id"; + FROM {attendance} a, {course_modules} cm, {modules} m + WHERE m.name='attendance' AND m.id=cm.module AND cm.instance=a.id"; if ($rs = $DB->get_records_sql($sql)) { - foreach ($rs as $attforblock) { -// if ($attforblock->grade != 0) { - attforblock_update_grades($attforblock); + foreach ($rs as $attendance) { +// if ($attendance->grade != 0) { + attendance_update_grades($attendance); // } else { -// attforblock_grade_item_update($attforblock); +// attendance_grade_item_update($attendance); // } } $rs->close($rs); @@ -341,13 +341,13 @@ function attforblock_cron () { }*/ /** - * Create grade item for given attforblock + * Create grade item for given attendance * - * @param object $attforblock object with extra cmidnumber + * @param object $attendance object with extra cmidnumber * @param mixed optional array/object of grade(s); 'reset' means reset grades in gradebook * @return int 0 if ok, error code otherwise */ -function attforblock_grade_item_update($attforblock, $grades=null) { +function attendance_grade_item_update($attendance, $grades=null) { global $CFG, $DB; require_once('locallib.php'); @@ -356,29 +356,29 @@ function attforblock_grade_item_update($attforblock, $grades=null) { require_once($CFG->libdir.'/gradelib.php'); } - if (!isset($attforblock->courseid)) { - $attforblock->courseid = $attforblock->course; + if (!isset($attendance->courseid)) { + $attendance->courseid = $attendance->course; } - if (! $course = $DB->get_record('course', array('id'=> $attforblock->course))) { + if (! $course = $DB->get_record('course', array('id'=> $attendance->course))) { error("Course is misconfigured"); } - // $attforblock->grade = get_maxgrade($course); + // $attendance->grade = get_maxgrade($course); - if (!empty($attforblock->cmidnumber)) { - $params = array('itemname'=>$attforblock->name, 'idnumber'=>$attforblock->cmidnumber); + if (!empty($attendance->cmidnumber)) { + $params = array('itemname'=>$attendance->name, 'idnumber'=>$attendance->cmidnumber); } else { // MDL-14303. - $cm = get_coursemodule_from_instance('attforblock', $attforblock->id); - $params = array('itemname'=>$attforblock->name/*, 'idnumber'=>$attforblock->id*/); + $cm = get_coursemodule_from_instance('attendance', $attendance->id); + $params = array('itemname'=>$attendance->name/*, 'idnumber'=>$attendance->id*/); } - if ($attforblock->grade > 0) { + if ($attendance->grade > 0) { $params['gradetype'] = GRADE_TYPE_VALUE; - $params['grademax'] = $attforblock->grade; + $params['grademax'] = $attendance->grade; $params['grademin'] = 0; - } else if ($attforblock->grade < 0) { + } else if ($attendance->grade < 0) { $params['gradetype'] = GRADE_TYPE_SCALE; - $params['scaleid'] = -$attforblock->grade; + $params['scaleid'] = -$attendance->grade; } else { $params['gradetype'] = GRADE_TYPE_NONE; @@ -389,28 +389,28 @@ function attforblock_grade_item_update($attforblock, $grades=null) { $grades = null; } - return grade_update('mod/attforblock', $attforblock->courseid, 'mod', 'attforblock', $attforblock->id, 0, $grades, $params); + return grade_update('mod/attendance', $attendance->courseid, 'mod', 'attendance', $attendance->id, 0, $grades, $params); } /** - * Delete grade item for given attforblock + * Delete grade item for given attendance * - * @param object $attforblock object - * @return object attforblock + * @param object $attendance object + * @return object attendance */ -function attforblock_grade_item_delete($attforblock) { +function attendance_grade_item_delete($attendance) { global $CFG; require_once($CFG->libdir.'/gradelib.php'); - if (!isset($attforblock->courseid)) { - $attforblock->courseid = $attforblock->course; + if (!isset($attendance->courseid)) { + $attendance->courseid = $attendance->course; } - return grade_update('mod/attforblock', $attforblock->courseid, 'mod', 'attforblock', - $attforblock->id, 0, null, array('deleted'=>1)); + return grade_update('mod/attendance', $attendance->courseid, 'mod', 'attendance', + $attendance->id, 0, null, array('deleted'=>1)); } -function attforblock_get_participants($attforblockid) { +function attendance_get_participants($attendanceid) { return false; } @@ -420,11 +420,11 @@ function attforblock_get_participants($attforblockid) { * modified if necessary. See book, glossary or journal modules * as reference. * - * @param int $attforblockid + * @param int $attendanceid * @param int $scaleid * @return boolean True if the scale is used by any attendance */ -function attforblock_scale_used ($attforblockid, $scaleid) { +function attendance_scale_used ($attendanceid, $scaleid) { return false; } @@ -436,7 +436,7 @@ function attforblock_scale_used ($attforblockid, $scaleid) { * @param int $scaleid * @return bool true if the scale is used by any book */ -function attforblock_scale_used_anywhere($scaleid) { +function attendance_scale_used_anywhere($scaleid) { return false; } @@ -451,7 +451,7 @@ function attforblock_scale_used_anywhere($scaleid) { * @param bool $forcedownload * @return bool false if file not found, does not return if found - justsend the file */ -function attforblock_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) { +function attendance_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) { global $CFG, $DB; if ($context->contextlevel != CONTEXT_MODULE) { @@ -460,7 +460,7 @@ function attforblock_pluginfile($course, $cm, $context, $filearea, $args, $force require_login($course, false, $cm); - if (!$att = $DB->get_record('attforblock', array('id' => $cm->instance))) { + if (!$att = $DB->get_record('attendance', array('id' => $cm->instance))) { return false; } @@ -477,7 +477,7 @@ function attforblock_pluginfile($course, $cm, $context, $filearea, $args, $force $fs = get_file_storage(); $relativepath = implode('/', $args); - $fullpath = "/$context->id/mod_attforblock/$filearea/$sessid/$relativepath"; + $fullpath = "/$context->id/mod_attendance/$filearea/$sessid/$relativepath"; if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) { return false; } diff --git a/locallib.php b/locallib.php index 55b69ea..18b34be 100644 --- a/locallib.php +++ b/locallib.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * local functions and constants for module attforblock + * local functions and constants for module attendance * * @package mod_attendance * @copyright 2011 Artem Andreev @@ -37,7 +37,7 @@ define('ATT_VIEW_ALL', 5); define('ATT_SORT_LASTNAME', 1); define('ATT_SORT_FIRSTNAME', 2); -class attforblock_permissions { +class attendance_permissions { private $canview; private $canviewreports; private $cantake; @@ -58,31 +58,31 @@ class attforblock_permissions { public function can_view() { if (is_null($this->canview)) { - $this->canview = has_capability('mod/attforblock:view', $this->context); + $this->canview = has_capability('mod/attendance:view', $this->context); } return $this->canview; } public function require_view_capability() { - require_capability('mod/attforblock:view', $this->context); + require_capability('mod/attendance:view', $this->context); } public function can_view_reports() { if (is_null($this->canviewreports)) { - $this->canviewreports = has_capability('mod/attforblock:viewreports', $this->context); + $this->canviewreports = has_capability('mod/attendance:viewreports', $this->context); } return $this->canviewreports; } public function require_view_reports_capability() { - require_capability('mod/attforblock:viewreports', $this->context); + require_capability('mod/attendance:viewreports', $this->context); } public function can_take() { if (is_null($this->cantake)) { - $this->cantake = has_capability('mod/attforblock:takeattendances', $this->context); + $this->cantake = has_capability('mod/attendance:takeattendances', $this->context); } return $this->cantake; @@ -93,7 +93,7 @@ class attforblock_permissions { return false; } - if ($groupid == attforblock::SESSION_COMMON + if ($groupid == attendance::SESSION_COMMON || $this->can_access_all_groups() || array_key_exists($groupid, groups_get_activity_allowed_groups($this->cm))) { return true; @@ -104,7 +104,7 @@ class attforblock_permissions { public function can_change() { if (is_null($this->canchange)) { - $this->canchange = has_capability('mod/attforblock:changeattendances', $this->context); + $this->canchange = has_capability('mod/attendance:changeattendances', $this->context); } return $this->canchange; @@ -112,43 +112,43 @@ class attforblock_permissions { public function can_manage() { if (is_null($this->canmanage)) { - $this->canmanage = has_capability('mod/attforblock:manageattendances', $this->context); + $this->canmanage = has_capability('mod/attendance:manageattendances', $this->context); } return $this->canmanage; } public function require_manage_capability() { - require_capability('mod/attforblock:manageattendances', $this->context); + require_capability('mod/attendance:manageattendances', $this->context); } public function can_change_preferences() { if (is_null($this->canchangepreferences)) { - $this->canchangepreferences = has_capability('mod/attforblock:changepreferences', $this->context); + $this->canchangepreferences = has_capability('mod/attendance:changepreferences', $this->context); } return $this->canchangepreferences; } public function require_change_preferences_capability() { - require_capability('mod/attforblock:changepreferences', $this->context); + require_capability('mod/attendance:changepreferences', $this->context); } public function can_export() { if (is_null($this->canexport)) { - $this->canexport = has_capability('mod/attforblock:export', $this->context); + $this->canexport = has_capability('mod/attendance:export', $this->context); } return $this->canexport; } public function require_export_capability() { - require_capability('mod/attforblock:export', $this->context); + require_capability('mod/attendance:export', $this->context); } public function can_be_listed() { if (is_null($this->canbelisted)) { - $this->canbelisted = has_capability('mod/attforblock:canbelisted', $this->context, null, false); + $this->canbelisted = has_capability('mod/attendance:canbelisted', $this->context, null, false); } return $this->canbelisted; @@ -327,10 +327,10 @@ class att_page_with_filter_controls { if ($allowedgroups) { if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $PAGE->context)) { - $this->sessgroupslist[self::SESSTYPE_ALL] = get_string('all', 'attforblock'); + $this->sessgroupslist[self::SESSTYPE_ALL] = get_string('all', 'attendance'); } if ($groupmode == VISIBLEGROUPS) { - $this->sessgroupslist[self::SESSTYPE_COMMON] = get_string('commonsessions', 'attforblock'); + $this->sessgroupslist[self::SESSTYPE_COMMON] = get_string('commonsessions', 'attendance'); } foreach ($allowedgroups as $group) { $this->sessgroupslist[$group->id] = format_string($group->name); @@ -436,17 +436,17 @@ class att_take_page_params { private function init_view_mode() { if (isset($this->viewmode)) { - set_user_preference("attforblock_take_view_mode", $this->viewmode); + set_user_preference("attendance_take_view_mode", $this->viewmode); } else { - $this->viewmode = get_user_preferences("attforblock_take_view_mode", self::DEFAULT_VIEW_MODE); + $this->viewmode = get_user_preferences("attendance_take_view_mode", self::DEFAULT_VIEW_MODE); } } private function init_gridcols() { if (isset($this->gridcols)) { - set_user_preference("attforblock_gridcolumns", $this->gridcols); + set_user_preference("attendance_gridcolumns", $this->gridcols); } else { - $this->gridcols = get_user_preferences("attforblock_gridcolumns", 5); + $this->gridcols = get_user_preferences("attendance_gridcolumns", 5); } } @@ -527,7 +527,7 @@ class att_preferences_page_params { -class attforblock { +class attendance { const SESSION_COMMON = 0; const SESSION_GROUP = 1; @@ -552,7 +552,7 @@ class attforblock { /** current page parameters */ public $pageparams; - /** @var attforblock_permissions permission of current user for attendance instance*/ + /** @var attendance_permissions permission of current user for attendance instance*/ public $perm; private $groupmode; @@ -572,17 +572,17 @@ class attforblock { * Makes deep copy of all passed records properties. Replaces integer $course attribute * with a full database record (course should not be stored in instances table anyway). * - * @param stdClass $dbrecord Attandance instance data from {attforblock} table + * @param stdClass $dbrecord Attandance instance data from {attendance} table * @param stdClass $cm Course module record as returned by {@link get_coursemodule_from_id()} * @param stdClass $course Course record from {course} table * @param stdClass $context The context of the workshop instance */ public function __construct(stdclass $dbrecord, stdclass $cm, stdclass $course, stdclass $context=null, $pageparams=null) { foreach ($dbrecord as $field => $value) { - if (property_exists('attforblock', $field)) { + if (property_exists('attendance', $field)) { $this->{$field} = $value; } else { - throw new coding_exception('The attendance table has a field with no property in the attforblock class'); + throw new coding_exception('The attendance table has a field with no property in the attendance class'); } } $this->cm = $cm; @@ -595,7 +595,7 @@ class attforblock { $this->pageparams = $pageparams; - $this->perm = new attforblock_permissions($this->cm, $this->context); + $this->perm = new attendance_permissions($this->cm, $this->context); } public function get_group_mode() { @@ -717,10 +717,10 @@ class attforblock { $sessions = $DB->get_records_select('attendance_sessions', $where, $params, 'sessdate asc'); foreach ($sessions as $sess) { if (empty($sess->description)) { - $sess->description = get_string('nodescription', 'attforblock'); + $sess->description = get_string('nodescription', 'attendance'); } else { $sess->description = file_rewrite_pluginfile_urls($sess->description, - 'pluginfile.php', $this->context->id, 'mod_attforblock', 'session', $sess->id); + 'pluginfile.php', $this->context->id, 'mod_attendance', 'session', $sess->id); } } @@ -732,7 +732,7 @@ class attforblock { */ public function url_manage($params=array()) { $params = array_merge(array('id' => $this->cm->id), $params); - return new moodle_url('/mod/attforblock/manage.php', $params); + return new moodle_url('/mod/attendance/manage.php', $params); } /** @@ -740,7 +740,7 @@ class attforblock { */ public function url_sessions($params=array()) { $params = array_merge(array('id' => $this->cm->id), $params); - return new moodle_url('/mod/attforblock/sessions.php', $params); + return new moodle_url('/mod/attendance/sessions.php', $params); } /** @@ -748,7 +748,7 @@ class attforblock { */ public function url_report($params=array()) { $params = array_merge(array('id' => $this->cm->id), $params); - return new moodle_url('/mod/attforblock/report.php', $params); + return new moodle_url('/mod/attendance/report.php', $params); } /** @@ -756,7 +756,7 @@ class attforblock { */ public function url_export() { $params = array('id' => $this->cm->id); - return new moodle_url('/mod/attforblock/export.php', $params); + return new moodle_url('/mod/attendance/export.php', $params); } /** @@ -764,7 +764,7 @@ class attforblock { */ public function url_preferences($params=array()) { $params = array_merge(array('id' => $this->cm->id), $params); - return new moodle_url('/mod/attforblock/preferences.php', $params); + return new moodle_url('/mod/attendance/preferences.php', $params); } /** @@ -772,12 +772,12 @@ class attforblock { */ public function url_take($params=array()) { $params = array_merge(array('id' => $this->cm->id), $params); - return new moodle_url('/mod/attforblock/take.php', $params); + return new moodle_url('/mod/attendance/take.php', $params); } public function url_view($params=array()) { $params = array_merge(array('id' => $this->cm->id), $params); - return new moodle_url('/mod/attforblock/view.php', $params); + return new moodle_url('/mod/attendance/view.php', $params); } public function add_sessions($sessions) { @@ -788,7 +788,7 @@ class attforblock { $sess->id = $DB->insert_record('attendance_sessions', $sess); $description = file_save_draft_area_files($sess->descriptionitemid, - $this->context->id, 'mod_attforblock', 'session', $sess->id, + $this->context->id, 'mod_attendance', 'session', $sess->id, array('subdirs' => false, 'maxfiles' => -1, 'maxbytes' => 0), $sess->description); $DB->set_field('attendance_sessions', 'description', $description, array('id' => $sess->id)); @@ -812,7 +812,7 @@ class attforblock { $sess->sessdate = $formdata->sessiondate; $sess->duration = $formdata->durtime['hours']*HOURSECS + $formdata->durtime['minutes']*MINSECS; $description = file_save_draft_area_files($formdata->sdescription['itemid'], - $this->context->id, 'mod_attforblock', 'session', $sessionid, + $this->context->id, 'mod_attendance', 'session', $sessionid, array('subdirs' => false, 'maxfiles' => -1, 'maxbytes' => 0), $formdata->sdescription['text']); $sess->description = $description; $sess->descriptionformat = $formdata->sdescription['format']; @@ -873,7 +873,7 @@ class attforblock { $url = $this->url_take($params); $this->log('attendance taked', $url, $USER->firstname.' '.$USER->lastname); - redirect($this->url_manage(), get_string('attendancesuccess', 'attforblock')); + redirect($this->url_manage(), get_string('attendancesuccess', 'attendance')); } /** @@ -891,7 +891,7 @@ class attforblock { $orderby = "u.lastname ASC, u.firstname ASC"; } - $users = get_enrolled_users($this->context, 'mod/attforblock:canbelisted', $groupid, $userfields, $orderby); + $users = get_enrolled_users($this->context, 'mod/attendance:canbelisted', $groupid, $userfields, $orderby); // Add a flag to each user indicating whether their enrolment is active. if (!empty($users)) { @@ -955,10 +955,10 @@ class attforblock { $this->sessioninfo[$sessionid] = $DB->get_record('attendance_sessions', array('id' => $sessionid)); } if (empty($this->sessioninfo[$sessionid]->description)) { - $this->sessioninfo[$sessionid]->description = get_string('nodescription', 'attforblock'); + $this->sessioninfo[$sessionid]->description = get_string('nodescription', 'attendance'); } else { $this->sessioninfo[$sessionid]->description = file_rewrite_pluginfile_urls($this->sessioninfo[$sessionid]->description, - 'pluginfile.php', $this->context->id, 'mod_attforblock', 'session', $this->sessioninfo[$sessionid]->id); + 'pluginfile.php', $this->context->id, 'mod_attendance', 'session', $this->sessioninfo[$sessionid]->id); } return $this->sessioninfo[$sessionid]; } @@ -971,10 +971,10 @@ class attforblock { foreach ($sessions as $sess) { if (empty($sess->description)) { - $sess->description = get_string('nodescription', 'attforblock'); + $sess->description = get_string('nodescription', 'attendance'); } else { $sess->description = file_rewrite_pluginfile_urls($sess->description, - 'pluginfile.php', $this->context->id, 'mod_attforblock', 'session', $sess->id); + 'pluginfile.php', $this->context->id, 'mod_attendance', 'session', $sess->id); } } @@ -1050,7 +1050,7 @@ class attforblock { $this->get_user_max_grade($userid)) * $this->grade; } - return grade_update('mod/attforblock', $this->course->id, 'mod', 'attforblock', + return grade_update('mod/attendance', $this->course->id, 'mod', 'attendance', $this->id, 0, $grades); } @@ -1134,10 +1134,10 @@ class attforblock { foreach ($sessions as $sess) { if (empty($sess->description)) { - $sess->description = get_string('nodescription', 'attforblock'); + $sess->description = get_string('nodescription', 'attendance'); } else { $sess->description = file_rewrite_pluginfile_urls($sess->description, - 'pluginfile.php', $this->context->id, 'mod_attforblock', 'session', $sess->id); + 'pluginfile.php', $this->context->id, 'mod_attendance', 'session', $sess->id); } } @@ -1151,7 +1151,7 @@ class attforblock { $DB->delete_records_select('attendance_log', "sessionid $sql", $params); $DB->delete_records_list('attendance_sessions', 'id', $sessionsids); - $this->log('sessions deleted', null, get_string('sessionsids', 'attforblock').implode(', ', $sessionsids)); + $this->log('sessions deleted', null, get_string('sessionsids', 'attendance').implode(', ', $sessionsids)); } public function update_sessions_duration($sessionsids, $duration) { @@ -1166,7 +1166,7 @@ class attforblock { } $this->log('sessions duration updated', $this->url_manage(), - get_string('sessionsids', 'attforblock').implode(', ', $sessionsids)); + get_string('sessionsids', 'attendance').implode(', ', $sessionsids)); } public function remove_status($statusid) { @@ -1189,7 +1189,7 @@ class attforblock { $this->log('status added', $this->url_preferences(), $acronym.': '.$description.' ('.$grade.')'); } else { - print_error('cantaddstatus', 'attforblock', $this->url_preferences()); + print_error('cantaddstatus', 'attendance', $this->url_preferences()); } } @@ -1238,7 +1238,7 @@ class attforblock { } $logurl = att_log_convert_url($url); - add_to_log($this->course->id, 'attforblock', $action, $logurl, $info, $this->cm->id); + add_to_log($this->course->id, 'attendance', $action, $logurl, $info, $this->cm->id); } } @@ -1317,7 +1317,7 @@ function att_get_user_courses_attendances($userid) { $sql = "SELECT att.id as attid, att.course as courseid, course.fullname as coursefullname, course.startdate as coursestartdate, att.name as attname, att.grade as attgrade - FROM {attforblock} att + FROM {attendance} att JOIN {course} course ON att.course = course.id WHERE att.course $usql @@ -1339,13 +1339,13 @@ function att_calc_user_grade_fraction($grade, $maxgrade) { function att_get_gradebook_maxgrade($attid) { global $DB; - return $DB->get_field('attforblock', 'grade', array('id' => $attid)); + return $DB->get_field('attendance', 'grade', array('id' => $attid)); } function att_update_all_users_grades($attid, $course, $context) { $grades = array(); - $userids = array_keys(get_enrolled_users($context, 'mod/attforblock:canbelisted', 0, 'u.id')); + $userids = array_keys(get_enrolled_users($context, 'mod/attendance:canbelisted', 0, 'u.id')); $statuses = att_get_statuses($attid); $gradebook_maxgrade = att_get_gradebook_maxgrade($attid); @@ -1360,7 +1360,7 @@ function att_update_all_users_grades($attid, $course, $context) { $grades[$userid] = $grade; } - return grade_update('mod/attforblock', $course->id, 'mod', 'attforblock', + return grade_update('mod/attendance', $course->id, 'mod', 'attendance', $attid, 0, $grades); } @@ -1374,9 +1374,33 @@ function att_log_convert_url(moodle_url $fullurl) { static $baseurl; if (!isset($baseurl)) { - $baseurl = new moodle_url('/mod/attforblock/'); + $baseurl = new moodle_url('/mod/attendance/'); $baseurl = $baseurl->out(); } return substr($fullurl->out(), strlen($baseurl)); } + +function attforblock_upgrade() { + global $DB, $CFG; + $module = $DB->get_record('modules', array('name' => 'attforblock')); + if ($module->version !== '2012120700') { + print_error("noupgradefromthisversion", 'attendance'); + } + if (file_exists($CFG->dirroot.'/mod/attforblock')) { + print_error("attforblockdirstillexists", 'attendance'); + } + + // Now rename attforblock table and replace with attendance? + $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes. + $table = new xmldb_table('attforblock'); + $newtable = new xmldb_table('attendance'); // Sanity check to make sure 'attendance' table doesn't already exist. + if ($dbman->table_exists($table) && !$dbman->table_exists($newtable)) { + $dbman->rename_table($table, 'attendance'); + } else { + print_error("tablerenamefailed", 'attendance'); + } + // Now convert module record. + $module->name = 'attendance'; + $DB->update_record('modules', $module); +} \ No newline at end of file diff --git a/manage.php b/manage.php index e8d9bbc..03a394c 100644 --- a/manage.php +++ b/manage.php @@ -17,7 +17,7 @@ /** * Manage attendance sessions * - * @package mod_attforblock + * @package mod_attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -32,14 +32,14 @@ $from = optional_param('from', null, PARAM_ALPHANUMEXT); $pageparams->view = optional_param('view', null, PARAM_INT); $pageparams->curdate = optional_param('curdate', null, PARAM_INT); -$cm = get_coursemodule_from_id('attforblock', $id, 0, false, MUST_EXIST); +$cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attforblock', array('id' => $cm->instance), '*', MUST_EXIST); +$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); require_login($course, true, $cm); $pageparams->init($cm); -$att = new attforblock($att, $cm, $course, $PAGE->context, $pageparams); +$att = new attendance($att, $cm, $course, $PAGE->context, $pageparams); if (!$att->perm->can_manage() && !$att->perm->can_take() && !$att->perm->can_change()) { redirect($att->url_view()); } @@ -50,8 +50,8 @@ if ($from === 'block') { $size = count($sessions); if ($size == 1) { $sess = reset($sessions); - $nottaken = !$sess->lasttaken && has_capability('mod/attforblock:takeattendances', $PAGE->context); - $canchange = $sess->lasttaken && has_capability('mod/attforblock:changeattendances', $PAGE->context); + $nottaken = !$sess->lasttaken && has_capability('mod/attendance:takeattendances', $PAGE->context); + $canchange = $sess->lasttaken && has_capability('mod/attendance:changeattendances', $PAGE->context); if ($nottaken || $canchange) { redirect($att->url_take(array('sessionid' => $sess->id, 'grouptype' => $sess->groupid))); } @@ -66,18 +66,18 @@ $PAGE->set_url($att->url_manage()); $PAGE->set_title($course->shortname. ": ".$att->name); $PAGE->set_heading($course->fullname); $PAGE->set_cacheable(true); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attforblock')); +$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attendance')); $PAGE->navbar->add($att->name); -$output = $PAGE->get_renderer('mod_attforblock'); -$tabs = new attforblock_tabs($att, attforblock_tabs::TAB_SESSIONS); -$filtercontrols = new attforblock_filter_controls($att); -$sesstable = new attforblock_manage_data($att); +$output = $PAGE->get_renderer('mod_attendance'); +$tabs = new attendance_tabs($att, attendance_tabs::TAB_SESSIONS); +$filtercontrols = new attendance_filter_controls($att); +$sesstable = new attendance_manage_data($att); // Output starts here. echo $output->header(); -echo $output->heading(get_string('attendanceforthecourse', 'attforblock').' :: ' .$course->fullname); +echo $output->heading(get_string('attendanceforthecourse', 'attendance').' :: ' .$course->fullname); echo $output->render($tabs); echo $output->render($filtercontrols); echo $output->render($sesstable); diff --git a/mod_form.php b/mod_form.php index 96e2666..e631205 100644 --- a/mod_form.php +++ b/mod_form.php @@ -15,9 +15,9 @@ // along with Moodle. If not, see . /** - * Forms for updating/adding attforblock + * Forms for updating/adding attendance * - * @package mod_attforblock + * @package mod_attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -28,7 +28,7 @@ if (!defined('MOODLE_INTERNAL')) { require_once($CFG->dirroot.'/course/moodleform_mod.php'); -class mod_attforblock_mod_form extends moodleform_mod { +class mod_attendance_mod_form extends moodleform_mod { public function definition() { @@ -40,7 +40,7 @@ class mod_attforblock_mod_form extends moodleform_mod { $mform->addElement('text', 'name', get_string('name'), array('size'=>'64')); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'required', null, 'client'); - $mform->setDefault('name', get_string('modulename', 'attforblock')); + $mform->setDefault('name', get_string('modulename', 'attendance')); $mform->addElement('modgrade', 'grade', get_string('grade')); $mform->setDefault('grade', 100); diff --git a/module.js b/module.js index a40b58c..31a4289 100644 --- a/module.js +++ b/module.js @@ -1,6 +1,6 @@ -M.mod_attforblock = {} +M.mod_attendance = {} -M.mod_attforblock.init_manage = function(Y) { +M.mod_attendance.init_manage = function(Y) { Y.on('click', function(e) { if (e.target.get('checked')) { @@ -11,7 +11,7 @@ M.mod_attforblock.init_manage = function(Y) { }, '#cb_selector' ); }; -M.mod_attforblock.set_preferences_action = function(action) { +M.mod_attendance.set_preferences_action = function(action) { var item = document.getElementById('preferencesaction'); if (item) { item.setAttribute('value', action); diff --git a/preferences.php b/preferences.php index 55982a9..b597958 100644 --- a/preferences.php +++ b/preferences.php @@ -17,7 +17,7 @@ /** * Manage attendance settings * - * @package mod_attforblock + * @package mod_attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -31,22 +31,22 @@ $id = required_param('id', PARAM_INT); $pageparams->action = optional_param('action', null, PARAM_INT); $pageparams->statusid = optional_param('statusid', null, PARAM_INT); -$cm = get_coursemodule_from_id('attforblock', $id, 0, false, MUST_EXIST); +$cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attforblock', array('id' => $cm->instance), '*', MUST_EXIST); +$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); require_login($course, true, $cm); -$att = new attforblock($att, $cm, $course, $PAGE->context, $pageparams); +$att = new attendance($att, $cm, $course, $PAGE->context, $pageparams); $att->perm->require_change_preferences_capability(); $PAGE->set_url($att->url_preferences()); -$PAGE->set_title($course->shortname. ": ".$att->name.' - '.get_string('settings', 'attforblock')); +$PAGE->set_title($course->shortname. ": ".$att->name.' - '.get_string('settings', 'attendance')); $PAGE->set_heading($course->fullname); $PAGE->set_cacheable(true); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attforblock')); -$PAGE->navbar->add(get_string('settings', 'attforblock')); +$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attendance')); +$PAGE->navbar->add(get_string('settings', 'attendance')); switch ($att->pageparams->action) { case att_preferences_page_params::ACTION_ADD: @@ -58,24 +58,24 @@ switch ($att->pageparams->action) { break; case att_preferences_page_params::ACTION_DELETE: if (att_has_logs_for_status($att->pageparams->statusid)) { - print_error('cantdeletestatus', 'attforblock', "attsettings.php?id=$id"); + print_error('cantdeletestatus', 'attendance', "attsettings.php?id=$id"); } $confirm = optional_param('confirm', null, PARAM_INT); if (isset($confirm)) { $att->remove_status($att->pageparams->statusid); - redirect($att->url_preferences(), get_string('statusdeleted', 'attforblock')); + redirect($att->url_preferences(), get_string('statusdeleted', 'attendance')); } $statuses = $att->get_statuses(); $status = $statuses[$att->pageparams->statusid]; - $message = get_string('deletecheckfull', '', get_string('variable', 'attforblock')); + $message = get_string('deletecheckfull', '', get_string('variable', 'attendance')); $message .= str_repeat(html_writer::empty_tag('br'), 2); $message .= $status->acronym.': '. - ($status->description ? $status->description : get_string('nodescription', 'attforblock')); + ($status->description ? $status->description : get_string('nodescription', 'attendance')); $params = array_merge($att->pageparams->get_significant_params(), array('confirm' => 1)); echo $OUTPUT->header(); - echo $OUTPUT->heading(get_string('attendanceforthecourse', 'attforblock').' :: ' .$course->fullname); + echo $OUTPUT->heading(get_string('attendanceforthecourse', 'attendance').' :: ' .$course->fullname); echo $OUTPUT->confirm($message, $att->url_preferences($params), $att->url_preferences()); echo $OUTPUT->footer(); exit; @@ -97,14 +97,14 @@ switch ($att->pageparams->action) { break; } -$output = $PAGE->get_renderer('mod_attforblock'); -$tabs = new attforblock_tabs($att, attforblock_tabs::TAB_PREFERENCES); -$prefdata = new attforblock_preferences_data($att); +$output = $PAGE->get_renderer('mod_attendance'); +$tabs = new attendance_tabs($att, attendance_tabs::TAB_PREFERENCES); +$prefdata = new attendance_preferences_data($att); // Output starts here. echo $output->header(); -echo $output->heading(get_string('attendanceforthecourse', 'attforblock').' :: ' .$course->fullname); +echo $output->heading(get_string('attendanceforthecourse', 'attendance').' :: ' .$course->fullname); echo $output->render($tabs); echo $output->render($prefdata); diff --git a/renderables.php b/renderables.php index e8a9b0e..fb4a44b 100644 --- a/renderables.php +++ b/renderables.php @@ -17,7 +17,7 @@ /** * Attendance module renderable components are defined here * - * @package mod_attforblock + * @package mod_attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -30,10 +30,10 @@ require_once(dirname(__FILE__).'/locallib.php'); /** * Represents info about attendance tabs. * - * Proxy class for security reasons (renderers must not have access to all attforblock methods) + * Proxy class for security reasons (renderers must not have access to all attendance methods) * */ -class attforblock_tabs implements renderable { +class attendance_tabs implements renderable { const TAB_SESSIONS = 1; const TAB_ADD = 2; const TAB_REPORT = 3; @@ -42,16 +42,16 @@ class attforblock_tabs implements renderable { public $currenttab; - /** @var attforblock */ + /** @var attendance */ private $att; /** * Prepare info about sessions for attendance taking into account view parameters. * - * @param attforblock $att instance - * @param $currenttab - one of attforblock_tabs constants + * @param attendance $att instance + * @param $currenttab - one of attendance_tabs constants */ - public function __construct(attforblock $att, $currenttab=null) { + public function __construct(attendance $att, $currenttab=null) { $this->att = $att; $this->currenttab = $currenttab; } @@ -66,18 +66,18 @@ class attforblock_tabs implements renderable { $this->att->perm->can_take() or $this->att->perm->can_change()) { $toprow[] = new tabobject(self::TAB_SESSIONS, $this->att->url_manage()->out(), - get_string('sessions', 'attforblock')); + get_string('sessions', 'attendance')); } if ($this->att->perm->can_manage()) { $toprow[] = new tabobject(self::TAB_ADD, $this->att->url_sessions()->out(true, array('action' => att_sessions_page_params::ACTION_ADD)), - get_string('add', 'attforblock')); + get_string('add', 'attendance')); } if ($this->att->perm->can_view_reports()) { $toprow[] = new tabobject(self::TAB_REPORT, $this->att->url_report()->out(), - get_string('report', 'attforblock')); + get_string('report', 'attendance')); } if ($this->att->perm->can_export()) { @@ -87,7 +87,7 @@ class attforblock_tabs implements renderable { if ($this->att->perm->can_change_preferences()) { $toprow[] = new tabobject(self::TAB_PREFERENCES, $this->att->url_preferences()->out(), - get_string('settings', 'attforblock')); + get_string('settings', 'attendance')); } return array($toprow); @@ -95,7 +95,7 @@ class attforblock_tabs implements renderable { } -class attforblock_filter_controls implements renderable { +class attendance_filter_controls implements renderable { /** @var int current view mode */ public $pageparams; @@ -112,7 +112,7 @@ class attforblock_filter_controls implements renderable { private $att; - public function __construct(attforblock $att) { + public function __construct(attendance $att) { global $PAGE; $this->pageparams = $att->pageparams; @@ -129,13 +129,13 @@ class attforblock_filter_controls implements renderable { switch ($this->pageparams->view) { case ATT_VIEW_DAYS: - $format = get_string('strftimedm', 'attforblock'); + $format = get_string('strftimedm', 'attendance'); $this->prevcur = make_timestamp($year, $mon, $mday - 1); $this->nextcur = make_timestamp($year, $mon, $mday + 1); $this->curdatetxt = userdate($att->pageparams->startdate, $format); break; case ATT_VIEW_WEEKS: - $format = get_string('strftimedm', 'attforblock'); + $format = get_string('strftimedm', 'attendance'); $this->prevcur = $att->pageparams->startdate - WEEKSECS; $this->nextcur = $att->pageparams->startdate + WEEKSECS; $this->curdatetxt = userdate($att->pageparams->startdate, $format). @@ -190,28 +190,28 @@ class attforblock_filter_controls implements renderable { * Represents info about attendance sessions taking into account view parameters. * */ -class attforblock_manage_data implements renderable { +class attendance_manage_data implements renderable { /** @var array of sessions*/ public $sessions; /** @var int number of hidden sessions (sessions before $course->startdate)*/ public $hiddensessionscount; - /** @var attforblock_permissions permission of current user for attendance instance*/ + /** @var attendance_permissions permission of current user for attendance instance*/ public $perm; public $groups; public $hiddensesscount; - /** @var attforblock */ + /** @var attendance */ private $att; /** * Prepare info about attendance sessions taking into account view parameters. * - * @param attforblock $att instance + * @param attendance $att instance */ - public function __construct(attforblock $att) { + public function __construct(attendance $att) { $this->perm = $att->perm; $this->sessions = $att->get_filtered_sessions(); @@ -235,7 +235,7 @@ class attforblock_manage_data implements renderable { } } -class attforblock_take_data implements renderable { +class attendance_take_data implements renderable { public $users; public $pageparams; @@ -258,7 +258,7 @@ class attforblock_take_data implements renderable { private $urlparams; private $att; - public function __construct(attforblock $att) { + public function __construct(attendance $att) { if ($att->pageparams->grouptype) { $this->users = $att->get_users($att->pageparams->grouptype); } else { @@ -315,7 +315,7 @@ class attforblock_take_data implements renderable { } } -class attforblock_user_data implements renderable { +class attendance_user_data implements renderable { public $user; public $pageparams; @@ -343,7 +343,7 @@ class attforblock_user_data implements renderable { private $urlpath; private $urlparams; - public function __construct(attforblock $att, $userid) { + public function __construct(attendance $att, $userid) { global $CFG; $this->user = $att->get_user($userid); @@ -365,7 +365,7 @@ class attforblock_user_data implements renderable { $this->maxgrade = $att->get_user_max_grade($userid); } - $this->filtercontrols = new attforblock_filter_controls($att); + $this->filtercontrols = new attendance_filter_controls($att); $this->sessionslog = $att->get_user_filtered_sessions_log_extended($userid); @@ -417,7 +417,7 @@ class attforblock_user_data implements renderable { } } -class attforblock_report_data implements renderable { +class attendance_report_data implements renderable { public $perm; public $pageparams; @@ -447,7 +447,7 @@ class attforblock_report_data implements renderable { private $att; - public function __construct(attforblock $att) { + public function __construct(attendance $att) { global $CFG; $this->perm = $att->perm; @@ -500,12 +500,12 @@ class attforblock_report_data implements renderable { } -class attforblock_preferences_data implements renderable { +class attendance_preferences_data implements renderable { public $statuses; private $att; - public function __construct(attforblock $att) { + public function __construct(attendance $att) { $this->statuses = $att->get_statuses(false); foreach ($this->statuses as $st) { diff --git a/renderer.php b/renderer.php index 25cabac..635ba55 100644 --- a/renderer.php +++ b/renderer.php @@ -17,7 +17,7 @@ /** * Attendance module renderering methods * - * @package mod_attforblock + * @package mod_attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -33,7 +33,7 @@ require_once(dirname(__FILE__).'/renderhelpers.php'); * * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class mod_attforblock_renderer extends plugin_renderer_base { +class mod_attendance_renderer extends plugin_renderer_base { // External API - methods to render attendance renderable components. /** @@ -42,7 +42,7 @@ class mod_attforblock_renderer extends plugin_renderer_base { * @param atttabs - tabs to display * @return string html code */ - protected function render_attforblock_tabs(attforblock_tabs $atttabs) { + protected function render_attendance_tabs(attendance_tabs $atttabs) { return print_tabs($atttabs->get_tabs(), $atttabs->currenttab, null, null, true); } @@ -52,7 +52,7 @@ class mod_attforblock_renderer extends plugin_renderer_base { * @param fcontrols - filter controls data to display * @return string html code */ - protected function render_attforblock_filter_controls(attforblock_filter_controls $fcontrols) { + protected function render_attendance_filter_controls(attendance_filter_controls $fcontrols) { $filtertable = new html_table(); $filtertable->attributes['class'] = ' '; $filtertable->width = '100%'; @@ -70,14 +70,14 @@ class mod_attforblock_renderer extends plugin_renderer_base { return $o; } - protected function render_sess_group_selector(attforblock_filter_controls $fcontrols) { + protected function render_sess_group_selector(attendance_filter_controls $fcontrols) { switch ($fcontrols->pageparams->selectortype) { case att_page_with_filter_controls::SELECTOR_SESS_TYPE: $sessgroups = $fcontrols->get_sess_groups_list(); if ($sessgroups) { $select = new single_select($fcontrols->url(), 'group', $sessgroups, $fcontrols->get_current_sesstype(), null, 'selectgroup'); - $select->label = get_string('sessions', 'attforblock'); + $select->label = get_string('sessions', 'attendance'); $output = $this->output->render($select); return html_writer::tag('div', $output, array('class' => 'groupselector')); @@ -90,25 +90,25 @@ class mod_attforblock_renderer extends plugin_renderer_base { return ''; } - protected function render_curdate_controls(attforblock_filter_controls $fcontrols) { + protected function render_curdate_controls(attendance_filter_controls $fcontrols) { global $CFG; $curdate_controls = ''; if ($fcontrols->curdatetxt) { - $this->page->requires->strings_for_js(array('calclose', 'caltoday'), 'attforblock'); + $this->page->requires->strings_for_js(array('calclose', 'caltoday'), 'attendance'); $jsvals = array( - 'cal_months' => explode(',', get_string('calmonths', 'attforblock')), - 'cal_week_days' => explode(',', get_string('calweekdays', 'attforblock')), + 'cal_months' => explode(',', get_string('calmonths', 'attendance')), + 'cal_week_days' => explode(',', get_string('calweekdays', 'attendance')), 'cal_start_weekday' => $CFG->calendar_startwday, 'cal_cur_date' => $fcontrols->curdate); - $curdate_controls = html_writer::script(js_writer::set_variable('M.attforblock', $jsvals)); + $curdate_controls = html_writer::script(js_writer::set_variable('M.attendance', $jsvals)); - $this->page->requires->js('/mod/attforblock/calendar.js'); + $this->page->requires->js('/mod/attendance/calendar.js'); $curdate_controls .= html_writer::link($fcontrols->url(array('curdate' => $fcontrols->prevcur)), $this->output->larrow()); $params = array( - 'title' => get_string('calshow', 'attforblock'), + 'title' => get_string('calshow', 'attendance'), 'id' => 'show', 'type' => 'button'); $button_form = html_writer::tag('button', $fcontrols->curdatetxt, $params); @@ -136,12 +136,12 @@ class mod_attforblock_renderer extends plugin_renderer_base { return $curdate_controls; } - protected function render_view_controls(attforblock_filter_controls $fcontrols) { - $views[ATT_VIEW_ALL] = get_string('all', 'attforblock'); - $views[ATT_VIEW_ALLPAST] = get_string('allpast', 'attforblock'); - $views[ATT_VIEW_MONTHS] = get_string('months', 'attforblock'); - $views[ATT_VIEW_WEEKS] = get_string('weeks', 'attforblock'); - $views[ATT_VIEW_DAYS] = get_string('days', 'attforblock'); + protected function render_view_controls(attendance_filter_controls $fcontrols) { + $views[ATT_VIEW_ALL] = get_string('all', 'attendance'); + $views[ATT_VIEW_ALLPAST] = get_string('allpast', 'attendance'); + $views[ATT_VIEW_MONTHS] = get_string('months', 'attendance'); + $views[ATT_VIEW_WEEKS] = get_string('weeks', 'attendance'); + $views[ATT_VIEW_DAYS] = get_string('days', 'attendance'); $viewcontrols = ''; foreach ($views as $key => $sview) { if ($key != $fcontrols->pageparams->view) { @@ -158,10 +158,10 @@ class mod_attforblock_renderer extends plugin_renderer_base { /** * Renders attendance sessions managing table * - * @param attforblock_manage_data $sessdata to display + * @param attendance_manage_data $sessdata to display * @return string html code */ - protected function render_attforblock_manage_data(attforblock_manage_data $sessdata) { + protected function render_attendance_manage_data(attendance_manage_data $sessdata) { $o = $this->render_sess_manage_table($sessdata) . $this->render_sess_manage_control($sessdata); $o = html_writer::tag('form', $o, array('method' => 'post', 'action' => $sessdata->url_sessions()->out())); $o = $this->output->container($o, 'generalbox attwidth'); @@ -170,17 +170,17 @@ class mod_attforblock_renderer extends plugin_renderer_base { return $o; } - protected function render_sess_manage_table(attforblock_manage_data $sessdata) { - $this->page->requires->js_init_call('M.mod_attforblock.init_manage'); + protected function render_sess_manage_table(attendance_manage_data $sessdata) { + $this->page->requires->js_init_call('M.mod_attendance.init_manage'); $table = new html_table(); $table->width = '100%'; $table->head = array( '#', - get_string('sessiontypeshort', 'attforblock'), + get_string('sessiontypeshort', 'attendance'), get_string('date'), get_string('time'), - get_string('description', 'attforblock'), + get_string('description', 'attendance'), get_string('actions'), html_writer::checkbox('cb_selector', 0, false, '', array('id' => 'cb_selector')) ); @@ -195,7 +195,7 @@ class mod_attforblock_renderer extends plugin_renderer_base { $table->data[$sess->id][] = $i; $table->data[$sess->id][] = $sess->groupid ? $sessdata->groups[$sess->groupid]->name : - get_string('commonsession', 'attforblock'); + get_string('commonsession', 'attendance'); $table->data[$sess->id][] = $dta['date']; $table->data[$sess->id][] = $dta['time']; $table->data[$sess->id][] = $sess->description; @@ -206,20 +206,20 @@ class mod_attforblock_renderer extends plugin_renderer_base { return html_writer::table($table); } - private function construct_date_time_actions(attforblock_manage_data $sessdata, $sess) { + private function construct_date_time_actions(attendance_manage_data $sessdata, $sess) { $actions = ''; - $date = userdate($sess->sessdate, get_string('strftimedmyw', 'attforblock')); + $date = userdate($sess->sessdate, get_string('strftimedmyw', 'attendance')); $time = $this->construct_time($sess->sessdate, $sess->duration); if ($sess->lasttaken > 0) { if ($sessdata->perm->can_change()) { $url = $sessdata->url_take($sess->id, $sess->groupid); - $title = get_string('changeattendance', 'attforblock'); + $title = get_string('changeattendance', 'attendance'); $date = html_writer::link($url, $date, array('title' => $title)); $time = html_writer::link($url, $time, array('title' => $title)); - $actions = $this->output->action_icon($url, new pix_icon('redo', $title, 'attforblock')); + $actions = $this->output->action_icon($url, new pix_icon('redo', $title, 'attendance')); } else { $date = '' . $date . ''; $time = '' . $time . ''; @@ -227,36 +227,36 @@ class mod_attforblock_renderer extends plugin_renderer_base { } else { if ($sessdata->perm->can_take()) { $url = $sessdata->url_take($sess->id, $sess->groupid); - $title = get_string('takeattendance', 'attforblock'); + $title = get_string('takeattendance', 'attendance'); $actions = $this->output->action_icon($url, new pix_icon('t/go', $title)); } } if ($sessdata->perm->can_manage()) { $url = $sessdata->url_sessions($sess->id, att_sessions_page_params::ACTION_UPDATE); - $title = get_string('editsession', 'attforblock'); + $title = get_string('editsession', 'attendance'); $actions .= $this->output->action_icon($url, new pix_icon('t/edit', $title)); $url = $sessdata->url_sessions($sess->id, att_sessions_page_params::ACTION_DELETE); - $title = get_string('deletesession', 'attforblock'); + $title = get_string('deletesession', 'attendance'); $actions .= $this->output->action_icon($url, new pix_icon('t/delete', $title)); } return array('date' => $date, 'time' => $time, 'actions' => $actions); } - protected function render_sess_manage_control(attforblock_manage_data $sessdata) { + protected function render_sess_manage_control(attendance_manage_data $sessdata) { $table = new html_table(); $table->attributes['class'] = ' '; $table->width = '100%'; $table->align = array('left', 'right'); - $table->data[0][] = $this->output->help_icon('hiddensessions', 'attforblock', - get_string('hiddensessions', 'attforblock').': '.$sessdata->hiddensessionscount); + $table->data[0][] = $this->output->help_icon('hiddensessions', 'attendance', + get_string('hiddensessions', 'attendance').': '.$sessdata->hiddensessionscount); if ($sessdata->perm->can_manage()) { $options = array( att_sessions_page_params::ACTION_DELETE_SELECTED => get_string('delete'), - att_sessions_page_params::ACTION_CHANGE_DURATION => get_string('changeduration', 'attforblock')); + att_sessions_page_params::ACTION_CHANGE_DURATION => get_string('changeduration', 'attendance')); $controls = html_writer::select($options, 'action'); $attributes = array( 'type' => 'submit', @@ -264,32 +264,32 @@ class mod_attforblock_renderer extends plugin_renderer_base { 'value' => get_string('ok')); $controls .= html_writer::empty_tag('input', $attributes); } else { - $controls = get_string('youcantdo', 'attforblock'); // You can't do anything. + $controls = get_string('youcantdo', 'attendance'); // You can't do anything. } $table->data[0][] = $controls; return html_writer::table($table); } - protected function render_attforblock_take_data(attforblock_take_data $takedata) { - $controls = $this->render_attforblock_take_controls($takedata); + protected function render_attendance_take_data(attendance_take_data $takedata) { + $controls = $this->render_attendance_take_controls($takedata); if ($takedata->pageparams->viewmode == att_take_page_params::SORTED_LIST) { - $table = $this->render_attforblock_take_list($takedata); + $table = $this->render_attendance_take_list($takedata); } else { - $table = $this->render_attforblock_take_grid($takedata); + $table = $this->render_attendance_take_grid($takedata); } $table .= html_writer::input_hidden_params($takedata->url()); $params = array( 'type' => 'submit', - 'value' => get_string('save', 'attforblock')); + 'value' => get_string('save', 'attendance')); $table .= html_writer::tag('center', html_writer::empty_tag('input', $params)); $table = html_writer::tag('form', $table, array('method' => 'post', 'action' => $takedata->url_path())); return $controls.$table; } - protected function render_attforblock_take_controls(attforblock_take_data $takedata) { + protected function render_attendance_take_controls(attendance_take_data $takedata) { $table = new html_table(); $table->attributes['class'] = ' '; @@ -299,11 +299,11 @@ class mod_attforblock_renderer extends plugin_renderer_base { return $this->output->container(html_writer::table($table), 'generalbox takecontrols'); } - private function construct_take_session_info(attforblock_take_data $takedata) { + private function construct_take_session_info(attendance_take_data $takedata) { $sess = $takedata->sessioninfo; $date = userdate($sess->sessdate, get_string('strftimedate')); - $starttime = userdate($sess->sessdate, get_string('strftimehm', 'attforblock')); - $endtime = userdate($sess->sessdate + $sess->duration, get_string('strftimehm', 'attforblock')); + $starttime = userdate($sess->sessdate, get_string('strftimehm', 'attendance')); + $endtime = userdate($sess->sessdate + $sess->duration, get_string('strftimehm', 'attendance')); $time = html_writer::tag('nobr', $starttime . ($sess->duration > 0 ? ' - ' . $endtime : '')); $sessinfo = $date.' '.$time; $sessinfo .= html_writer::empty_tag('br'); @@ -313,9 +313,9 @@ class mod_attforblock_renderer extends plugin_renderer_base { return $sessinfo; } - private function construct_take_controls(attforblock_take_data $takedata) { + private function construct_take_controls(attendance_take_data $takedata) { $controls = ''; - if ($takedata->pageparams->grouptype == attforblock::SESSION_COMMON and + if ($takedata->pageparams->grouptype == attendance::SESSION_COMMON and ($takedata->groupmode == VISIBLEGROUPS or ($takedata->groupmode and $takedata->perm->can_access_all_groups()))) { $controls .= groups_print_activity_menu($takedata->cm, $takedata->url(), true); @@ -324,19 +324,19 @@ class mod_attforblock_renderer extends plugin_renderer_base { $controls .= html_writer::empty_tag('br'); $options = array( - att_take_page_params::SORTED_LIST => get_string('sortedlist', 'attforblock'), - att_take_page_params::SORTED_GRID => get_string('sortedgrid', 'attforblock')); + att_take_page_params::SORTED_LIST => get_string('sortedlist', 'attendance'), + att_take_page_params::SORTED_GRID => get_string('sortedgrid', 'attendance')); $select = new single_select($takedata->url(), 'viewmode', $options, $takedata->pageparams->viewmode, null); - $select->set_label(get_string('viewmode', 'attforblock')); + $select->set_label(get_string('viewmode', 'attendance')); $select->class = 'singleselect inline'; $controls .= $this->output->render($select); if ($takedata->pageparams->viewmode == att_take_page_params::SORTED_GRID) { - $options = array (1 => '1 '.get_string('column', 'attforblock'), '2 '.get_string('columns', 'attforblock'), - '3 '.get_string('columns', 'attforblock'), '4 '.get_string('columns', 'attforblock'), - '5 '.get_string('columns', 'attforblock'), '6 '.get_string('columns', 'attforblock'), - '7 '.get_string('columns', 'attforblock'), '8 '.get_string('columns', 'attforblock'), - '9 '.get_string('columns', 'attforblock'), '10 '.get_string('columns', 'attforblock')); + $options = array (1 => '1 '.get_string('column', 'attendance'), '2 '.get_string('columns', 'attendance'), + '3 '.get_string('columns', 'attendance'), '4 '.get_string('columns', 'attendance'), + '5 '.get_string('columns', 'attendance'), '6 '.get_string('columns', 'attendance'), + '7 '.get_string('columns', 'attendance'), '8 '.get_string('columns', 'attendance'), + '9 '.get_string('columns', 'attendance'), '10 '.get_string('columns', 'attendance')); $select = new single_select($takedata->url(), 'gridcols', $options, $takedata->pageparams->gridcols, null); $select->class = 'singleselect inline'; $controls .= $this->output->render($select); @@ -348,13 +348,13 @@ class mod_attforblock_renderer extends plugin_renderer_base { $options = array(); foreach ($takedata->sessions4copy as $sess) { - $start = userdate($sess->sessdate, get_string('strftimehm', 'attforblock')); + $start = userdate($sess->sessdate, get_string('strftimehm', 'attendance')); $end = $sess->duration ? ' - '.userdate($sess->sessdate + $sess->duration, - get_string('strftimehm', 'attforblock')) : ''; + get_string('strftimehm', 'attendance')) : ''; $options[$sess->id] = $start . $end; } $select = new single_select($takedata->url(array(), array('copyfrom')), 'copyfrom', $options); - $select->set_label(get_string('copyfrom', 'attforblock')); + $select->set_label(get_string('copyfrom', 'attendance')); $select->class = 'singleselect inline'; $controls .= $this->output->render($select); } @@ -362,7 +362,7 @@ class mod_attforblock_renderer extends plugin_renderer_base { return $controls; } - protected function render_attforblock_take_list(attforblock_take_data $takedata) { + protected function render_attendance_take_list(attendance_take_data $takedata) { $table = new html_table(); $table->width = '0%'; $table->head = array( @@ -374,11 +374,11 @@ class mod_attforblock_renderer extends plugin_renderer_base { $table->wrap[1] = 'nowrap'; foreach ($takedata->statuses as $st) { $table->head[] = html_writer::link("javascript:select_all_in(null, 'st" . $st->id . "', null);", $st->acronym, - array('title' => get_string('setallstatusesto', 'attforblock', $st->description))); + array('title' => get_string('setallstatusesto', 'attendance', $st->description))); $table->align[] = 'center'; $table->size[] = '20px'; } - $table->head[] = get_string('remarks', 'attforblock'); + $table->head[] = get_string('remarks', 'attendance'); $table->align[] = 'center'; $table->size[] = '20px'; $table->attributes['class'] = 'generaltable takelist'; @@ -416,7 +416,7 @@ class mod_attforblock_renderer extends plugin_renderer_base { return html_writer::table($table); } - protected function render_attforblock_take_grid(attforblock_take_data $takedata) { + protected function render_attendance_take_grid(attendance_take_data $takedata) { $table = new html_table(); for ($i=0; $i < $takedata->pageparams->gridcols; $i++) { $table->align[] = 'center'; @@ -427,7 +427,7 @@ class mod_attforblock_renderer extends plugin_renderer_base { $head = array(); foreach ($takedata->statuses as $st) { $head[] = html_writer::link("javascript:select_all_in(null, 'st" . $st->id . "', null);", $st->acronym, - array('title' => get_string('setallstatusesto', 'attforblock', $st->description))); + array('title' => get_string('setallstatusesto', 'attendance', $st->description))); } $table->head[] = implode('  ', $head); @@ -489,15 +489,15 @@ class mod_attforblock_renderer extends plugin_renderer_base { return $fullnamehead; } - private function construct_take_user_controls(attforblock_take_data $takedata, $user) { + private function construct_take_user_controls(attendance_take_data $takedata, $user) { $celldata = array(); if ($user->enrolmentend and $user->enrolmentend < $takedata->sessioninfo->sessdate) { - $celldata['text'] = get_string('enrolmentend', 'attforblock', userdate($user->enrolmentend, '%d.%m.%Y')); + $celldata['text'] = get_string('enrolmentend', 'attendance', userdate($user->enrolmentend, '%d.%m.%Y')); $celldata['colspan'] = count($takedata->statuses) + 1; $celldata['class'] = 'userwithoutenrol'; } else if (!$user->enrolmentend and $user->enrolmentstatus == ENROL_USER_SUSPENDED) { // No enrolmentend and ENROL_USER_SUSPENDED. - $celldata['text'] = get_string('enrolmentsuspended', 'attforblock'); + $celldata['text'] = get_string('enrolmentsuspended', 'attendance'); $celldata['colspan'] = count($takedata->statuses) + 1; $celldata['class'] = 'userwithoutenrol'; } else { @@ -533,7 +533,7 @@ class mod_attforblock_renderer extends plugin_renderer_base { $celldata['text'][] = html_writer::empty_tag('input', $params); if ($user->enrolmentstart > $takedata->sessioninfo->sessdate + $takedata->sessioninfo->duration) { - $celldata['warning'] = get_string('enrolmentstart', 'attforblock', + $celldata['warning'] = get_string('enrolmentstart', 'attendance', userdate($user->enrolmentstart, '%H:%M %d.%m.%Y')); $celldata['class'] = 'userwithoutenrol'; } @@ -542,7 +542,7 @@ class mod_attforblock_renderer extends plugin_renderer_base { return $celldata; } - protected function render_attforblock_user_data(attforblock_user_data $userdata) { + protected function render_attendance_user_data(attendance_user_data $userdata) { $o = $this->render_user_report_tabs($userdata); $table = new html_table(); @@ -557,21 +557,21 @@ class mod_attforblock_renderer extends plugin_renderer_base { return $o; } - protected function render_user_report_tabs(attforblock_user_data $userdata) { + protected function render_user_report_tabs(attendance_user_data $userdata) { $tabs = array(); $tabs[] = new tabobject(att_view_page_params::MODE_THIS_COURSE, $userdata->url()->out(true, array('mode' => att_view_page_params::MODE_THIS_COURSE)), - get_string('thiscourse', 'attforblock')); + get_string('thiscourse', 'attendance')); $tabs[] = new tabobject(att_view_page_params::MODE_ALL_COURSES, $userdata->url()->out(true, array('mode' => att_view_page_params::MODE_ALL_COURSES)), - get_string('allcourses', 'attforblock')); + get_string('allcourses', 'attendance')); return print_tabs(array($tabs), $userdata->pageparams->mode, null, null, true); } - private function construct_user_data(attforblock_user_data $userdata) { + private function construct_user_data(attendance_user_data $userdata) { $o = html_writer::tag('h2', fullname($userdata->user)); if ($userdata->pageparams->mode == att_view_page_params::MODE_THIS_COURSE) { @@ -580,7 +580,7 @@ class mod_attforblock_renderer extends plugin_renderer_base { $o .= construct_user_data_stat($userdata->stat, $userdata->statuses, $userdata->gradable, $userdata->grade, $userdata->maxgrade, $userdata->decimalpoints); - $o .= $this->render_attforblock_filter_controls($userdata->filtercontrols); + $o .= $this->render_attendance_filter_controls($userdata->filtercontrols); $o .= $this->construct_user_sessions_log($userdata); } else { @@ -603,17 +603,17 @@ class mod_attforblock_renderer extends plugin_renderer_base { return $o; } - private function construct_user_sessions_log(attforblock_user_data $userdata) { + private function construct_user_sessions_log(attendance_user_data $userdata) { $table = new html_table(); $table->attributes['class'] = 'generaltable attwidth boxaligncenter'; $table->head = array( '#', - get_string('sessiontypeshort', 'attforblock'), + get_string('sessiontypeshort', 'attendance'), get_string('date'), get_string('time'), - get_string('description', 'attforblock'), - get_string('status', 'attforblock'), - get_string('remarks', 'attforblock') + get_string('description', 'attendance'), + get_string('status', 'attendance'), + get_string('remarks', 'attendance') ); $table->align = array('', '', '', 'left', 'left', 'center', 'left'); $table->size = array('1px', '1px', '1px', '1px', '*', '1px', '1px'); @@ -625,20 +625,20 @@ class mod_attforblock_renderer extends plugin_renderer_base { $row = new html_table_row(); $row->cells[] = $i; $row->cells[] = html_writer::tag('nobr', $sess->groupid ? $userdata->groups[$sess->groupid]->name : - get_string('commonsession', 'attforblock')); - $row->cells[] = userdate($sess->sessdate, get_string('strftimedmyw', 'attforblock')); + get_string('commonsession', 'attendance')); + $row->cells[] = userdate($sess->sessdate, get_string('strftimedmyw', 'attendance')); $row->cells[] = $this->construct_time($sess->sessdate, $sess->duration); $row->cells[] = $sess->description; if (isset($sess->statusid)) { $row->cells[] = $userdata->statuses[$sess->statusid]->description; $row->cells[] = $sess->remarks; } else if ($sess->sessdate < $userdata->user->enrolmentstart) { - $cell = new html_table_cell(get_string('enrolmentstart', 'attforblock', + $cell = new html_table_cell(get_string('enrolmentstart', 'attendance', userdate($userdata->user->enrolmentstart, '%d.%m.%Y'))); $cell->colspan = 2; $row->cells[] = $cell; } else if ($userdata->user->enrolmentend and $sess->sessdate > $userdata->user->enrolmentend) { - $cell = new html_table_cell(get_string('enrolmentend', 'attforblock', + $cell = new html_table_cell(get_string('enrolmentend', 'attendance', userdate($userdata->user->enrolmentend, '%d.%m.%Y'))); $cell->colspan = 2; $row->cells[] = $cell; @@ -659,7 +659,7 @@ class mod_attforblock_renderer extends plugin_renderer_base { return $time; } - protected function render_attforblock_report_data(attforblock_report_data $reportdata) { + protected function render_attendance_report_data(attendance_report_data $reportdata) { $table = new html_table(); $table->attributes['class'] = 'generaltable attwidth'; @@ -674,14 +674,14 @@ class mod_attforblock_renderer extends plugin_renderer_base { $table->size[] = ''; foreach ($reportdata->sessions as $sess) { - $sesstext = userdate($sess->sessdate, get_string('strftimedm', 'attforblock')); + $sesstext = userdate($sess->sessdate, get_string('strftimedm', 'attendance')); $sesstext .= html_writer::empty_tag('br'); - $sesstext .= userdate($sess->sessdate, '('.get_string('strftimehm', 'attforblock').')'); + $sesstext .= userdate($sess->sessdate, '('.get_string('strftimehm', 'attendance').')'); if (is_null($sess->lasttaken) and $reportdata->perm->can_take() or $reportdata->perm->can_change()) { $sesstext = html_writer::link($reportdata->url_take($sess->id, $sess->groupid), $sesstext); } $sesstext .= html_writer::empty_tag('br'); - $sesstext .= $sess->groupid ? $reportdata->groups[$sess->groupid]->name : get_string('commonsession', 'attforblock'); + $sesstext .= $sess->groupid ? $reportdata->groups[$sess->groupid]->name : get_string('commonsession', 'attendance'); $table->head[] = $sesstext; $table->align[] = 'center'; @@ -727,13 +727,13 @@ class mod_attforblock_renderer extends plugin_renderer_base { return html_writer::table($table); } - protected function render_attforblock_preferences_data(attforblock_preferences_data $prefdata) { - $this->page->requires->js('/mod/attforblock/module.js'); + protected function render_attendance_preferences_data(attendance_preferences_data $prefdata) { + $this->page->requires->js('/mod/attendance/module.js'); $table = new html_table(); $table->width = '100%'; $table->head = array('#', - get_string('acronym', 'attforblock'), + get_string('acronym', 'attendance'), get_string('description'), get_string('grade'), get_string('action')); @@ -754,13 +754,13 @@ class mod_attforblock_renderer extends plugin_renderer_base { $table->data[$i][] = $this->construct_text_input('newacronym', 2, 2); $table->data[$i][] = $this->construct_text_input('newdescription', 30, 30); $table->data[$i][] = $this->construct_text_input('newgrade', 4, 4); - $table->data[$i][] = $this->construct_preferences_button(get_string('add', 'attforblock'), + $table->data[$i][] = $this->construct_preferences_button(get_string('add', 'attendance'), att_preferences_page_params::ACTION_ADD); - $o = html_writer::tag('h1', get_string('myvariables', 'attforblock')); + $o = html_writer::tag('h1', get_string('myvariables', 'attendance')); $o .= html_writer::table($table); $o .= html_writer::input_hidden_params($prefdata->url(array(), false)); - $o .= $this->construct_preferences_button(get_string('update', 'attforblock'), att_preferences_page_params::ACTION_SAVE); + $o .= $this->construct_preferences_button(get_string('update', 'attendance'), att_preferences_page_params::ACTION_SAVE); $o = html_writer::tag('form', $o, array('id' => 'preferencesform', 'method' => 'post', 'action' => $prefdata->url(array(), false)->out_omit_querystring())); $o = $this->output->container($o, 'generalbox attwidth'); @@ -814,7 +814,7 @@ class mod_attforblock_renderer extends plugin_renderer_base { $attributes = array( 'type' => 'submit', 'value' => $text, - 'onclick' => 'M.mod_attforblock.set_preferences_action('.$action.')'); + 'onclick' => 'M.mod_attendance.set_preferences_action('.$action.')'); return html_writer::empty_tag('input', $attributes); } diff --git a/renderhelpers.php b/renderhelpers.php index faf2ecb..417bc30 100644 --- a/renderhelpers.php +++ b/renderhelpers.php @@ -17,7 +17,7 @@ /** * Attendance module renderering helpers * - * @package mod_attforblock + * @package mod_attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -35,7 +35,7 @@ class user_sessions_cells_generator { protected $reportdata; protected $user; - public function __construct(attforblock_report_data $reportdata, $user) { + public function __construct(attendance_report_data $reportdata, $user) { $this->reportdata = $reportdata; $this->user = $user; } @@ -52,14 +52,14 @@ class user_sessions_cells_generator { } } else { if ($this->user->enrolmentstart > $sess->sessdate) { - $starttext = get_string('enrolmentstart', 'attforblock', userdate($this->user->enrolmentstart, '%d.%m.%Y')); + $starttext = get_string('enrolmentstart', 'attendance', userdate($this->user->enrolmentstart, '%d.%m.%Y')); $this->construct_enrolments_info_cell($starttext); } else if ($this->user->enrolmentend and $this->user->enrolmentend < $sess->sessdate) { - $endtext = get_string('enrolmentend', 'attforblock', userdate($this->user->enrolmentend, '%d.%m.%Y')); + $endtext = get_string('enrolmentend', 'attendance', userdate($this->user->enrolmentend, '%d.%m.%Y')); $this->construct_enrolments_info_cell($endtext); } else if (!$this->user->enrolmentend and $this->user->enrolmentstatus == ENROL_USER_SUSPENDED) { // No enrolmentend and ENROL_USER_SUSPENDED. - $suspendext = get_string('enrolmentsuspended', 'attforblock', userdate($this->user->enrolmentend, '%d.%m.%Y')); + $suspendext = get_string('enrolmentsuspended', 'attendance', userdate($this->user->enrolmentend, '%d.%m.%Y')); $this->construct_enrolments_info_cell($suspendext); } else { if ($sess->groupid == 0 or array_key_exists($sess->groupid, $this->reportdata->usersgroups[$this->user->id])) { @@ -172,14 +172,14 @@ class user_sessions_cells_text_generator extends user_sessions_cells_generator { } function construct_session_time($datetime, $duration) { - $starttime = userdate($datetime, get_string('strftimehm', 'attforblock')); - $endtime = userdate($datetime + $duration, get_string('strftimehm', 'attforblock')); + $starttime = userdate($datetime, get_string('strftimehm', 'attendance')); + $endtime = userdate($datetime + $duration, get_string('strftimehm', 'attendance')); return $starttime . ($duration > 0 ? ' - ' . $endtime : ''); } function construct_session_full_date_time($datetime, $duration) { - $sessinfo = userdate($datetime, get_string('strftimedmyw', 'attforblock')); + $sessinfo = userdate($datetime, get_string('strftimedmyw', 'attendance')); $sessinfo .= ' '.construct_session_time($datetime, $duration); return $sessinfo; @@ -191,7 +191,7 @@ function construct_user_data_stat($stat, $statuses, $gradable, $grade, $maxgrade $stattable = new html_table(); $stattable->attributes['class'] = 'attlist'; $row = new html_table_row(); - $row->cells[] = get_string('sessionscompleted', 'attforblock').':'; + $row->cells[] = get_string('sessionscompleted', 'attendance').':'; $row->cells[] = $stat['completed']; $stattable->data[] = $row; @@ -205,13 +205,13 @@ function construct_user_data_stat($stat, $statuses, $gradable, $grade, $maxgrade if ($gradable) { $row = new html_table_row(); - $row->cells[] = get_string('attendancegrade', 'attforblock') . - $OUTPUT->help_icon('gradebookexplanation', 'attforblock') . ':'; + $row->cells[] = get_string('attendancegrade', 'attendance') . + $OUTPUT->help_icon('gradebookexplanation', 'attendance') . ':'; $row->cells[] = $grade . ' / ' . $maxgrade; $stattable->data[] = $row; $row = new html_table_row(); - $row->cells[] = get_string('attendancepercent', 'attforblock') . ':'; + $row->cells[] = get_string('attendancepercent', 'attendance') . ':'; if ($maxgrade == 0) { $percent = 0; } else { @@ -224,16 +224,16 @@ function construct_user_data_stat($stat, $statuses, $gradable, $grade, $maxgrade return html_writer::table($stattable); } -function construct_full_user_stat_html_table($attforblock, $course, $user) { +function construct_full_user_stat_html_table($attendance, $course, $user) { global $CFG; - $gradeable = $attforblock->grade > 0; - $statuses = att_get_statuses($attforblock->id); - $userstatusesstat = att_get_user_statuses_stat($attforblock->id, $course->startdate, $user->id); - $stat['completed'] = att_get_user_taken_sessions_count($attforblock->id, $course->startdate, $user->id); + $gradeable = $attendance->grade > 0; + $statuses = att_get_statuses($attendance->id); + $userstatusesstat = att_get_user_statuses_stat($attendance->id, $course->startdate, $user->id); + $stat['completed'] = att_get_user_taken_sessions_count($attendance->id, $course->startdate, $user->id); $stat['statuses'] = $userstatusesstat; if ($gradeable) { $grade = att_get_user_grade($userstatusesstat, $statuses); - $maxgrade = att_get_user_max_grade(att_get_user_taken_sessions_count($attforblock->id, $course->startdate, + $maxgrade = att_get_user_max_grade(att_get_user_taken_sessions_count($attendance->id, $course->startdate, $user->id), $statuses); if (!$decimalpoints = grade_get_setting($course->id, 'decimalpoints')) { $decimalpoints = $CFG->grade_decimalpoints; diff --git a/report.php b/report.php index feb356b..d46d38a 100644 --- a/report.php +++ b/report.php @@ -17,7 +17,7 @@ /** * Attendance report * - * @package mod_attforblock + * @package mod_attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -34,29 +34,29 @@ $pageparams->curdate = optional_param('curdate', null, PARAM_INT); $pageparams->group = optional_param('group', null, PARAM_INT); $pageparams->sort = optional_param('sort', null, PARAM_INT); -$cm = get_coursemodule_from_id('attforblock', $id, 0, false, MUST_EXIST); +$cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attforblock', array('id' => $cm->instance), '*', MUST_EXIST); +$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); require_login($course, true, $cm); $pageparams->init($cm); -$att = new attforblock($att, $cm, $course, $PAGE->context, $pageparams); +$att = new attendance($att, $cm, $course, $PAGE->context, $pageparams); $att->perm->require_view_reports_capability(); $PAGE->set_url($att->url_report()); $PAGE->set_pagelayout('report'); -$PAGE->set_title($course->shortname. ": ".$att->name.' - '.get_string('report', 'attforblock')); +$PAGE->set_title($course->shortname. ": ".$att->name.' - '.get_string('report', 'attendance')); $PAGE->set_heading($course->fullname); $PAGE->set_cacheable(true); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attforblock')); -$PAGE->navbar->add(get_string('report', 'attforblock')); +$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attendance')); +$PAGE->navbar->add(get_string('report', 'attendance')); -$output = $PAGE->get_renderer('mod_attforblock'); -$tabs = new attforblock_tabs($att, attforblock_tabs::TAB_REPORT); -$filtercontrols = new attforblock_filter_controls($att); -$reportdata = new attforblock_report_data($att); +$output = $PAGE->get_renderer('mod_attendance'); +$tabs = new attendance_tabs($att, attendance_tabs::TAB_REPORT); +$filtercontrols = new attendance_filter_controls($att); +$reportdata = new attendance_report_data($att); global $USER; $att->log('report viewed', null, $USER->firstname.' '.$USER->lastname); @@ -64,7 +64,7 @@ $att->log('report viewed', null, $USER->firstname.' '.$USER->lastname); // Output starts here. echo $output->header(); -echo $output->heading(get_string('attendanceforthecourse', 'attforblock').' :: ' .$course->fullname); +echo $output->heading(get_string('attendanceforthecourse', 'attendance').' :: ' .$course->fullname); echo $output->render($tabs); echo $output->render($filtercontrols); echo $output->render($reportdata); diff --git a/sessions.php b/sessions.php index d927108..2676d1f 100644 --- a/sessions.php +++ b/sessions.php @@ -17,7 +17,7 @@ /** * Adding attendance sessions * - * @package mod_attforblock + * @package mod_attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -33,13 +33,13 @@ $pageparams = new att_sessions_page_params(); $id = required_param('id', PARAM_INT); $pageparams->action = required_param('action', PARAM_INT); -$cm = get_coursemodule_from_id('attforblock', $id, 0, false, MUST_EXIST); +$cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attforblock', array('id' => $cm->instance), '*', MUST_EXIST); +$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); require_login($course, true, $cm); -$att = new attforblock($att, $cm, $course, $PAGE->context, $pageparams); +$att = new attendance($att, $cm, $course, $PAGE->context, $pageparams); $att->perm->require_manage_capability(); @@ -47,19 +47,19 @@ $PAGE->set_url($att->url_sessions()); $PAGE->set_title($course->shortname. ": ".$att->name); $PAGE->set_heading($course->fullname); $PAGE->set_cacheable(true); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attforblock')); +$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attendance')); $PAGE->navbar->add($att->name); $formparams = array('course' => $course, 'cm' => $cm, 'modcontext' => $PAGE->context); switch ($att->pageparams->action) { case att_sessions_page_params::ACTION_ADD: $url = $att->url_sessions(array('action' => att_sessions_page_params::ACTION_ADD)); - $mform = new mod_attforblock_add_form($url, $formparams); + $mform = new mod_attendance_add_form($url, $formparams); if ($formdata = $mform->get_data()) { $sessions = construct_sessions_data_for_add($formdata); $att->add_sessions($sessions); - redirect($url, get_string('sessionsgenerated', 'attforblock')); + redirect($url, get_string('sessionsgenerated', 'attendance')); } break; case att_sessions_page_params::ACTION_UPDATE: @@ -67,7 +67,7 @@ switch ($att->pageparams->action) { $url = $att->url_sessions(array('action' => att_sessions_page_params::ACTION_UPDATE, 'sessionid' => $sessionid)); $formparams['sessionid'] = $sessionid; - $mform = new mod_attforblock_update_form($url, $formparams); + $mform = new mod_attendance_update_form($url, $formparams); if ($mform->is_cancelled()) { redirect($att->url_manage()); @@ -76,7 +76,7 @@ switch ($att->pageparams->action) { if ($formdata = $mform->get_data()) { $att->update_session_from_form_data($formdata, $sessionid); - redirect($att->url_manage(), get_string('sessionupdated', 'attforblock')); + redirect($att->url_manage(), get_string('sessionupdated', 'attendance')); } break; case att_sessions_page_params::ACTION_DELETE: @@ -86,21 +86,21 @@ switch ($att->pageparams->action) { if (isset($confirm)) { $att->delete_sessions(array($sessionid)); att_update_all_users_grades($att->id, $att->course, $att->context); - redirect($att->url_manage(), get_string('sessiondeleted', 'attforblock')); + redirect($att->url_manage(), get_string('sessiondeleted', 'attendance')); } $sessinfo = $att->get_session_info($sessionid); - $message = get_string('deletecheckfull', '', get_string('session', 'attforblock')); + $message = get_string('deletecheckfull', '', get_string('session', 'attendance')); $message .= str_repeat(html_writer::empty_tag('br'), 2); - $message .= userdate($sessinfo->sessdate, get_string('strftimedmyhm', 'attforblock')); + $message .= userdate($sessinfo->sessdate, get_string('strftimedmyhm', 'attendance')); $message .= html_writer::empty_tag('br'); $message .= $sessinfo->description; $params = array('action' => $att->pageparams->action, 'sessionid' => $sessionid, 'confirm' => 1); echo $OUTPUT->header(); - echo $OUTPUT->heading(get_string('attendanceforthecourse', 'attforblock').' :: ' .$course->fullname); + echo $OUTPUT->heading(get_string('attendanceforthecourse', 'attendance').' :: ' .$course->fullname); echo $OUTPUT->confirm($message, $att->url_sessions($params), $att->url_manage()); echo $OUTPUT->footer(); exit; @@ -113,22 +113,22 @@ switch ($att->pageparams->action) { $att->delete_sessions($sessionsids); att_update_all_users_grades($att->id, $att->course, $att->context); - redirect($att->url_manage(), get_string('sessiondeleted', 'attforblock')); + redirect($att->url_manage(), get_string('sessiondeleted', 'attendance')); } $fromform = data_submitted(); // Nothing selected. if (!isset($fromform->sessid)) { - print_error ('nosessionsselected', 'attforblock', $att->url_manage()); + print_error ('nosessionsselected', 'attendance', $att->url_manage()); } $sessionsinfo = $att->get_sessions_info($fromform->sessid); - $message = get_string('deletecheckfull', '', get_string('session', 'attforblock')); + $message = get_string('deletecheckfull', '', get_string('session', 'attendance')); $message .= html_writer::empty_tag('br'); foreach ($sessionsinfo as $sessinfo) { $message .= html_writer::empty_tag('br'); - $message .= userdate($sessinfo->sessdate, get_string('strftimedmyhm', 'attforblock')); + $message .= userdate($sessinfo->sessdate, get_string('strftimedmyhm', 'attendance')); $message .= html_writer::empty_tag('br'); $message .= $sessinfo->description; } @@ -137,7 +137,7 @@ switch ($att->pageparams->action) { $params = array('action' => $att->pageparams->action, 'sessionsids' => $sessionsids, 'confirm' => 1); echo $OUTPUT->header(); - echo $OUTPUT->heading(get_string('attendanceforthecourse', 'attforblock').' :: ' .$course->fullname); + echo $OUTPUT->heading(get_string('attendanceforthecourse', 'attendance').' :: ' .$course->fullname); echo $OUTPUT->confirm($message, $att->url_sessions($params), $att->url_manage()); echo $OUTPUT->footer(); exit; @@ -147,7 +147,7 @@ switch ($att->pageparams->action) { $url = $att->url_sessions(array('action' => att_sessions_page_params::ACTION_CHANGE_DURATION)); $formparams['ids'] = $slist; - $mform = new mod_attforblock_duration_form($url, $formparams); + $mform = new mod_attendance_duration_form($url, $formparams); if ($mform->is_cancelled()) { redirect($att->url_manage()); @@ -157,20 +157,20 @@ switch ($att->pageparams->action) { $sessionsids = explode('_', $fromform->ids); $duration = $formdata->durtime['hours']*HOURSECS + $formdata->durtime['minutes']*MINSECS; $att->update_sessions_duration($sessionsids, $duration); - redirect($att->url_manage(), get_string('sessionupdated', 'attforblock')); + redirect($att->url_manage(), get_string('sessionupdated', 'attendance')); } if ($slist === '') { - print_error('nosessionsselected', 'attforblock', $att->url_manage()); + print_error('nosessionsselected', 'attendance', $att->url_manage()); } break; } -$output = $PAGE->get_renderer('mod_attforblock'); -$tabs = new attforblock_tabs($att, attforblock_tabs::TAB_ADD); +$output = $PAGE->get_renderer('mod_attendance'); +$tabs = new attendance_tabs($att, attendance_tabs::TAB_ADD); echo $output->header(); -echo $output->heading(get_string('attendanceforthecourse', 'attforblock').' :: ' .$course->fullname); +echo $output->heading(get_string('attendanceforthecourse', 'attendance').' :: ' .$course->fullname); echo $output->render($tabs); $mform->display(); @@ -243,7 +243,7 @@ function construct_sessions_data_for_add($formdata) { } function fill_groupid($formdata, &$sessions, $sess) { - if ($formdata->sessiontype == attforblock::SESSION_COMMON) { + if ($formdata->sessiontype == attendance::SESSION_COMMON) { $sess = clone $sess; $sess->groupid = 0; $sessions[] = $sess; diff --git a/styles.css b/styles.css index e187be9..6e00166 100644 --- a/styles.css +++ b/styles.css @@ -1,4 +1,4 @@ -.path-mod-attforblock .attbtn { +.path-mod-attendance .attbtn { border:1px solid #AAAAAA; margin-left: 2px; margin-right: 2px; @@ -10,116 +10,116 @@ -khtml-border-radius: 5px; } -.path-mod-attforblock .attcurbtn { +.path-mod-attendance .attcurbtn { margin-left: 2px; margin-right: 2px; padding: 5px; } -.path-mod-attforblock .attfiltercontrols { +.path-mod-attendance .attfiltercontrols { margin-bottom: 10px; margin-right:auto; margin-left:auto; } -.path-mod-attforblock .attfiltercontrols #currentdate{ +.path-mod-attendance .attfiltercontrols #currentdate{ display: inline; } -.path-mod-attforblock .attwidth { +.path-mod-attendance .attwidth { width:90%; margin: auto; } -.path-mod-attforblock .userwithoutenrol, -.path-mod-attforblock .userwithoutenrol a{ +.path-mod-attendance .userwithoutenrol, +.path-mod-attendance .userwithoutenrol a{ color: gray; } -.path-mod-attforblock .userwithoutdata, -.path-mod-attforblock .userwithoutdata a{ +.path-mod-attendance .userwithoutdata, +.path-mod-attendance .userwithoutdata a{ color: red; } -.path-mod-attforblock .takelist td { +.path-mod-attendance .takelist td { vertical-align: middle; } -.path-mod-attforblock .takelist .userpicture { +.path-mod-attendance .takelist .userpicture { margin:0 3px; vertical-align:middle; } -.path-mod-attforblock .takegrid input { +.path-mod-attendance .takegrid input { margin: 0px 3px 0px 6px; } -.path-mod-attforblock .takegrid .fullname { +.path-mod-attendance .takegrid .fullname { font-size: 0.8em; } -.path-mod-attforblock table.controls { +.path-mod-attendance table.controls { width: 100%; text-align: center; } -.path-mod-attforblock table.controls tr { +.path-mod-attendance table.controls tr { vertical-align: top; } -.path-mod-attforblock table.controls td.right, -.path-mod-attforblock table.controls td.left { +.path-mod-attendance table.controls td.right, +.path-mod-attendance table.controls td.left { padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px; } -.path-mod-attforblock table.controls .right { +.path-mod-attendance table.controls .right { text-align: right; } /* for IE7*/ -.path-mod-attforblock .filtercontrols td { +.path-mod-attendance .filtercontrols td { padding:6px; } -.path-mod-attforblock .takecontrols { +.path-mod-attendance .takecontrols { width: 800px; margin: 0px auto 20px auto; } -.path-mod-attforblock .takecontrols table{ +.path-mod-attendance .takecontrols table{ margin: 0px auto; } -.path-mod-attforblock .takecontrols .c0 { +.path-mod-attendance .takecontrols .c0 { width: 500px; text-align: left; } -.path-mod-attforblock .takecontrols .c1 { +.path-mod-attendance .takecontrols .c1 { text-align: right; } -.path-mod-attforblock .inline, -.path-mod-attforblock .inline form, -.path-mod-attforblock .inline div { +.path-mod-attendance .inline, +.path-mod-attendance .inline form, +.path-mod-attendance .inline div { display: inline; } -.path-mod-attforblock table.userinfobox { +.path-mod-attendance table.userinfobox { border: 1px solid #EEEEEE; padding: 0px; } -.path-mod-attforblock table.userinfobox td.left { +.path-mod-attendance table.userinfobox td.left { background-color: #EEEEEE; padding: 30px 10px; } -.path-mod-attforblock table.attlist td.c0 { +.path-mod-attendance table.attlist td.c0 { text-align: right; } -#page-mod-attforblock-preferences .generalbox { +#page-mod-attendance-preferences .generalbox { text-align: center; } -.path-mod-attforblock .attsessions_manage_table .action-icon img.smallicon { +.path-mod-attendance .attsessions_manage_table .action-icon img.smallicon { margin-left: 5px; } \ No newline at end of file diff --git a/take.php b/take.php index 0f88fc4..b539170 100644 --- a/take.php +++ b/take.php @@ -17,7 +17,7 @@ /** * Take Attendance * - * @package mod_attforblock + * @package mod_attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -35,20 +35,20 @@ $pageparams->copyfrom = optional_param('copyfrom', null, PARAM_INT); $pageparams->viewmode = optional_param('viewmode', null, PARAM_INT); $pageparams->gridcols = optional_param('gridcols', null, PARAM_INT); -$cm = get_coursemodule_from_id('attforblock', $id, 0, false, MUST_EXIST); +$cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$att = $DB->get_record('attforblock', array('id' => $cm->instance), '*', MUST_EXIST); +$att = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); require_login($course, true, $cm); $pageparams->group = groups_get_activity_group($cm, true); $pageparams->init($course->id); -$att = new attforblock($att, $cm, $course, $PAGE->context, $pageparams); +$att = new attendance($att, $cm, $course, $PAGE->context, $pageparams); if (!$att->perm->can_take_session($pageparams->grouptype)) { $group = groups_get_group($pageparams->grouptype); - throw new moodle_exception('cannottakeforgroup', 'attforblock', '', $group->name); + throw new moodle_exception('cannottakeforgroup', 'attendance', '', $group->name); } if ($formdata = data_submitted()) { @@ -59,17 +59,17 @@ $PAGE->set_url($att->url_take()); $PAGE->set_title($course->shortname. ": ".$att->name); $PAGE->set_heading($course->fullname); $PAGE->set_cacheable(true); -$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attforblock')); +$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'attendance')); $PAGE->navbar->add($att->name); -$output = $PAGE->get_renderer('mod_attforblock'); -$tabs = new attforblock_tabs($att); -$sesstable = new attforblock_take_data($att); +$output = $PAGE->get_renderer('mod_attendance'); +$tabs = new attendance_tabs($att); +$sesstable = new attendance_take_data($att); // Output starts here. echo $output->header(); -echo $output->heading(get_string('attendanceforthecourse', 'attforblock').' :: ' .$course->fullname); +echo $output->heading(get_string('attendanceforthecourse', 'attendance').' :: ' .$course->fullname); echo $output->render($tabs); echo $output->render($sesstable); diff --git a/update_form.php b/update_form.php index cf1fcd9..83964c7 100644 --- a/update_form.php +++ b/update_form.php @@ -17,7 +17,7 @@ /** * Update form * - * @package mod_attforblock + * @package mod_attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -25,7 +25,7 @@ require_once($CFG->libdir.'/formslib.php'); -class mod_attforblock_update_form extends moodleform { +class mod_attendance_update_form extends moodleform { public function definition() { global $CFG, $DB; @@ -42,16 +42,16 @@ class mod_attforblock_update_form extends moodleform { $dhours = floor($sess->duration / HOURSECS); $dmins = floor(($sess->duration - $dhours * HOURSECS) / MINSECS); $defopts = array('maxfiles'=>EDITOR_UNLIMITED_FILES, 'noclean'=>true, 'context'=>$modcontext); - $sess = file_prepare_standard_editor($sess, 'description', $defopts, $modcontext, 'mod_attforblock', 'session', $sess->id); + $sess = file_prepare_standard_editor($sess, 'description', $defopts, $modcontext, 'mod_attendance', 'session', $sess->id); $data = array('sessiondate' => $sess->sessdate, 'durtime' => array('hours' => $dhours, 'minutes' => $dmins), 'sdescription' => $sess->description_editor); - $mform->addElement('header', 'general', get_string('changesession', 'attforblock')); + $mform->addElement('header', 'general', get_string('changesession', 'attendance')); - $mform->addElement('static', 'olddate', get_string('olddate', 'attforblock'), - userdate($sess->sessdate, get_string('strftimedmyhm', 'attforblock'))); - $mform->addElement('date_time_selector', 'sessiondate', get_string('newdate', 'attforblock')); + $mform->addElement('static', 'olddate', get_string('olddate', 'attendance'), + userdate($sess->sessdate, get_string('strftimedmyhm', 'attendance'))); + $mform->addElement('date_time_selector', 'sessiondate', get_string('newdate', 'attendance')); for ($i=0; $i<=23; $i++) { $hours[$i] = sprintf("%02d", $i); @@ -61,14 +61,14 @@ class mod_attforblock_update_form extends moodleform { } $durselect[] =& $mform->createElement('select', 'hours', '', $hours); $durselect[] =& $mform->createElement('select', 'minutes', '', $minutes, false, true); - $mform->addGroup($durselect, 'durtime', get_string('duration', 'attforblock'), array(' '), true); + $mform->addGroup($durselect, 'durtime', get_string('duration', 'attendance'), array(' '), true); - $mform->addElement('editor', 'sdescription', get_string('description', 'attforblock'), null, $defopts); + $mform->addElement('editor', 'sdescription', get_string('description', 'attendance'), null, $defopts); $mform->setType('sdescription', PARAM_RAW); $mform->setDefaults($data); - $submit_string = get_string('update', 'attforblock'); + $submit_string = get_string('update', 'attendance'); $this->add_action_buttons(true, $submit_string); } } diff --git a/version.php b/version.php index e9599e7..fdf8281 100644 --- a/version.php +++ b/version.php @@ -17,7 +17,7 @@ /** * Version information * - * @package mod_attforblock + * @package mod_attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -27,4 +27,12 @@ $module->requires = 2012120300; $module->release = '2.4.1'; $module->maturity = MATURITY_ALPHA; $module->cron = 0; -$module->component = 'mod_attforblock'; +$module->component = 'mod_attendance'; + +// Nasty upgrade code to check if need to upgrade from attforblock. +// TODO: remove this asap. +global $DB; +if ($DB->record_exists('modules', array('name' =>'attforblock'))) { + require_once('locallib.php'); + attforblock_upgrade(); +} diff --git a/view.php b/view.php index 30681c9..5117605 100644 --- a/view.php +++ b/view.php @@ -17,7 +17,7 @@ /** * Prints attendance info for particular user * - * @package mod_attforblock + * @package mod_attendance * @copyright 2011 Artem Andreev * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ @@ -34,14 +34,14 @@ $pageparams->mode = optional_param('mode', att_view_page_params::MODE_THIS $pageparams->view = optional_param('view', null, PARAM_INT); $pageparams->curdate = optional_param('curdate', null, PARAM_INT); -$cm = get_coursemodule_from_id('attforblock', $id, 0, false, MUST_EXIST); +$cm = get_coursemodule_from_id('attendance', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); -$attforblock = $DB->get_record('attforblock', array('id' => $cm->instance), '*', MUST_EXIST); +$attendance = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST); require_login($course, true, $cm); $pageparams->init($cm); -$att = new attforblock($attforblock, $cm, $course, $PAGE->context, $pageparams); +$att = new attendance($attendance, $cm, $course, $PAGE->context, $pageparams); // Not specified studentid for displaying attendance? // Redirect to appropriate page if can. @@ -59,12 +59,12 @@ $PAGE->set_url($att->url_view()); $PAGE->set_title($course->shortname. ": ".$att->name); $PAGE->set_heading($course->fullname); $PAGE->set_cacheable(true); -$PAGE->navbar->add(get_string('attendancereport', 'attforblock')); +$PAGE->navbar->add(get_string('attendancereport', 'attendance')); -$output = $PAGE->get_renderer('mod_attforblock'); +$output = $PAGE->get_renderer('mod_attendance'); $userid = isset($pageparams->studentid) ? $pageparams->studentid : $USER->id; -$userdata = new attforblock_user_data($att, $userid); +$userdata = new attendance_user_data($att, $userid); echo $output->header();