diff --git a/_attendances.php b/_attendances.php
deleted file mode 100644
index e1fa7ab..0000000
--- a/_attendances.php
+++ /dev/null
@@ -1,322 +0,0 @@
-libdir.'/blocklib.php');
- require_once('locallib.php');
- require_once('lib.php');
-
- if (!function_exists('grade_update')) { //workaround for buggy PHP versions
- require_once($CFG->libdir.'/gradelib.php');
- }
-
- $id = required_param('id', PARAM_INT);
- $sessionid = required_param('sessionid', PARAM_INT);
- $grouptype = required_param('grouptype', PARAM_INT);
- $group = optional_param('group', -1, PARAM_INT); // Group to show
- $sort = optional_param('sort','lastname', PARAM_ALPHA);
- $copyfrom = optional_param('copyfrom', -1, PARAM_INT);
-
- if (! $cm = $DB->get_record('course_modules', array('id'=>$id))) {
- error('Course Module ID was incorrect');
- }
-
- if (! $course = $DB->get_record('course', array('id'=> $cm->course))) {
- error('Course is misconfigured');
- }
-
- require_login($course->id);
-
- if (! $attforblock = $DB->get_record('attforblock', array('id'=> $cm->instance))) {
- error("Course module is incorrect");
- }
- if (! $user = $DB->get_record('user', array('id'=> $USER->id) )) {
- error("No such user in this course");
- }
-
- if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
- print_error('badcontext');
- }
-
- $statlist = implode(',', array_keys( (array)get_statuses($attforblock->id) ));
- if ($form = data_submitted()) {
- $students = array(); // stores students ids
- $formarr = (array)$form;
- $i = 0;
- $now = time();
- foreach($formarr as $key => $value) {
- if(substr($key,0,7) == 'student' && $value !== '') {
- $students[$i] = new Object();
- $sid = substr($key,7); // gets studeent id from radiobutton name
- $students[$i]->studentid = $sid;
- $students[$i]->statusid = $value;
- $students[$i]->statusset = $statlist;
- $students[$i]->remarks = array_key_exists('remarks'.$sid, $formarr) ? $formarr['remarks'.$sid] : '';
- $students[$i]->sessionid = $sessionid;
- $students[$i]->timetaken = $now;
- $students[$i]->takenby = $USER->id;
- $i++;
- }
- }
- $attforblockrecord = $DB->get_record('attforblock', array('attendanceid' => $attforblock->id));
-
- foreach($students as $student) {
- if ($log = $DB->get_record('attendance_log', array('sessionid' => $sessionid, 'studentid'=> $student->studentid))) {
- $student->id = $log->id; // this is id of log
- $DB->update_record('attendance_log', $student);
- } else {
- $DB->insert_record('attendance_log', $student);
- }
- }
- $DB->set_field('attendance_sessions', 'lasttaken', $now, array('id' => $sessionid));
- $DB->set_field('attendance_sessions', 'lasttakenby', $USER->id, array('id' => $sessionid));
-
- attforblock_update_grades($attforblockrecord);
- add_to_log($course->id, 'attendance', 'updated', 'mod/attforblock/report.php?id='.$id, $user->lastname.' '.$user->firstname);
- redirect('manage.php?id='.$id, get_string('attendancesuccess','attforblock'), 3);
- exit();
- }
-
-/// Print headers
- $url = new moodle_url('/mod/attforblock/manage.php', array('id'=> $id, 'sessionid'=> $sessionid, 'grouptype' => $grouptype, 'group' => $group, 'sort' => $sort, 'copyfrom' => $copyfrom));
- $PAGE->set_url($url);
- $PAGE->set_title($course->shortname. ": ".$attforblock->name . ' - ' .get_string('update','attforblock'));
- $PAGE->set_heading($course->fullname);
- $PAGE->set_focuscontrol('');
- $PAGE->set_cacheable(true);
- $PAGE->set_button($OUTPUT->update_module_button($cm->id,'attforblock'));
- $PAGE->navbar->add($attforblock->name);
-
- echo $OUTPUT->header();
-
- /*$navlinks[] = array('name' => $attforblock->name, 'link' => "view.php?id=$id", 'type' => 'activity');
- $navlinks[] = array('name' => get_string('update', 'attforblock'), 'link' => null, 'type' => 'activityinstance');
- $navigation = build_navigation($navlinks);
- print_header("$course->shortname: ".$attforblock->name.' - ' .get_string('update','attforblock'), $course->fullname,
- $navigation, "", "", true, " ", navmenu($course));*/
-
-//check for hack
- if (!$sessdata = $DB->get_record('attendance_sessions', array('id'=> $sessionid))) {
- error("Required Information is missing", "manage.php?id=".$id);
- }
- $help = helpbutton ('updateattendance', get_string('help'), 'attforblock', true, false, '', true);
- $update = $DB->count_records('attendance_log', array('sessionid'=> $sessionid));
-
- if ($update) {
- require_capability('mod/attforblock:changeattendances', $context);
- print_heading(get_string('update','attforblock').' ' .get_string('attendanceforthecourse','attforblock').' :: ' .$course->fullname.$help);
- } else {
- require_capability('mod/attforblock:takeattendances', $context);
- echo $OUTPUT->heading(get_string('attendanceforthecourse','attforblock').' :: ' .$course->fullname.$help);
- }
-
- /// find out current groups mode
- $groupmode = groups_get_activity_groupmode($cm);
- $currentgroup = groups_get_activity_group($cm, true);
-
- // get the viewmode & grid columns
- $attforblockrecord = $DB->get_record('attforblock', array('id'=> $cm->instance));//'course', $course->id);'course', $course->id);
- $view = optional_param('view', -1, PARAM_INT);
- if ($view != -1) {
- set_user_preference("attforblock_viewmode", $view);
- }
- else {
- $view = get_user_preferences("attforblock_viewmode", SORTEDLISTVIEW);
- }
- $gridcols = optional_param('gridcols', -1, PARAM_INT);
- if ($gridcols != -1) {
- set_user_preference("attforblock_gridcolumns", $gridcols);
- }
- else {
- $gridcols = get_user_preferences("attforblock_gridcolumns",5);
- }
-
- echo '
'; //echo '';
- $options = array (SORTEDLISTVIEW => get_string('sortedlist','attforblock'), SORTEDGRIDVIEW => get_string('sortedgrid','attforblock'));
- $dataurl = "/mod/attforblock/attendances.php?id=$id&grouptype=$grouptype&gridcols=$gridcols";
- if ($group!=-1) {
- $dataurl = $dataurl . "&group=$group";
- }
- $today = usergetmidnight($sessdata->sessdate);
- $select = "sessdate>=? AND sessdate AND attendanceid=?";
- $tomorrow = $today + 86400;
- $todaysessions = $DB->get_records_select('attendance_sessions', $select, array($today, $tomorrow, $cm->instance), 'sessdate ASC');
- $optionssesions = array();
- if (count($todaysessions)>1) {
- echo '";
- foreach($todaysessions as $sessdatarow) {
- $descr = userdate($sessdatarow->sessdate, get_string('strftimehm', 'attforblock')) . "-" . userdate($sessdatarow->sessdate+$sessdatarow->duration, get_string('strftimehm', 'attforblock'));
- if ($sessdatarow->description) {
- $descr = $sessdatarow->description . ' ('.$descr.')';
- }
- $optionssessions[$sessdatarow->id] = $descr;
- }
- //popup_form("$dataurl&sessionid=", $optionssessions, 'fastsessionmenu', $sessionid, '');
- echo $OUTPUT->single_select(new moodle_url('/mod/attforblock/attendances.php', array('id'=> $id, 'grouptype' => $grouptype, 'group' => $group, 'sort' => $sort)),'sessionid',$optionssessions, $sessionid);
- echo " | | |
";
- }
- $dataurl .= "&sessionid=$sessionid";
- echo '";
- //popup_form("$dataurl&view=", $options, 'viewmenu', $view, '');
- echo $OUTPUT->single_select(new moodle_url('/mod/attforblock/attendances.php', array('id'=> $id, 'sessionid'=>$sessionid, 'grouptype' => $grouptype, 'group' => $group, 'sort' => $sort)),'view',$options, $view);
- if ($view == SORTEDGRIDVIEW) {
- $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'));
- $dataurl .= "&view=$view";
- //popup_form("$dataurl&gridcols=", $options, 'colsmenu', $gridcols, '');
- echo $OUTPUT->single_select(new moodle_url('/mod/attforblock/attendances.php', array('id'=> $id, 'sessionid'=>$sessionid, 'view'=>$view, 'grouptype' => $grouptype, 'group' => $group, 'sort' => $sort)),'gridcols',$options, $gridcols);
- }
- echo ' |
';//';
- if ($grouptype === 0) {
- if ($currentgroup) {
- $students = get_users_by_capability($context, 'mod/attforblock:canbelisted', '', "u.$sort ASC", '', '', $currentgroup, '', false);
- } else {
- $students = get_users_by_capability($context, 'mod/attforblock:canbelisted', '', "u.$sort ASC", '', '', '', '', false);
- }
- } else {
- $students = get_users_by_capability($context, 'mod/attforblock:canbelisted', '', "u.$sort ASC", '', '', $grouptype, '', false);
- }
-
- $sort = $sort == 'firstname' ? 'firstname' : 'lastname';
- /// Now we need a menu for separategroups as well!
- if ($grouptype === 0 &&
- ($groupmode == VISIBLEGROUPS ||
- ($groupmode && has_capability('moodle/site:accessallgroups', $context)))) {
- groups_print_activity_menu($cm, "attendances.php?id=$id&sessionid=$sessionid&grouptype=$grouptype&sort=$sort");
- }
-
- $table->data[][] = ''.get_string('sessiondate','attforblock').': '.userdate($sessdata->sessdate, get_string('strftimedate').', '.get_string('strftimehm', 'attforblock')).
- ', "'.($sessdata->description ? $sessdata->description : get_string('nodescription', 'attforblock')).'"';
- print_table($table);
-
- $statuses = get_statuses($attforblock->id);
- $i = 3;
- $tabhead = array();
- foreach($statuses as $st) {
- switch($view) {
- case SORTEDLISTVIEW:
- $tabhead[] = "$st->acronym";
- break;
- case SORTEDGRIDVIEW:
- $tabhead[] = "acronym . "', null);\">$st->acronym";
- break;
- }
- $i++;
- }
- if ($view == SORTEDLISTVIEW) {
- $tabhead[] = get_string('remarks','attforblock');
- }
-
- $firstname = "".get_string('firstname').'';
- $lastname = "".get_string('lastname').'';
- if ($CFG->fullnamedisplay == 'lastname firstname') { // for better view (dlnsk)
- $fullnamehead = "$lastname / $firstname";
- } else {
- $fullnamehead = "$firstname / $lastname";
- }
-
- if ($students) {
- unset($table);
-
- switch($view) {
- case SORTEDLISTVIEW: // sorted list
- $table->width = '0%';
- $table->head[] = '#';
- $table->align[] = 'center';
- $table->size[] = '20px';
-
- $table->head[] = '';
- $table->align[] = '';
- $table->size[] = '1px';
-
- $table->head[] = $fullnamehead;
- $table->align[] = 'left';
- $table->size[] = '';
- $table->wrap[2] = 'nowrap';
- foreach ($tabhead as $hd) {
- $table->head[] = $hd;
- $table->align[] = 'center';
- $table->size[] = '20px';
- }
- $i = 0;
- foreach($students as $student) {
- $i++;
- $att = $DB->get_record('attendance_log', array('sessionid'=> $sessionid, 'studentid'=> $student->id));
- $table->data[$student->id][] = (!$att && $update) ? "$i" : $i;
- $table->data[$student->id][] = print_user_picture($student->id, $course->id, $student->picture, 20, true, true);//, $returnstring=false, $link=true, $target='');
- $table->data[$student->id][] = "id}\">".((!$att && $update) ? '' : '').fullname($student).((!$att && $update) ? '' : '').'';
-
- foreach($statuses as $st) {
- $copyid = ($copyfrom == "-1") ? $sessionid : $copyfrom;
- $att = $DB->get_record('attendance_log', array('sessionid'=> $copyid, 'studentid'=> $student->id));
- $currentstatusid = $att===false ? -1 : $att->statusid;
- @$table->data[$student->id][] = 'id == $currentstatusid ? 'checked' : '').'>';
- }
- $table->data[$student->id][] = '';
- }
- break;
- case SORTEDGRIDVIEW: // sorted grid
- $table->width = '0%';
-
- $data = '';
- foreach ($tabhead as $hd) {
- $data = $data . $hd . ' ';
- }
- print_heading($data,'center');
-
- $i = 0;
- // sanity check
- $gridcols = $gridcols < 1 ? 1 : $gridcols;
- for ($i=0; $i<$gridcols; $i++) {
- $table->head[] = ' ';
- $table->align[] = 'center';
- $table->size[] = '110px';
- }
-
- $i = 0;
- foreach($students as $student) {
- $i++;
- $copyid = ($copyfrom == "-1") ? $sessionid : $copyfrom;
- $att = $DB->get_record('attendance_log', array('sessionid'=> $copyid, 'studentid'=> $student->id));
- $currentstatusid = $att===false ? -1 : $att->statusid;
- $data = "" . print_user_picture($student, $course->id, $student->picture, true, true, '', fullname($student)) . "
" . fullname($student) . "
";//, $returnstring=false, $link=true, $target='');
- foreach($statuses as $st) {
- $data = $data . 'id == $currentstatusid ? 'checked' : '').'> ' . $st->acronym . " ";
- }
- $table->data[($i-1) / ($gridcols)][] = $data;
- }
- break;
- }
-
- echo '';
-
- if (count($todaysessions)>1) {
- echo '
';
- echo '";
- //popup_form("$dataurl©from=", $optionssessions, 'copysessionmenu', $sessionid, '');
- echo $OUTPUT->single_select(new moodle_url('/mod/attforblock/attendances.php', array('id'=> $id, 'sessionid'=>$sessionid, 'grouptype' => $grouptype, 'group' => $group, 'sort' => $sort)),'copyfrom',$optionssessions, $sessionid);
- echo ' |
';
- }
-
- } else {
- print_heading(get_string('nothingtodisplay'), 'center');
- }
-
- echo get_string('status','attforblock').':
';
- foreach($statuses as $st) {
- echo $st->acronym.' - '.$st->description.'
';
- }
-
- $OUTPUT->footer($course);
-
-?>
diff --git a/_attsettings.php b/_attsettings.php
deleted file mode 100644
index 5c2b8c1..0000000
--- a/_attsettings.php
+++ /dev/null
@@ -1,180 +0,0 @@
-get_record('course_modules', array('id'=> $id))) {
- error('Course Module ID was incorrect');
- }
- if (! $course = $DB->get_record('course', array('id'=> $cm->course))) {
- error('Course is misconfigured');
- }
- if (! $attforblock = $DB->get_record('attforblock', array('id'=> $cm->instance))) {
- error("Course module is incorrect");
- }
- }
- //$attforblockrecord = get_record('attforblock','course',$course->id);
- if (! $attforblockrecord = $DB->get_record('attforblock', array('id'=> $cm->instance))) {
- error("Course module is incorrect");
- }
-
-
- require_login($course->id);
-
- if (! $user = $DB->get_record('user', array('id'=> $USER->id) )) {
- error("No such user in this course");
- }
-
- if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
- print_error('badcontext');
- }
-
- require_capability('mod/attforblock:manageattendances', $context);
-
- /// Print headers
- $navlinks[] = array('name' => $attforblock->name, 'link' => "view.php?id=$id", 'type' => 'activity');
- $navlinks[] = array('name' => get_string('settings', 'attforblock'), 'link' => null, 'type' => 'activityinstance');
- $navigation = build_navigation($navlinks);
- print_header("$course->shortname: ".$attforblock->name.' - '.get_string('settings','attforblock'), $course->fullname,
- $navigation, "", "", true, " ", navmenu($course));
-
- if (!empty($action)) {
- switch ($action) {
- case 'delete':
- if (!$rec = $DB->get_record('attendance_statuses', array('attendanceid'=> $$attforblockrecord->id, 'id'=> $stid))) {
- print_error('notfoundstatus', 'attforblock', "attsettings.php?id=$id");
- }
- if ($DB->count_records('attendance_log', array('statusid'=> $stid))) {
- print_error('cantdeletestatus', 'attforblock', "attsettings.php?id=$id");
- }
-
- $confirm = optional_param('confirm');
- if (isset($confirm)) {
- $DB->set_field('attendance_statuses', 'deleted', 1, array('id' => $rec->id));
-// delete_records('attendance_statuses', 'id', $rec->id);
- redirect('attsettings.php?id='.$id, get_string('statusdeleted','attforblock'), 3);
- }
- print_heading(get_string('deletingstatus','attforblock').' :: ' .$course->fullname);
-
- notice_yesno(get_string('deletecheckfull', '', get_string('variable', 'attforblock')).
- '
'.$rec->acronym.': '.
- ($rec->description ? $rec->description : get_string('nodescription', 'attforblock')),
- "attsettings.php?id=$id&st=$stid&action=delete&confirm=1", $_SERVER['HTTP_REFERER']);
- exit;
- case 'show':
- $DB->set_field('attendance_statuses', 'visible', 1, array('id' => $stid));
- break;
- case 'hide':
- $students = get_users_by_capability($context, 'moodle/legacy:student', '', '', '', '', '', '', false);
- $studlist = implode(',', array_keys($students));
- if (!$DB->count_records_select('attendance_log', "studentid IN (?) AND statusid = ?", array( $studlist, $stid) )) {
- $DB->set_field('attendance_statuses', 'visible', 0, array('id' => $stid));
- } else {
- print_error('canthidestatus', 'attforblock', "attsettings.php?id=$id");
- }
- break;
- default: //Adding new status
- $newacronym = optional_param('newacronym', '', PARAM_MULTILANG);
- $newdescription = optional_param('newdescription', '', PARAM_MULTILANG);
- $newgrade = optional_param('newgrade', 0, PARAM_INT);
- if (!empty($newacronym) && !empty($newdescription)) {
- unset($rec);
- $rec->courseid = $course->id;
- $rec->attendanceid = $attforblock->id;
- $rec->acronym = $newacronym;
- $rec->description = $newdescription;
- $rec->grade = $newgrade;
- $DB->insert_record('attendance_statuses', $rec);
- add_to_log($course->id, 'attendance', 'setting added', 'mod/attforblock/attsettings.php?course='.$course->id, $user->lastname.' '.$user->firstname);
- } else {
- print_error('cantaddstatus', 'attforblock', "attsettings.php?id=$id");
- }
- break;
- }
- }
-
- show_tabs($cm, $context, 'settings');
-
- if ($submitsettings) {
- config_save(); //////////////////////////////
- notice(get_string('variablesupdated','attforblock'), 'attsettings.php?id='.$id);
- }
-
- $i = 1;
- $table->width = '100%';
- //$table->tablealign = 'center';
- $table->head = array('#',
- get_string('acronym','attforblock'),
- get_string('description'),
- get_string('grade'),
- get_string('action'));
- $table->align = array('center', 'center', 'center', 'center', 'center', 'center');
- //$table->size = array('1px', '1px', '*', '1px', '1px', '1px');
- $statuses = get_statuses($attforblockrecord->id, false);
- $deltitle = get_string('delete');
- foreach($statuses as $st)
- {
- $table->data[$i][] = $i;
-// $table->data[$i][] = $st->status;
- $table->data[$i][] = '';
- $table->data[$i][] = '';
- $table->data[$i][] = '';
-
- $action = $st->visible ? 'hide' : 'show';
- $titlevis = get_string($action);
- $deleteact = '';
- if (!$DB->count_records('attendance_log', array('statusid'=> $st->id))) {
- $deleteact = "id&st={$st->id}&action=delete\">".
- "pixpath}/t/delete.gif\" alt=\"$deltitle\" /> ";
- }
- $table->data[$i][] = "id&st={$st->id}&action=$action\">".
- "pixpath}/t/{$action}.gif\" alt=\"$titlevis\" /> ".
- $deleteact;
- $i++;
- }
- $new_row = array('*',
- '',
- '',
- '',
- ''
- );
- $table->data[$i] = $new_row;
-
- echo '';
-
- print_footer($course);
-
-
-function config_save()
-{
- global $course, $user, $attforblockrecord, $DB;
-
- $acronym = required_param('acronym');
- $description = required_param('description');
- $grade = required_param('grade',PARAM_INT);
-
- foreach ($acronym as $id => $v) {
- $rec = $DB->get_record('attendance_statuses', array('id'=> $id));
- $rec->acronym = $acronym[$id];
- $rec->description = $description[$id];
- $rec->grade = $grade[$id];
- $DB->update_record('attendance_statuses', $rec);
- add_to_log($course->id, 'attendance', 'settings updated', 'mod/attforblock/attsettings.php?course='.$course->id, $user->lastname.' '.$user->firstname);
- }
- attforblock_update_grades($attforblockrecord);
-}
-
-?>
diff --git a/_backuplib.php b/_backuplib.php
deleted file mode 100644
index 23aa51f..0000000
--- a/_backuplib.php
+++ /dev/null
@@ -1,206 +0,0 @@
- $instance) {
- $info += attforblock_check_backup_mods_instances($course, $instance, $backup_unique_code);
- }
- return $info;
- }
- return $info;
- }
-
-
-
- function attforblock_check_backup_mods_instances($course, $instance, $backup_unique_code) {
-
- global $DB;
-
- //First the course data
- $info[$instance->id.'0'][0] = ''.$instance->name.'';
- $info[$instance->id.'0'][1] = '';
-
- $sessions = $DB->get_records_menu('attendance_sessions', array('courseid'=> $course));
- $info[$instance->id.'1'][0] = get_string('sessions', 'attforblock');
- $info[$instance->id.'1'][1] = count($sessions);
-
- //Now, if requested, the user_data
- if (!empty($instance->userdata)) {
- $info[$instance->id.'2'][0] = get_string('attrecords', 'attforblock');
- $sesslist = implode(',', array_keys($sessions));
- if ($datas = $DB->get_records_list('attendance_log', array('sessionid'=> $sesslist))) {
- $info[$instance->id.'2'][1] = count($datas);
- } else {
- $info[$instance->id.'2'][1] = 0;
- }
- }
- return $info;
- }
-
-
- function attforblock_backup_mods($bf, $preferences) {
-
- global $CFG, $DB;
-
- $status = true;
-
- //Iterate over attforblock table
- $attforblocks = $DB->get_records ('attforblock', 'course', array($preferences->backup_course=> 'id'));
- if ($attforblocks) {
- foreach ($attforblocks as $attforblock) {
- if (backup_mod_selected($preferences, 'attforblock', $attforblock->id)) {
- $status = attforblock_backup_one_mod($bf, $preferences, $attforblock);
- }
- }
- }
-
- return $status;
- }
-
-
-
- function attforblock_backup_one_mod($bf, $preferences, $attforblock) {
-
- global $CFG, $DB;
-
- if (is_numeric($attforblock)) {
- $attforblock = $DB->get_record('attforblock', array('id'=> $attforblock));
- }
-
- $status = true;
-
- //Start mod
- fwrite ($bf,start_tag('MOD',3,true));
- //Print attforblock data
- fwrite ($bf,full_tag('ID',4,false,$attforblock->id));
- fwrite ($bf,full_tag('MODTYPE',4,false,'attforblock'));
- fwrite ($bf,full_tag('COURSE',4,false,$attforblock->course));
- fwrite ($bf,full_tag('NAME',4,false,$attforblock->name));
- fwrite ($bf,full_tag('GRADE',4,false,$attforblock->grade));
-
- attforblock_backup_attendance_statuses ($bf,$preferences,$attforblock);
- attforblock_backup_attendance_sessions ($bf,$preferences,$attforblock);
- if (backup_userdata_selected($preferences, 'attforblock', $attforblock->id)) {
- attforblock_backup_attendance_log ($bf,$preferences,$attforblock);
- }
-
- //End mod
- $status =fwrite ($bf,end_tag('MOD',3,true));
-
- return $status;
- }
-
-
- function attforblock_backup_attendance_sessions ($bf,$preferences,$attforblock) {
-
- global $CFG, $DB;
-
- $status = true;
-
- $datas = $DB->get_records('attendance_sessions', array('attendanceid'=> $attforblock->id));
- if ($datas) {
- //Write start tag
- $status =fwrite ($bf,start_tag('SESSIONS',4,true));
- //Iterate over each session
- foreach ($datas as $item) {
- //Start session
- $status =fwrite ($bf,start_tag('SESSION',5,true));
- //Print contents
- fwrite ($bf,full_tag('ID',6,false,$item->id));
- fwrite ($bf,full_tag('COURSEID',6,false,$item->courseid));
- fwrite ($bf,full_tag('GROUPID',6,false,$item->groupid));
- fwrite ($bf,full_tag('SESSDATE',6,false,$item->sessdate));
- fwrite ($bf,full_tag('DURATION',6,false,$item->duration));
- fwrite ($bf,full_tag('TIMEMODIFIED',6,false,$item->timemodified));
- fwrite ($bf,full_tag('DESCRIPTION',6,false,$item->description));
- if (backup_userdata_selected($preferences, 'attforblock', $attforblock->id)) {
- fwrite ($bf,full_tag('LASTTAKEN',6,false,$item->lasttaken));
- fwrite ($bf,full_tag('LASTTAKENBY',6,false,$item->lasttakenby));
- } else {
- fwrite ($bf,full_tag('LASTTAKEN',6,false,0));
- fwrite ($bf,full_tag('LASTTAKENBY',6,false,0));
- }
- //End submission
- $status =fwrite ($bf,end_tag('SESSION',5,true));
- }
- //Write end tag
- $status =fwrite ($bf,end_tag('SESSIONS',4,true));
- }
- return $status;
- }
-
-
- function attforblock_backup_attendance_statuses ($bf,$preferences,$attforblock) {
-
- global $CFG, $DB;
-
- $status = true;
-
- $datas = $DB->get_records('attendance_statuses', array('courseid'=> $attforblock->course, 'attendanceid' => $attforblock->id));
- //If there is levels
- if ($datas) {
- //Write start tag
- $status =fwrite ($bf,start_tag('STATUSES',4,true));
- //Iterate over each status
- foreach ($datas as $item) {
- //Start status
- $status =fwrite ($bf,start_tag('STATUS',5,true));
- //Print status contents
- fwrite ($bf,full_tag('ID',6,false,$item->id));
- fwrite ($bf,full_tag('COURSEID',6,false,$item->courseid));
- fwrite ($bf,full_tag('ACRONYM',6,false,$item->acronym));
- fwrite ($bf,full_tag('DESCRIPTION',6,false,$item->description));
- fwrite ($bf,full_tag('GRADE',6,false,$item->grade));
- fwrite ($bf,full_tag('VISIBLE',6,false,$item->visible));
- fwrite ($bf,full_tag('DELETED',6,false,$item->deleted));
- //End submission
- $status =fwrite ($bf,end_tag('STATUS',5,true));
- }
- //Write end tag
- $status =fwrite ($bf,end_tag('STATUSES',4,true));
- }
- return $status;
- }
-
-
-
- function attforblock_backup_attendance_log ($bf,$preferences,$attforblock) {
-
- global $CFG, $DB;
-
- $status = true;
-
- $sessions = $DB->get_records_menu('attendance_sessions', array('courseid'=> $attforblock->course, 'attendanceid' => $attforblock->id));
- $sesslist = implode(',', array_keys($sessions));
- $datas = $DB->get_records_list('attendance_log', array('sessionid'=> $sesslist));
- //If there is levels
- if ($datas) {
- //Write start tag
- $status = fwrite ($bf,start_tag('LOGS',4,true));
- //Iterate over each log
- foreach ($datas as $item) {
- //Start log
- $status = fwrite ($bf,start_tag('LOG',5,true));
- //Print log contents
- fwrite ($bf,full_tag('ID',6,false,$item->id));
- fwrite ($bf,full_tag('SESSIONID',6,false,$item->sessionid));
- fwrite ($bf,full_tag('STUDENTID',6,false,$item->studentid));
- fwrite ($bf,full_tag('STATUSID',6,false,$item->statusid));
- fwrite ($bf,full_tag('TIMETAKEN',6,false,$item->timetaken));
- fwrite ($bf,full_tag('TAKENBY',6,false,$item->takenby));
- fwrite ($bf,full_tag('STATUSSET',6,false,$item->statusset));
- fwrite ($bf,full_tag('REMARKS',6,false,$item->remarks));
- //End submission
- $status = fwrite ($bf,end_tag('LOG',5,true));
- }
- //Write end tag
- $status = fwrite ($bf,end_tag('LOGS',4,true));
- }
- return $status;
- }
-
-
-?>
\ No newline at end of file
diff --git a/_export.php b/_export.php
deleted file mode 100644
index 9ab8a90..0000000
--- a/_export.php
+++ /dev/null
@@ -1,188 +0,0 @@
-get_record("course_modules", array("id"=> $id))) {
- error("Course Module ID was incorrect");
- }
-
- if (! $course = $DB->get_record("course", array("id"=> $cm->course))) {
- error("Course is misconfigured");
- }
-
- if (! $attforblock = $DB->get_record('attforblock', array('id'=> $cm->instance))) {
- error("Course module is incorrect");
- }
-
- require_login($course->id);
-
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
- require_capability('mod/attforblock:export', $context);
-
- $mform_export = new mod_attforblock_export_form('export.php', array('course'=>$course, 'cm'=>$cm, 'modcontext'=>$context));
-
- if ($fromform = $mform_export->get_data()) {
- $group = groups_get_group($fromform->group);
- if ($group) {
- $students = get_users_by_capability($context, 'moodle/legacy:student', '', 'u.lastname ASC', '', '', $group->id, '', false);
- } else {
- $students = get_users_by_capability($context, 'moodle/legacy:student', '', 'u.lastname ASC', '', '', '', '', false);
- }
-
- if ($students) {
- $filename = clean_filename($course->shortname.'_Attendances_'.userdate(time(), '%Y%m%d-%H%M'));
-
- $data->tabhead = array();
-// $data->sheettitle = $course->fullname.' - ';
-// $data->sheettitle .= $group ? $group->name : get_string('allparticipants');
- $data->course = $course->fullname;
- $data->group = $group ? $group->name : get_string('allparticipants');
-
- if (isset($fromform->ident['id'])) {
- $data->tabhead[] = get_string('studentid','attforblock');
- }
- if (isset($fromform->ident['uname'])) {
- $data->tabhead[] = get_string('username');
- }
- $data->tabhead[] = get_string('lastname');
- $data->tabhead[] = get_string('firstname');
-
- $select = "courseid = :cid AND sessdate >= :cstartdate";
- if (isset($fromform->includenottaken)) {
- $select .= " AND sessdate <= :cenddate";
- } else {
- $select .= " AND lasttaken != 0";
- }
-
- if ($sessions = $DB->get_records_select('attendance_sessions', $select,
- array('cid' => $course->id, 'cstartdate' => $course->startdate, 'cenddate' => $fromform->sessionenddate ), 'sessdate ASC')) {
- foreach($sessions as $sess) {
- $data->tabhead[] = userdate($sess->sessdate, get_string('strftimedmyhm', 'attforblock'));
- }
- } else {
- error('Sessions not found!', 'report.php?id='.$id);
- }
- $data->tabhead[] = '%';
-
- $i = 0;
- $data->table = array();
- $statuses = get_statuses($attforblock->id);
- foreach($students as $student) {
- if (isset($fromform->ident['id'])) {
- $data->table[$i][] = $student->id;
- }
- if (isset($fromform->ident['uname'])) {
- $data->table[$i][] = $student->username;
- }
- $data->table[$i][] = $student->lastname;
- $data->table[$i][] = $student->firstname;
- foreach ($sessions as $sess) {
- if ($rec = $DB->get_record('attendance_log', array('sessionid'=> $sess->id, 'studentid'=> $student->id))) {
- $data->table[$i][] = $statuses[$rec->statusid]->acronym;
- } else {
- $data->table[$i][] = '-';
- }
- }
- $data->table[$i][] = get_percent($student->id, $course, $attforblock).'%';
- $i++;
- }
-
- if ($fromform->format === 'text') {
- ExportToCSV($data, $filename);
- } else {
- ExportToTableEd($data, $filename, $fromform->format);
- }
- exit;
- } else {
- error('Students not found!', 'report.php?id='.$id);
- }
- } else {
- /// Print headers
- $navlinks[] = array('name' => $attforblock->name, 'link' => "view.php?id=$id", 'type' => 'activity');
- $navlinks[] = array('name' => get_string('export', 'quiz'), 'link' => null, 'type' => 'activityinstance');
- $navigation = build_navigation($navlinks);
- print_header("$course->shortname: ".$attforblock->name.' - ' .get_string('export', 'quiz'), $course->fullname,
- $navigation, "", "", true, " ", navmenu($course));
-
- show_tabs($cm, $context, 'export');
- $mform_export->display();
- }
- print_footer($course);
-
-/////////////////////////////////////////////////////////////////////////////////
-
-function ExportToTableEd($data, $filename, $format) {
- global $CFG;
-
- if ($format === 'excel') {
- require_once("$CFG->libdir/excellib.class.php");
- $filename .= ".xls";
- $workbook = new MoodleExcelWorkbook("-");
- } else {
- require_once("$CFG->libdir/odslib.class.php");
- $filename .= ".ods";
- $workbook = new MoodleODSWorkbook("-");
- }
-/// Sending HTTP headers
- $workbook->send($filename);
-/// Creating the first worksheet
- $myxls =& $workbook->add_worksheet('Attendances');
-/// format types
- $formatbc =& $workbook->add_format();
- $formatbc->set_bold(1);
-
- $myxls->write(0, 0, get_string('course'), $formatbc);
- $myxls->write(0, 1, $data->course);
- $myxls->write(1, 0, get_string('group'), $formatbc);
- $myxls->write(1, 1, $data->group);
-
- $i = 3;
- $j = 0;
- foreach ($data->tabhead as $cell) {
- $myxls->write($i, $j++, $cell, $formatbc);
- }
- $i++;
- $j = 0;
- foreach ($data->table as $row) {
- foreach ($row as $cell) {
- $myxls->write($i, $j++, $cell);
-// if (is_numeric($cell)) {
-// $myxls->write_number($i, $j++, $cell);
-// } else {
-// $myxls->write_string($i, $j++, $cell);
-// }
- }
- $i++;
- $j = 0;
- }
- $workbook->close();
-}
-
-function ExportToCSV($data, $filename) {
- $filename .= ".txt";
-
- header("Content-Type: application/download\n");
- header("Content-Disposition: attachment; filename=\"$filename\"");
- header("Expires: 0");
- header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
- header("Pragma: public");
-
- echo get_string('course')."\t".$data->course."\n";
- echo get_string('group')."\t".$data->group."\n\n";
-
- echo implode("\t", $data->tabhead)."\n";
- foreach ($data->table as $row) {
- echo implode("\t", $row)."\n";
- }
-}
-
-?>
diff --git a/_locallib.php b/_locallib.php
deleted file mode 100644
index fbc8f9a..0000000
--- a/_locallib.php
+++ /dev/null
@@ -1,555 +0,0 @@
-libdir.'/gradelib.php');
-
-define('ONE_DAY', 86400); // Seconds in one day
-define('ONE_WEEK', 604800); // Seconds in one week
-
-define('COMMONSESSION', 0);
-define('GROUPSESSION', 1);
-
-define('WITHOUT_SELECTOR', 0);
-define('GROUP_SELECTOR', 1);
-define('SESSION_TYPE_SELECTOR', 2);
-
-define('SORTEDLISTVIEW', 0);
-define('SORTEDGRIDVIEW', 1);
-
-function show_tabs($cm, $context, $currenttab='sessions')
-{
- $toprow = array();
- if (has_capability('mod/attforblock:manageattendances', $context) or
- has_capability('mod/attforblock:takeattendances', $context) or
- has_capability('mod/attforblock:changeattendances', $context)) {
- $toprow[] = new tabobject('sessions', 'manage.php?id='.$cm->id,
- get_string('sessions','attforblock'));
- }
-
- if (has_capability('mod/attforblock:manageattendances', $context)) {
- $toprow[] = new tabobject('add', "sessions.php?id=$cm->id&action=add",
- get_string('add','attforblock'));
- }
- if (has_capability('mod/attforblock:viewreports', $context)) {
- $toprow[] = new tabobject('report', 'report.php?id='.$cm->id,
- get_string('report','attforblock'));
- }
- if (has_capability('mod/attforblock:export', $context)) {
- $toprow[] = new tabobject('export', 'export.php?id='.$cm->id,
- get_string('export','quiz'));
- }
- if (has_capability('mod/attforblock:changepreferences', $context)) {
- $toprow[] = new tabobject('settings', 'attsettings.php?id='.$cm->id,
- get_string('settings','attforblock'));
- }
-
- $tabs = array($toprow);
- print_tabs($tabs, $currenttab);
-}
-
-
-//getting settings for course
-
-function get_statuses($attendanceid, $onlyvisible = true)
-{
- global $DB;
-
- if ($onlyvisible) {
- $result = $DB->get_records_select('attendance_statuses', "attendanceid = :aid AND visible = 1 AND deleted = 0", array('aid' => $attendanceid), 'grade DESC');
- } else {
- $result = $DB->get_records_select('attendance_statuses', "attendanceid = :aid AND deleted = 0", array('aid' => $attendanceid), 'grade DESC');
-// $result = get_records('attendance_statuses', 'courseid', $courseid, 'grade DESC');
- }
- return $result;
-}
-
-//gets attendance status for a student, returns count
-
-function get_attendance($userid, $course, $attendance, $statusid=0)
-{
- global $CFG, $DB;
- $qry = "SELECT count(*) as cnt
- FROM {attendance_log} al
- JOIN {attendance_sessions} ats
- ON al.sessionid = ats.id
- WHERE ats.attendanceid = :aid
- AND ats.sessdate >= :cstartdate
- AND al.studentid = :uid";
- if ($statusid) {
- $qry .= " AND al.statusid = :sid";
- }
-
- return $DB->count_records_sql($qry, array('aid' => $attendance->id, 'cstartdate' => $course->startdate, 'uid'=>$userid, 'sid'=>$statusid ));
-}
-
-function get_grade($userid, $course, $attendance)
-{
- global $CFG, $DB;
- $logs = $DB->get_records_sql("SELECT l.id, l.statusid, l.statusset
- FROM {attendance_log} l
- JOIN {attendance_sessions} s
- ON l.sessionid = s.id
- WHERE l.studentid = :usid
- AND s.attendanceid = :aid
- AND s.courseid = :cid
- AND s.sessdate >= :cstartdate", array('usid' => $userid, 'aid' => $attendance->id, 'cid' => $course->id, 'cstartdate' => $course->startdate ));
- $result = 0;
- if ($logs) {
- $stat_grades = $DB->records_to_menu($DB->get_records('attendance_statuses', array('attendanceid'=> $attendance->id)), 'id', 'grade');
- foreach ($logs as $log) {
- $result += $stat_grades[$log->statusid];
- }
- }
-
- return $result;
-}
-
-//temporary solution, for support PHP 4.3.0 which minimal requirement for Moodle 1.9.x
-function local_array_intersect_key($array1, $array2) {
- $result = array();
- foreach ($array1 as $key => $value) {
- if (isset($array2[$key])) {
- $result[$key] = $value;
- }
- }
- return $result;
-}
-
-function get_maxgrade($userid, $course, $attendance)
-{
- global $CFG, $DB;
- $logs = $DB->get_records_sql("SELECT l.id, l.statusid, l.statusset
- FROM {attendance_log} l
- JOIN {attendance_sessions} s
- ON l.sessionid = s.id
- WHERE l.studentid = :usid
- AND s.attendanceid = :aid
- AND s.courseid = :cid
- AND s.sessdate >= :cstartdate", array('usid' => $userid, 'aid' => $attendance->id, 'cid' => $course->id, 'cstartdate' => $course->startdate ));
-
- $maxgrade = 0;
- if ($logs) {
- $stat_grades = $DB->records_to_menu($DB->get_records('attendance_statuses', array('attendanceid'=> $attendance->id)), 'id', 'grade');
- foreach ($logs as $log) {
- $ids = array_flip(explode(',', $log->statusset));
-// $grades = array_intersect_key($stat_grades, $ids); // require PHP 5.1.0 and higher
- $grades = local_array_intersect_key($stat_grades, $ids); //temporary solution, for support PHP 4.3.0 which minimal requirement for Moodle 1.9.x
- $maxgrade += max($grades);
- }
- }
-
- return $maxgrade;
-}
-
-function get_percent_adaptive($userid, $course) // NOT USED
-{
- global $CFG, $DB;
- $logs = $DB->get_records_sql("SELECT l.id, l.statusid, l.statusset
- FROM {attendance_log} l
- JOIN {attendance_sessions} s
- ON l.sessionid = s.id
- WHERE l.studentid = :usid
- AND s.attendanceid = :aid
- AND s.courseid = :cid
- AND s.sessdate >= :cstartdate", array('usid' => $userid, 'aid' => $attendance->id, 'cid' => $course->id, 'cstartdate' => $course->startdate ));
- $result = 0;
- if ($logs) {
- $stat_grades = $DB->records_to_menu($DB->get_records('attendance_statuses', array('attendanceid'=> $attendance->id)), 'id', 'grade');
-
- $percent = 0;
- foreach ($logs as $log) {
- $ids = array_flip(explode(',', $log->statusset));
- $grades = array_intersect_key($stat_grades, $ids);
- $delta = max($grades) - min($grades);
- $percent += $stat_grades[$log->statusid] / $delta;
- }
- $result = $percent / count($logs) * 100;
- }
- if (!$dp = grade_get_setting($course->id, 'decimalpoints')) {
- $dp = $CFG->grade_decimalpoints;
- }
-
- return sprintf("%0.{$dp}f", $result);
-}
-
-function get_percent($userid, $course, $attforblock)
-{
- global $CFG;
-
- $maxgrd = get_maxgrade($userid, $course, $attforblock);
- if ($maxgrd == 0) {
- $result = 0;
- } else {
- $result = get_grade($userid, $course, $attforblock) / $maxgrd * 100;
- }
- if ($result < 0) {
- $result = 0;
- }
- if (!$dp = grade_get_setting($course->id, 'decimalpoints')) {
- $dp = $CFG->grade_decimalpoints;
- }
-
- return sprintf("%0.{$dp}f", $result);
-}
-
-function set_current_view($courseid, $view) {
- global $SESSION;
-
- return $SESSION->currentattview[$courseid] = $view;
-}
-
-function get_current_view($courseid, $defaultview='weeks') {
- global $SESSION;
-
- if (isset($SESSION->currentattview[$courseid]))
- return $SESSION->currentattview[$courseid];
- else
- return $defaultview;
-}
-
-function set_current_date($courseid, $date) {
- global $SESSION;
-
- return $SESSION->currentattdate[$courseid] = $date;
-}
-
-function get_current_date($courseid) {
- global $SESSION;
-
- if (isset($SESSION->currentattdate[$courseid]))
- return $SESSION->currentattdate[$courseid];
- else
- return time();
-}
-
-function print_row($left, $right) {
- echo "\n$left | $right |
\n";
-}
-
-function print_attendance_table($user, $course, $attforblock) {
-
- $complete = get_attendance($user->id, $course, $attforblock);
-
- echo '';
- print_row(get_string('sessionscompleted','attforblock').':', "$complete");
- $statuses = get_statuses($attforblock->id);
- foreach($statuses as $st) {
- print_row($st->description.': ', ''.get_attendance($user->id, $course, $attforblock, $st->id).'');
- }
-
- if ($attforblock->grade) {
- $percent = get_percent($user->id, $course, $attforblock).' %';
- $grade = get_grade($user->id, $course, $attforblock);
- print_row(get_string('attendancepercent','attforblock').':', "$percent");
- print_row(get_string('attendancegrade','attforblock').':', "$grade / ".get_maxgrade($user->id, $course, $attforblock));
- }
- print_row(' ', ' ');
- echo '
';
-
-}
-
-function print_user_attendaces($user, $cm, $attforblock, $course = 0, $printing = null) {
- global $CFG, $COURSE, $mode, $current, $view, $id, $studentid, $DB;
-
- echo '';
- if (!$printing) {
- echo '';
- echo ' | ';
- echo '
';
- }
-// echo '';
-// echo ''.get_string('attendancereport','attforblock').helpbutton('studentview', get_string('attendancereport','attforblock'), 'attforblock', true, false, '', true).' | ';
-// echo '
';
- echo '';
- echo '';
- print_user_picture($user->id, $COURSE->id, $user->picture, true);
- echo ' | ';
- echo '';
- echo ''.fullname($user).'';
- if ($course) {
- echo ' ';
- $complete = get_attendance($user->id, $course, $attforblock);
- if($complete) {
- print_attendance_table($user, $course, $attforblock);
- } else {
- echo get_string('attendancenotstarted','attforblock');
- }
- } else {
- $stqry = "SELECT ats.id,ats.courseid AS 'cid',ats.attendanceid AS 'aid'
- FROM {attendance_log} al
- JOIN {attendance_sessions} ats
- ON al.sessionid = ats.id
- WHERE al.studentid = ?
- GROUP BY cid
- ORDER BY cid,aid asc";
- $recs = $DB->get_records_sql($stqry, array($user->id));
- foreach ($recs as $rec) {
- echo ' ';
- echo '';
- $nextcourse = $DB->get_record('course', array('id'=> $rec['cid']));
- $nextattendance = $DB->get_record('attforblock', array('id'=> $rec['aid']));
- echo ''.$nextcourse->fullname.' - '.$nextattendance->name . ' | ';
- echo '';
- $complete = get_attendance($user->id, $nextcourse, $nextattendance);
- if($complete) {
- print_attendance_table($user, $nextcourse, $nextattendance);
- } else {
- echo get_string('attendancenotstarted','attforblock');
- }
- echo ' | ';
- echo ' ';
- }
- }
-
-
- if ($course) {
- if ($current == 0)
- $current = get_current_date($course->id);
- else
- set_current_date ($course->id, $current);
-
- $ret = print_filter_controls("view.php", $id, $studentid);
- $startdate = $ret['startdate'];
- $enddate = $ret['enddate'];
-
- if ($startdate && $enddate) {
- $where = "ats.courseid=:cid AND al.studentid = :uid AND ats.sessdate >= :sdate AND ats.sessdate < :edate";
- } else {
- $where = "ats.courseid=:cid AND al.studentid = :uid";
- }
-
- $stqry = "SELECT ats.id,ats.sessdate,ats.description,al.statusid,al.remarks
- FROM {attendance_log} al
- JOIN {attendance_sessions} ats
- ON al.sessionid = ats.id";
- $stqry .= " WHERE " . $where;
- $stqry .= " ORDER BY ats.sessdate asc";
-
- if ($sessions = $DB->get_records_sql($stqry, array('cid' => $course->id, 'uid'=> $user->id, 'sdate'=> $startdate, 'edate'=> $enddate))) {
- $statuses = get_statuses($course->id);
-
- $i = 0;
- $table->head = array('#', get_string('date'), get_string('time'), get_string('description','attforblock'), get_string('status','attforblock'), get_string('remarks','attforblock'));
- $table->align = array('', '', 'left', 'left', 'center', 'left');
- $table->size = array('1px', '1px', '1px', '*', '1px', '1px');
- $table->class = 'generaltable attwidth';
- foreach($sessions as $key=>$sessdata)
- {
- $i++;
- $table->data[$sessdata->id][] = $i;
- $table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimedmyw', 'attforblock'));
- $table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimehm', 'attforblock'));
- $table->data[$sessdata->id][] = empty($sessdata->description) ? get_string('nodescription', 'attforblock') : $sessdata->description;
- $table->data[$sessdata->id][] = $statuses[$sessdata->statusid]->description;
- $table->data[$sessdata->id][] = $sessdata->remarks;
- }
- print_table($table);
- }
- }
- echo ' |
|
';
-}
-
-function print_filter_controls($url, $id, $studentid=0, $sort=NULL, $printselector=WITHOUT_SELECTOR) {
-
- global $CFG, $SESSION, $current, $view, $cm;
-
- $date = usergetdate($current);
- $mday = $date['mday'];
- $wday = $date['wday'];
- $mon = $date['mon'];
- $year = $date['year'];
-
- $curdatecontrols = '';
- $curdatetxt = '';
- switch ($view) {
- case 'days':
- $format = get_string('strftimedm', 'attforblock');
- $startdate = make_timestamp($year, $mon, $mday);
- $enddate = make_timestamp($year, $mon, $mday + 1);
- $prevcur = make_timestamp($year, $mon, $mday - 1);
- $nextcur = make_timestamp($year, $mon, $mday + 1);
- $curdatetxt = userdate($startdate, $format);
- break;
- case 'weeks':
- $format = get_string('strftimedm', 'attforblock');
- $startdate = make_timestamp($year, $mon, $mday - $wday + 1);
- $enddate = make_timestamp($year, $mon, $mday + 7 - $wday + 1) - 1;
- $prevcur = $startdate - WEEKSECS;
- $nextcur = $startdate + WEEKSECS;
- $curdatetxt = userdate($startdate, $format)." - ".userdate($enddate, $format);
- break;
- case 'months':
- $format = '%B';
- $startdate = make_timestamp($year, $mon);
- $enddate = make_timestamp($year, $mon + 1);
- $prevcur = make_timestamp($year, $mon - 1);
- $nextcur = make_timestamp($year, $mon + 1);
- $curdatetxt = userdate($startdate, $format);
- break;
- case 'alltaken':
- $startdate = 1;
- $enddate = time();
- break;
- case 'all':
- $startdate = 0;
- $enddate = 0;
- break;
- }
-
- $link = $url . "?id=$id" . ($sort ? "&sort=$sort" : "") . ($studentid ? "&student=$studentid" : "");
-
- $currentgroup = -1;
- $sessiontypeselector = '';
- if ($printselector === GROUP_SELECTOR) {
- $groupmode = groups_get_activity_groupmode($cm);
- $currentgroup = groups_get_activity_group($cm, true);
- $groupselector = '';
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
- if ($groupmode == VISIBLEGROUPS ||
- ($groupmode && has_capability('moodle/site:accessallgroups', $context))) {
- $groupselector = groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/attforblock/' . $link, true);
- }
- } elseif ($printselector === SESSION_TYPE_SELECTOR and $groupmode = groups_get_activity_groupmode($cm)) {
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
- if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $context)) {
- $allowedgroups = groups_get_all_groups($cm->course, 0, $cm->groupingid); // any group in grouping (all if groupings not used)
- // detect changes related to groups and fix active group
- if (!empty($SESSION->activegroup[$cm->course][VISIBLEGROUPS][$cm->groupingid])) {
- if (!array_key_exists($SESSION->activegroup[$cm->course][VISIBLEGROUPS][$cm->groupingid], $allowedgroups)) {
- // active group does not exist anymore
- unset($SESSION->activegroup[$cm->course][VISIBLEGROUPS][$cm->groupingid]);
- }
- }
- if (!empty($SESSION->activegroup[$cm->course]['aag'][$cm->groupingid])) {
- if (!array_key_exists($SESSION->activegroup[$cm->course]['aag'][$cm->groupingid], $allowedgroups)) {
- // active group does not exist anymore
- unset($SESSION->activegroup[$cm->course]['aag'][$cm->groupingid]);
- }
- }
-
- } else {
- $allowedgroups = groups_get_all_groups($cm->course, $USER->id, $cm->groupingid); // only assigned groups
- // detect changes related to groups and fix active group
- if (isset($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid])) {
- if ($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid] == 0) {
- if ($allowedgroups) {
- // somebody must have assigned at least one group, we can select it now - yay!
- unset($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid]);
- }
- } else {
- if (!array_key_exists($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid], $allowedgroups)) {
- // active group not allowed or does not exist anymore
- unset($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid]);
- }
- }
- }
- }
-
- $group = optional_param('group', -2, PARAM_INT);
- if (!array_key_exists('attsessiontype', $SESSION)) {
- $SESSION->attsessiontype = array();
- }
- if ($group > -2) {
- $SESSION->attsessiontype[$cm->course] = $group;
- } elseif (!array_key_exists($cm->course, $SESSION->attsessiontype)) {
- $SESSION->attsessiontype[$cm->course] = -1;
- }
-
- if ($group == -1) {
- $currentgroup = $group;
- unset($SESSION->activegroup[$cm->course][VISIBLEGROUPS][$cm->groupingid]);
- unset($SESSION->activegroup[$cm->course]['aag'][$cm->groupingid]);
- unset($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid]);
- } else {
- $currentgroup = groups_get_activity_group($cm, true);
- if ($currentgroup == 0 and $SESSION->attsessiontype[$cm->course] == -1) {
- $currentgroup = -1;
- }
- }
-
- $selector = array();
- if ($allowedgroups or $groupmode == VISIBLEGROUPS or
- has_capability('moodle/site:accessallgroups', $context)) {
- $selector[-1] = get_string('all', 'attforblock');
- }
- if ($groupmode == VISIBLEGROUPS) {
- $selector[0] = get_string('commonsessions', 'attforblock');
- }
-
- if ($allowedgroups) {
- foreach ($allowedgroups as $group) {
- $selector[$group->id] = format_string($group->name);
- }
- }
-
- if (count($selector) > 1) {
- $sessiontypeselector = popup_form($url.'?id='.$cm->id.'&group=', $selector, 'selectgroup', $currentgroup, '', '', '', true, 'self', get_string('sessions', 'attforblock'));
- }
-
- $sessiontypeselector = ''.$sessiontypeselector.'
';
- }
-
-
- $views['all'] = get_string('all','attforblock');
- $views['alltaken'] = get_string('alltaken','attforblock');
- $views['months'] = get_string('months','attforblock');
- $views['weeks'] = get_string('weeks','attforblock');
- $views['days'] = get_string('days','attforblock');
- $viewcontrols = '';
- foreach ($views as $key => $sview) {
- if ($key != $view)
- $viewcontrols .= "$sview";
- else
- $viewcontrols .= "$sview";
- }
- $viewcontrols .= '';
-
- echo "";
- echo "
";
- if ($printselector === GROUP_SELECTOR) {
- echo "$groupselector | ";
- } elseif ($printselector === SESSION_TYPE_SELECTOR) {
- echo "$sessiontypeselector | ";
- }
-
- if ($curdatetxt) {
- $curdatecontrols = "◄";
- $curdatecontrols .= "";
- $curdatecontrols .= "►";
- plug_yui_calendar($current);
- }
- echo "$curdatecontrols | ";
- echo "$viewcontrols |
";
-
- echo "
";
-
- return array('startdate' => $startdate, 'enddate' => $enddate, 'currentgroup' => $currentgroup);
-}
-
-function plug_yui_calendar($current) {
- global $CFG;
-
- require_js(array('yui_dom-event', 'yui_dragdrop', 'yui_element', 'yui_button', 'yui_container', 'yui_calendar'));
-
- echo "\n";
-
- require_js($CFG->wwwroot . '/mod/attforblock/calendar.js');
-}
-
-?>
diff --git a/_manage.php b/_manage.php
deleted file mode 100644
index 4e3749a..0000000
--- a/_manage.php
+++ /dev/null
@@ -1,212 +0,0 @@
-get_record('course_modules', array('id'=> $id))) {
- error('Course Module ID was incorrect');
- }
-
- if (! $course = $DB->get_record('course', array('id'=> $cm->course))) {
- error("Course is misconfigured");
- }
-
- if (! $attforblock = $DB->get_record('attforblock', array('id'=> $cm->instance))) {
- error("Course module is incorrect");
- }
-
- require_login($course->id);
-
- if (! $user = $DB->get_record('user', array('id'=> $USER->id) )) {
- error("No such user in this course");
- }
-
- if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
- print_error('badcontext');
- }
-
- if ($view)
- set_current_view($course->id, $_GET['view']);
- else
- $view = get_current_view($course->id);
-
- if (!has_capability('mod/attforblock:manageattendances', $context) AND
- !has_capability('mod/attforblock:takeattendances', $context) AND
- !has_capability('mod/attforblock:changeattendances', $context)) {
- redirect("view.php?id=$cm->id");
- }
-
- set_user_preference("attforblock_showendtime",$showendtime);
-
- //if teacher is coming from block, then check for a session exists for today
- if($from === 'block') {
- $today = time(); // because we compare with database, we don't need to use usertime()
- $sql = "SELECT id, groupid, lasttaken
- FROM {attendance_sessions}
- WHERE ? BETWEEN sessdate AND (sessdate + duration)
- AND courseid = ? AND attendanceid = ?";
- if($atts = $DB->get_records_sql($sql, array($today, $course->id, $attforblock->id))) {
- $size = count($atts);
- if ($size == 1) {
- $att = reset($atts);
- if ((!$att->lasttaken and has_capability('mod/attforblock:takeattendances', $context)) or
- ($att->lasttaken and has_capability('mod/attforblock:changeattendances', $context))) {
- redirect('attendances.php?id='.$id.'&sessionid='.$att->id.'&grouptype='.$att->groupid);
- }
- } elseif ($size > 1) {
- $current = $today;
- //temporally set $view for single access to page from block
- $view = 'days';
- }
- }
- }
-
-/// Print headers
-
- $url = new moodle_url('/mod/attforblock/manage.php', array('id'=> $id, 'from'=> $from, 'view' => $view, 'current' => $current, 'showendtime' => $showendtime));
- $PAGE->set_url($url);
- $PAGE->set_title($course->shortname. ": ".$attforblock->name);
- $PAGE->set_heading($course->fullname);
- $PAGE->set_focuscontrol('');
- $PAGE->set_cacheable(true);
- $PAGE->set_button($OUTPUT->update_module_button($cm->id,'attforblock'));
- $PAGE->navbar->add($attforblock->name);
-
- echo $OUTPUT->header();
- echo $OUTPUT->heading(get_string('attendanceforthecourse','attforblock').' :: ' .$course->fullname);
-
- if(!$DB->count_records_select('attendance_sessions', "courseid = ? AND attendanceid = ? AND sessdate >= ?", array($course->id, $attforblock->id, $course->startdate))) { // no session exists for this course
- show_tabs($cm, $context);
- print_heading(get_string('nosessionexists','attforblock'));
- $hiddensess = $DB->count_records_select('attendance_sessions', "courseid = ? AND attendanceid = ? AND sessdate < ?", array($course->id, $attforblock->id, $course->startdate));
- echo ''.helpbutton('hiddensessions', '--', 'attforblock', true, true, '', true); //TODO: fix '--'
- echo get_string('hiddensessions', 'attforblock').': '.$hiddensess.'
';
- } else { //sessions generated , display them
- add_to_log($course->id, 'attendance', 'manage attendances', 'mod/attforblock/manage.php?course='.$course->id, $user->lastname.' '.$user->firstname);
- show_tabs($cm, $context);
- print_sessions_list($course, $attforblock);
- }
-// require_once('lib.php');
-// $t = attforblock_get_user_grades($attforblock); ////////////////////////////////////////////
- $OUTPUT->footer();//print_footer($course);
-
-
-function print_sessions_list($course, $attforblock) {
- global $CFG, $context, $cm, $current, $view, $id, $showendtime, $DB, $OUTPUT;
-
- $strhours = get_string('hours');
- $strmins = get_string('min');
-
- if ($current == 0)
- $current = get_current_date($course->id);
- else
- set_current_date ($course->id, $current);
-
- $ret = print_filter_controls("manage.php", $id, 0, NULL, SESSION_TYPE_SELECTOR);
- $startdate = $ret['startdate'];
- $enddate = $ret['enddate'];
- $currentgroup = $ret['currentgroup'];
-
- if ($startdate && $enddate) {
- $where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :sdate AND sessdate >= :sdate2 AND sessdate < :edate";
- } else {
- $where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :sdate";
- }
-
- if ($currentgroup > -1) {
- $where .= " AND groupid=:cgroup";
- }
-
- $qry = $DB->get_records_select('attendance_sessions', $where, array('cid' => $course->id, 'aid' => $attforblock->id, 'sdate' => $course->startdate,'sdate2' => $startdate, 'edate'=> $enddate, 'cgroup'=> $currentgroup), 'sessdate asc');
- $i = 0;
- $table = new html_table();
- $table->width = '100%';
- //$table->tablealign = 'center';
- $table->head = array('#', get_string('sessiontypeshort', 'attforblock'), get_string('date'), get_string('from'), ($showendtime=='0') ? get_string('duration', 'attforblock') : get_string('to'), get_string('description','attforblock'), get_string('actions'), get_string('select'));
- $table->align = array('', '', '', 'right', 'left', 'center', 'center');
- $table->size = array('1px', '', '1px', '1px', '1px', '*', '1px', '1px');
-
- $allowtake = has_capability('mod/attforblock:takeattendances', $context);
- $allowchange = has_capability('mod/attforblock:changeattendances', $context);
- $allowmanage = has_capability('mod/attforblock:manageattendances', $context);
- $groups = groups_get_all_groups($course->id);
- if ($qry) {
- foreach($qry as $key=>$sessdata)
- {
- $i++;
- $actions = '';
-// if ($allowtake) {
- if($sessdata->lasttaken > 0) //attendance has taken
- {
- if ($allowchange) {
- $desc = "id&sessionid={$sessdata->id}&grouptype={$sessdata->groupid}\">".
- ($sessdata->description ? $sessdata->description : get_string('nodescription', 'attforblock')).
- '';
- } else {
- $desc = ''.(empty($sessdata->description) ? get_string('nodescription', 'attforblock') : $sessdata->description).'';
- }
- } else {
- $desc = empty($sessdata->description) ? get_string('nodescription', 'attforblock') : $sessdata->description;
- if ($allowtake) {
- $title = get_string('takeattendance','attforblock');
- $actions = "id&sessionid={$sessdata->id}&grouptype={$sessdata->groupid}\">".
- "pix_url('t/go') . "\" alt=\"$title\" /> ";
- }
- }
-// }
- if($allowmanage) {
- $title = get_string('editsession','attforblock');
- $actions .= "id&sessionid={$sessdata->id}&action=update\">".
- "pix_url('t/edit') . "\" alt=\"$title\" /> ";
- $title = get_string('deletesession','attforblock');
- $actions .= "id&sessionid={$sessdata->id}&action=delete\">".
- "pix_url('t/delete') . "\" alt=\"$title\" /> ";
- }
-
- $table->data[$sessdata->id][] = $i;
- $table->data[$sessdata->id][] = $sessdata->groupid ? $groups[$sessdata->groupid]->name : get_string('commonsession', 'attforblock');
- $table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimedmyw', 'attforblock'));
- $table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimehm', 'attforblock'));
- $hours = floor($sessdata->duration / HOURSECS);
- $mins = floor(($sessdata->duration - $hours * HOURSECS) / MINSECS);
- $mins = $mins < 10 ? "0$mins" : "$mins";
- $table->data[$sessdata->id][] = ($showendtime=='0') ? ($hours ? "{$hours} {$strhours} {$mins} {$strmins}" : "{$mins} {$strmins}") : userdate($sessdata->sessdate+$sessdata->duration, get_string('strftimehm', 'attforblock'));;
- $table->data[$sessdata->id][] = $desc;
- $table->data[$sessdata->id][] = $actions;
- $table->data[$sessdata->id][] = '';
- unset($desc, $actions);
- }
- }
-
- echo '';
-
-}
-?>
diff --git a/_report.php b/_report.php
deleted file mode 100644
index 1ed27cc..0000000
--- a/_report.php
+++ /dev/null
@@ -1,201 +0,0 @@
-libdir.'/blocklib.php');
- require_once('locallib.php');
-
- define('USER_SMALL_CLASS', 20); // Below this is considered small
- define('USER_LARGE_CLASS', 200); // Above this is considered large
- define('DEFAULT_PAGE_SIZE', 20);
-
- $id = required_param('id', PARAM_INT);
- $group = optional_param('group', -1, PARAM_INT); // Group to show
- $view = optional_param('view', NULL, PARAM_ALPHA); // which page to show
- $current = optional_param('current', 0, PARAM_INT);
- $sort = optional_param('sort', 'lastname', PARAM_ALPHA);
-
- if ($id) {
- if (! $cm = $DB->get_record('course_modules', array('id'=> $id))) {
- error('Course Module ID was incorrect');
- }
- if (! $course = $DB->get_record('course', array('id'=> $cm->course))) {
- error('Course is misconfigured');
- }
- if (! $attforblock = $DB->get_record('attforblock', array('id'=> $cm->instance))) {
- error("Course module is incorrect");
- }
- }
-
- require_login($course->id);
-
- if (! $user = $DB->get_record('user', array('id'=> $USER->id) )) {
- error("No such user in this course");
- }
-
- if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
- print_error('badcontext');
- }
-
- if ($view)
- set_current_view($course->id, $_GET['view']);
- else
- $view = get_current_view($course->id);
-
-
- require_capability('mod/attforblock:viewreports', $context);
-
- //add info to log
- add_to_log($course->id, 'attendance', 'report displayed', 'mod/attforblock/report.php?id='.$id, $user->lastname.' '.$user->firstname);
-
- /// Print headers
- $navlinks[] = array('name' => $attforblock->name, 'link' => "view.php?id=$id", 'type' => 'activity');
- $navlinks[] = array('name' => get_string('report', 'attforblock'), 'link' => null, 'type' => 'activityinstance');
- $navigation = build_navigation($navlinks);
- print_header("$course->shortname: ".$attforblock->name.' - ' .get_string('report','attforblock'), $course->fullname,
- $navigation, "", "", true, " ", navmenu($course));
-
- show_tabs($cm, $context, 'report');
-
- $sort = $sort == 'firstname' ? 'firstname' : 'lastname';
-
- if(!$DB->count_records('attendance_sessions', array('courseid'=> $course->id))) { // no session exists for this course
- redirect("sessions.php?id=$cm->id&action=add");
- } else {
- if ($current == 0)
- $current = get_current_date($course->id);
- else
- set_current_date ($course->id, $current);
-
- $ret = print_filter_controls("report.php", $id, 0, $sort, GROUP_SELECTOR);
- $startdate = $ret['startdate'];
- $enddate = $ret['enddate'];
- $currentgroup = $ret['currentgroup'];
-
- if ($startdate && $enddate) {
- $where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :sdate AND sessdate >= :sdate2 AND sessdate < :edate";
- } else {
- $where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :sdate";
- }
-
- if ($currentgroup) {
- $where .= " AND (groupid=0 OR groupid=:cgroup)";
- $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', $currentgroup, '', false);
- } else {
- $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', '', '', false);
- }
-
- $statuses = get_statuses($attforblock->id);
- $allstatuses = get_statuses($attforblock->id, false);
-
-
- if ($students and
- ($course_sess = $DB->get_records_select('attendance_sessions', $where, array('cid' => $course->id, 'aid'=> $attforblock->id, 'sdate' => $course->startdate,'sdate2' => $startdate, 'edate'=> $enddate, 'cgroup'=> $currentgroup), 'sessdate ASC'))) {
-
- $firstname = "".get_string('firstname').'';
- $lastname = "".get_string('lastname').'';
- if ($CFG->fullnamedisplay == 'lastname firstname') { // for better view (dlnsk)
- $fullnamehead = "$lastname / $firstname";
- } else {
- $fullnamehead = "$firstname / $lastname";
- }
-
- $table->head[] = '';
- $table->align[] = '';
- $table->size[] = '1px';
- $table->head[] = $fullnamehead;
- $table->align[] = 'left';
- $table->size[] = '';
- $table->class = 'generaltable attwidth';
- $allowtake = has_capability('mod/attforblock:takeattendances', $context);
- $allowchange = has_capability('mod/attforblock:changeattendances', $context);
- $groups = groups_get_all_groups($course->id);
- foreach($course_sess as $sessdata) {
- if ($DB->count_records('attendance_log', array('sessionid'=> $sessdata->id))) {
- if ($allowchange) {
- $sessdate = "id}&grouptype={$sessdata->groupid}\">".
- userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'
('.get_string('strftimehm', 'attforblock').')').
- '';
- } else {
- $sessdate = userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'
('.get_string('strftimehm', 'attforblock').')');
- }
- $sesstype = $sessdata->groupid ? $groups[$sessdata->groupid]->name : get_string('commonsession', 'attforblock');
- $table->head[] = $sessdate.'
'.$sesstype;
- } else {
- if ($allowtake) {
- $sessdate = "id}&grouptype={$sessdata->groupid}\">".
- userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'
('.get_string('strftimehm', 'attforblock').')').
- '';
- } else {
- $sessdate = userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').'
('.get_string('strftimehm', 'attforblock').')');
- }
- $sesstype = $sessdata->groupid ? $groups[$sessdata->groupid]->name : get_string('commonsession', 'attforblock');
- $table->head[] = $sessdate.'
'.$sesstype;
- }
- $table->align[] = 'center';
- $table->size[] = '1px';
- }
- for ($i=0; $i<5; $i++) {
- $table->align[] = 'center';
- $table->size[] = '1px';
- }
-
- foreach($statuses as $st) {
- $table->head[] = $st->acronym;
- }
-
- if ($attforblock->grade) {
- $table->head[] = get_string('grade');//.' / '.$maxgrade;
-
- $table->align[] = 'right';
- $table->size[] = '1px';
- $table->head[] = '%';
- }
-
- foreach($students as $student) {
- $table->data[$student->id][] = print_user_picture($student->id, $course->id, $student->picture, 20, true, true);
- $table->data[$student->id][] = "id}\">".fullname($student).'';
- $studgroups = groups_get_all_groups($COURSE->id, $student->id);
- foreach($course_sess as $sessdata) {
- if ($att = $DB->get_record('attendance_log', array('sessionid'=> $sessdata->id, 'studentid'=> $student->id))) {
- if (isset($statuses[$att->statusid])) {
- $table->data[$student->id][] = $statuses[$att->statusid]->acronym;
- } else {
- $table->data[$student->id][] = ''.$allstatuses[$att->statusid]->acronym.'';
- }
- } else {
- if (!$studgroups || $sessdata->groupid && !array_key_exists($sessdata->groupid, $studgroups))
- // student is not memeber of any group OR it is session of other group
- $table->data[$student->id][] = '';
- else
- if($sessdata->lasttaken > 0) {
- // student began to study in the group later this session
- $table->data[$student->id][] = '–';
- } else {
- // no attendance data for session
- $table->data[$student->id][] = '?';
- }
- }
- }
- foreach($statuses as $st) {
- $table->data[$student->id][] = get_attendance($student->id, $course, $attforblock, $st->id);
- }
- if ($attforblock->grade) {
- $table->data[$student->id][] = get_grade($student->id, $course, $attforblock).' / '.get_maxgrade($student->id, $course, $attforblock);
- $table->data[$student->id][] = get_percent($student->id, $course, $attforblock).'%';
- }
- }
- print_table($table);
- } else {
- print_heading(get_string('nothingtodisplay'), 'center');
- }
-
- echo get_string('status','attforblock').':
';
- foreach($statuses as $st) {
- echo $st->acronym.' - '.$st->description.'
';
- }
- }
- print_footer($course);
- exit;
-?>
\ No newline at end of file
diff --git a/_restorelib.php b/_restorelib.php
deleted file mode 100644
index 6dcf162..0000000
--- a/_restorelib.php
+++ /dev/null
@@ -1,264 +0,0 @@
-backup_unique_code, $mod->modtype, $mod->id);
-
- if ($data) {
- //Now get completed xmlized object
- $info = $data->info;
-
- /*if (count_records('attforblock', 'course', $restore->course_id)) {
- return false;
- }*/
-
- //Now, build the attforblock record structure
- $attforblock->course = $restore->course_id;
-// $attforblock->teacher = backup_todb($info['MOD']['#']['TEACHER']['0']['#']);
- $attforblock->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
- if (isset($info['MOD']['#']['GRADE'])) {
- $attforblock->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']);
- } else {
- $attforblock->grade = 100;
- }
-
- //The structure is equal to the db, so insert the attforblock
- $newid = $DB->insert_record ('attforblock', $attforblock);
- if ($newid) {
- //We have the newid, update backup_ids
- backup_putid($restore->backup_unique_code, $mod->modtype, $mod->id, $newid);
-
- attforblock_restore_attendance_statuses ($mod->id, $newid, $info, $restore);
- attforblock_restore_attendance_sessions ($mod->id, $newid, $info, $restore);
- //Now check if want to restore user data and do it.
- if (restore_userdata_selected($restore, 'attforblock', $mod->id)) {
- attforblock_restore_attendance_log ($mod->id, $newid, $info, $restore);
- }
- } else {
- $status = false;
- }
- } else {
- $status = false;
- }
-
- return $status;
- }
-
-
-
- function attforblock_restore_attendance_sessions ($old_attforblock_id, $new_attforblock_id, $info, $restore) {
-
- global $CFG, $oldidarray, $DB;
-
- $status = true;
-
- if (isset($info['MOD']['#']['SESSIONS'])) {
- @$stats = $info['MOD']['#']['SESSIONS']['0']['#']['SESSION'];
- }else {
- @$stats = $info['MOD']['#']['ATTFORBLOCK_SESSIONS']['0']['#']['ROWS'];
- }
- for($i = 0; $i < sizeof($stats); $i++) {
- $stat_info = $stats[$i];
- //Now, build the attforblock_SESSIONS record structure
-
- $stat->courseid = $restore->course_id;
- $stat->attendanceid = $new_attforblock_id;
- $stat->groupid = backup_todb($stat_info['#']['GROUPID']['0']['#']);
- $group = restore_group_getid($restore, $stat->groupid);
- if ($group) {
- $stat->groupid = $group->new_id;
- }
-// $stat->creator = backup_todb($stat_info['#']['CREATOR']['0']['#']);
- $stat->sessdate = backup_todb($stat_info['#']['SESSDATE']['0']['#']);
- $stat->timemodified = backup_todb($stat_info['#']['TIMEMODIFIED']['0']['#']);
- $stat->description = backup_todb($stat_info['#']['DESCRIPTION']['0']['#']);
- if (isset($info['MOD']['#']['SESSIONS'])) {
- $stat->duration = backup_todb($stat_info['#']['DURATION']['0']['#']);;
- $stat->lasttaken = backup_todb($stat_info['#']['LASTTAKEN']['0']['#']);
- $stat->lasttakenby = backup_todb($stat_info['#']['LASTTAKENBY']['0']['#']);
- } else { //Old backup
- $stat->duration = 0;
- $stat->lasttaken = backup_todb($stat_info['#']['TIMETAKEN']['0']['#']);
- $stat->lasttakenby = backup_todb($stat_info['#']['TAKENBY']['0']['#']);
- }
- if (restore_userdata_selected($restore, 'attforblock', $old_attforblock_id)) {
- if ($user = backup_getid($restore->backup_unique_code, 'user', $stat->lasttakenby)) {
- $stat->lasttakenby = $user->new_id;
- }
- } else {
- $stat->lasttaken = 0;
- $stat->lasttakenby = 0;
- }
-
- $newid = $DB->insert_record ('attendance_sessions', $stat);
- $oldidarray[$old_attforblock_id]['attendance_sessions'][backup_todb($stat_info['#']['ID']['0']['#'])] = $newid;
- }
-
- return $status;
- }
-
-
-
- function attforblock_restore_attendance_statuses ($old_attforblock_id, $new_attforblock_id,$info,$restore) {
-
- global $CFG, $oldidarray, $DB;
-
- $status = true;
-
- //Get the statuses array
- if (isset($info['MOD']['#']['STATUSES'])) {
- $stats = $info['MOD']['#']['STATUSES']['0']['#']['STATUS'];
- for($i = 0; $i < sizeof($stats); $i++) {
- $stat_info = $stats[$i];
- //Now, build the attforblock_STATUS record structure
-
- $stat->courseid = $restore->course_id;
- $stat->attendanceid = $new_attforblock_id;
- $stat->acronym = backup_todb($stat_info['#']['ACRONYM']['0']['#']);
- $stat->description = backup_todb($stat_info['#']['DESCRIPTION']['0']['#']);
- $stat->grade = backup_todb($stat_info['#']['GRADE']['0']['#']);
- $stat->visible = backup_todb($stat_info['#']['VISIBLE']['0']['#']);
- $stat->deleted = backup_todb($stat_info['#']['DELETED']['0']['#']);
- //if user's data not required, we don't restore invisible and deleted statuses
- if (!restore_userdata_selected($restore, 'attforblock', $old_attforblock_id)
- and (!$stat->visible or $stat->deleted)) {
- continue;
- }
-
- $newid = $DB->insert_record ('attendance_statuses', $stat);
- $oldidarray[$old_attforblock_id]['attendance_statuses'][backup_todb($stat_info['#']['ID']['0']['#'])] = $newid;
- }
-
- } elseif (isset($info['MOD']['#']['ATTFORBLOCK_SETTINGS'])) {
- $stats = $info['MOD']['#']['ATTFORBLOCK_SETTINGS']['0']['#']['ROWS'];
- for($i = 0; $i < sizeof($stats); $i++) {
- $stat_info = $stats[$i];
- //Now, build the attforblock_STATUS record structure
-
- $stat->courseid = $restore->course_id;
- $stat->attendanceid = $new_attforblock_id;
- $stat->acronym = backup_todb($stat_info['#']['ACRONYM']['0']['#']);
- $stat->description = backup_todb($stat_info['#']['DESCRIPTION']['0']['#']);
- $stat->grade = backup_todb($stat_info['#']['GRADE']['0']['#']);
- $stat->visible = 1;
- $stat->deleted = 0;
-
- $newid = $DB->insert_record ('attendance_statuses', $stat);
- $oldidarray[$old_attforblock_id]['attendance_statuses'][backup_todb($stat_info['#']['STATUS']['0']['#'])] = $newid;
-
- }
-
- } else {
- // ATTFORBLOCK_SETTINGS tag don't exists
- // so course used default statuses (can be only in old version)
- $stats = $DB->get_records('attendance_statuses', array('courseid'=> 0), 'id ASC');
- $oldstats = array('P', 'A', 'L', 'E');
- $i = 0;
- foreach($stats as $stat) {
-// $stat = $stats[$i];
- $stat->courseid = $restore->course_id;
- $stat->attendanceid = $new_attforblock_id;
- $newid = $DB->insert_record('attendance_statuses', $stat);
- $oldidarray[$old_attforblock_id]['attendance_statuses'][$oldstats[$i++]] = $newid;
-// $i++;
- }
- }
-
- return $status;
- }
-
-
- function attforblock_restore_attendance_log ($old_attforblock_id, $new_attforblock_id,$info,$restore) {
-
- global $CFG, $oldidarray, $DB;
-
- $status = true;
-
- //Get the logs array
- if (isset($info['MOD']['#']['LOGS'])) {
- @$logs = $info['MOD']['#']['LOGS']['0']['#']['LOG'];
- } else {
- @$logs = $info['MOD']['#']['ATTFORBLOCK_LOG']['0']['#']['ROWS'];
- }
-
- $stats = $DB->get_records_menu('attendance_statuses', array('attendanceid'=> $new_attforblock_id));
- $statslist = implode(',', array_keys($stats));
- $sessions = $DB->get_records('attendance_sessions', array('attendanceid'=> $new_attforblock_id));
-
- //Iterate over logs
- for($i = 0; $i < sizeof($logs); $i++) {
- $log_info = $logs[$i];
- //Now, build the attforblock_LOG record structure
-
- $log->studentid = backup_todb($log_info['#']['STUDENTID']['0']['#']);
- $log->remarks = backup_todb($log_info['#']['REMARKS']['0']['#']);
- $user = backup_getid($restore->backup_unique_code, 'user', $log->studentid);
- if ($user) {
- $log->studentid = $user->new_id;
- }
- if (isset($info['MOD']['#']['LOGS'])) {
- $log->sessionid = $oldidarray[$old_attforblock_id]['attendance_sessions'][backup_todb($log_info['#']['SESSIONID']['0']['#'])];
- $log->statusid = $oldidarray[$old_attforblock_id]['attendance_statuses'][backup_todb($log_info['#']['STATUSID']['0']['#'])];
- $log->timetaken = backup_todb($log_info['#']['TIMETAKEN']['0']['#']);
-
- $log->statusset = backup_todb($log_info['#']['STATUSSET']['0']['#']);
- $ids = explode(',', $log->statusset);
- foreach ($ids as $id) {
- $new_ids[] = $oldidarray[$old_attforblock_id]['attendance_statuses'][$id];
- }
- $log->statusset = implode(',', $new_ids);
-
- $log->takenby = backup_todb($log_info['#']['TAKENBY']['0']['#']);
- $user = backup_getid($restore->backup_unique_code, 'user', $log->takenby);
- if ($user) {
- $log->takenby = $user->new_id;
- }
-
- } else { //Old version
- // Catching bug of first version of backup
- if (isset($oldidarray[$old_attforblock_id]['attendance_sessions'][backup_todb($log_info['#']['ATTSID']['0']['#'])])) {
- $log->sessionid = $oldidarray[$old_attforblock_id]['attendance_sessions'][backup_todb($log_info['#']['ATTSID']['0']['#'])];
- } else {
- continue;
- }
- $log->statusid = $oldidarray[$old_attforblock_id]['attendance_statuses'][backup_todb($log_info['#']['STATUS']['0']['#'])];
- $log->statusset = $statslist;
-// $log->timetaken = get_field('attendance_sessions', 'lasttaken', 'id', $log->sessionid);
- $log->timetaken = $sessions[$log->sessionid]->lasttaken;
- $log->takenby = $sessions[$log->sessionid]->lasttakenby;
-// $log->takenby = backup_todb($log_info['#']['TAKENBY']['0']['#']);
- }
-
- $newid = $DB->insert_record ('attendance_log', $log);
- $oldidarray[$old_attforblock_id]['attendance_log'][backup_todb($log_info['#']['ID']['0']['#'])] = $newid;
-
-
- //Do some output
- if (($i+1) % 50 == 0) {
- if (!defined('RESTORE_SILENTLY')) {
- echo '.';
- if (($i+1) % 1000 == 0) {
- echo '
';
- }
- }
- backup_flush(300);
- }
- }
-
- return $status;
- }
-
-
-// function attforblock_restore_logs($restore,$log) {
-//
-// $status = true;
-//
-// return $status;
-// }
-
-?>
\ No newline at end of file
diff --git a/_sessions.php b/_sessions.php
deleted file mode 100644
index f2e70e9..0000000
--- a/_sessions.php
+++ /dev/null
@@ -1,286 +0,0 @@
-libdir.'/blocklib.php');
- require_once('locallib.php');
- require_once('lib.php');
- require_once('add_form.php');
- require_once('update_form.php');
- require_once('duration_form.php');
-
- if (!function_exists('grade_update')) { //workaround for buggy PHP versions
- require_once($CFG->libdir.'/gradelib.php');
- }
-
- $id = required_param('id', PARAM_INT);
- $action = required_param('action', PARAM_ACTION);
-
- if ($id) {
- if (! $cm = $DB->get_record('course_modules', array('id'=> $id))) {
- error('Course Module ID was incorrect');
- }
- if (! $course = $DB->get_record('course', array('id'=> $cm->course))) {
- error('Course is misconfigured');
- }
- if (! $attforblock = $DB->get_record('attforblock', array('id'=> $cm->instance))) {
- error("Course module is incorrect");
- }
- }
-
- require_login($course->id);
-
- if (! $user = $DB->get_record('user', array('id'=> $USER->id) )) {
- error("No such user in this course");
- }
-
- if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
- print_error('badcontext');
- }
-
- require_capability('mod/attforblock:manageattendances', $context);
-
- $navlinks[] = array('name' => $attforblock->name, 'link' => "view.php?id=$id", 'type' => 'activity');
- $navlinks[] = array('name' => get_string($action, 'attforblock'), 'link' => null, 'type' => 'activityinstance');
- $navigation = build_navigation($navlinks);
- print_header("$course->shortname: ".$attforblock->name.' - '.get_string($action,'attforblock'), $course->fullname,
- $navigation, "", "", true, " ", navmenu($course));
-
- //////////////////////////////////////////////////////////
- // Adding sessions
- //////////////////////////////////////////////////////////
-
- if ($action === 'add') {
-
- show_tabs($cm, $context, 'add');
- $mform_add = new mod_attforblock_add_form('sessions.php', array('course'=>$course, 'cm'=>$cm, 'modcontext'=>$context));
-
- if ($fromform = $mform_add->get_data()) {
- $duration = $fromform->durtime['hours']*HOURSECS + $fromform->durtime['minutes']*MINSECS;
- $now = time();
-
- if (isset($fromform->addmultiply)) {
- $startdate = $fromform->sessiondate;// + $fromform->stime['hour']*3600 + $fromform->stime['minute']*60;
- $starttime = $startdate - usergetmidnight($startdate);
- $enddate = $fromform->sessionenddate + ONE_DAY; // because enddate in 0:0am
-
- //get number of days
- $days = (int)ceil(($enddate - $startdate) / ONE_DAY);
- if($days <= 0)
- error(get_string('wrongdatesselected','attforblock'), "sessions.php?id=$id&action=add");
- else {
- add_to_log($course->id, 'attendance', 'multiply sessions added', 'mod/attforblock/manage.php?id='.$id, $user->lastname.' '.$user->firstname);
-
- // Getting first day of week
- $sdate = $startdate;
- $dinfo = usergetdate($sdate);
- if ($CFG->calendar_startwday === '0') { //week start from sunday
- $startweek = $startdate - $dinfo['wday'] * ONE_DAY; //call new variable
- } else {
- $wday = $dinfo['wday'] === 0 ? 7 : $dinfo['wday'];
- $startweek = $startdate - ($wday-1) * ONE_DAY;
- }
- // Adding sessions
- $wdaydesc = array(0=>'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
- while ($sdate < $enddate) {
- if($sdate < $startweek + ONE_WEEK) {
- $dinfo = usergetdate($sdate);
- if(key_exists($wdaydesc[$dinfo['wday']] ,$fromform->sdays)) {
- //check whether this date there is in our session days
-// if(count_records('attendance_sessions', 'courseid', $course->id, 'sessdate', $sdate) > 0) {
-// notify(strftime(get_string('strftimedmy', 'attforblock'), $sdate).': '.get_string('sessionexist','attforblock'));
-// $sdate += ONE_DAY;
-// continue;
-// }
- $rec->courseid = $course->id;
- $rec->attendanceid = $attforblock->id;
- $rec->sessdate = usergetmidnight($sdate) + $starttime;
- $rec->duration = $duration;
- $rec->description = $fromform->sdescription;
- $rec->timemodified = $now;
- if ($fromform->sessiontype == COMMONSESSION) {
- if(!$DB->insert_record('attendance_sessions', $rec))
- error(get_string('erroringeneratingsessions','attforblock'), "sessions.php?id=$id&action=add");
- } else {
- foreach ($fromform->groups as $groupid) {
- $rec->groupid = $groupid;
- if(!insert_record('attendance_sessions', $rec))
- error(get_string('erroringeneratingsessions','attforblock'), "sessions.php?id=$id&action=add");
- }
- }
- }
- $sdate += ONE_DAY;
- } else {
- $startweek += ONE_WEEK * $fromform->period;
- $sdate = $startweek;
- }
- }
- notice(get_string('sessionsgenerated','attforblock'));
- }
- } else {
- // insert one session
- $rec->courseid = $course->id;
- $rec->attendanceid = $attforblock->id;
- $rec->sessdate = $fromform->sessiondate;
- $rec->duration = $duration;
- $rec->description = $fromform->sdescription;
- $rec->timemodified = $now;
- if ($fromform->sessiontype == COMMONSESSION) {
- if(insert_record('attendance_sessions', $rec)) {
- add_to_log($course->id, 'attendance', 'one session added', 'mod/attforblock/manage.php?id='.$id, $user->lastname.' '.$user->firstname);
- notice(get_string('sessionadded','attforblock'));
- } else
- error(get_string('errorinaddingsession','attforblock'), "sessions.php?id=$id&action=add");
- } else {
- foreach ($fromform->groups as $groupid) {
- $rec->groupid = $groupid;
- if(!insert_record('attendance_sessions', $rec))
- error(get_string('errorinaddingsession','attforblock'), "sessions.php?id=$id&action=add");
- }
- add_to_log($course->id, 'attendance', 'one session added', 'mod/attforblock/manage.php?id='.$id, $user->lastname.' '.$user->firstname);
- notice(get_string('sessionadded','attforblock'));
- }
- }
- }
- $mform_add->display();
- }
-
- //////////////////////////////////////////////////////////
- // Updating sessions
- //////////////////////////////////////////////////////////
-
- if ($action === 'update') {
-
- $sessionid = required_param('sessionid');
- $mform_update = new mod_attforblock_update_form('sessions.php', array('course'=>$course,
- 'cm'=>$cm,
- 'modcontext'=>$context,
- 'sessionid'=>$sessionid));
- if ($mform_update->is_cancelled()) {
- redirect('manage.php?id='.$id);
- }
- if ($fromform = $mform_update->get_data()) {
- if (!$att = $DB->get_record('attendance_sessions', array('id'=> $sessionid) )) {
- error('No such session in this course');
- }
-
-// $newdate = mktime($newhour, $newminute, 0, $newmonth, $newday, $newyear); //new variables called here
-
- //check for duplicate
-// $count = count_records('attendance_sessions','courseid', $course->id, 'sessdate', $newdate);
-// if($count != 0 && $newdate != $att->sessdate) //duplicate session exists
-// error(get_string('sessionalreadyexists','attforblock'),"sessions.php?id=".$id."&sessionid=".
-// $sessionid."&sessdate=".$att->sessdate."&action=update");
-// else
-// {
- //update session
- $att->sessdate = $fromform->sessiondate;
- $att->duration = $fromform->durtime['hours']*HOURSECS + $fromform->durtime['minutes']*MINSECS;
- $att->description = $fromform->sdescription;
- $att->timemodified = time();
- $DB->update_record('attendance_sessions', $att);
- add_to_log($course->id, 'attendance', 'Session updated', 'mod/attforblock/manage.php?id='.$id, $user->lastname.' '.$user->firstname);
- //notice(get_string('sessionupdated','attforblock'), 'manage.php?id='.$id);
- redirect('manage.php?id='.$id, get_string('sessionupdated','attforblock'), 3);
-// }
- }
-
- print_heading(get_string('update','attforblock').' ' .get_string('attendanceforthecourse','attforblock').' :: ' .$course->fullname);
- $mform_update->display();
- }
-
- //////////////////////////////////////////////////////////
- // Deleting sessions
- //////////////////////////////////////////////////////////
-
- if ($action === 'delete') {
- $sessionid = required_param('sessionid');
- $confirm = optional_param('confirm');
-
- if (!$att = $DB->get_record('attendance_sessions', array('id'=> $sessionid) )) {
- error('No such session in this course');
- }
-
- if (isset($confirm)) {
- $DB->delete_records('attendance_log', array('sessionid'=> $sessionid));
- $DB->delete_records('attendance_sessions', array('id'=> $sessionid));
- add_to_log($course->id, 'attendance', 'Session deleted', 'mod/attforblock/manage.php?id='.$id, $user->lastname.' '.$user->firstname);
- $attforblockrecord = $DB->get_record('attforblock', array('course'=> $course->id));
- attforblock_update_grades($attforblockrecord);
- redirect('manage.php?id='.$id, get_string('sessiondeleted','attforblock'), 3);
- }
-
- print_heading(get_string('deletingsession','attforblock').' :: ' .$course->fullname);
-
- notice_yesno(get_string('deletecheckfull', '', get_string('session', 'attforblock')).
- '
'.userdate($att->sessdate, get_string('strftimedmyhm', 'attforblock')).': '.
- ($att->description ? $att->description : get_string('nodescription', 'attforblock')),
- "sessions.php?id=$id&sessionid=$sessionid&action=delete&confirm=1", $_SERVER['HTTP_REFERER']);
- }
-
- if ($action === 'deleteselected') {
- $confirm = optional_param('confirm');
- if (isset($confirm)) {
- $sessionid = required_param('sessionid');
- $ids = implode(',', explode('_', $sessionid));
- $DB->delete_records_select('attendance_log', "sessionid IN ($ids)");
- $DB->delete_records_select('attendance_sessions', "id IN ($ids)");
- add_to_log($course->id, 'attendance', 'Several sessions deleted', 'mod/attforblock/manage.php?id='.$id, $user->lastname.' '.$user->firstname);
-
- $attforblockrecord = $DB->get_record('attforblock',array('course'=> $course->id));
- attforblock_update_grades($attforblockrecord);
- redirect('manage.php?id='.$id, get_string('sessiondeleted','attforblock'), 3);
- }
-
- $fromform = data_submitted();
- $slist = implode(',', array_keys($fromform->sessid));
- $sessions = $DB->get_records_list('attendance_sessions', array('id'=> $slist), 'sessdate');
-
- print_heading(get_string('deletingsession','attforblock').' :: ' .$course->fullname);
- $message = '
';
- foreach ($sessions as $att) {
- $message .= '
'.userdate($att->sessdate, get_string('strftimedmyhm', 'attforblock')).': '.
- ($att->description ? $att->description : get_string('nodescription', 'attforblock'));
- }
-
- $slist = implode('_', array_keys($fromform->sessid));
- notice_yesno(get_string('deletecheckfull', '', get_string('sessions', 'attforblock')).$message,
- "sessions.php?id=$id&sessionid=$slist&action=deleteselected&confirm=1", $_SERVER['HTTP_REFERER']);
- }
-
- //////////////////////////////////////////////////////////
- // Change duration
- //////////////////////////////////////////////////////////
-
- if ($action === 'changeduration') {
- $fromform = data_submitted();
- $slist = isset($fromform->sessid) ? implode('_', array_keys($fromform->sessid)) : '';
-
- $mform_duration = new mod_attforblock_duration_form('sessions.php', array('course'=>$course,
- 'cm'=>$cm,
- 'modcontext'=>$context,
- 'ids'=>$slist));
- if ($mform_duration->is_cancelled()) {
- redirect('manage.php?id='.$id);
- }
- if ($fromform = $mform_duration->get_data()) {
- $now = time();
- $slist = implode(',', explode('_', $fromform->ids));
- if (!$sessions = $DB->get_records_list('attendance_sessions', array('id'=> $slist) )) {
- error('No such session in this course');
- }
- foreach ($sessions as $sess) {
- $sess->duration = $fromform->durtime['hours']*HOURSECS + $fromform->durtime['minutes']*MINSECS;
- $sess->timemodified = $now;
- $DB->update_record('attendance_sessions', $sess);
- }
- add_to_log($course->id, 'attendance', 'Session updated', 'mod/attforblock/manage.php?id='.$id, $user->lastname.' '.$user->firstname);
- redirect('manage.php?id='.$id, get_string('sessionupdated','attforblock'), 3);
- }
- print_heading(get_string('update','attforblock').' ' .get_string('attendanceforthecourse','attforblock').' :: ' .$course->fullname);
- $mform_duration->display();
-
- }
-
- print_footer($course);
-
- ?>
diff --git a/_styles.php b/_styles.php
deleted file mode 100644
index 1f9e1d8..0000000
--- a/_styles.php
+++ /dev/null
@@ -1,66 +0,0 @@
-.attbtn {
- border:1px solid #AAAAAA;
- margin-left: 2px;
- margin-right: 2px;
- padding: 5px;
- border-radius: 5px;
- -moz-border-radius: 5px;
- -webkit-border-radius: 5px;
- -opera-border-radius: 5px;
- -khtml-border-radius: 5px;
-}
-
-.attcurbtn {
- margin-left: 2px;
- margin-right: 2px;
- padding: 5px;
-}
-
-.attfiltercontrols {
- margin-bottom: 10px;
- margin-right:auto;
- margin-left:auto;
-}
-
-.attwidth {
- width:90%;
-}
-
-body#mod-attforblock-attendances table.controls {
- width: 100%;
- text-align: center;
-}
-
-body#mod-attforblock-attendances table.controls tr {
- vertical-align: top;
-}
-
-body#mod-attforblock-attendances table.controls td.right, body#mod-attforblock-attendances table.controls td.left {
- padding-bottom: 4px;
- padding-left: 4px;
- padding-right: 4px;
- padding-top: 4px;
-}
-
-body#mod-attforblock-attendances table.controls .right {
- text-align: right;
-}
-/* for IE7*/
-.attfiltercontrols td {
- padding:6px;
-}
-
-wwwroot}/lib/yui"
-?>
-/*
-Copyright (c) 2010, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.8.1
-*/
-.yuidialog body{font:13px/1.231 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;} .yuidialog select,.yuidialog input,.yuidialog button,.yuidialog textarea,.yuidialog button{font:99% arial,helvetica,clean,sans-serif;} .yuidialog table{font-size:inherit;font:100%;} .yuidialog pre,.yuidialog code,.yuidialog kbd,.yuidialog samp,.yuidialog tt{font-family:monospace;*font-size:108%;line-height:100%;}
-.yui-button{display:-moz-inline-box;display:inline-block;vertical-align:text-bottom;}.yui-button .first-child{display:block;*display:inline-block;}.yui-button button,.yui-button a{display:block;*display:inline-block;border:none;margin:0;}.yui-button button{background-color:transparent;*overflow:visible;cursor:pointer;}.yui-button a{text-decoration:none;}.yui-skin-sam .yui-button{border-width:1px 0;border-style:solid;border-color:#808080;background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) repeat-x 0 0;margin:auto .25em;}.yui-skin-sam .yui-button .first-child{border-width:0 1px;border-style:solid;border-color:#808080;margin:0 -1px;_margin:0;}.yui-skin-sam .yui-button button,.yui-skin-sam .yui-button a,.yui-skin-sam .yui-button a:visited{padding:0 10px;font-size:93%;line-height:2;*line-height:1.7;min-height:2em;*min-height:auto;color:#000;}.yui-skin-sam .yui-button a{*line-height:1.875;*padding-bottom:1px;}.yui-skin-sam .yui-split-button button,.yui-skin-sam .yui-menu-button button{padding-right:20px;background-position:right center;background-repeat:no-repeat;}.yui-skin-sam .yui-menu-button button{background-image:url(/assets/skins/sam/menu-button-arrow.png);}.yui-skin-sam .yui-split-button button{background-image:url(/assets/skins/sam/split-button-arrow.png);}.yui-skin-sam .yui-button-focus{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-focus .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-split-button-focus button{background-image:url(/assets/skins/sam/split-button-arrow-focus.png);}.yui-skin-sam .yui-button-hover{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-hover .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-split-button-hover button{background-image:url(/assets/skins/sam/split-button-arrow-hover.png);}.yui-skin-sam .yui-button-active{border-color:#7D98B8;background-position:0 -1700px;}.yui-skin-sam .yui-button-active .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-split-button-activeoption{border-color:#808080;background-position:0 0;}.yui-skin-sam .yui-split-button-activeoption .first-child{border-color:#808080;}.yui-skin-sam .yui-split-button-activeoption button{background-image:url(/assets/skins/sam/split-button-arrow-active.png);}.yui-skin-sam .yui-radio-button-checked,.yui-skin-sam .yui-checkbox-button-checked{border-color:#304369;background-position:0 -1400px;}.yui-skin-sam .yui-radio-button-checked .first-child,.yui-skin-sam .yui-checkbox-button-checked .first-child{border-color:#304369;}.yui-skin-sam .yui-radio-button-checked button,.yui-skin-sam .yui-checkbox-button-checked button{color:#fff;}.yui-skin-sam .yui-button-disabled{border-color:#ccc;background-position:0 -1500px;}.yui-skin-sam .yui-button-disabled .first-child{border-color:#ccc;}.yui-skin-sam .yui-button-disabled button,.yui-skin-sam .yui-button-disabled a,.yui-skin-sam .yui-button-disabled a:visited{color:#A6A6A6;cursor:default;}.yui-skin-sam .yui-menu-button-disabled button{background-image:url(/assets/skins/sam/menu-button-arrow-disabled.png);}.yui-skin-sam .yui-split-button-disabled button{background-image:url(/assets/skins/sam/split-button-arrow-disabled.png);}
-.yui-overlay,.yui-panel-container{visibility:hidden;position:absolute;z-index:2;}.yui-panel{position:relative;}.yui-panel-container form{margin:0;}.mask{z-index:1;display:none;position:absolute;top:0;left:0;right:0;bottom:0;}.mask.block-scrollbars{overflow:auto;}.masked select,.drag select,.hide-select select{_visibility:hidden;}.yui-panel-container select{_visibility:inherit;}.hide-scrollbars,.hide-scrollbars *{overflow:hidden;}.hide-scrollbars select{display:none;}.show-scrollbars{overflow:auto;}.yui-panel-container.show-scrollbars,.yui-tt.show-scrollbars{overflow:visible;}.yui-panel-container.show-scrollbars .underlay,.yui-tt.show-scrollbars .yui-tt-shadow{overflow:auto;}.yui-panel-container.shadow .underlay.yui-force-redraw{padding-bottom:1px;}.yui-effect-fade .underlay,.yui-effect-fade .yui-tt-shadow{display:none;}.yui-tt-shadow{position:absolute;}.yui-override-padding{padding:0!important;}.yui-panel-container .container-close{overflow:hidden;text-indent:-10000em;text-decoration:none;}.yui-overlay.yui-force-redraw,.yui-panel-container.yui-force-redraw{margin-bottom:1px;}.yui-skin-sam .mask{background-color:#000;opacity:.25;filter:alpha(opacity=25);}.yui-skin-sam .yui-panel-container{padding:0 1px;*padding:2px;}.yui-skin-sam .yui-panel{position:relative;left:0;top:0;border-style:solid;border-width:1px 0;border-color:#808080;z-index:1;*border-width:1px;*zoom:1;_zoom:normal;}.yui-skin-sam .yui-panel .hd,.yui-skin-sam .yui-panel .bd,.yui-skin-sam .yui-panel .ft{border-style:solid;border-width:0 1px;border-color:#808080;margin:0 -1px;*margin:0;*border:0;}.yui-skin-sam .yui-panel .hd{border-bottom:solid 1px #ccc;}.yui-skin-sam .yui-panel .bd,.yui-skin-sam .yui-panel .ft{background-color:#F2F2F2;}.yui-skin-sam .yui-panel .hd{padding:0 10px;font-size:93%;line-height:2;*line-height:1.9;font-weight:bold;color:#000;background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) repeat-x 0 -200px;}.yui-skin-sam .yui-panel .bd{padding:10px;}.yui-skin-sam .yui-panel .ft{border-top:solid 1px #808080;padding:5px 10px;font-size:77%;}.yui-skin-sam .container-close{position:absolute;top:5px;right:6px;width:25px;height:15px;background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) no-repeat 0 -300px;cursor:pointer;}.yui-skin-sam .yui-panel-container .underlay{right:-1px;left:-1px;}.yui-skin-sam .yui-panel-container.matte{padding:9px 10px;background-color:#fff;}.yui-skin-sam .yui-panel-container.shadow{_padding:2px 4px 0 2px;}.yui-skin-sam .yui-panel-container.shadow .underlay{position:absolute;top:2px;left:-3px;right:-3px;bottom:-3px;*top:4px;*left:-1px;*right:-1px;*bottom:-1px;_top:0;_left:0;_right:0;_bottom:0;_margin-top:3px;_margin-left:-1px;background-color:#000;opacity:.12;filter:alpha(opacity=12);}.yui-skin-sam .yui-dialog .ft{border-top:none;padding:0 10px 10px 10px;font-size:100%;}.yui-skin-sam .yui-dialog .ft .button-group{display:block;text-align:right;}.yui-skin-sam .yui-dialog .ft button.default{font-weight:bold;}.yui-skin-sam .yui-dialog .ft span.default{border-color:#304369;background-position:0 -1400px;}.yui-skin-sam .yui-dialog .ft span.default .first-child{border-color:#304369;}.yui-skin-sam .yui-dialog .ft span.default button{color:#fff;}.yui-skin-sam .yui-dialog .ft span.yui-button-disabled{background-position:0 -1500px;border-color:#ccc;}.yui-skin-sam .yui-dialog .ft span.yui-button-disabled .first-child{border-color:#ccc;}.yui-skin-sam .yui-dialog .ft span.yui-button-disabled button{color:#a6a6a6;}.yui-skin-sam .yui-simple-dialog .bd .yui-icon{background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) no-repeat 0 0;width:16px;height:16px;margin-right:10px;float:left;}.yui-skin-sam .yui-simple-dialog .bd span.blckicon{background-position:0 -1100px;}.yui-skin-sam .yui-simple-dialog .bd span.alrticon{background-position:0 -1050px;}.yui-skin-sam .yui-simple-dialog .bd span.hlpicon{background-position:0 -1150px;}.yui-skin-sam .yui-simple-dialog .bd span.infoicon{background-position:0 -1200px;}.yui-skin-sam .yui-simple-dialog .bd span.warnicon{background-position:0 -1900px;}.yui-skin-sam .yui-simple-dialog .bd span.tipicon{background-position:0 -1250px;}.yui-skin-sam .yui-tt .bd{position:relative;top:0;left:0;z-index:1;color:#000;padding:2px 5px;border-color:#D4C237 #A6982B #A6982B #A6982B;border-width:1px;border-style:solid;background-color:#FFEE69;}.yui-skin-sam .yui-tt.show-scrollbars .bd{overflow:auto;}.yui-skin-sam .yui-tt-shadow{top:2px;right:-3px;left:-3px;bottom:-3px;background-color:#000;}.yui-skin-sam .yui-tt-shadow-visible{opacity:.12;filter:alpha(opacity=12);}
-.yui-calcontainer{position:relative;float:left;_overflow:hidden;}.yui-calcontainer iframe{position:absolute;border:none;margin:0;padding:0;z-index:0;width:100%;height:100%;left:0;top:0;}.yui-calcontainer iframe.fixedsize{width:50em;height:50em;top:-1px;left:-1px;}.yui-calcontainer.multi .groupcal{z-index:1;float:left;position:relative;}.yui-calcontainer .title{position:relative;z-index:1;}.yui-calcontainer .close-icon{position:absolute;z-index:1;text-indent:-10000em;overflow:hidden;}.yui-calendar{position:relative;}.yui-calendar .calnavleft{position:absolute;z-index:1;text-indent:-10000em;overflow:hidden;}.yui-calendar .calnavright{position:absolute;z-index:1;text-indent:-10000em;overflow:hidden;}.yui-calendar .calheader{position:relative;width:100%;text-align:center;}.yui-calcontainer .yui-cal-nav-mask{position:absolute;z-index:2;margin:0;padding:0;width:100%;height:100%;_width:0;_height:0;left:0;top:0;display:none;}.yui-calcontainer .yui-cal-nav{position:absolute;z-index:3;top:0;display:none;}.yui-calcontainer .yui-cal-nav .yui-cal-nav-btn{display:-moz-inline-box;display:inline-block;}.yui-calcontainer .yui-cal-nav .yui-cal-nav-btn button{display:block;*display:inline-block;*overflow:visible;border:none;background-color:transparent;cursor:pointer;}.yui-calendar .calbody a:hover{background:inherit;}p#clear{clear:left;padding-top:10px;}.yui-skin-sam .yui-calcontainer{background-color:#f2f2f2;border:1px solid #808080;padding:10px;}.yui-skin-sam .yui-calcontainer.multi{padding:0 5px 0 5px;}.yui-skin-sam .yui-calcontainer.multi .groupcal{background-color:transparent;border:none;padding:10px 5px 10px 5px;margin:0;}.yui-skin-sam .yui-calcontainer .title{background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) repeat-x 0 0;border-bottom:1px solid #ccc;font:100% sans-serif;color:#000;font-weight:bold;height:auto;padding:.4em;margin:0 -10px 10px -10px;top:0;left:0;text-align:left;}.yui-skin-sam .yui-calcontainer.multi .title{margin:0 -5px 0 -5px;}.yui-skin-sam .yui-calcontainer.withtitle{padding-top:0;}.yui-skin-sam .yui-calcontainer .calclose{background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) no-repeat 0 -300px;width:25px;height:15px;top:.4em;right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar{border-spacing:0;border-collapse:collapse;font:100% sans-serif;text-align:center;margin:0;}.yui-skin-sam .yui-calendar .calhead{background:transparent;border:none;vertical-align:middle;padding:0;}.yui-skin-sam .yui-calendar .calheader{background:transparent;font-weight:bold;padding:0 0 .6em 0;text-align:center;}.yui-skin-sam .yui-calendar .calheader img{border:none;}.yui-skin-sam .yui-calendar .calnavleft{background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) no-repeat 0 -450px;width:25px;height:15px;top:0;bottom:0;left:-10px;margin-left:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calnavright{background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) no-repeat 0 -500px;width:25px;height:15px;top:0;bottom:0;right:-10px;margin-right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calweekdayrow{height:2em;}.yui-skin-sam .yui-calendar .calweekdayrow th{padding:0;border:none;}.yui-skin-sam .yui-calendar .calweekdaycell{color:#000;font-weight:bold;text-align:center;width:2em;}.yui-skin-sam .yui-calendar .calfoot{background-color:#f2f2f2;}.yui-skin-sam .yui-calendar .calrowhead,.yui-skin-sam .yui-calendar .calrowfoot{color:#a6a6a6;font-size:85%;font-style:normal;font-weight:normal;border:none;}.yui-skin-sam .yui-calendar .calrowhead{text-align:right;padding:0 2px 0 0;}.yui-skin-sam .yui-calendar .calrowfoot{text-align:left;padding:0 0 0 2px;}.yui-skin-sam .yui-calendar td.calcell{border:1px solid #ccc;background:#fff;padding:1px;height:1.6em;line-height:1.6em;text-align:center;white-space:nowrap;}.yui-skin-sam .yui-calendar td.calcell a{color:#06c;display:block;height:100%;text-decoration:none;}.yui-skin-sam .yui-calendar td.calcell.today{background-color:#000;}.yui-skin-sam .yui-calendar td.calcell.today a{background-color:#fff;}.yui-skin-sam .yui-calendar td.calcell.oom{background-color:#ccc;color:#a6a6a6;cursor:default;}.yui-skin-sam .yui-calendar td.calcell.selected{background-color:#fff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.selected a{background-color:#b3d4ff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.calcellhover{background-color:#426fd9;color:#fff;cursor:pointer;}.yui-skin-sam .yui-calendar td.calcell.calcellhover a{background-color:#426fd9;color:#fff;}.yui-skin-sam .yui-calendar td.calcell.previous{color:#e0e0e0;}.yui-skin-sam .yui-calendar td.calcell.restricted{text-decoration:line-through;}.yui-skin-sam .yui-calendar td.calcell.highlight1{background-color:#cf9;}.yui-skin-sam .yui-calendar td.calcell.highlight2{background-color:#9cf;}.yui-skin-sam .yui-calendar td.calcell.highlight3{background-color:#fcc;}.yui-skin-sam .yui-calendar td.calcell.highlight4{background-color:#cf9;}.yui-skin-sam .yui-calendar a.calnav{border:1px solid #f2f2f2;padding:0 4px;text-decoration:none;color:#000;zoom:1;}.yui-skin-sam .yui-calendar a.calnav:hover{background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) repeat-x 0 0;border-color:#A0A0A0;cursor:pointer;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-mask{background-color:#000;opacity:.25;filter:alpha(opacity=25);}.yui-skin-sam .yui-calcontainer .yui-cal-nav{font-family:arial,helvetica,clean,sans-serif;font-size:93%;border:1px solid #808080;left:50%;margin-left:-7em;width:14em;padding:0;top:2.5em;background-color:#f2f2f2;}.yui-skin-sam .yui-calcontainer.withtitle .yui-cal-nav{top:4.5em;}.yui-skin-sam .yui-calcontainer.multi .yui-cal-nav{width:16em;margin-left:-8em;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-y,.yui-skin-sam .yui-calcontainer .yui-cal-nav-m,.yui-skin-sam .yui-calcontainer .yui-cal-nav-b{padding:5px 10px 5px 10px;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-b{text-align:center;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-e{margin-top:5px;padding:5px;background-color:#EDF5FF;border-top:1px solid black;display:none;}.yui-skin-sam .yui-calcontainer .yui-cal-nav label{display:block;font-weight:bold;}
-.yui-skin-sam .yui-calcontainer .yui-cal-nav-mc{width:100%;_width:auto;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-y input.yui-invalid{background-color:#FFEE69;border:1px solid #000;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-yc{width:4em;}.yui-skin-sam .yui-calcontainer .yui-cal-nav .yui-cal-nav-btn{border:1px solid #808080;background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) repeat-x 0 0;background-color:#ccc;margin:auto .15em;}.yui-skin-sam .yui-calcontainer .yui-cal-nav .yui-cal-nav-btn button{padding:0 8px;font-size:93%;line-height:2;*line-height:1.7;min-height:2em;*min-height:auto;color:#000;}.yui-skin-sam .yui-calcontainer .yui-cal-nav .yui-cal-nav-btn.yui-default{border:1px solid #304369;background-color:#426fd9;background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) repeat-x 0 -1400px;}.yui-skin-sam .yui-calcontainer .yui-cal-nav .yui-cal-nav-btn.yui-default button{color:#fff;}
diff --git a/_view.php b/_view.php
deleted file mode 100644
index 02e3ba1..0000000
--- a/_view.php
+++ /dev/null
@@ -1,125 +0,0 @@
-get_record("course_modules", array("id"=> $id))) {
- error("Course Module ID was incorrect");
- }
-
- if (! $course = $DB->get_record("course", array("id"=> $cm->course))) {
- error("Course is misconfigured");
- }
-
- if (! $attforblock = $DB->get_record("attforblock", array("id"=> $cm->instance))) {
- error("Course module is incorrect");
- }
-
- } else {
- error("Module id is incorrect.");
-// if (! $attforblock = get_record("attforblock", "id", $a)) {
-// error("Course module is incorrect");
-// }
-// if (! $course = get_record("course", "id", $attforblock->course)) {
-// error("Course is misconfigured");
-// }
-// if (! $cm = get_coursemodule_from_instance("attforblock", $attforblock->id, $course->id)) {
-// error("Course Module ID was incorrect");
-// }
- }
-
- require_login($course->id);
-
- if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
- print_error('badcontext');
- }
-
- if (!$studentid && (has_capability('mod/attforblock:manageattendances', $context) ||
- has_capability('mod/attforblock:takeattendances', $context) ||
- has_capability('mod/attforblock:changeattendances', $context))) {
- redirect("manage.php?id=$cm->id");
- }
- if (!$studentid && has_capability('mod/attforblock:viewreports', $context)) {
- redirect("report.php?id=$cm->id");
- }
-
- if (! $user = $DB->get_record('user', array('id'=> $USER->id) )) {
- error("No such user in this course");
- }
-
- if ($view)
- set_current_view($course->id, $_GET['view']);
- else
- $view = get_current_view($course->id, 'months');
-
- require_capability('mod/attforblock:view', $context);
-
- $student = false;
- if ($studentid) {
- if ($studentid == $USER->id or has_capability('mod/attforblock:viewreports', $context)) {
- if (!$student = $DB->get_record('user', array('id'=> $studentid) )) {
- error("No such user in this course");
- }
- }
- }
-
-// if (empty($student) && has_capability('mod/attforblock:manageattendances', $context)) {
-// redirect("manage.php?id=$cm->id");
-// }
-
- if ($student) {
- $user = $student;
- }
- if ($printing) {
- if ($mode === 'thiscourse') {
- print_header('', $course->fullname.' - '.get_string('attendancereport','attforblock'));
- print_user_attendaces($user, $cm, $attforblock, $course, 'printing');
- } else {
- print_header('', get_string('attendancereport','attforblock'));
- print_user_attendaces($user, $cm, $attforblock, 0, 'printing');
- }
- exit();
- }
-
-/// Print headers
- $navlinks[] = array('name' => $attforblock->name, 'link' => "view.php?id=$id", 'type' => 'activityinstance');
- $navlinks[] = array('name' => get_string('attendancereport', 'attforblock'), 'link' => null, 'type' => 'title');
- $navigation = build_navigation($navlinks);
- print_header("$course->shortname: ".$attforblock->name.' - ' .get_string('export', 'quiz'), $course->fullname,
- $navigation, "", "", true, " ", navmenu($course));
-
- //add info to log
- add_to_log($course->id, 'attendance', 'student view', "mod/attforblock/view.php?course=$course->id&student=$USER->id", $USER->lastname.' '.$USER->firstname);
-// print_heading(get_string('attendanceforthecourse','attforblock').' :: ' .$course->fullname);
-
- /// Prints out tabs
- $currenttab = $mode;
- $studstr = $student ? '&student='.$student->id : '';
- $toprow = array();
- $toprow[] = new tabobject('thiscourse', "view.php?id=$id&mode=thiscourse{$studstr}",
- get_string('thiscourse','attforblock'));
- $toprow[] = new tabobject('allcourses', "view.php?id=$id&mode=allcourses{$studstr}",
- get_string('allcourses','attforblock'));
- print_tabs(array($toprow), $currenttab);
-
- if ($mode === 'thiscourse') {
- print_user_attendaces($user, $cm, $attforblock, $course);
- } else {
- print_user_attendaces($user, $cm, $attforblock);
- }
-
- print_footer($course);
-
-?>
\ No newline at end of file