commit b86085074fe8fb547c881ff371efecb37c292b57
Author: Artem Andreev Attendance Create Multiple Sessions This function allows you to create multiple sessions in one simple
+ step.
';
+ foreach($statuses as $st) {
+ echo $st->acronym.' - '.$st->description.'
';
+ }
+
+ print_footer($course);
+
+?>
diff --git a/attsettings.php b/attsettings.php
new file mode 100644
index 0000000..c10a9c2
--- /dev/null
+++ b/attsettings.php
@@ -0,0 +1,176 @@
+course)) {
+ error('Course is misconfigured');
+ }
+ if (! $attforblock = get_record('attforblock', 'id', $cm->instance)) {
+ error("Course module is incorrect");
+ }
+ }
+ $attforblockrecord = get_record('attforblock','course',$course->id);
+
+
+ require_login($course->id);
+
+ if (! $user = get_record('user', '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 = get_record('attendance_statuses', 'courseid', $course->id, 'id', $stid)) {
+ print_error('notfoundstatus', 'attforblock', "attsettings.php?id=$id");
+ }
+ if (count_records('attendance_log', 'statusid', $stid)) {
+ print_error('cantdeletestatus', 'attforblock', "attsettings.php?id=$id");
+ }
+
+ $confirm = optional_param('confirm');
+ if (isset($confirm)) {
+ set_field('attendance_statuses', 'deleted', 1, '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':
+ set_field('attendance_statuses', 'visible', 1, 'id', $stid);
+ break;
+ case 'hide':
+ $students = get_users_by_capability($context, 'moodle/legacy:student', '', '', '', '', '', '', false);
+ $studlist = implode(',', array_keys($students));
+ if (!count_records_select('attendance_log', "studentid IN ($studlist) AND statusid = $stid")) {
+ set_field('attendance_statuses', 'visible', 0, '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->acronym = $newacronym;
+ $rec->description = $newdescription;
+ $rec->grade = $newgrade;
+ 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($course->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 (!count_records('attendance_log', '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 '
+
+
+
+
+
+
+
+
'), true);
+ $mform->setDefaults(array('ident[id]' => true, 'ident[uname]' => true));
+
+
+
+
+
+// for ($i=0; $i<=23; $i++) {
+// $hours[$i] = sprintf("%02d",$i);
+// }
+// for ($i=0; $i<60; $i+=5) {
+// $minutes[$i] = sprintf("%02d",$i);
+// }
+// $stime = array();
+// $stime[] =& MoodleQuickForm::createElement('select', 'hours', get_string('hour', 'form'), $hours, false, true);
+// $stime[] =& MoodleQuickForm::createElement('select', 'minutes', get_string('minute', 'form'), $minutes, false, true);
+// $mform->addGroup($stime, 'stime', get_string('sessionstarttime','attforblock'), array(' '), true);
+
+// $durtime = array();
+// $durtime[] =& MoodleQuickForm::createElement('select', 'hours', get_string('hour', 'form'), $hours, false, true);
+// $durtime[] =& MoodleQuickForm::createElement('select', 'minutes', get_string('minute', 'form'), $minutes, false, true);
+// $mform->addGroup($durtime, 'durtime', get_string('duration','attforblock'), array(' '), true);
+
+ $mform->addElement('checkbox', 'includenottaken', get_string('includenottaken','attforblock'), get_string('yes'));
+ $mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod','attforblock'));
+ $mform->disabledIf('sessionenddate', 'includenottaken', 'notchecked');
+
+ $mform->addElement('select', 'format', get_string('format'),
+ array('excel' => get_string('downloadexcel','attforblock'),
+ 'ooo' => get_string('downloadooo','attforblock'),
+ 'text' => get_string('downloadtext','attforblock')
+ ));
+
+// $opts = array();
+// $opts[] =& MoodleQuickForm::createElement('checkbox', 'Mon', '', get_string('monday','calendar'));
+//// $opts[] =& MoodleQuickForm::createElement('checkbox', 'Tue', '', get_string('tuesday','calendar'));
+//// $opts[] =& MoodleQuickForm::createElement('checkbox', 'Wed', '', get_string('wednesday','calendar'));
+//// $opts[] =& MoodleQuickForm::createElement('checkbox', 'Thu', '', get_string('thursday','calendar'));
+//// $opts[] =& MoodleQuickForm::createElement('checkbox', 'Fri', '', get_string('friday','calendar'));
+//// $opts[] =& MoodleQuickForm::createElement('checkbox', 'Sat', '', get_string('saturday','calendar'));
+// $mform->addGroup($opts, 'opts', get_string('sessiondays','attforblock'), array(' '), true);
+// $mform->disabledIf('opts', 'addmultiply', 'notchecked');
+//
+// $period = array(1=>1,2,3,4,5,6,7,8);
+// $periodgroup = array();
+// $periodgroup[] =& MoodleQuickForm::createElement('select', 'period', '', $period, false, true);
+// $periodgroup[] =& MoodleQuickForm::createElement('static', 'perioddesc', '', get_string('week','attforblock'));
+// $mform->addGroup($periodgroup, 'periodgroup', get_string('period','attforblock'), array(' '), false);
+// $mform->disabledIf('periodgroup', 'addmultiply', 'notchecked');
+//
+// $mform->addElement('text', 'sdescription', get_string('description', 'attforblock'), 'size="48"');
+// $mform->setType('sdescription', PARAM_TEXT);
+// $mform->addRule('sdescription', get_string('maximumchars', '', 100), 'maxlength', 100, 'client');
+
+//-------------------------------------------------------------------------------
+ // buttons
+ $submit_string = get_string('ok');
+ $this->add_action_buttons(false, $submit_string);
+
+ $mform->addElement('hidden', 'id', $cm->id);
+// $mform->addElement('hidden', 'action', 'add');
+
+ }
+
+// function validation($data, $files) {
+// $errors = parent::validation($data, $files);
+// if (($data['timeend']!=0) && ($data['timestart']!=0)
+// && $data['timeend'] <= $data['timestart']) {
+// $errors['timeend'] = get_string('timestartenderror', 'forum');
+// }
+// return $errors;
+// }
+
+}
+?>
diff --git a/icon.gif b/icon.gif
new file mode 100644
index 0000000..5157566
Binary files /dev/null and b/icon.gif differ
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..e9ad94b
--- /dev/null
+++ b/index.php
@@ -0,0 +1,20 @@
+coursemodule");
+ } else {
+ print_error('notfound', 'attforblock');
+ }
+
+?>
diff --git a/lang/cs_utf8/attforblock.php b/lang/cs_utf8/attforblock.php
new file mode 100644
index 0000000..465345a
--- /dev/null
+++ b/lang/cs_utf8/attforblock.php
@@ -0,0 +1,116 @@
+Odstranění tohoto modulu neodstraní data!';
+$string['modulename'] = 'Docházka';
+$string['modulenameplural'] = 'Docházky';
+$string['months'] = 'Měsíce';
+$string['myvariables'] = 'Volby';
+$string['newdate'] = 'Nové datum';
+$string['newduration'] = 'Nové trvání';
+$string['noattforuser'] = 'Pro uživatele neexistují žádné záznamy docházky';
+$string['nodescription'] = 'Řádný záznam třídy';
+$string['noguest'] = 'Hosté nemohou vidět docházku';
+$string['noofdaysabsent'] = 'Žádné dny absence';
+$string['noofdaysexcused'] = 'Žádné dny omluvené';
+$string['noofdayslate'] = 'Žádné dny pozdě';
+$string['noofdayspresent'] = 'Žádné dny přítomen';
+$string['nosessiondayselected'] = 'Nebyl vybrán žádný den se záznamem';
+$string['nosessionexists'] = 'Pro tento kurz neexistují žádné záznamy';
+$string['notfound'] = 'Docházková činnost nebyla v tomto kurzu nalezena!';
+$string['olddate'] = 'Staré datum';
+$string['period'] = 'Frekvence';
+$string['remarks'] = 'Poznámky';
+$string['report'] = 'Přehled';
+$string['resetdescription'] = 'Nezapomeňte, že smazání docházkových dat smaže informace z databáze. Můžete skrýt starší záznamy změnou data zahájení kurzu.';
+$string['resetstatuses'] = 'Obnovit stavy do výchozích hodnot';
+$string['restoredefaults'] = 'Obnovit výchozí';
+$string['session'] = 'Záznam';
+$string['sessionadded'] = 'Záznam úspěšně přidán';
+$string['sessionalreadyexists'] = 'Záznam pro toto datum již existuje';
+$string['sessiondate'] = 'Datum záznamu';
+$string['sessiondays'] = 'Dny';
+$string['sessiondeleted'] = 'Záznam úspěšně smazán';
+$string['sessionenddate'] = 'Koncové datum záznamů';
+$string['sessionexist'] = 'Záznam nebyl přidán (již existuje)!';
+$string['sessions'] = 'Záznamy';
+$string['sessionscompleted'] = 'Všechny záznamy';
+$string['sessionsgenerated'] = 'Záznamy úspěšně vygenerovány';
+$string['sessionstartdate'] = 'Počáteční datum záznamů';
+$string['sessionupdated'] = 'Záznam úspěšně aktualizován';
+$string['settings'] = 'Nastavení';
+$string['showdefaults'] = 'Ukázat výchozí';
+$string['status'] = 'Stav';
+$string['strftimedm'] = '%%d.%%m.';
+$string['strftimedmy'] = '%%d.%%m.%%Y';
+$string['strftimedmyhm'] = '%%d.%%m.%%Y %%H:%%M'; // line added to allow multiple sessions in the same day
+$string['strftimedmyw'] = '%%A %%d.%%m.%%Y';
+$string['strftimehm'] = '%%H:%%M'; //line added to allow display of time
+$string['strftimeshortdate'] = '%%d.%%m.%%Y';
+$string['studentid'] = 'ID studenta';
+$string['takeattendance'] = 'Vyplnit docházku';
+$string['thiscourse'] = 'Tento kurz';
+$string['update'] = 'Aktualizovat';
+$string['variablesupdated'] = 'Volby úspěšně aktualizovány';
+$string['versionforprinting'] = 'verze pro tisk';
+$string['week'] = 'týdnů';
+$string['weeks'] = 'Týdny';
+$string['youcantdo'] = 'Nemůžete nic udělat';
+
+?>
diff --git a/lang/de/attforblock.php b/lang/de/attforblock.php
new file mode 100644
index 0000000..7261cfa
--- /dev/null
+++ b/lang/de/attforblock.php
@@ -0,0 +1,84 @@
+
\ No newline at end of file
diff --git a/lang/en_us_utf8/README b/lang/en_us_utf8/README
new file mode 100644
index 0000000..829e352
--- /dev/null
+++ b/lang/en_us_utf8/README
@@ -0,0 +1,11 @@
+US English is only slightly different from standard English.
+
+Only a few words are changed, like :
+
+ enrolment -> enrollment
+ colour -> color
+
+Note that many help files and strings may be missing but this
+doesn't matter much. Because the "parent language" of this
+pack is "en", missing strings will be taken from there.
+So you should also copy en_utf8 language files.
\ No newline at end of file
diff --git a/lang/en_us_utf8/attforblock.php b/lang/en_us_utf8/attforblock.php
new file mode 100644
index 0000000..976675e
--- /dev/null
+++ b/lang/en_us_utf8/attforblock.php
@@ -0,0 +1,10 @@
+
\ No newline at end of file
diff --git a/lang/en_utf8/attforblock.php b/lang/en_utf8/attforblock.php
new file mode 100644
index 0000000..cee5f09
--- /dev/null
+++ b/lang/en_utf8/attforblock.php
@@ -0,0 +1,119 @@
+Removal of this module will not entail removal of the data!';
+$string['modulename'] = 'Attendance';
+$string['modulenameplural'] = 'Attendances';
+$string['months'] = 'Months';
+$string['myvariables'] = 'My Variables';
+$string['newdate'] = 'New date';
+$string['newduration'] = 'New duration';
+$string['noattforuser'] = 'No attendance records exist for the user';
+$string['nodescription'] = 'Regular class session';
+$string['noguest'] = 'Guest can\'t see attendance';
+$string['noofdaysabsent'] = 'No of days absent';
+$string['noofdaysexcused'] = 'No of days excused';
+$string['noofdayslate'] = 'No of days late';
+$string['noofdayspresent'] = 'No of days present';
+$string['nosessiondayselected'] = 'No Session day selected';
+$string['nosessionexists'] = 'No Session exists for this course';
+$string['notfound'] = 'Attendance activity not found in this course!';
+$string['olddate'] = 'Old date';
+$string['period'] = 'Frequency';
+$string['remarks'] = 'Remarks';
+$string['report'] = 'Report';
+$string['resetdescription'] = 'Remember that deleting attendance data will erase information from database. You can just hide older sessions having changed start date of course!';
+$string['resetstatuses'] = 'Reset statuses to default';
+$string['restoredefaults'] = 'Restore defaults';
+$string['session'] = 'Session';
+$string['sessionadded'] = 'Session successfully added';
+$string['sessionalreadyexists'] = 'Session already exists for this date';
+$string['sessiondate'] = 'Session Date';
+$string['sessiondays'] = 'Session Days';
+$string['sessiondeleted'] = 'Session successfully deleted';
+$string['sessionenddate'] = 'Session end date';
+$string['sessionexist'] = 'Session not added (already exists)!';
+$string['sessions'] = 'Sessions';
+$string['sessionscompleted'] = 'Sessions completed';
+$string['sessionsgenerated'] = 'Sessions successfully generated';
+$string['sessionstartdate'] = 'Session start date';
+$string['sessionupdated'] = 'Session successfully updated';
+$string['settings'] = 'Settings';
+$string['showdefaults'] = 'Show defaults';
+$string['status'] = 'Status';
+$string['statusdeleted'] = 'Status deleted';
+$string['strftimedm'] = '%%d.%%m';
+$string['strftimedmy'] = '%%d.%%m.%%Y';
+$string['strftimedmyhm'] = '%%d.%%m.%%Y %%H.%%M'; // line added to allow multiple sessions in the same day
+$string['strftimedmyw'] = '%%d.%%m.%%y (%%a)';
+$string['strftimehm'] = '%%H:%%M'; //line added to allow display of time
+$string['strftimeshortdate'] = '%%d.%%m.%%Y';
+$string['studentid'] = 'Student ID';
+$string['takeattendance'] = 'Take attendance';
+$string['thiscourse'] = 'This course';
+$string['update'] = 'Update';
+$string['variable'] = 'variable';
+$string['variablesupdated'] = 'Variables successfully updated';
+$string['versionforprinting'] = 'version for printing';
+$string['week'] = 'week(s)';
+$string['weeks'] = 'Weeks';
+$string['youcantdo'] = 'You can\'t do anything';
+
+?>
diff --git a/lang/en_utf8/help/attforblock/createmultiplesessions.html b/lang/en_utf8/help/attforblock/createmultiplesessions.html
new file mode 100644
index 0000000..4751943
--- /dev/null
+++ b/lang/en_utf8/help/attforblock/createmultiplesessions.html
@@ -0,0 +1,12 @@
+
+ Session End Date: Select the last
+ day of class (the last day you want to take attendance).
+ Session Days: Select the days of the week when your class will meet (for example, Monday/Wednesday/Friday).
+ Frequency: This allows for a frequency setting. If your class will meet every week, select
+ 1; if it will meet every other week, select 2; every 3rd week, select 3, etc.
Attendance
+Create One Session
+To create one session that you want to take attendance for, select + the date, enter a description (optional) and click on "Add Session".
diff --git a/lang/en_utf8/help/attforblock/defaultstatuses.html b/lang/en_utf8/help/attforblock/defaultstatuses.html new file mode 100644 index 0000000..f3e006f --- /dev/null +++ b/lang/en_utf8/help/attforblock/defaultstatuses.html @@ -0,0 +1,26 @@ + +# | ++ | + | + | + |
. | +status;?> | +acronym;?> | +description;?> | +grade;?> | +
Attendance
+Display
+Use this option to modify the way the attendance record is displayed. + You can chose between "all taken" which will show all sessions, "weeks" + which will show weekly averages, and "months" to display monthly averages + for each student.
diff --git a/lang/en_utf8/help/attforblock/export.html b/lang/en_utf8/help/attforblock/export.html new file mode 100644 index 0000000..2ee8c6f --- /dev/null +++ b/lang/en_utf8/help/attforblock/export.html @@ -0,0 +1,3 @@ +Attendance
+Export
+Use this option to select the format for the export data.
diff --git a/lang/en_utf8/help/attforblock/hiddensessions.html b/lang/en_utf8/help/attforblock/hiddensessions.html new file mode 100644 index 0000000..b4d7924 --- /dev/null +++ b/lang/en_utf8/help/attforblock/hiddensessions.html @@ -0,0 +1,6 @@ +Attendance
+Hidden sessions
+Session hides if course's start date older than its date. +Change start date of course and hidden sessions will be shown.
+You can use this feature to hide older sessions instead delete. +Remember than only visible sessions using in Gradebook.
\ No newline at end of file diff --git a/lang/en_utf8/help/attforblock/myvariables.html b/lang/en_utf8/help/attforblock/myvariables.html new file mode 100644 index 0000000..424e398 --- /dev/null +++ b/lang/en_utf8/help/attforblock/myvariables.html @@ -0,0 +1,4 @@ +Attendance
+My Variables
+Change settings here to modify the default attendance categories + and points assigned to each category.
diff --git a/lang/en_utf8/help/attforblock/report.html b/lang/en_utf8/help/attforblock/report.html new file mode 100644 index 0000000..934bd42 --- /dev/null +++ b/lang/en_utf8/help/attforblock/report.html @@ -0,0 +1,5 @@ +Attendance
+Report
+Modify attendance data by adjusting the display settings. Data + may also be downloaded for offline viewing and analysis via the "Report" + pulldown menu found at the bottom of the report screen.
diff --git a/lang/en_utf8/help/attforblock/sessions.html b/lang/en_utf8/help/attforblock/sessions.html new file mode 100644 index 0000000..470c4f7 --- /dev/null +++ b/lang/en_utf8/help/attforblock/sessions.html @@ -0,0 +1,20 @@ +Attendance module
++ dirroot.'/mod/attforblock/version.php'); + echo get_string('version').": $module->release ($module->version)"; + unset($module); + $module = $temp; + ?> +
+Attendance sessions are shown here. If no sessions appear, click + on the "Add" tab to create new sessions.
+Take attendance by clicking on the green icon under the "actions" + menu (left side).
+Edit each session by clicking on the middle "edit session" + icon. After taking attendance you can edit the session by clicking on the description. +
+Delete the session entirely by clicking on the delete icon on + the right side.
diff --git a/lang/en_utf8/help/attforblock/studentview.html b/lang/en_utf8/help/attforblock/studentview.html new file mode 100644 index 0000000..8e3a4ca --- /dev/null +++ b/lang/en_utf8/help/attforblock/studentview.html @@ -0,0 +1,3 @@ +Attendance
+Student View
+This screen allows you to view the attendance records for a single student. Use the "version for printing" link to print a copy without the tabs and headers displayed on the webpage.
diff --git a/lang/es_utf8/attforblock.php b/lang/es_utf8/attforblock.php new file mode 100644 index 0000000..6c44f82 --- /dev/null +++ b/lang/es_utf8/attforblock.php @@ -0,0 +1,113 @@ +Si se elimina esta actividad, los datos de la base de datos no se verán afectados, así que reaparecerán en caso de volver a agregar nuevamente la actividad.'; +$string['modulename'] = 'Asistencia'; +$string['modulenameplural'] = 'Asistencias'; +$string['months'] = 'Meses'; +$string['myvariables'] = 'Mis Variables'; +$string['newdate'] = 'Nueva Fecha'; +$string['newduration'] = 'Nueva duración'; +$string['noattforuser'] = 'No existen registros de asistencia para el usuario'; +$string['nodescription'] = 'Sesión de Clase Normal'; +$string['noguest'] = 'Los invitados no pueden ver la asistencia'; +$string['noofdaysabsent'] = 'Nº de días de ausencia'; +$string['noofdaysexcused'] = 'Nº de días con faltas justificadas'; +$string['noofdayslate'] = 'Nº de días de retrasos'; +$string['noofdayspresent'] = 'Nº de días de asistencia'; +$string['nosessiondayselected'] = 'No se ha seleccionado día de Sesión'; +$string['nosessionexists'] = 'No existen Sesiones para este curso'; +$string['notfound'] = 'No se ha encontrado ninguna actividad Asistencia en este curso'; +$string['olddate'] = 'Fecha Anterior'; +$string['Pacronym'] = 'P'; +$string['period'] = 'Frecuencia'; +$string['Pfull'] = 'Presente'; +$string['remarks'] = 'Observaciones'; +$string['report'] = 'Informe'; +$string['resetdescription'] = 'Recuerde que eliminando los datos de la asistencia provocará el borrado de información en la base de datos. Usted puede ocultar sesiones anteriores cambiando la fecha de inicio del curso en la zona de administración.'; +$string['resetstatuses'] = 'Reinicar la configuración por defecto'; +$string['restoredefaults'] = 'Restarurar valores por defecto'; +$string['session'] = 'Sesión'; +$string['sessionadded'] = 'Sesión añadida con éxito'; +$string['sessionalreadyexists'] = 'Ya existe una sesión para la fecha indicada'; +$string['sessiondate'] = 'Fecha de la Sesión'; +$string['sessiondays'] = 'Días de Sesión'; +$string['sessiondeleted'] = 'Sesión eliminada con éxito'; +$string['sessionenddate'] = 'Fecha de Fin de Sesión'; +$string['sessionexist'] = 'Sesión no añadida (ya existe)'; +$string['sessions'] = 'Sesiones'; +$string['sessionscompleted'] = 'Sesiones completadas'; +$string['sessionsgenerated'] = 'Sesiones generadas con éxito'; +$string['sessionstartdate'] = 'Fecha de Inicio de la Sesión'; +$string['sessionupdated'] = 'Sesión actualizada con éxito'; +$string['settings'] = 'Configuración'; +$string['showdefaults'] = 'Mostrar opciones por defecto'; +$string['status'] = 'Estado'; +$string['strftimedm'] = '%%d.%%m'; +$string['strftimedmy'] = '%%d.%%m.%%Y'; +$string['strftimedmyhm'] = '%%d.%%m.%%Y %%H.%%M'; +$string['strftimedmyw'] = '%%d.%%m.%%y (%%a)'; +$string['strftimehm'] = '%%H:%%M'; +$string['strftimeshortdate'] = '%%d.%%m.%%Y'; +$string['studentid'] = 'ID de Estudiante'; +$string['takeattendance'] = 'Iniciar Asistencia'; +$string['thiscourse'] = 'Este curso'; +$string['update'] = 'Actualizar'; +$string['variablesupdated'] = 'Variables actualizadas con éxito'; +$string['versionforprinting'] = 'versión para Imprimir'; +$string['week'] = 'semana(s)'; +$string['weeks'] = 'Semanas'; +$string['youcantdo'] = 'Usted no puede hacer nada'; +?> diff --git a/lang/es_utf8/help/attforblock/changesession.html b/lang/es_utf8/help/attforblock/changesession.html new file mode 100644 index 0000000..0b6de7d --- /dev/null +++ b/lang/es_utf8/help/attforblock/changesession.html @@ -0,0 +1,4 @@ +Asistencia
+ +Cambiar sesión
+Esta función le permite cambiar la fecha, la hora de inicio, la duración y la descripción de una sesión en particular.
diff --git a/lang/es_utf8/help/attforblock/createmultiplesessions.html b/lang/es_utf8/help/attforblock/createmultiplesessions.html
new file mode 100644
index 0000000..19e9c11
--- /dev/null
+++ b/lang/es_utf8/help/attforblock/createmultiplesessions.html
@@ -0,0 +1,10 @@
+
Asistencia
+ +Crear Múltiples Sesiones
+Esta función le permite crear múltiples sesiones en un único paso.
+ Fecha de Inicio de Sesión: seleccione la fecha de inicio de su curso
Fecha de Fin de Sesión: indique aquí el último día de clase
+ (el último día en que usted quiera tomar asistencia).
+ Días de Sesión: Seleccione los días de la semana en los que tenga clase.
+ Frecuencia: Esto permite configurar las repeticiones. Si su clase se repite semanalmente, seleccione 1,
+ si su clase se repite cada dos semanas, seleccione 2, si sucede cada 3 semanas, seleccione 3, etc.
Finalmente, usted puede escribir el nombre que desea otorgarle a cada asistencia por defecto. En cualquier caso, siempre podrá editar individualmente este valor.
Asistencia
+Crear Una Sesión
+Para crear una sesión en la que desee tomar la asistencia seleccione + la fecha, introduzca una descripción (opcional) y haga click sobre "Añadir Sesión".
diff --git a/lang/es_utf8/help/attforblock/defaultstatuses.html b/lang/es_utf8/help/attforblock/defaultstatuses.html new file mode 100644 index 0000000..f3e006f --- /dev/null +++ b/lang/es_utf8/help/attforblock/defaultstatuses.html @@ -0,0 +1,26 @@ + +# | ++ | + | + | + |
. | +status;?> | +acronym;?> | +description;?> | +grade;?> | +
Asitencia
+Mostrar
+Utilice esta opción para modificar la forma en que se visualizan los registros de asistencia.
+ Puede elegir entre:
"Hasta hoy", que mostrará las asistencias tomadas hasta el día en curso.
"Semanas", que mostrará las asistencias agrupadas por semanas y
"Meses" para mostrar las asistencias mensuales de cada grupo de estudiantes.
diff --git a/lang/es_utf8/help/attforblock/export.html b/lang/es_utf8/help/attforblock/export.html
new file mode 100644
index 0000000..6a8e63b
--- /dev/null
+++ b/lang/es_utf8/help/attforblock/export.html
@@ -0,0 +1,3 @@
+
Asistencia
+Exportar
+Utilice esta opción para seleccionar el formato en que se exportarán los datos. Puede decidir si incluye o no las sesiones no registradas. También puede exportar hasta una fecha determinada, dejando las demás fuera del archivo de exportación.
Se exporta en formato xls (MsExcell), ods (OoCalc) o Texto txt.
Asistencia
+ +Crear - Editar asistencia
+El módulo asistencia permite llevar un seguimiento de los estudiantes en cuanto a su asistencia/retrasos/ausencias a las clases. Los parámetros elegidos pueden ser calificados, asignando valores. Ejemplo: Asiste = 2; Retraso = 1; Justificado = 1; Ausente = 0. Esta actividad debe ir acompañada, obligatoriamente, del bloque Asistencia correspondiente y sólo se permite una actividad por curso. En caso de eliminar la actividad, los datos permanecen registrados en la base de datos, de modo que reaparecerán en caso de volver a agregarla.
Es importante tener en cuenta que el módulo funciona atendiendo a la fecha de inicio curso. Usted debe mantener la configuración de fecha de inicio del curso debidamente actualizada accediendo a "Configuración" en el Panel de Adminsitración del curso. La actividad Asistencia no mostrará las sesiones anteriores a la fecha de inicio del curso.
diff --git a/lang/es_utf8/help/attforblock/myvariables.html b/lang/es_utf8/help/attforblock/myvariables.html
new file mode 100644
index 0000000..fbe3bba
--- /dev/null
+++ b/lang/es_utf8/help/attforblock/myvariables.html
@@ -0,0 +1,3 @@
+
Asistencia
+Mis Variables
+Cambie esta configuración para modificar las categorías de asistencia que vienen definidas por defecto y la puntuación asignada a cada categoría.
Si usted lo desea, puede agregar nuevas categorías completando el recuadro vacío y utilizando el botón "añadir"-
Puede utilizar valores negativos. No se admiten campos vacíos, siendo el valor predeterminado el cero (0).
Puede modificar los valores cuantas veces lo desee, el módulo recalculará los valores que han sido previamente asignados a los alumnos, mostrando su nueva calificación sin ningún problema.
Asistencia
+Informe
+Modifique la forma en que se visualizan los datos de asistencia ajustando los parámetros. Los datos también pueden ser +descargados para una visualización sin conexión y analizarlos mediante el menú desplegable de "Informe" +que puede encontrar en la pestaña "exportar".
Asistencia
++ dirroot.'/mod/attforblock/version.php'); + echo get_string('version').": $module->release ($module->version)"; + unset($module); + $module = $temp; + ?> +
+Las sesiones de Asistencia se muestran aquí. Si no aparecen sesiones, utilice la pestaña "Añadir" para crear una nuevas sesiones.
Es importante tener en cuenta que el módulo funciona atendiendo a la fecha de inicio curso. Usted debe mantener la configuración de fecha de inicio del curso debidamente actualizada accediendo a "Configuración" en el Panel de Adminsitración del curso. La actividad Asistencia no mostrará las sesiones anteriores a la fecha de inicio del curso. +Iniciar registro de asistencia: Inicie el registro de asistencias por medio del icono de color verde que hay bajo el menú "acciones" (parte izquierda).
+Editar sesión: Edite cada sesión haciendo uso del icono central "editar sesión". Una vez haya finalizado la toma de Asistencias, puede editar la sesión haciendo click en la descripción. +
+Eliminar sesión: elimine por completo la sesión en el icono de la derecha.
Asistencia
+Vista de Estudiante
+Esta pantalla permite ver los registros de asistencia de un estudiante en concreto. Use el enlace "versión para imprimir" si desea imprimir una copia sin las pestañas ni encabezados mostrados en la página web.
La opción "todos los cursos" le permitirá consultar en una página la asistencia registrada en los demás cursos en los que el estudiante está matriculado (rol). diff --git a/lang/es_utf8/help/attforblock/updateattendance.html b/lang/es_utf8/help/attforblock/updateattendance.html new file mode 100644 index 0000000..fb2f8ee --- /dev/null +++ b/lang/es_utf8/help/attforblock/updateattendance.html @@ -0,0 +1,3 @@ +Asistencia
+Actualizar asistencia
+Desde aquí podrá marcar los datos de asistencia de su grupo de estudiantes. Puede hacerlo individualmente o en bloque. Para asignar a todos sus alumnos el mismo valor, puede seleccionar la letra que figura en el encabezado de cada columna (P, J, T...) y luego modificar individualmente algún dato concreto. Al final del listado encontrará el botón "ok" (puede acceder rápidamente pulsando la tecla Fin de su teclado) que grabará los resultados. Puede modificar los valores en cualquier momento accediendo nuevamente la asistencia de este día/hora. Junto a cada registro encontrará una caja de texto que le permitirá anotar observaciones personalizadas para cada estudiante.
# | ++ | + | + | + |
. | +status;?> | +acronym;?> | +description;?> | +grade;?> | +
Asistentziarako blokea
+ ++ dirroot.'/mod/attforblock/version.php'); + echo get_string('version').": $module->release ($module->version)"; + unset($module); + $module = $temp; + ?> +
\ No newline at end of file diff --git a/lang/fr_utf8/attforblock.php b/lang/fr_utf8/attforblock.php new file mode 100644 index 0000000..1316646 --- /dev/null +++ b/lang/fr_utf8/attforblock.php @@ -0,0 +1,94 @@ + diff --git a/lang/it/attforblock.php b/lang/it/attforblock.php new file mode 100644 index 0000000..c4ed6d2 --- /dev/null +++ b/lang/it/attforblock.php @@ -0,0 +1,84 @@ + diff --git a/lang/it/help/attforblock/sessions.html b/lang/it/help/attforblock/sessions.html new file mode 100644 index 0000000..8b9b85b --- /dev/null +++ b/lang/it/help/attforblock/sessions.html @@ -0,0 +1,12 @@ +Blocco Presenze
+ ++ dirroot.'/mod/attforblock/version.php'); + echo get_string('version').": $module->release ($module->version)"; + unset($module); + $module = $temp; + ?> +
\ No newline at end of file diff --git a/lang/ja_utf8/attforblock.php b/lang/ja_utf8/attforblock.php new file mode 100644 index 0000000..fd6fe56 --- /dev/null +++ b/lang/ja_utf8/attforblock.php @@ -0,0 +1,116 @@ +このモジュールを削除したとしても、データが削除されるわけではありません!'; +$string['modulename'] = '出欠'; +$string['modulenameplural'] = '出欠'; +$string['months'] = '月'; +$string['myvariables'] = 'マイ変数'; +$string['newdate'] = '新しい出欠日'; +$string['newduration'] = '新しい持続時間'; +$string['noattforuser'] = 'このユーザの出欠レコードはありません。'; +$string['nodescription'] = '標準クラスセッション'; +$string['noguest'] = 'ゲストは出欠を閲覧できません。'; +$string['noofdaysabsent'] = '欠席数'; +$string['noofdaysexcused'] = '早退数'; +$string['noofdayslate'] = '遅刻数'; +$string['noofdayspresent'] = '出席数'; +$string['nosessiondayselected'] = 'セッション日が選択されませんでした。'; +$string['nosessionexists'] = 'このコースには、セッションがありません。'; +$string['notfound'] = 'このコースには、出欠活動はありません!'; +$string['olddate'] = '古い出欠日'; +$string['period'] = '頻度'; +$string['remarks'] = '備考'; +$string['report'] = 'レポート'; +$string['resetdescription'] = '出欠を削除することで、データベースから情報が削除されることに留意してください。あなたは、コースの開始日を変更することで、古いセッションを隠すことができます!'; +$string['resetstatuses'] = 'ステータスをデフォルトにリセットする'; +$string['restoredefaults'] = 'デフォルトをリストアする'; +$string['session'] = 'セッション'; +$string['sessionadded'] = 'セッションが正常に追加されました。'; +$string['sessionalreadyexists'] = 'この日には、すでにセッションが追加されています。'; +$string['sessiondate'] = 'セッション日'; +$string['sessiondays'] = 'セッション曜日'; +$string['sessiondeleted'] = 'セッションが正常に削除されました。'; +$string['sessionenddate'] = 'セッション終了日'; +$string['sessionexist'] = 'セッションは追加されませんでした (すでに追加されています)!'; +$string['sessions'] = 'セッション'; +$string['sessionscompleted'] = 'セッション完了'; +$string['sessionsgenerated'] = 'セッションが正常に生成されました。'; +$string['sessionstartdate'] = 'セッション開始日'; +$string['sessionupdated'] = 'セッションが正常に更新されました。'; +$string['settings'] = '設定'; +$string['showdefaults'] = 'デフォルトを表示する'; +$string['status'] = 'ステータス'; +$string['strftimedm'] = '%%m/%%d'; +$string['strftimedmy'] = '%%Y/%%m/%%d'; +$string['strftimedmyhm'] = '%%Y/%%m/%%d %%H.%%M'; +$string['strftimedmyw'] = '%%Y/%%m/%%d (%%a)'; +$string['strftimehm'] = '%%H:%%M'; +$string['strftimeshortdate'] = '%%Y/%%m/%%d'; +$string['studentid'] = '学籍番号'; +$string['takeattendance'] = '出欠を取る'; +$string['thiscourse'] = 'このコース'; +$string['update'] = '更新'; +$string['variablesupdated'] = '変数が正常に更新されました。'; +$string['versionforprinting'] = '印刷画面'; +$string['week'] = '週'; +$string['weeks'] = '週'; +$string['youcantdo'] = 'あなたは、何もできません。'; + +?> diff --git a/lang/ja_utf8/help/attforblock/createmultiplesessions.html b/lang/ja_utf8/help/attforblock/createmultiplesessions.html new file mode 100644 index 0000000..3518fd7 --- /dev/null +++ b/lang/ja_utf8/help/attforblock/createmultiplesessions.html @@ -0,0 +1,6 @@ +あなたは、この機能を使って、1つのシンプルなステップで倍数セッションを作成することができます。
+セッション開始日: あなたのコース開始日 (授業の初日) を選択してください。
+セッション終了日: 授業の最終日 (あなたが出欠を取りたい最終日) を選択してください。
+ セッション曜日: あなたの授業が開講される週の曜日を選択してください (例 月曜日/水曜日/金曜日)。
+ 頻度: ここでは、頻度を設定することができます。あなたの授業が毎週開講される場合、1を設定してください。隔週に開講される場合は、2を設定してください。また、第3週に開講される場合は、3を選択してください。
あなたが出欠を取りたい、1つのセッションを作成するには、日付を選択して説明 (任意) を入力した後、「セッションを追加する」をクリックしてください。
\ No newline at end of file diff --git a/lang/ja_utf8/help/attforblock/defaultstatuses.html b/lang/ja_utf8/help/attforblock/defaultstatuses.html new file mode 100644 index 0000000..8f66cad --- /dev/null +++ b/lang/ja_utf8/help/attforblock/defaultstatuses.html @@ -0,0 +1,26 @@ + +# | ++ | + | + | + |
. | +status;?> | +acronym;?> | +description;?> | +grade;?> | +
このオプションは、出欠レコードの表示方法の変更に使用してください。あなたは、それぞれの学生に関して、すべてを表示する「すべて」、週ごとの平均を表示する「週」、月ごとの平均を表示する「月」を選択することができます。
\ No newline at end of file diff --git a/lang/ja_utf8/help/attforblock/export.html b/lang/ja_utf8/help/attforblock/export.html new file mode 100644 index 0000000..7c00a28 --- /dev/null +++ b/lang/ja_utf8/help/attforblock/export.html @@ -0,0 +1,2 @@ +このオプションは、エクスポートデータのフォーマット選択に使用してください。
\ No newline at end of file diff --git a/lang/ja_utf8/help/attforblock/hiddensessions.html b/lang/ja_utf8/help/attforblock/hiddensessions.html new file mode 100644 index 0000000..bd4e4ed --- /dev/null +++ b/lang/ja_utf8/help/attforblock/hiddensessions.html @@ -0,0 +1,3 @@ +コース開始日が実際の日時より古い場合、セッションが隠されます。コース開始日を変更することで、非表示セッションが表示されます。
+あなたは、古いセッションを削除する代わりに、この機能を使用することができます。評定表には、表示セッションのみ使用されますので留意してください。
\ No newline at end of file diff --git a/lang/ja_utf8/help/attforblock/myvariables.html b/lang/ja_utf8/help/attforblock/myvariables.html new file mode 100644 index 0000000..56fad2a --- /dev/null +++ b/lang/ja_utf8/help/attforblock/myvariables.html @@ -0,0 +1,2 @@ +デフォルトの出欠カテゴリおよび各カテゴリに割り当てられている評点を修正するには、ここで設定を変更してください。
\ No newline at end of file diff --git a/lang/ja_utf8/help/attforblock/report.html b/lang/ja_utf8/help/attforblock/report.html new file mode 100644 index 0000000..68b6acd --- /dev/null +++ b/lang/ja_utf8/help/attforblock/report.html @@ -0,0 +1,2 @@ +表示設定を調整することで、出欠データを修正してください。オフライン閲覧および分析のため、レポート画面下部にある「レポート」プルダウンメニューより、データをダウンロードすることもできます。
\ No newline at end of file diff --git a/lang/ja_utf8/help/attforblock/sessions.html b/lang/ja_utf8/help/attforblock/sessions.html new file mode 100644 index 0000000..7a3d6c1 --- /dev/null +++ b/lang/ja_utf8/help/attforblock/sessions.html @@ -0,0 +1,14 @@ ++ dirroot.'/mod/attforblock/version.php'); + echo get_string('version').": $module->release ($module->version)"; + unset($module); + $module = $temp; + ?> +
+ここに出欠セッションが表示されます。セッションが表示されない場合、新しいセッションを追加するため、「追加」タブをクリックしてください。
+「操作」メニューの下 (左側) にあるグリーンのアイコンをクリックすることで、出欠を取ることができます。
+中央にある「セッションを編集する」アイコンをクリックすることで、それぞれのセッションを編集してください。出欠を取った後、説明をクリックすることで、あなたはセッションを編集することができます。
+右側にあるアイコンをクリックすることで、セッションを削除することができます。
\ No newline at end of file diff --git a/lang/ja_utf8/help/attforblock/studentview.html b/lang/ja_utf8/help/attforblock/studentview.html new file mode 100644 index 0000000..b57ac2a --- /dev/null +++ b/lang/ja_utf8/help/attforblock/studentview.html @@ -0,0 +1,2 @@ +この画面では、学生の出欠レコードを個別に閲覧することができます。「印刷画面」リンクを使用することで、タブおよびヘッダを含まないページをウェブページに表示することができます。
\ No newline at end of file diff --git a/lang/ru_utf8/attforblock.php b/lang/ru_utf8/attforblock.php new file mode 100644 index 0000000..ad2f73a --- /dev/null +++ b/lang/ru_utf8/attforblock.php @@ -0,0 +1,113 @@ +Удаление этого модуля не повлечет удаление данных о посещаемости!'; +$string['modulename'] = 'Посещаемость'; +$string['modulenameplural'] = 'Посещаемость'; +$string['months'] = 'По месяцам'; +$string['myvariables'] = 'Мои переменные'; +$string['newdate'] = 'Новая дата'; +$string['newduration'] = 'New duration'; +$string['noattforuser'] = 'Нет отметок посещаемости для этого пользователя'; +$string['nodescription'] = 'Для этого занятия нет описания'; +$string['noguest'] = 'Гость не может видеть информацию о посещаемости'; +$string['noofdaysabsent'] = 'Пропущено'; +$string['noofdaysexcused'] = 'Пропущено по ув. причине'; +$string['noofdayslate'] = 'Опозданий'; +$string['noofdayspresent'] = 'Вы присутствовали'; +$string['nosessiondayselected'] = 'Не выбран день занятия'; +$string['nosessionexists'] = 'В данном курсе отсутствуют занятия. Сначала добавьте их'; +$string['notfound'] = 'Элемент курса - \"Посещаемость\" не найден в данном курсе!'; +$string['olddate'] = 'Старая дата'; +$string['period'] = 'Периодичность'; +$string['remarks'] = 'Заметка'; +$string['report'] = 'Отчет'; +$string['restoredefaults'] = 'Востановить значения по-умолчанию'; +$string['session'] = 'Занятие'; +$string['sessionadded'] = 'Занятие успешно добавлено'; +$string['sessionalreadyexists'] = 'В этот день занятие уже существует'; +$string['sessiondate'] = 'Дата занятия'; +$string['sessiondays'] = 'Дни занятий'; +$string['sessiondeleted'] = 'Занятие успешно удалено'; +$string['sessionenddate'] = 'Дата завершения занятий'; +$string['sessionexist'] = 'Занятие не добавлено (уже существует)!'; +$string['sessions'] = 'Занятия'; +$string['sessionscompleted'] = 'Прошло занятий'; +$string['sessionsgenerated'] = 'Занятия успешно созданы'; +$string['sessionstartdate'] = 'Дата начала занятий'; +$string['sessionupdated'] = 'Занятие успешно изменено'; +$string['settings'] = 'Настройки'; +$string['showdefaults'] = 'Показать значения по-умолчанию'; +$string['status'] = 'Статус'; +$string['statusdeleted'] = 'Статус удален'; +$string['strftimedm'] = '%%d.%%m'; +$string['strftimedmy'] = '%%d.%%m.%%Y'; +$string['strftimedmyhm'] = '%%d.%%m.%%Y %%H.%%M'; +$string['strftimedmyw'] = '%%d.%%m.%%y (%%a)'; +$string['strftimehm'] = '%%H:%%M'; +$string['strftimeshortdate'] = '%%d.%%m.%%Y'; +$string['studentid'] = 'ID студента'; +$string['takeattendance'] = 'Отметить посещаемость'; +$string['update'] = 'Обновить'; +$string['variable'] = 'переменную'; +$string['variablesupdated'] = 'Переменные успешно обновлены'; +$string['versionforprinting'] = 'версия для печати'; +$string['week'] = 'неделя(и)'; +$string['weeks'] = 'По неделям'; +$string['youcantdo'] = 'Вы ничего не можете сделать'; + +?> diff --git a/lang/ru_utf8/help/attforblock/sessions.html b/lang/ru_utf8/help/attforblock/sessions.html new file mode 100644 index 0000000..b19e27a --- /dev/null +++ b/lang/ru_utf8/help/attforblock/sessions.html @@ -0,0 +1,12 @@ +Модуль Посещаемость
+ ++ dirroot.'/mod/attforblock/version.php'); + echo get_string('version').": $module->release ($module->version)"; + unset($module); + $module = $temp; + ?> +
\ No newline at end of file diff --git a/lang/sk_utf8/attforblock.php b/lang/sk_utf8/attforblock.php new file mode 100644 index 0000000..743f9e8 --- /dev/null +++ b/lang/sk_utf8/attforblock.php @@ -0,0 +1,87 @@ + diff --git a/lang/sv/attforblock.php b/lang/sv/attforblock.php new file mode 100644 index 0000000..b4399c0 --- /dev/null +++ b/lang/sv/attforblock.php @@ -0,0 +1,77 @@ + diff --git a/lib.php b/lib.php new file mode 100644 index 0000000..eabf781 --- /dev/null +++ b/lib.php @@ -0,0 +1,389 @@ + 2, 'A' => 0, 'L' => 1, 'E' => 1); + foreach ($arr as $k => $v) { + unset($rec); + $rec->courseid = 0; + $rec->acronym = get_string($k.'acronym', 'attforblock'); + $rec->description = get_string($k.'full', 'attforblock'); + $rec->grade = $v; + $rec->visible = 1; + $rec->deleted = 0; + $result = $result && insert_record('attendance_statuses', $rec); + } + return $result; +} + +function attforblock_add_instance($attforblock) { +/// Given an object containing all the necessary data, +/// (defined by the form in mod.html) this function +/// will create a new instance and return the id number +/// of the new instance. + + $attforblock->timemodified = time(); + + if ($att = get_record('attforblock', 'course', $attforblock->course)) { + $modnum = get_field('modules', 'id', 'name', 'attforblock'); + if (!get_record('course_modules', 'course', $attforblock->course, 'module', $modnum)) { + delete_records('attforblock', 'course', $attforblock->course); + $attforblock->id = insert_record('attforblock', $attforblock); + } else { + return false; + } + } else { + $attforblock->id = insert_record('attforblock', $attforblock); + } + + //Copy statuses for new instance from defaults + if (!get_records('attendance_statuses', 'courseid', $attforblock->course)) { + $statuses = get_records('attendance_statuses', 'courseid', 0, 'id'); + foreach($statuses as $stat) { + $rec = $stat; + $rec->courseid = $attforblock->course; + insert_record('attendance_statuses', $rec); + } + } + +// attforblock_grade_item_update($attforblock); +// attforblock_update_grades($attforblock); + return $attforblock->id; +} + + +function attforblock_update_instance($attforblock) { +/// Given an object containing all the necessary data, +/// (defined by the form in mod.html) this function +/// will update an existing instance with new data. + + $attforblock->timemodified = time(); + $attforblock->id = $attforblock->instance; + + if (! update_record('attforblock', $attforblock)) { + return false; + } + + attforblock_grade_item_update($attforblock); + + return true; +} + + +function attforblock_delete_instance($id) { +/// Given an ID of an instance of this module, +/// this function will permanently delete the instance +/// and any data that depends on it. + + if (! $attforblock = get_record('attforblock', 'id', $id)) { + return false; + } + + $result = delete_records('attforblock', 'id', $id); + + attforblock_grade_item_delete($attforblock); + + return $result; +} + +function attforblock_delete_course($course, $feedback=true){ + + if ($sess = get_records('attendance_sessions', 'courseid', $course->id, '', 'id')) { + $slist = implode(',', array_keys($sess)); + delete_records_select('attendance_log', "sessionid IN ($slist)"); + delete_records('attendance_sessions', 'courseid', $course->id); + } + delete_records('attendance_statuses', 'courseid', $course->id); + + //Inform about changes performed if feedback is enabled +// if ($feedback) { +// notify(get_string('deletedefaults', 'lesson', $count)); +// } + + return true; +} + +/** + * Called by course/reset.php + * @param $mform form passed by reference + */ +function attforblock_reset_course_form_definition(&$mform) { + $mform->addElement('header', 'attendanceheader', get_string('modulename', 'attforblock')); + + $mform->addElement('static', 'description', get_string('description', 'attforblock'), + get_string('resetdescription', 'attforblock')); + $mform->addElement('checkbox', 'reset_attendance_log', get_string('deletelogs','attforblock')); + + $mform->addElement('checkbox', 'reset_attendance_sessions', get_string('deletesessions','attforblock')); + $mform->disabledIf('reset_attendance_sessions', 'reset_attendance_log', 'notchecked'); + + $mform->addElement('checkbox', 'reset_attendance_statuses', get_string('resetstatuses','attforblock')); + $mform->setAdvanced('reset_attendance_statuses'); + $mform->disabledIf('reset_attendance_statuses', 'reset_attendance_log', 'notchecked'); +} + +/** + * Course reset form defaults. + */ +function attforblock_reset_course_form_defaults($course) { + return array('reset_attendance_log'=>0, 'reset_attendance_statuses'=>0, 'reset_attendance_sessions'=>0); +} + +function attforblock_reset_userdata($data) { + if (!empty($data->reset_attendance_log)) { + $sess = get_records('attendance_sessions', 'courseid', $data->courseid, '', 'id'); + $slist = implode(',', array_keys($sess)); + delete_records_select('attendance_log', "sessionid IN ($slist)"); + set_field('attendance_sessions', 'lasttaken', 0, 'courseid', $data->courseid); + } + if (!empty($data->reset_attendance_statuses)) { + delete_records('attendance_statuses', 'courseid', $data->courseid); + $statuses = get_records('attendance_statuses', 'courseid', 0, 'id'); + foreach($statuses as $stat) { + $rec = $stat; + $rec->courseid = $data->courseid; + insert_record('attendance_statuses', $rec); + } + } + if (!empty($data->reset_attendance_sessions)) { + delete_records('attendance_sessions', 'courseid', $data->courseid); + } +} + +function attforblock_user_outline($course, $user, $mod, $attforblock) { +/// Return a small object with summary information about what a +/// user has done with a given particular instance of this module +/// Used for user activity reports. +/// $return->time = the time they did it +/// $return->info = a short text description + + require_once('locallib.php'); + + if (isstudent($course->id, $user->id)) { + if ($sescount = get_attendance($user->id,$course)) { + $strgrade = get_string('grade'); + $maxgrade = get_maxgrade($user->id, $course); + $usergrade = get_grade($user->id, $course); + $percent = get_percent($user->id,$course); + $result->info = "$strgrade: $usergrade / $maxgrade ($percent%)"; + } + } + + return $result; +} + +function attforblock_user_complete($course, $user, $mod, $attforblock) { +/// Print a detailed representation of what a user has done with +/// a given particular instance of this module, for user activity reports. + + require_once('locallib.php'); + + if (isstudent($course->id, $user->id)) { +// if (! $cm = get_coursemodule_from_instance("attforblock", $attforblock->id, $course->id)) { +// error("Course Module ID was incorrect"); +// } + print_user_attendaces($user, $mod, $course); + } + + //return true; +} + +function attforblock_print_recent_activity($course, $isteacher, $timestart) { +/// Given a course and a time, this module should find recent activity +/// that has occurred in attforblock activities and print it out. +/// Return true if there was output, or false is there was none. + + return false; // True if anything was printed, otherwise false +} + +function attforblock_cron () { +/// Function to be run periodically according to the moodle cron +/// This function searches for things that need to be done, such +/// as sending out mail, toggling flags etc ... + + return true; +} + +/** + * Return grade for given user or all users. + * + * @param int $attforblockid id of attforblock + * @param int $userid optional user id, 0 means all users + * @return array array of grades, false if none + */ +function attforblock_get_user_grades($attforblock, $userid=0) { + global $CFG; + + require_once('locallib.php'); + + if (! $course = get_record('course', 'id', $attforblock->course)) { + error("Course is misconfigured"); + } + + $result = false; + if ($userid) { + $result = array(); + $result[$userid]->userid = $userid; + $result[$userid]->rawgrade = $attforblock->grade * get_percent($userid, $course) / 100; + } else { + if ($students = get_course_students($course->id)) { + $result = array(); + foreach ($students as $student) { + $result[$student->id]->userid = $student->id; + $result[$student->id]->rawgrade = $attforblock->grade * get_percent($student->id, $course) / 100; + } + } + } + + return $result; +} + +/** + * Update grades by firing grade_updated event + * + * @param object $attforblock null means all attforblocks + * @param int $userid specific user only, 0 mean all + */ +function attforblock_update_grades($attforblock=null, $userid=0, $nullifnone=true) { + global $CFG; + if (!function_exists('grade_update')) { //workaround for buggy PHP versions + require_once($CFG->libdir.'/gradelib.php'); + } + + if ($attforblock != null) { + if ($grades = attforblock_get_user_grades($attforblock, $userid)) { + foreach($grades as $k=>$v) { + if ($v->rawgrade == -1) { + $grades[$k]->rawgrade = null; + } + } + attforblock_grade_item_update($attforblock, $grades); + } else { + attforblock_grade_item_update($attforblock); + } + + } else { + $sql = "SELECT a.*, cm.idnumber as cmidnumber, a.course as courseid + FROM {$CFG->prefix}attforblock a, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m + WHERE m.name='attforblock' AND m.id=cm.module AND cm.instance=a.id"; + if ($rs = get_recordset_sql($sql)) { + while ($attforblock = rs_fetch_next_record($rs)) { +// if ($attforblock->grade != 0) { + attforblock_update_grades($attforblock); +// } else { +// attforblock_grade_item_update($attforblock); +// } + } + rs_close($rs); + } + } +} + +/** + * Create grade item for given attforblock + * + * @param object $attforblock object with extra cmidnumber + * @param mixed optional array/object of grade(s); 'reset' means reset grades in gradebook + * @return int 0 if ok, error code otherwise + */ +function attforblock_grade_item_update($attforblock, $grades=NULL) { + global $CFG; + + require_once('locallib.php'); + + if (!function_exists('grade_update')) { //workaround for buggy PHP versions + require_once($CFG->libdir.'/gradelib.php'); + } + + if (!isset($attforblock->courseid)) { + $attforblock->courseid = $attforblock->course; + } + if (! $course = get_record('course', 'id', $attforblock->course)) { + error("Course is misconfigured"); + } + //$attforblock->grade = get_maxgrade($course); + + if(!empty($attforblock->cmidnumber)){ + $params = array('itemname'=>$attforblock->name, 'idnumber'=>$attforblock->cmidnumber); + }else{ + // MDL-14303 + $cm = get_coursemodule_from_instance('attforblock', $attforblock->id); + $params = array('itemname'=>$attforblock->name, 'idnumber'=>$cm->id); + } + + if ($attforblock->grade > 0) { + $params['gradetype'] = GRADE_TYPE_VALUE; + $params['grademax'] = $attforblock->grade; + $params['grademin'] = 0; + + } + else if ($attforblock->grade < 0) { + $params['gradetype'] = GRADE_TYPE_SCALE; + $params['scaleid'] = -$attforblock->grade; + + } else { + $params['gradetype'] = GRADE_TYPE_NONE; + } + + if ($grades === 'reset') { + $params['reset'] = true; + $grades = NULL; + } + + return grade_update('mod/attforblock', $attforblock->courseid, 'mod', 'attforblock', $attforblock->id, 0, $grades, $params); +} + +/** + * Delete grade item for given attforblock + * + * @param object $attforblock object + * @return object attforblock + */ +function attforblock_grade_item_delete($attforblock) { + global $CFG; + require_once($CFG->libdir.'/gradelib.php'); + + if (!isset($attforblock->courseid)) { + $attforblock->courseid = $attforblock->course; + } + + return grade_update('mod/attforblock', $attforblock->courseid, 'mod', 'attforblock', $attforblock->id, 0, NULL, array('deleted'=>1)); +} + +function attforblock_get_participants($attforblockid) { +//Must return an array of user records (all data) who are participants +//for a given instance of attforblock. Must include every user involved +//in the instance, independient of his role (student, teacher, admin...) +//See other modules as example. + + return false; +} + +function attforblock_scale_used ($attforblockid, $scaleid) { +//This function returns if a scale is being used by one attforblock +//it it has support for grading and scales. Commented code should be +//modified if necessary. See forum, glossary or journal modules +//as reference. + + $return = false; + + //$rec = get_record("attforblock","id","$attforblockid","scale","-$scaleid"); + // + //if (!empty($rec) && !empty($scaleid)) { + // $return = true; + //} + + return $return; +} + +////////////////////////////////////////////////////////////////////////////////////// +/// Any other attforblock functions go here. Each of them must have a name that +/// starts with attforblock_ + + +?> diff --git a/locallib.php b/locallib.php new file mode 100644 index 0000000..8022259 --- /dev/null +++ b/locallib.php @@ -0,0 +1,314 @@ +libdir.'/gradelib.php'); + +define('ONE_DAY', 86400); // Seconds in one day +define('ONE_WEEK', 604800); // Seconds in one week + +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($courseid, $onlyvisible = true) +{ + if ($onlyvisible) { + $result = get_records_select('attendance_statuses', "courseid = $courseid AND visible = 1 AND deleted = 0", 'grade DESC'); + } else { + $result = get_records_select('attendance_statuses', "courseid = $courseid AND deleted = 0", '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, $statusid=0) +{ + global $CFG; + $qry = "SELECT count(*) as cnt + FROM {$CFG->prefix}attendance_log al + JOIN {$CFG->prefix}attendance_sessions ats + ON al.sessionid = ats.id + WHERE ats.courseid = $course->id + AND ats.sessdate >= $course->startdate + AND al.studentid = $userid"; + if ($statusid) { + $qry .= " AND al.statusid = $statusid"; + } + + return count_records_sql($qry); +} + +function get_grade($userid, $course) +{ + global $CFG; + $logs = get_records_sql("SELECT l.id, l.statusid, l.statusset + FROM {$CFG->prefix}attendance_log l + JOIN {$CFG->prefix}attendance_sessions s + ON l.sessionid = s.id + WHERE l.studentid = $userid + AND s.courseid = $course->id + AND s.sessdate >= $course->startdate"); + $result = 0; + if ($logs) { + $stat_grades = records_to_menu(get_records('attendance_statuses', 'courseid', $course->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) +{ + global $CFG; + $logs = get_records_sql("SELECT l.id, l.statusid, l.statusset + FROM {$CFG->prefix}attendance_log l + JOIN {$CFG->prefix}attendance_sessions s + ON l.sessionid = s.id + WHERE l.studentid = $userid + AND s.courseid = $course->id + AND s.sessdate >= $course->startdate"); + $maxgrade = 0; + if ($logs) { + $stat_grades = records_to_menu(get_records('attendance_statuses', 'courseid', $course->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; + $logs = get_records_sql("SELECT l.id, l.statusid, l.statusset + FROM {$CFG->prefix}attendance_log l + JOIN {$CFG->prefix}attendance_sessions s + ON l.sessionid = s.id + WHERE l.studentid = $userid + AND s.courseid = $course->id + AND s.sessdate >= $course->startdate"); + $result = 0; + if ($logs) { + $stat_grades = records_to_menu(get_records('attendance_statuses', 'courseid', $course->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) +{ + global $CFG; + + $maxgrd = get_maxgrade($userid, $course); + if ($maxgrd == 0) { + $result = 0; + } else { + $result = get_grade($userid, $course) / $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) { + global $SESSION; + + if (isset($SESSION->currentattview[$courseid])) + return $SESSION->currentattview[$courseid]; + else + return 'all'; +} + +function print_row($left, $right) { + echo "\n'.
+ helpbutton('studentview', get_string('attendancereport','attforblock'), 'attforblock', true, false, '', true).
+ "id}&student={$user->id}&mode=$mode&printing=yes\" target=\"_blank\">[".get_string('versionforprinting','attforblock').'] | ';
+ 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); + if($complete) { + print_attendance_table($user, $course); + } else { + echo get_string('attendancenotstarted','attforblock'); + } + } else { + $stqry = "SELECT ats.id,ats.courseid + FROM {$CFG->prefix}attendance_log al + JOIN {$CFG->prefix}attendance_sessions ats + ON al.sessionid = ats.id + WHERE al.studentid = {$user->id} + GROUP BY ats.courseid + ORDER BY ats.courseid asc"; + $recs = get_records_sql_menu($stqry); + foreach ($recs as $id => $courseid) { + echo ' '; + echo '
+ ';
+}
+
+?>
diff --git a/manage.php b/manage.php
new file mode 100644
index 0000000..5e20c21
--- /dev/null
+++ b/manage.php
@@ -0,0 +1,164 @@
+course)) {
+ error("Course is misconfigured");
+ }
+
+ if (! $attforblock = get_record('attforblock', 'id', $cm->instance)) {
+ error("Course module is incorrect");
+ }
+
+ require_login($course->id);
+
+ if (! $user = get_record('user', 'id', $USER->id) ) {
+ error("No such user in this course");
+ }
+
+ if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
+ print_error('badcontext');
+ }
+
+ 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");
+ }
+
+ //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, lasttaken
+ FROM {$CFG->prefix}attendance_sessions
+ WHERE $today BETWEEN sessdate AND (sessdate + duration)
+ AND courseid = $course->id";
+ if($att = get_record_sql($sql)) {
+ 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);
+ }
+ }
+ }
+
+/// Print headers
+ $navlinks[] = array('name' => $attforblock->name, 'link' => null, 'type' => 'activity');
+ $navigation = build_navigation($navlinks);
+ print_header("$course->shortname: ".$attforblock->name, $course->fullname,
+ $navigation, "", "", true, update_module_button($cm->id, $course->id, get_string('modulename', 'attforblock')),
+ navmenu($course));
+
+ print_heading(get_string('attendanceforthecourse','attforblock').' :: ' .$course->fullname);
+
+ if(!count_records_select('attendance_sessions', "courseid = $course->id AND sessdate >= $course->startdate")) { // no session exists for this course
+ show_tabs($cm, $context);
+ print_heading(get_string('nosessionexists','attforblock'));
+ $hiddensess = count_records_select('attendance_sessions', "courseid = $course->id AND sessdate < $course->startdate");
+ echo '
'.helpbutton('hiddensessions', '', 'attforblock', true, true, '', true);
+ 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);
+ }
+// require_once('lib.php');
+// $t = attforblock_get_user_grades($attforblock); ////////////////////////////////////////////
+ print_footer($course);
+
+
+function print_sessions_list($course) {
+ global $CFG, $context, $cm;
+
+ $strhours = get_string('hours');
+ $strmins = get_string('min');
+
+ $qry = get_records_select('attendance_sessions', "courseid = $course->id AND sessdate >= $course->startdate", 'sessdate asc');
+ $i = 0;
+ $table->width = '100%';
+ //$table->tablealign = 'center';
+ $table->head = array('#', get_string('date'), get_string('time'), get_string('duration', 'attforblock'), 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);
+ foreach($qry as $key=>$sessdata)
+ {
+ $i++;
+ $actions = '';
+// if ($allowtake) {
+ if($sessdata->lasttaken > 0) //attendance has taken
+ {
+ if ($allowchange) {
+ $desc = "id&sessionid={$sessdata->id}\">".
+ ($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}\">".
+ "pixpath}/t/go.gif\" alt=\"$title\" /> ";
+ }
+ }
+// }
+ if($allowmanage) {
+ $title = get_string('editsession','attforblock');
+ $actions .= "id&sessionid={$sessdata->id}&action=update\">".
+ "pixpath}/t/edit.gif\" alt=\"$title\" /> ";
+ $title = get_string('deletesession','attforblock');
+ $actions .= "id&sessionid={$sessdata->id}&action=delete\">".
+ "pixpath}/t/delete.gif\" alt=\"$title\" /> ";
+ }
+
+ $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'));
+ $hours = floor($sessdata->duration / HOURSECS);
+ $mins = floor(($sessdata->duration - $hours * HOURSECS) / MINSECS);
+ $mins = $mins < 10 ? "0$mins" : "$mins";
+ $table->data[$sessdata->id][] = $hours ? "{$hours} {$strhours} {$mins} {$strmins}" : "{$mins} {$strmins}";
+ $table->data[$sessdata->id][] = $desc;
+ $table->data[$sessdata->id][] = $actions;
+ $table->data[$sessdata->id][] = '';
+ unset($desc, $actions);
+ }
+ echo '';
+ echo " '.helpbutton ('report', get_string('help'), 'attforblock', true, true, '', true).' ';
+
+ if ($currentgroup) {
+ $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);
+ }
+
+ // display date interval selector
+ $rec = get_record_sql("SELECT MIN(sessdate) AS min, MAX(sessdate) AS max
+ FROM {$CFG->prefix}attendance_sessions
+ WHERE courseid=$course->id AND sessdate >= $course->startdate");
+ $firstdate = $rec->min;
+ $lastdate = $rec->max;
+ $now = time();
+ $current = $current == 0 ? $now : $current;
+ list(,,,$wday, $syear, $smonth, $sday) = array_values(usergetdate($firstdate));
+ $wday = $wday == 0 ? 7 : $wday; //////////////////////////////////////////////////// Нужна проверка настройки календаря
+ $startdate = make_timestamp($syear, $smonth, $sday-$wday+1); //GMT timestamp but for local midnight of monday
+
+ $options['all'] = get_string('alltaken','attforblock');
+ $options['weeks'] = get_string('weeks','attforblock');
+ $options['months'] = get_string('months','attforblock');
+ echo '('.get_string('strftimehm', 'attforblock').')'). + ''; + } else { + $table->head[] = userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').' ('.get_string('strftimehm', 'attforblock').')'); + } + + } else { + if ($allowtake) { + $table->head[] = "id}\">". + userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').' ('.get_string('strftimehm', 'attforblock').')'). + ''; + } else { + $table->head[] = userdate($sessdata->sessdate, get_string('strftimedm', 'attforblock').' ('.get_string('strftimehm', 'attforblock').')'); + } + } + $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; + } + $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).''; + foreach($course_sess as $sessdata) { + if ($att = get_record('attendance_log', '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 { + $table->data[$student->id][] = '-'; + } + } + foreach($statuses as $st) { + $table->data[$student->id][] = get_attendance($student->id, $course, $st->id); + } + $table->data[$student->id][] = get_grade($student->id, $course).' / '.get_maxgrade($student->id, $course); + $table->data[$student->id][] = get_percent($student->id, $course).'%'; + } + echo ' '; + 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 new file mode 100644 index 0000000..79a22c1 --- /dev/null +++ b/restorelib.php @@ -0,0 +1,255 @@ +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 = 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; + + $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->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 = 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; + + $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->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 = 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->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 = 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 = get_records('attendance_statuses', 'courseid', 0, 'id ASC'); + $oldstats = array('P', 'A', 'L', 'E'); + $i = 0; + foreach($stats as $stat) { +// $stat = $stats[$i]; + $stat->courseid = $restore->course_id; + $newid = 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; + + $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 = get_records_menu('attendance_statuses', 'courseid', $restore->course_id); + $statslist = implode(',', array_keys($stats)); + $sessions = get_records('attendance_sessions', 'courseid', $restore->course_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 = 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 new file mode 100644 index 0000000..adc98d1 --- /dev/null +++ b/sessions.php @@ -0,0 +1,265 @@ +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 = get_record('course_modules', 'id', $id)) { + error('Course Module ID was incorrect'); + } + if (! $course = get_record('course', 'id', $cm->course)) { + error('Course is misconfigured'); + } + if (! $attforblock = get_record('attforblock', 'id', $cm->instance)) { + error("Course module is incorrect"); + } + } + + require_login($course->id); + + if (! $user = get_record('user', '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; + $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->sessdate = $sdate; + $rec->duration = $duration; + $rec->description = $fromform->sdescription; + $rec->timemodified = $now; + 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->sessdate = $fromform->sessiondate; + $rec->duration = $duration; + $rec->description = $fromform->sdescription; + $rec->timemodified = $now; + 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"); + } + } + $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 = get_record('attendance_sessions', '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(); + 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 = get_record('attendance_sessions', 'id', $sessionid) ) { + error('No such session in this course'); + } + + if (isset($confirm)) { + delete_records('attendance_log', 'sessionid', $sessionid); + delete_records('attendance_sessions', 'id', $sessionid); + add_to_log($course->id, 'attendance', 'Session deleted', 'mod/attforblock/manage.php?id='.$id, $user->lastname.' '.$user->firstname); + $attforblockrecord = get_record('attforblock', '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)); + delete_records_select('attendance_log', "sessionid IN ($ids)"); + 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 = get_record('attforblock','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 = get_records_list('attendance_sessions', '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 = get_records_list('attendance_sessions', '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; + 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/update_form.php b/update_form.php new file mode 100644 index 0000000..7bc8d6b --- /dev/null +++ b/update_form.php @@ -0,0 +1,69 @@ +libdir.'/formslib.php'); + +class mod_attforblock_update_form extends moodleform { + + function definition() { + + global $CFG; + $mform =& $this->_form; + + $course = $this->_customdata['course']; + $cm = $this->_customdata['cm']; +// $coursecontext = $this->_customdata['coursecontext']; + $modcontext = $this->_customdata['modcontext']; + $sessionid = $this->_customdata['sessionid']; + + + if (!$att = get_record('attendance_sessions', 'id', $sessionid) ) { + error('No such session in this course'); + } + $mform->addElement('header', 'general', get_string('changesession','attforblock')); + $mform->setHelpButton('general', array('changesession', get_string('changesession','attforblock'), 'attforblock')); + + $mform->addElement('static', 'olddate', get_string('olddate','attforblock'), userdate($att->sessdate, get_string('strftimedmyhm', 'attforblock'))); + $mform->addElement('date_time_selector', 'sessiondate', get_string('newdate','attforblock')); + + for ($i=0; $i<=23; $i++) { + $hours[$i] = sprintf("%02d",$i); + } + for ($i=0; $i<60; $i+=5) { + $minutes[$i] = sprintf("%02d",$i); + } + $durselect[] =& MoodleQuickForm::createElement('select', 'hours', '', $hours); + $durselect[] =& MoodleQuickForm::createElement('select', 'minutes', '', $minutes, false, true); + $mform->addGroup($durselect, 'durtime', get_string('duration','attforblock'), array(' '), true); + + $mform->addElement('text', 'sdescription', get_string('description', 'attforblock'), 'size="48"'); + $mform->setType('sdescription', PARAM_TEXT); + $mform->addRule('sdescription', get_string('maximumchars', '', 100), 'maxlength', 100, 'client'); + + $dhours = floor($att->duration / HOURSECS); + $dmins = floor(($att->duration - $dhours * HOURSECS) / MINSECS); + $mform->setDefaults(array('sessiondate' => $att->sessdate, + 'durtime' => array('hours'=>$dhours, 'minutes'=>$dmins), + 'sdescription' => $att->description)); + +//------------------------------------------------------------------------------- + // buttons + $submit_string = get_string('update', 'attforblock'); + $this->add_action_buttons(true, $submit_string); + + $mform->addElement('hidden', 'id', $cm->id); + $mform->addElement('hidden', 'sessionid', $sessionid); + $mform->addElement('hidden', 'action', 'update'); + + } + +// function validation($data, $files) { +// $errors = parent::validation($data, $files); +// if (($data['timeend']!=0) && ($data['timestart']!=0) +// && $data['timeend'] <= $data['timestart']) { +// $errors['timeend'] = get_string('timestartenderror', 'forum'); +// } +// return $errors; +// } + +} +?> diff --git a/version.php b/version.php new file mode 100644 index 0000000..b213430 --- /dev/null +++ b/version.php @@ -0,0 +1,11 @@ +version = 2009022800; // The current module version (Date: YYYYMMDDXX) +$module->release = '2.1.1'; +$module->cron = 0; // Period for cron to check this module (secs) +?> diff --git a/view.php b/view.php new file mode 100644 index 0000000..3393fbe --- /dev/null +++ b/view.php @@ -0,0 +1,118 @@ +course)) { + error("Course is misconfigured"); + } + + if (! $attforblock = get_record("attforblock", "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 = get_record('user', 'id', $USER->id) ) { + error("No such user in this course"); + } + + require_capability('mod/attforblock:view', $context); + + $student = false; + if ($studentid) { + if ($studentid == $USER->id or has_capability('mod/attforblock:viewreports', $context)) { + if (!$student = get_record('user', '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, $course, 'printing'); + } else { + print_header('', get_string('attendancereport','attforblock')); + print_user_attendaces($user, $cm, 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, $course); + } else { + print_user_attendaces($user, $cm); + } + + print_footer($course); + +?> \ No newline at end of file |