From 28ab5c77a24afa68149a1d0bcc9969b362bd7215 Mon Sep 17 00:00:00 2001 From: Luis Ramon Lopez Date: Thu, 30 Dec 2010 04:22:45 +0100 Subject: [PATCH 01/13] Implemented grid display mode --- CHANGES | 9 ++++++ attendances.php | 56 ++++++++++++++++++++++++++++++++++++ db/install.xml | 2 ++ db/upgrade.php | 12 ++++++++ lang/en_utf8/attforblock.php | 5 ++++ lang/es_utf8/attforblock.php | 5 ++++ mod_form.php | 4 +++ version.php | 4 +-- 8 files changed, 95 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index b4f181c..1c6da13 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,12 @@ +2010-12-29 - 2010-12-30 lrlopez + + * db/install.xml: + * db/upgrade.php: + Implemented display modes (list and grid) + + * lang/: en_utf8/attforblock.php, es_utf8/attforblock.php: + Added new strings for the new display modes + 2010-07-10 - 2010-09-17 andreev.artem Implemented ability to add two types of sessions: common and group diff --git a/attendances.php b/attendances.php index 237ce6c..7c5aa6d 100644 --- a/attendances.php +++ b/attendances.php @@ -103,6 +103,18 @@ $groupmode = groups_get_activity_groupmode($cm); $currentgroup = groups_get_activity_group($cm, true); + // get the viewmode & grid columns (default is set in module settings) + $attforblockrecord = get_record('attforblock', 'course', $course->id); + $view = optional_param('view', $attforblockrecord->displaymode, PARAM_INT); + $gridcols = optional_param('gridcols', $attforblockrecord->gridcolumns, PARAM_INT); + echo '
'; + $options = array (get_string('sortedlist','attforblock'), get_string('sortedgrid','attforblock')); + $data = "attendances.php?id=$id&sessionid=$sessionid&grouptype=$grouptype"; + if ($group!=-1) { + $data = $data . "&group=$group"; + } + popup_form("$data&view=", $options, 'viewmenu', $view, ''); + echo '
'; if ($grouptype === 0) { if ($currentgroup) { $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', $currentgroup, '', false); @@ -128,10 +140,19 @@ $statuses = get_statuses($course->id); $i = 3; foreach($statuses as $st) { + switch($view) { + case 0: $tabhead[] = "$st->acronym"; + break; + case 1: + $tabhead[] = "acronym . "', null);\">$st->acronym"; + break; + } $i++; } + if ($view == 0) { $tabhead[] = get_string('remarks','attforblock'); + } $firstname = "".get_string('firstname').''; $lastname = "".get_string('lastname').''; @@ -143,6 +164,9 @@ if ($students) { unset($table); + + switch($view) { + case 0: // sorted list $table->width = '0%'; $table->head[] = '#'; $table->align[] = 'center'; @@ -174,6 +198,38 @@ } $table->data[$student->id][] = ''; } + break; + case 1: // sorted grid + $table->width = '0%'; + + $data = ''; + foreach ($tabhead as $hd) { + $data = $data . $hd . ' '; + } + print_heading($data,'center'); + + $i = 0; + // sanity check + $gridcols = $gridcols < 0 ? 0 : $gridcols; + for ($i=0; $i<=$gridcols; $i++) { + $table->head[] = ' '; + $table->align[] = 'center'; + $table->size[] = '110px'; + } + + $i = 0; + foreach($students as $student) { + $i++; + $att = get_record('attendance_log', 'sessionid', $sessionid, 'studentid', $student->id); + + $data = "" . print_user_picture($student, $course->id, $student->picture, true, true, '', fullname($student)) . "
" . fullname($student) . "
";//, $returnstring=false, $link=true, $target=''); + foreach($statuses as $st) { + $data = $data . 'id == $att->statusid ? 'checked' : '').'>' . $st->acronym; + } + $table->data[($i-1) / ($gridcols+1)][] = $data; + } + break; + } echo '
'; print_table($table); diff --git a/db/install.xml b/db/install.xml index d4a7667..c9cf21c 100644 --- a/db/install.xml +++ b/db/install.xml @@ -10,6 +10,8 @@ + + diff --git a/db/upgrade.php b/db/upgrade.php index 8b4cc7a..751b04f 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -228,6 +228,18 @@ function xmldb_attforblock_upgrade($oldversion=0) { $result = $result && add_index($table, $index); } + if ($oldversion < 2010122900 and $result) { + $table = new XMLDBTable('attforblock'); + + $field = new XMLDBField('displaymode'); + $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'grade'); + $result = $result && add_field($table, $field); + + $field = new XMLDBField('gridcolumns'); + $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '4', 'displaymode'); + $result = $result && add_field($table, $field); + } + return $result; } diff --git a/lang/en_utf8/attforblock.php b/lang/en_utf8/attforblock.php index 7bda8a4..6f03cad 100644 --- a/lang/en_utf8/attforblock.php +++ b/lang/en_utf8/attforblock.php @@ -46,6 +46,7 @@ $string['createmultiplesessions'] = 'Create multiple sessions'; $string['createonesession'] = 'Create one session for the course'; $string['days'] = 'Day'; $string['defaults'] = 'Defaults'; +$string['defaultdisplaymode'] = 'Default display mode'; $string['delete'] = 'Delete'; $string['deletelogs'] = 'Delete attendance data'; $string['deleteselected'] = 'Delete selected'; @@ -55,6 +56,7 @@ $string['deletingsession'] = 'Deleting session for the course'; $string['deletingstatus'] = 'Deleting status for the course'; $string['description'] = 'Description'; $string['display'] = 'Display'; +$string['displaymode'] = 'Display mode'; $string['downloadexcel'] = 'Download in Excel format'; $string['downloadooo'] = 'Download in OpenOffice format'; $string['downloadtext'] = 'Download in text format'; @@ -64,6 +66,7 @@ $string['endofperiod'] = 'End of period'; $string['errorgroupsnotselected'] = 'Select one or more groups'; $string['errorinaddingsession'] = 'Error in adding session'; $string['erroringeneratingsessions'] = 'Error in generating sessions '; +$string['gridcolumns'] = 'Grid columns'; $string['groupsession'] = 'Group'; $string['hiddensessions'] = 'Hidden sessions'; $string['identifyby'] = 'Identify student by'; @@ -111,6 +114,8 @@ $string['sessiontypeshort'] = 'Type'; $string['sessionupdated'] = 'Session successfully updated'; $string['settings'] = 'Settings'; $string['showdefaults'] = 'Show defaults'; +$string['sortedgrid'] = 'Sorted grid'; +$string['sortedlist'] = 'Sorted list'; $string['status'] = 'Status'; $string['statusdeleted'] = 'Status deleted'; $string['strftimedm'] = '%%d.%%m'; diff --git a/lang/es_utf8/attforblock.php b/lang/es_utf8/attforblock.php index 6c44f82..34e3efe 100644 --- a/lang/es_utf8/attforblock.php +++ b/lang/es_utf8/attforblock.php @@ -30,6 +30,7 @@ $string['countofselected'] = 'Recuento de selección'; $string['createmultiplesessions'] = 'Crear varias sesiones'; $string['createonesession'] = 'Crear una sesión para el curso'; $string['defaults'] = 'Por Defecto'; +$string['defaultdisplaymode'] = 'Visualización por defecto'; $string['delete'] = 'Eliminar'; $string['deletelogs'] = 'Eliminar datos de asistencia'; $string['deleteselected'] = 'Eliminar selección'; @@ -38,6 +39,7 @@ $string['deletesessions'] = 'Eliminar todas las sesiones'; $string['deletingsession'] = 'Eliminando Sesión para el Curso/Asignatura'; $string['description'] = 'Descripción'; $string['display'] = 'Mostrar'; +$string['displaymode'] = 'Modo de visualización'; $string['downloadexcel'] = 'Descargar en Formato Excell'; $string['downloadooo'] = 'Descargar en Formato OpenOffice'; $string['downloadtext'] = 'Descargar en Formato de Texto'; @@ -48,6 +50,7 @@ $string['Efull'] = 'Justificado'; $string['endofperiod'] = 'Fin del periodo'; $string['errorinaddingsession'] = 'Error añadiendo Sesión'; $string['erroringeneratingsessions'] = 'Error generando sesión '; +$string['gridcolumns'] = 'Columnas de la rejilla'; $string['identifyby'] = 'Identificar estudiantes por'; $string['includenottaken'] = 'Incluir sesiones no registradas'; $string['indetail'] = 'En Detalle...'; @@ -94,6 +97,8 @@ $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['sortedgrid'] = 'Rejilla alfabética'; +$string['sortedlist'] = 'Lista alfabética'; $string['status'] = 'Estado'; $string['strftimedm'] = '%%d.%%m'; $string['strftimedmy'] = '%%d.%%m.%%Y'; diff --git a/mod_form.php b/mod_form.php index 47549eb..866f41d 100644 --- a/mod_form.php +++ b/mod_form.php @@ -20,7 +20,11 @@ class mod_attforblock_mod_form extends moodleform_mod { $mform->addElement('modgrade', 'grade', get_string('grade')); $mform->setDefault('grade', 100); + + $mform->addElement('select', 'displaymode', get_string('displaymode','attforblock'), array (get_string('sortedlist','attforblock'), get_string('sortedgrid','attforblock'))); + $mform->addElement('select', 'gridcolumns', get_string('gridcolumns','attforblock'), array ('1','2','3','4','5','6','7','8','9','10')); + $this->standard_coursemodule_elements(true); //------------------------------------------------------------------------------- diff --git a/version.php b/version.php index f2b017b..bbf2968 100644 --- a/version.php +++ b/version.php @@ -5,7 +5,7 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2010070900; // The current module version (Date: YYYYMMDDXX) -$module->release = '2.2.0'; +$module->version = 2010122900; // The current module version (Date: YYYYMMDDXX) +$module->release = '2.2.1'; $module->cron = 0; // Period for cron to check this module (secs) ?> From 2bf9f94c8f271ac2cefafc14557eb002010e8430 Mon Sep 17 00:00:00 2001 From: Luis Ramon Lopez Date: Wed, 5 Jan 2011 03:52:51 +0100 Subject: [PATCH 02/13] Grid view support. Multiple instances in the same course now allowed. Updated es_utf8 language strings --- CHANGES | 28 +++++++- attendances.php | 33 +++++++--- attsettings.php | 8 ++- backuplib.php | 6 +- db/install.xml | 8 +-- db/upgrade.php | 29 +++++++-- export.php | 6 +- lang/en_utf8/attforblock.php | 5 ++ lang/es_utf8/attforblock.php | 61 ++++++++++++----- .../help/attforblock/hiddensessions.html | 15 +++++ .../help/attforblock/sessiontypes.html | 17 +++++ lib.php | 27 ++++---- locallib.php | 65 ++++++++++--------- manage.php | 27 ++++---- mod_form.php | 4 -- report.php | 16 ++--- restorelib.php | 12 ++-- sessions.php | 5 +- styles.php | 2 +- version.php | 2 +- 20 files changed, 251 insertions(+), 125 deletions(-) create mode 100644 lang/es_utf8/help/attforblock/hiddensessions.html create mode 100644 lang/es_utf8/help/attforblock/sessiontypes.html diff --git a/CHANGES b/CHANGES index 1c6da13..44ca102 100644 --- a/CHANGES +++ b/CHANGES @@ -1,7 +1,29 @@ -2010-12-29 - 2010-12-30 lrlopez +2010-12-30 - 2011-01-04 lrlopez - * db/install.xml: - * db/upgrade.php: + * lang/: es_utf8/attforblock.php: + + Updated and fixed Spanish translation (Enrique Robredo) + + * styles.php: + + Fixed yui-calendar CSS modifying global CSS behaviour. + + * manage.php: + + Added an option for choosing between show session duration or show end + time in session list. + + * db/: install.xml: upgrade.php: version.php: + * attsettings.php: lib.php: locallib.php: manage.php: report.php: + + Added support to allow more than one attendance in the same course. + + * sessions.php: + + Fixed DST bug (adding multiple sessions could generate invalid start + times if any DST change occur in-between) + + * attendances.php: Implemented display modes (list and grid) * lang/: en_utf8/attforblock.php, es_utf8/attforblock.php: diff --git a/attendances.php b/attendances.php index 7c5aa6d..9f04b38 100644 --- a/attendances.php +++ b/attendances.php @@ -38,7 +38,7 @@ print_error('badcontext'); } - $statlist = implode(',', array_keys( (array)get_statuses($course->id) )); + $statlist = implode(',', array_keys( (array)get_statuses($attforblock->id) )); if ($form = data_submitted()) { $students = array(); // stores students ids $formarr = (array)$form; @@ -105,15 +105,28 @@ // get the viewmode & grid columns (default is set in module settings) $attforblockrecord = get_record('attforblock', 'course', $course->id); - $view = optional_param('view', $attforblockrecord->displaymode, PARAM_INT); - $gridcols = optional_param('gridcols', $attforblockrecord->gridcolumns, PARAM_INT); + $view = optional_param('view', get_user_preferences("attforblock_viewmode",0), PARAM_INT); + $gridcols = optional_param('gridcols', get_user_preferences("attforblock_gridcolumns",5), PARAM_INT); echo '
'; - $options = array (get_string('sortedlist','attforblock'), get_string('sortedgrid','attforblock')); - $data = "attendances.php?id=$id&sessionid=$sessionid&grouptype=$grouptype"; + $options = array (0 => get_string('sortedlist','attforblock'), 1 => get_string('sortedgrid','attforblock')); + $data = "attendances.php?id=$id&sessionid=$sessionid&grouptype=$grouptype&gridcols=$gridcols"; if ($group!=-1) { $data = $data . "&group=$group"; } popup_form("$data&view=", $options, 'viewmenu', $view, ''); + if ($view==1) { + set_user_preference("attforblock_viewmode", $view); + set_user_preference("attforblock_gridcolumns", $gridcols); + $options = array (1 => '1 '.get_string('column','attforblock'),'2 '.get_string('columns','attforblock'),'3 '.get_string('columns','attforblock'), + '4 '.get_string('columns','attforblock'),'5 '.get_string('columns','attforblock'),'6 '.get_string('columns','attforblock'), + '7 '.get_string('columns','attforblock'),'8 '.get_string('columns','attforblock'),'9 '.get_string('columns','attforblock'), + '10 '.get_string('columns','attforblock')); + $data = "attendances.php?id=$id&sessionid=$sessionid&grouptype=$grouptype&view=$view"; + if ($group!=-1) { + $data = $data . "&group=$group"; + } + popup_form("$data&gridcols=", $options, 'colsmenu', $gridcols, ''); + } echo '
'; if ($grouptype === 0) { if ($currentgroup) { @@ -137,7 +150,7 @@ ', "'.($sessdata->description ? $sessdata->description : get_string('nodescription', 'attforblock')).'"'; print_table($table); - $statuses = get_statuses($course->id); + $statuses = get_statuses($attforblock->id); $i = 3; foreach($statuses as $st) { switch($view) { @@ -210,8 +223,8 @@ $i = 0; // sanity check - $gridcols = $gridcols < 0 ? 0 : $gridcols; - for ($i=0; $i<=$gridcols; $i++) { + $gridcols = $gridcols < 1 ? 1 : $gridcols; + for ($i=0; $i<$gridcols; $i++) { $table->head[] = ' '; $table->align[] = 'center'; $table->size[] = '110px'; @@ -226,7 +239,7 @@ foreach($statuses as $st) { $data = $data . 'id == $att->statusid ? 'checked' : '').'>' . $st->acronym; } - $table->data[($i-1) / ($gridcols+1)][] = $data; + $table->data[($i-1) / ($gridcols)][] = $data; } break; } @@ -237,7 +250,7 @@ echo ''; echo ''; echo ''; - echo '
'; + echo '
'; echo ''; } else { print_heading(get_string('nothingtodisplay'), 'center'); diff --git a/attsettings.php b/attsettings.php index c10a9c2..ca8ef25 100644 --- a/attsettings.php +++ b/attsettings.php @@ -20,7 +20,10 @@ error("Course module is incorrect"); } } - $attforblockrecord = get_record('attforblock','course',$course->id); + //$attforblockrecord = get_record('attforblock','course',$course->id); + if (! $attforblockrecord = get_record('attforblock', 'id', $cm->instance)) { + error("Course module is incorrect"); + } require_login($course->id); @@ -84,6 +87,7 @@ if (!empty($newacronym) && !empty($newdescription)) { unset($rec); $rec->courseid = $course->id; + $rec->attendanceid = $attforblock->id; $rec->acronym = $newacronym; $rec->description = $newdescription; $rec->grade = $newgrade; @@ -113,7 +117,7 @@ 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); + $statuses = get_statuses($attforblockrecord->id, false); $deltitle = get_string('delete'); foreach($statuses as $st) { diff --git a/backuplib.php b/backuplib.php index 0c36cc7..dab2af9 100644 --- a/backuplib.php +++ b/backuplib.php @@ -97,7 +97,7 @@ $status = true; - $datas = get_records('attendance_sessions', 'courseid', $attforblock->course); + $datas = get_records('attendance_sessions', 'attendanceid', $attforblock->id); if ($datas) { //Write start tag $status =fwrite ($bf,start_tag('SESSIONS',4,true)); @@ -136,7 +136,7 @@ $status = true; - $datas = get_records('attendance_statuses', 'courseid', $attforblock->course); + $datas = get_records('attendance_statuses', 'attendanceid', $attforblock->id); //If there is levels if ($datas) { //Write start tag @@ -170,7 +170,7 @@ $status = true; - $sessions = get_records_menu('attendance_sessions', 'courseid', $attforblock->course); + $sessions = get_records_menu('attendance_sessions', 'attendanceid', $attforblock->id); $sesslist = implode(',', array_keys($sessions)); $datas = get_records_list('attendance_log', 'sessionid', $sesslist); //If there is levels diff --git a/db/install.xml b/db/install.xml index c9cf21c..e7f83e0 100644 --- a/db/install.xml +++ b/db/install.xml @@ -10,8 +10,6 @@ - - @@ -24,7 +22,8 @@ - + + @@ -37,7 +36,8 @@ - + + diff --git a/db/upgrade.php b/db/upgrade.php index 751b04f..c72e99c 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -228,18 +228,33 @@ function xmldb_attforblock_upgrade($oldversion=0) { $result = $result && add_index($table, $index); } - if ($oldversion < 2010122900 and $result) { - $table = new XMLDBTable('attforblock'); + if ($oldversion < 2010123003 and $result) { + + $table = new XMLDBTable('attendance_sessions'); - $field = new XMLDBField('displaymode'); - $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'grade'); + $field = new XMLDBField('attendanceid'); + $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'groupid'); $result = $result && add_field($table, $field); - $field = new XMLDBField('gridcolumns'); - $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '4', 'displaymode'); + $index = new XMLDBIndex('attendanceid'); + $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('attendanceid')); + $result = $result && add_index($table, $index); + + $sql = "UPDATE {$CFG->prefix}attendance_sessions AS ses,{$CFG->prefix}attforblock AS att SET ses.attendanceid=att.id WHERE att.course=ses.courseid"; + $result = $result && execute_sql($sql); + + $table = new XMLDBTable('attendance_statuses'); + + $field = new XMLDBField('attendanceid'); + $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'courseid'); $result = $result && add_field($table, $field); - } + $index = new XMLDBIndex('attendanceid'); + $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('attendanceid')); + $result = $result && add_index($table, $index); + $sql = "UPDATE {$CFG->prefix}attendance_statuses AS sta,{$CFG->prefix}attforblock AS att SET sta.attendanceid=att.id WHERE att.course=sta.courseid"; + $result = $result && execute_sql($sql); + } return $result; } diff --git a/export.php b/export.php index d2ec5ce..f152d7f 100644 --- a/export.php +++ b/export.php @@ -56,7 +56,7 @@ $data->tabhead[] = get_string('lastname'); $data->tabhead[] = get_string('firstname'); - $select = "courseid = {$course->id} AND sessdate >= {$course->startdate}"; + $select = "courseid = {$course->id} AND attendanceid = {$attforblock->id} AND sessdate >= {$course->startdate}"; if (isset($fromform->includenottaken)) { $select .= " AND sessdate <= {$fromform->sessionenddate}"; } else { @@ -74,7 +74,7 @@ $i = 0; $data->table = array(); - $statuses = get_statuses($course->id); + $statuses = get_statuses($attforblock->id); foreach($students as $student) { if (isset($fromform->ident['id'])) { $data->table[$i][] = $student->id; @@ -91,7 +91,7 @@ $data->table[$i][] = '-'; } } - $data->table[$i][] = get_percent($student->id, $course).'%'; + $data->table[$i][] = get_percent($student->id, $course, $attforblock).'%'; $i++; } diff --git a/lang/en_utf8/attforblock.php b/lang/en_utf8/attforblock.php index 6f03cad..ffcca82 100644 --- a/lang/en_utf8/attforblock.php +++ b/lang/en_utf8/attforblock.php @@ -39,6 +39,8 @@ $string['caltoday'] = 'Today'; $string['calweekdays'] = ' \"Su\", \"Mo\", \"Tu\", \"We\", \"Th\", \"Fr\", \"Sa\"'; $string['changeduration'] = 'Change duration'; $string['changesession'] = 'Change session'; +$string['column'] = 'column'; +$string['columns'] = 'columns'; $string['commonsession'] = 'Common'; $string['commonsessions'] = 'Common'; $string['countofselected'] = 'Count of selected'; @@ -62,6 +64,7 @@ $string['downloadooo'] = 'Download in OpenOffice format'; $string['downloadtext'] = 'Download in text format'; $string['duration'] = 'Duration'; $string['editsession'] = 'Edit Session'; +$string['endtime'] = 'Session end time'; $string['endofperiod'] = 'End of period'; $string['errorgroupsnotselected'] = 'Select one or more groups'; $string['errorinaddingsession'] = 'Error in adding session'; @@ -97,6 +100,7 @@ $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['save'] = 'Save attendance'; $string['session'] = 'Session'; $string['sessionadded'] = 'Session successfully added'; $string['sessionalreadyexists'] = 'Session already exists for this date'; @@ -114,6 +118,7 @@ $string['sessiontypeshort'] = 'Type'; $string['sessionupdated'] = 'Session successfully updated'; $string['settings'] = 'Settings'; $string['showdefaults'] = 'Show defaults'; +$string['showduration'] = 'Show duration'; $string['sortedgrid'] = 'Sorted grid'; $string['sortedlist'] = 'Sorted list'; $string['status'] = 'Status'; diff --git a/lang/es_utf8/attforblock.php b/lang/es_utf8/attforblock.php index 34e3efe..8b27014 100644 --- a/lang/es_utf8/attforblock.php +++ b/lang/es_utf8/attforblock.php @@ -1,13 +1,21 @@ -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['months'] = 'Mensual'; $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['nogroups'] = 'No puede incluir sesiones grupales. No existen grupos en este curso.'; $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'; @@ -74,14 +94,13 @@ $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['save'] = 'Guardar asistencia'; $string['session'] = 'Sesión'; $string['sessionadded'] = 'Sesión añadida con éxito'; $string['sessionalreadyexists'] = 'Ya existe una sesión para la fecha indicada'; @@ -94,12 +113,16 @@ $string['sessions'] = 'Sesiones'; $string['sessionscompleted'] = 'Sesiones completadas'; $string['sessionsgenerated'] = 'Sesiones generadas con éxito'; $string['sessionstartdate'] = 'Fecha de Inicio de la Sesión'; +$string['sessiontype'] = 'Tipo de sesión'; +$string['sessiontypeshort'] = 'Tipo'; $string['sessionupdated'] = 'Sesión actualizada con éxito'; $string['settings'] = 'Configuración'; +$string['showduration'] = 'Mostrar duración'; $string['showdefaults'] = 'Mostrar opciones por defecto'; $string['sortedgrid'] = 'Rejilla alfabética'; $string['sortedlist'] = 'Lista alfabética'; $string['status'] = 'Estado'; +$string['statusdeleted'] = 'Estado eliminado'; $string['strftimedm'] = '%%d.%%m'; $string['strftimedmy'] = '%%d.%%m.%%Y'; $string['strftimedmyhm'] = '%%d.%%m.%%Y %%H.%%M'; @@ -110,9 +133,11 @@ $string['studentid'] = 'ID de Estudiante'; $string['takeattendance'] = 'Iniciar Asistencia'; $string['thiscourse'] = 'Este curso'; $string['update'] = 'Actualizar'; +$string['variable'] = 'variable'; $string['variablesupdated'] = 'Variables actualizadas con éxito'; $string['versionforprinting'] = 'versión para Imprimir'; $string['week'] = 'semana(s)'; -$string['weeks'] = 'Semanas'; +$string['weeks'] = 'Semanal'; $string['youcantdo'] = 'Usted no puede hacer nada'; + ?> diff --git a/lang/es_utf8/help/attforblock/hiddensessions.html b/lang/es_utf8/help/attforblock/hiddensessions.html new file mode 100644 index 0000000..1ce36db --- /dev/null +++ b/lang/es_utf8/help/attforblock/hiddensessions.html @@ -0,0 +1,15 @@ +

Asistencia

+

Ocultar sesiones

+

+ dirroot.'/mod/attforblock/version.php'); + echo get_string('version').": $module->release ($module->version)"; + unset($module); + $module = $temp; + ?> +

+

Las sesiones se ocultan cuando la fecha de comienzo de un curso es anterior que la actual. Modifique la fecha de inicio del curso y las sesiones ocultas se mostrarán.

+

Se puede utilizar esta opción para ocultar sesiones antiguas en lugar de eliminarlas. +Tenga en cuenta que únicamente las sesiones visibles son las que se tendrán en cuenta en el Libro de Calificaciones.

diff --git a/lang/es_utf8/help/attforblock/sessiontypes.html b/lang/es_utf8/help/attforblock/sessiontypes.html new file mode 100644 index 0000000..99f35c9 --- /dev/null +++ b/lang/es_utf8/help/attforblock/sessiontypes.html @@ -0,0 +1,17 @@ +

Asistencia

+

+ dirroot.'/mod/attforblock/version.php'); + echo get_string('version').": $module->release ($module->version)"; + unset($module); + $module = $temp; + ?> +

+

Hay dos tipos de sesiones: comunes y grupales. + La posibilidad de elegir una u otra dependerá del modo de grupo con que fue creada la actividad.

+

Modo de grupo "No hay grupos" únicamente se pueden elegir sesiones comunes.

+

Modo de grupo "Grupos visible" es posible elegir sesiones grupales o comunes.

+

Modo de grupo "Grupos Separados" únicamente es posible elegir sesiones grupales.

+

En caso de que fuese necesario, es posible seleccionar varios grupos simultáneos o alternos utilizando la tecla ctrl

diff --git a/lib.php b/lib.php index e1bc832..5a2f987 100644 --- a/lib.php +++ b/lib.php @@ -29,27 +29,28 @@ function attforblock_add_instance($attforblock) { $attforblock->timemodified = time(); - if ($att = get_record('attforblock', 'course', $attforblock->course)) { + /*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 { + /*} else { return false; } - } else { + } else {*/ $attforblock->id = insert_record('attforblock', $attforblock); - } + //} //Copy statuses for new instance from defaults - if (!get_records('attendance_statuses', 'courseid', $attforblock->course)) { + //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; + $rec->attendanceid = $attforblock->id; insert_record('attendance_statuses', $rec); } - } + //} // attforblock_grade_item_update($attforblock); // attforblock_update_grades($attforblock); @@ -165,11 +166,11 @@ function attforblock_user_outline($course, $user, $mod, $attforblock) { require_once('locallib.php'); if (isstudent($course->id, $user->id)) { - if ($sescount = get_attendance($user->id,$course)) { + if ($sescount = get_attendance($user->id,$course, $attforblock)) { $strgrade = get_string('grade'); - $maxgrade = get_maxgrade($user->id, $course); - $usergrade = get_grade($user->id, $course); - $percent = get_percent($user->id,$course); + $maxgrade = get_maxgrade($user->id, $course,$attforblock); + $usergrade = get_grade($user->id, $course,$attforblock); + $percent = get_percent($user->id,$course, $attforblock); $result->info = "$strgrade: $usergrade / $maxgrade ($percent%)"; } } @@ -229,13 +230,13 @@ function attforblock_get_user_grades($attforblock, $userid=0) { if ($userid) { $result = array(); $result[$userid]->userid = $userid; - $result[$userid]->rawgrade = $attforblock->grade * get_percent($userid, $course) / 100; + $result[$userid]->rawgrade = $attforblock->grade * get_percent($userid, $course, $attforblock) / 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; + $result[$student->id]->rawgrade = $attforblock->grade * get_percent($student->id, $course, $attforblock) / 100; } } } @@ -313,7 +314,7 @@ function attforblock_grade_item_update($attforblock, $grades=NULL) { }else{ // MDL-14303 $cm = get_coursemodule_from_instance('attforblock', $attforblock->id); - $params = array('itemname'=>$attforblock->name, 'idnumber'=>$cm->id); + $params = array('itemname'=>$attforblock->name/*, 'idnumber'=>$attforblock->id*/); } if ($attforblock->grade > 0) { diff --git a/locallib.php b/locallib.php index 1f42c6c..9114c09 100644 --- a/locallib.php +++ b/locallib.php @@ -46,12 +46,12 @@ function show_tabs($cm, $context, $currenttab='sessions') //getting settings for course -function get_statuses($courseid, $onlyvisible = true) +function get_statuses($attendanceid, $onlyvisible = true) { if ($onlyvisible) { - $result = get_records_select('attendance_statuses', "courseid = $courseid AND visible = 1 AND deleted = 0", 'grade DESC'); + $result = get_records_select('attendance_statuses', "attendanceid = $attendanceid 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_select('attendance_statuses', "attendanceid = $attendanceid AND deleted = 0", 'grade DESC'); // $result = get_records('attendance_statuses', 'courseid', $courseid, 'grade DESC'); } return $result; @@ -59,14 +59,14 @@ function get_statuses($courseid, $onlyvisible = true) //gets attendance status for a student, returns count -function get_attendance($userid, $course, $statusid=0) +function get_attendance($userid, $course, $attendance, $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 + WHERE ats.attendanceid = $attendance->id AND ats.sessdate >= $course->startdate AND al.studentid = $userid"; if ($statusid) { @@ -76,7 +76,7 @@ function get_attendance($userid, $course, $statusid=0) return count_records_sql($qry); } -function get_grade($userid, $course) +function get_grade($userid, $course, $attendance) { global $CFG; $logs = get_records_sql("SELECT l.id, l.statusid, l.statusset @@ -85,10 +85,11 @@ function get_grade($userid, $course) ON l.sessionid = s.id WHERE l.studentid = $userid AND s.courseid = $course->id + AND s.attendanceid = $attendance->id AND s.sessdate >= $course->startdate"); $result = 0; if ($logs) { - $stat_grades = records_to_menu(get_records('attendance_statuses', 'courseid', $course->id), 'id', 'grade'); + $stat_grades = records_to_menu(get_records('attendance_statuses', 'attendanceid', $attendance->id), 'id', 'grade'); foreach ($logs as $log) { $result += $stat_grades[$log->statusid]; } @@ -108,7 +109,7 @@ function local_array_intersect_key($array1, $array2) { return $result; } -function get_maxgrade($userid, $course) +function get_maxgrade($userid, $course, $attendance) { global $CFG; $logs = get_records_sql("SELECT l.id, l.statusid, l.statusset @@ -117,10 +118,11 @@ function get_maxgrade($userid, $course) ON l.sessionid = s.id WHERE l.studentid = $userid AND s.courseid = $course->id + AND s.attendanceid = $attendance->id AND s.sessdate >= $course->startdate"); $maxgrade = 0; if ($logs) { - $stat_grades = records_to_menu(get_records('attendance_statuses', 'courseid', $course->id), 'id', 'grade'); + $stat_grades = records_to_menu(get_records('attendance_statuses', 'attendanceid', $attendance->id), 'id', 'grade'); foreach ($logs as $log) { $ids = array_flip(explode(',', $log->statusset)); // $grades = array_intersect_key($stat_grades, $ids); // require PHP 5.1.0 and higher @@ -162,15 +164,15 @@ function get_percent_adaptive($userid, $course) // NOT USED return sprintf("%0.{$dp}f", $result); } -function get_percent($userid, $course) +function get_percent($userid, $course, $attforblock) { global $CFG; - $maxgrd = get_maxgrade($userid, $course); + $maxgrd = get_maxgrade($userid, $course, $attforblock); if ($maxgrd == 0) { $result = 0; } else { - $result = get_grade($userid, $course) / $maxgrd * 100; + $result = get_grade($userid, $course, $attforblock) / $maxgrd * 100; } if ($result < 0) { $result = 0; @@ -218,20 +220,20 @@ function print_row($left, $right) { function print_attendance_table($user, $course, $attforblock) { - $complete = get_attendance($user->id, $course); + $complete = get_attendance($user->id, $course, $attforblock); echo ''; print_row(get_string('sessionscompleted','attforblock').':', "$complete"); - $statuses = get_statuses($course->id); + $statuses = get_statuses($attforblock->id); foreach($statuses as $st) { - print_row($st->description.': ', ''.get_attendance($user->id, $course, $st->id).''); + print_row($st->description.': ', ''.get_attendance($user->id, $course, $attforblock, $st->id).''); } if ($attforblock->grade) { - $percent = get_percent($user->id, $course).' %'; - $grade = get_grade($user->id, $course); + $percent = get_percent($user->id, $course, $attforblock).' %'; + $grade = get_grade($user->id, $course, $attforblock); print_row(get_string('attendancepercent','attforblock').':', "$percent"); - print_row(get_string('attendancegrade','attforblock').':', "$grade / ".get_maxgrade($user->id, $course)); + print_row(get_string('attendancegrade','attforblock').':', "$grade / ".get_maxgrade($user->id, $course, $attforblock)); } print_row(' ', ' '); echo '
'; @@ -260,30 +262,31 @@ function print_user_attendaces($user, $cm, $attforblock, $course = 0, $printing echo ''.fullname($user).''; if ($course) { echo '
'; - $complete = get_attendance($user->id, $course); + $complete = get_attendance($user->id, $course, $attforblock); if($complete) { print_attendance_table($user, $course, $attforblock); } else { echo get_string('attendancenotstarted','attforblock'); } } else { - $stqry = "SELECT ats.id,ats.courseid + $stqry = "SELECT ats.id,ats.courseid AS 'cid',ats.attendanceid AS 'aid' 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) { + GROUP BY cid + ORDER BY cid,aid asc"; + $recs = get_records_sql($stqry); + foreach ($recs as $rec) { echo '
'; echo ''; - $nextcourse = get_record('course', 'id', $courseid); - echo ''; + $nextcourse = get_record('course', 'id', $rec['cid']); + $nextattendance = get_record('attforblock', 'id', $rec['aid']); + echo ''; echo '
'.$nextcourse->fullname.'
'.$nextcourse->fullname.' - '.$nextattendance->name . ''; - $complete = get_attendance($user->id, $nextcourse); + $complete = get_attendance($user->id, $nextcourse, $nextattendance); if($complete) { - print_attendance_table($user, $nextcourse, $attforblock); + print_attendance_table($user, $nextcourse, $nextattendance); } else { echo get_string('attendancenotstarted','attforblock'); } @@ -304,9 +307,9 @@ function print_user_attendaces($user, $cm, $attforblock, $course = 0, $printing $enddate = $ret['enddate']; if ($startdate && $enddate) { - $where = "ats.courseid={$course->id} AND al.studentid = {$user->id} AND ats.sessdate >= $startdate AND ats.sessdate < $enddate"; + $where = "ats.courseid={$course->id} AND ats.attendanceid={$attforblock->id} AND al.studentid = {$user->id} AND ats.sessdate >= $startdate AND ats.sessdate < $enddate"; } else { - $where = "ats.courseid={$course->id} AND al.studentid = {$user->id}"; + $where = "ats.courseid={$course->id} AND ats.attendanceid={$attforblock->id} AND al.studentid = {$user->id}"; } $stqry = "SELECT ats.id,ats.sessdate,ats.description,al.statusid,al.remarks @@ -317,7 +320,7 @@ function print_user_attendaces($user, $cm, $attforblock, $course = 0, $printing $stqry .= " ORDER BY ats.sessdate asc"; if ($sessions = get_records_sql($stqry)) { - $statuses = get_statuses($course->id); + $statuses = get_statuses($attforblock->id); $i = 0; $table->head = array('#', get_string('date'), get_string('time'), get_string('description','attforblock'), get_string('status','attforblock'), get_string('remarks','attforblock')); diff --git a/manage.php b/manage.php index d61952a..e9acf72 100644 --- a/manage.php +++ b/manage.php @@ -10,7 +10,7 @@ $from = optional_param('from', PARAM_ACTION); $view = optional_param('view', NULL, PARAM_ALPHA); // which page to show $current = optional_param('current', 0, PARAM_INT); - + $showendtime = optional_param('showendtime', get_user_preferences("attforblock_showendtime",0), PARAM_INT); if (! $cm = get_record('course_modules', 'id', $id)) { error('Course Module ID was incorrect'); } @@ -43,14 +43,16 @@ !has_capability('mod/attforblock:changeattendances', $context)) { redirect("view.php?id=$cm->id"); } - + + set_user_preference("attforblock_showendtime",$showendtime); + //if teacher is coming from block, then check for a session exists for today if($from === 'block') { $today = time(); // because we compare with database, we don't need to use usertime() $sql = "SELECT id, groupid, lasttaken FROM {$CFG->prefix}attendance_sessions WHERE $today BETWEEN sessdate AND (sessdate + duration) - AND courseid = $course->id"; + AND courseid = $course->id AND attendanceid = $attforblock->id"; if($atts = get_records_sql($sql)) { $size = count($atts); if ($size == 1) { @@ -76,23 +78,23 @@ 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 + if(!count_records_select('attendance_sessions', "courseid = $course->id AND attendanceid = $attforblock->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"); + $hiddensess = count_records_select('attendance_sessions', "courseid = $course->id AND attendanceid = $attforblock->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); + print_sessions_list($course, $attforblock); } // require_once('lib.php'); // $t = attforblock_get_user_grades($attforblock); //////////////////////////////////////////// print_footer($course); -function print_sessions_list($course) { +function print_sessions_list($course, $attforblock) { global $CFG, $context, $cm, $current, $view, $id; $strhours = get_string('hours'); @@ -109,9 +111,9 @@ function print_sessions_list($course) { $currentgroup = $ret['currentgroup']; if ($startdate && $enddate) { - $where = "courseid={$course->id} AND sessdate >= $course->startdate AND sessdate >= $startdate AND sessdate < $enddate"; + $where = "courseid={$course->id} AND attendanceid = $attforblock->id AND sessdate >= $course->startdate AND sessdate >= $startdate AND sessdate < $enddate"; } else { - $where = "courseid={$course->id} AND sessdate >= $course->startdate"; + $where = "courseid={$course->id} AND attendanceid = $attforblock->id AND sessdate >= $course->startdate"; } if ($currentgroup > -1) { @@ -122,7 +124,7 @@ function print_sessions_list($course) { $i = 0; $table->width = '100%'; //$table->tablealign = 'center'; - $table->head = array('#', get_string('sessiontypeshort', 'attforblock'), get_string('date'), get_string('time'), get_string('duration', 'attforblock'), get_string('description','attforblock'), get_string('actions'), get_string('select')); + $table->head = array('#', get_string('sessiontypeshort', 'attforblock'), get_string('date'), get_string('from'), ($showendtime=='0') ? get_string('duration', 'attforblock') : get_string('to'), get_string('description','attforblock'), get_string('actions'), get_string('select')); $table->align = array('', '', '', 'right', 'left', 'center', 'center'); $table->size = array('1px', '', '1px', '1px', '1px', '*', '1px', '1px'); @@ -170,17 +172,18 @@ function print_sessions_list($course) { $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][] = ($showendtime=='0') ? ($hours ? "{$hours} {$strhours} {$mins} {$strmins}" : "{$mins} {$strmins}") : userdate($sessdata->sessdate+$sessdata->duration, get_string('strftimehm', 'attforblock'));; $table->data[$sessdata->id][] = $desc; $table->data[$sessdata->id][] = $actions; $table->data[$sessdata->id][] = ''; unset($desc, $actions); } } + echo '
'; echo "
id}\">"; //&sessionid={$sessdata->id} print_table($table); - $hiddensess = count_records_select('attendance_sessions', "courseid = $course->id AND sessdate < $course->startdate"); + $hiddensess = count_records_select('attendance_sessions', "courseid = $course->id AND attendanceid = $attforblock->id AND sessdate < $course->startdate"); echo ''; diff --git a/mod_form.php b/mod_form.php index 866f41d..47549eb 100644 --- a/mod_form.php +++ b/mod_form.php @@ -20,11 +20,7 @@ class mod_attforblock_mod_form extends moodleform_mod { $mform->addElement('modgrade', 'grade', get_string('grade')); $mform->setDefault('grade', 100); - - $mform->addElement('select', 'displaymode', get_string('displaymode','attforblock'), array (get_string('sortedlist','attforblock'), get_string('sortedgrid','attforblock'))); - $mform->addElement('select', 'gridcolumns', get_string('gridcolumns','attforblock'), array ('1','2','3','4','5','6','7','8','9','10')); - $this->standard_coursemodule_elements(true); //------------------------------------------------------------------------------- diff --git a/report.php b/report.php index 9090e03..5141999 100644 --- a/report.php +++ b/report.php @@ -60,7 +60,7 @@ $sort = $sort == 'firstname' ? 'firstname' : 'lastname'; - if(!count_records('attendance_sessions', 'courseid', $course->id)) { // no session exists for this course + if(!count_records_select('attendance_sessions', "courseid = {$course->id} AND attendanceid = {$attforblock->id}")) { // no session exists for this course redirect("sessions.php?id=$cm->id&action=add"); } else { if ($current == 0) @@ -74,9 +74,9 @@ $currentgroup = $ret['currentgroup']; if ($startdate && $enddate) { - $where = "courseid={$course->id} AND sessdate >= $course->startdate AND sessdate >= $startdate AND sessdate < $enddate"; + $where = "courseid={$course->id} AND attendanceid = {$attforblock->id} AND sessdate >= $course->startdate AND sessdate >= $startdate AND sessdate < $enddate"; } else { - $where = "courseid={$course->id} AND sessdate >= $course->startdate"; + $where = "courseid={$course->id} AND attendanceid = {$attforblock->id} AND sessdate >= $course->startdate"; } if ($currentgroup) { @@ -86,8 +86,8 @@ $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', '', '', false); } - $statuses = get_statuses($course->id); - $allstatuses = get_statuses($course->id, false); + $statuses = get_statuses($attforblock->id); + $allstatuses = get_statuses($attforblock->id, false); if ($students and @@ -176,11 +176,11 @@ } } foreach($statuses as $st) { - $table->data[$student->id][] = get_attendance($student->id, $course, $st->id); + $table->data[$student->id][] = get_attendance($student->id, $course, $attforblock, $st->id); } if ($attforblock->grade) { - $table->data[$student->id][] = get_grade($student->id, $course).' / '.get_maxgrade($student->id, $course); - $table->data[$student->id][] = get_percent($student->id, $course).'%'; + $table->data[$student->id][] = get_grade($student->id, $course, $attforblock).' / '.get_maxgrade($student->id, $course, $attforblock); + $table->data[$student->id][] = get_percent($student->id, $course, $attforblock).'%'; } } print_table($table); diff --git a/restorelib.php b/restorelib.php index 26320ad..00ae151 100644 --- a/restorelib.php +++ b/restorelib.php @@ -13,9 +13,9 @@ //Now get completed xmlized object $info = $data->info; - if (count_records('attforblock', 'course', $restore->course_id)) { + /*if (count_records('attforblock', 'course', $restore->course_id)) { return false; - } + }*/ //Now, build the attforblock record structure $attforblock->course = $restore->course_id; @@ -67,6 +67,7 @@ //Now, build the attforblock_SESSIONS record structure $stat->courseid = $restore->course_id; + $stat->attendanceid = $new_attforblock_id; $stat->groupid = backup_todb($stat_info['#']['GROUPID']['0']['#']); $group = restore_group_getid($restore, $stat->groupid); if ($group) { @@ -117,6 +118,7 @@ //Now, build the attforblock_STATUS record structure $stat->courseid = $restore->course_id; + $stat->attendanceid = $new_attforblock_id; $stat->acronym = backup_todb($stat_info['#']['ACRONYM']['0']['#']); $stat->description = backup_todb($stat_info['#']['DESCRIPTION']['0']['#']); $stat->grade = backup_todb($stat_info['#']['GRADE']['0']['#']); @@ -139,6 +141,7 @@ //Now, build the attforblock_STATUS record structure $stat->courseid = $restore->course_id; + $stat->attendanceid = $new_attforblock_id; $stat->acronym = backup_todb($stat_info['#']['ACRONYM']['0']['#']); $stat->description = backup_todb($stat_info['#']['DESCRIPTION']['0']['#']); $stat->grade = backup_todb($stat_info['#']['GRADE']['0']['#']); @@ -159,6 +162,7 @@ foreach($stats as $stat) { // $stat = $stats[$i]; $stat->courseid = $restore->course_id; + $stat->attendanceid = $new_attforblock_id; $newid = insert_record('attendance_statuses', $stat); $oldidarray[$old_attforblock_id]['attendance_statuses'][$oldstats[$i++]] = $newid; // $i++; @@ -182,9 +186,9 @@ @$logs = $info['MOD']['#']['ATTFORBLOCK_LOG']['0']['#']['ROWS']; } - $stats = get_records_menu('attendance_statuses', 'courseid', $restore->course_id); + $stats = get_records_menu('attendance_statuses', 'attendanceid', $new_attforblock_id); $statslist = implode(',', array_keys($stats)); - $sessions = get_records('attendance_sessions', 'courseid', $restore->course_id); + $sessions = get_records('attendance_sessions', 'attendanceid', $new_attforblock_id); //Iterate over logs for($i = 0; $i < sizeof($logs); $i++) { diff --git a/sessions.php b/sessions.php index 79d11fb..713ae93 100644 --- a/sessions.php +++ b/sessions.php @@ -60,6 +60,7 @@ if (isset($fromform->addmultiply)) { $startdate = $fromform->sessiondate;// + $fromform->stime['hour']*3600 + $fromform->stime['minute']*60; + $starttime = $startdate - usergetmidnight($startdate); $enddate = $fromform->sessionenddate + ONE_DAY; // because enddate in 0:0am //get number of days @@ -91,7 +92,8 @@ // continue; // } $rec->courseid = $course->id; - $rec->sessdate = $sdate; + $rec->attendanceid = $attforblock->id; + $rec->sessdate = usergetmidnight($sdate) + $starttime; $rec->duration = $duration; $rec->description = $fromform->sdescription; $rec->timemodified = $now; @@ -117,6 +119,7 @@ } else { // insert one session $rec->courseid = $course->id; + $rec->attendanceid = $attforblock->id; $rec->sessdate = $fromform->sessiondate; $rec->duration = $duration; $rec->description = $fromform->sdescription; diff --git a/styles.php b/styles.php index a9ed2aa..57e109b 100644 --- a/styles.php +++ b/styles.php @@ -40,7 +40,7 @@ Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 2.8.1 */ -body{font:13px/1.231 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}select,input,button,textarea,button{font:99% arial,helvetica,clean,sans-serif;}table{font-size:inherit;font:100%;}pre,code,kbd,samp,tt{font-family:monospace;*font-size:108%;line-height:100%;} +.yuidialog body{font:13px/1.231 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;} .yuidialog select,.yuidialog input,.yuidialog button,.yuidialog textarea,.yuidialog button{font:99% arial,helvetica,clean,sans-serif;} .yuidialog table{font-size:inherit;font:100%;} .yuidialog pre,.yuidialog code,.yuidialog kbd,.yuidialog samp,.yuidialog tt{font-family:monospace;*font-size:108%;line-height:100%;} .yui-button{display:-moz-inline-box;display:inline-block;vertical-align:text-bottom;}.yui-button .first-child{display:block;*display:inline-block;}.yui-button button,.yui-button a{display:block;*display:inline-block;border:none;margin:0;}.yui-button button{background-color:transparent;*overflow:visible;cursor:pointer;}.yui-button a{text-decoration:none;}.yui-skin-sam .yui-button{border-width:1px 0;border-style:solid;border-color:#808080;background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) repeat-x 0 0;margin:auto .25em;}.yui-skin-sam .yui-button .first-child{border-width:0 1px;border-style:solid;border-color:#808080;margin:0 -1px;_margin:0;}.yui-skin-sam .yui-button button,.yui-skin-sam .yui-button a,.yui-skin-sam .yui-button a:visited{padding:0 10px;font-size:93%;line-height:2;*line-height:1.7;min-height:2em;*min-height:auto;color:#000;}.yui-skin-sam .yui-button a{*line-height:1.875;*padding-bottom:1px;}.yui-skin-sam .yui-split-button button,.yui-skin-sam .yui-menu-button button{padding-right:20px;background-position:right center;background-repeat:no-repeat;}.yui-skin-sam .yui-menu-button button{background-image:url(/assets/skins/sam/menu-button-arrow.png);}.yui-skin-sam .yui-split-button button{background-image:url(/assets/skins/sam/split-button-arrow.png);}.yui-skin-sam .yui-button-focus{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-focus .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-split-button-focus button{background-image:url(/assets/skins/sam/split-button-arrow-focus.png);}.yui-skin-sam .yui-button-hover{border-color:#7D98B8;background-position:0 -1300px;}.yui-skin-sam .yui-button-hover .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-split-button-hover button{background-image:url(/assets/skins/sam/split-button-arrow-hover.png);}.yui-skin-sam .yui-button-active{border-color:#7D98B8;background-position:0 -1700px;}.yui-skin-sam .yui-button-active .first-child{border-color:#7D98B8;}.yui-skin-sam .yui-split-button-activeoption{border-color:#808080;background-position:0 0;}.yui-skin-sam .yui-split-button-activeoption .first-child{border-color:#808080;}.yui-skin-sam .yui-split-button-activeoption button{background-image:url(/assets/skins/sam/split-button-arrow-active.png);}.yui-skin-sam .yui-radio-button-checked,.yui-skin-sam .yui-checkbox-button-checked{border-color:#304369;background-position:0 -1400px;}.yui-skin-sam .yui-radio-button-checked .first-child,.yui-skin-sam .yui-checkbox-button-checked .first-child{border-color:#304369;}.yui-skin-sam .yui-radio-button-checked button,.yui-skin-sam .yui-checkbox-button-checked button{color:#fff;}.yui-skin-sam .yui-button-disabled{border-color:#ccc;background-position:0 -1500px;}.yui-skin-sam .yui-button-disabled .first-child{border-color:#ccc;}.yui-skin-sam .yui-button-disabled button,.yui-skin-sam .yui-button-disabled a,.yui-skin-sam .yui-button-disabled a:visited{color:#A6A6A6;cursor:default;}.yui-skin-sam .yui-menu-button-disabled button{background-image:url(/assets/skins/sam/menu-button-arrow-disabled.png);}.yui-skin-sam .yui-split-button-disabled button{background-image:url(/assets/skins/sam/split-button-arrow-disabled.png);} .yui-overlay,.yui-panel-container{visibility:hidden;position:absolute;z-index:2;}.yui-panel{position:relative;}.yui-panel-container form{margin:0;}.mask{z-index:1;display:none;position:absolute;top:0;left:0;right:0;bottom:0;}.mask.block-scrollbars{overflow:auto;}.masked select,.drag select,.hide-select select{_visibility:hidden;}.yui-panel-container select{_visibility:inherit;}.hide-scrollbars,.hide-scrollbars *{overflow:hidden;}.hide-scrollbars select{display:none;}.show-scrollbars{overflow:auto;}.yui-panel-container.show-scrollbars,.yui-tt.show-scrollbars{overflow:visible;}.yui-panel-container.show-scrollbars .underlay,.yui-tt.show-scrollbars .yui-tt-shadow{overflow:auto;}.yui-panel-container.shadow .underlay.yui-force-redraw{padding-bottom:1px;}.yui-effect-fade .underlay,.yui-effect-fade .yui-tt-shadow{display:none;}.yui-tt-shadow{position:absolute;}.yui-override-padding{padding:0!important;}.yui-panel-container .container-close{overflow:hidden;text-indent:-10000em;text-decoration:none;}.yui-overlay.yui-force-redraw,.yui-panel-container.yui-force-redraw{margin-bottom:1px;}.yui-skin-sam .mask{background-color:#000;opacity:.25;filter:alpha(opacity=25);}.yui-skin-sam .yui-panel-container{padding:0 1px;*padding:2px;}.yui-skin-sam .yui-panel{position:relative;left:0;top:0;border-style:solid;border-width:1px 0;border-color:#808080;z-index:1;*border-width:1px;*zoom:1;_zoom:normal;}.yui-skin-sam .yui-panel .hd,.yui-skin-sam .yui-panel .bd,.yui-skin-sam .yui-panel .ft{border-style:solid;border-width:0 1px;border-color:#808080;margin:0 -1px;*margin:0;*border:0;}.yui-skin-sam .yui-panel .hd{border-bottom:solid 1px #ccc;}.yui-skin-sam .yui-panel .bd,.yui-skin-sam .yui-panel .ft{background-color:#F2F2F2;}.yui-skin-sam .yui-panel .hd{padding:0 10px;font-size:93%;line-height:2;*line-height:1.9;font-weight:bold;color:#000;background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) repeat-x 0 -200px;}.yui-skin-sam .yui-panel .bd{padding:10px;}.yui-skin-sam .yui-panel .ft{border-top:solid 1px #808080;padding:5px 10px;font-size:77%;}.yui-skin-sam .container-close{position:absolute;top:5px;right:6px;width:25px;height:15px;background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) no-repeat 0 -300px;cursor:pointer;}.yui-skin-sam .yui-panel-container .underlay{right:-1px;left:-1px;}.yui-skin-sam .yui-panel-container.matte{padding:9px 10px;background-color:#fff;}.yui-skin-sam .yui-panel-container.shadow{_padding:2px 4px 0 2px;}.yui-skin-sam .yui-panel-container.shadow .underlay{position:absolute;top:2px;left:-3px;right:-3px;bottom:-3px;*top:4px;*left:-1px;*right:-1px;*bottom:-1px;_top:0;_left:0;_right:0;_bottom:0;_margin-top:3px;_margin-left:-1px;background-color:#000;opacity:.12;filter:alpha(opacity=12);}.yui-skin-sam .yui-dialog .ft{border-top:none;padding:0 10px 10px 10px;font-size:100%;}.yui-skin-sam .yui-dialog .ft .button-group{display:block;text-align:right;}.yui-skin-sam .yui-dialog .ft button.default{font-weight:bold;}.yui-skin-sam .yui-dialog .ft span.default{border-color:#304369;background-position:0 -1400px;}.yui-skin-sam .yui-dialog .ft span.default .first-child{border-color:#304369;}.yui-skin-sam .yui-dialog .ft span.default button{color:#fff;}.yui-skin-sam .yui-dialog .ft span.yui-button-disabled{background-position:0 -1500px;border-color:#ccc;}.yui-skin-sam .yui-dialog .ft span.yui-button-disabled .first-child{border-color:#ccc;}.yui-skin-sam .yui-dialog .ft span.yui-button-disabled button{color:#a6a6a6;}.yui-skin-sam .yui-simple-dialog .bd .yui-icon{background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) no-repeat 0 0;width:16px;height:16px;margin-right:10px;float:left;}.yui-skin-sam .yui-simple-dialog .bd span.blckicon{background-position:0 -1100px;}.yui-skin-sam .yui-simple-dialog .bd span.alrticon{background-position:0 -1050px;}.yui-skin-sam .yui-simple-dialog .bd span.hlpicon{background-position:0 -1150px;}.yui-skin-sam .yui-simple-dialog .bd span.infoicon{background-position:0 -1200px;}.yui-skin-sam .yui-simple-dialog .bd span.warnicon{background-position:0 -1900px;}.yui-skin-sam .yui-simple-dialog .bd span.tipicon{background-position:0 -1250px;}.yui-skin-sam .yui-tt .bd{position:relative;top:0;left:0;z-index:1;color:#000;padding:2px 5px;border-color:#D4C237 #A6982B #A6982B #A6982B;border-width:1px;border-style:solid;background-color:#FFEE69;}.yui-skin-sam .yui-tt.show-scrollbars .bd{overflow:auto;}.yui-skin-sam .yui-tt-shadow{top:2px;right:-3px;left:-3px;bottom:-3px;background-color:#000;}.yui-skin-sam .yui-tt-shadow-visible{opacity:.12;filter:alpha(opacity=12);} .yui-calcontainer{position:relative;float:left;_overflow:hidden;}.yui-calcontainer iframe{position:absolute;border:none;margin:0;padding:0;z-index:0;width:100%;height:100%;left:0;top:0;}.yui-calcontainer iframe.fixedsize{width:50em;height:50em;top:-1px;left:-1px;}.yui-calcontainer.multi .groupcal{z-index:1;float:left;position:relative;}.yui-calcontainer .title{position:relative;z-index:1;}.yui-calcontainer .close-icon{position:absolute;z-index:1;text-indent:-10000em;overflow:hidden;}.yui-calendar{position:relative;}.yui-calendar .calnavleft{position:absolute;z-index:1;text-indent:-10000em;overflow:hidden;}.yui-calendar .calnavright{position:absolute;z-index:1;text-indent:-10000em;overflow:hidden;}.yui-calendar .calheader{position:relative;width:100%;text-align:center;}.yui-calcontainer .yui-cal-nav-mask{position:absolute;z-index:2;margin:0;padding:0;width:100%;height:100%;_width:0;_height:0;left:0;top:0;display:none;}.yui-calcontainer .yui-cal-nav{position:absolute;z-index:3;top:0;display:none;}.yui-calcontainer .yui-cal-nav .yui-cal-nav-btn{display:-moz-inline-box;display:inline-block;}.yui-calcontainer .yui-cal-nav .yui-cal-nav-btn button{display:block;*display:inline-block;*overflow:visible;border:none;background-color:transparent;cursor:pointer;}.yui-calendar .calbody a:hover{background:inherit;}p#clear{clear:left;padding-top:10px;}.yui-skin-sam .yui-calcontainer{background-color:#f2f2f2;border:1px solid #808080;padding:10px;}.yui-skin-sam .yui-calcontainer.multi{padding:0 5px 0 5px;}.yui-skin-sam .yui-calcontainer.multi .groupcal{background-color:transparent;border:none;padding:10px 5px 10px 5px;margin:0;}.yui-skin-sam .yui-calcontainer .title{background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) repeat-x 0 0;border-bottom:1px solid #ccc;font:100% sans-serif;color:#000;font-weight:bold;height:auto;padding:.4em;margin:0 -10px 10px -10px;top:0;left:0;text-align:left;}.yui-skin-sam .yui-calcontainer.multi .title{margin:0 -5px 0 -5px;}.yui-skin-sam .yui-calcontainer.withtitle{padding-top:0;}.yui-skin-sam .yui-calcontainer .calclose{background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) no-repeat 0 -300px;width:25px;height:15px;top:.4em;right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar{border-spacing:0;border-collapse:collapse;font:100% sans-serif;text-align:center;margin:0;}.yui-skin-sam .yui-calendar .calhead{background:transparent;border:none;vertical-align:middle;padding:0;}.yui-skin-sam .yui-calendar .calheader{background:transparent;font-weight:bold;padding:0 0 .6em 0;text-align:center;}.yui-skin-sam .yui-calendar .calheader img{border:none;}.yui-skin-sam .yui-calendar .calnavleft{background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) no-repeat 0 -450px;width:25px;height:15px;top:0;bottom:0;left:-10px;margin-left:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calnavright{background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) no-repeat 0 -500px;width:25px;height:15px;top:0;bottom:0;right:-10px;margin-right:.4em;cursor:pointer;}.yui-skin-sam .yui-calendar .calweekdayrow{height:2em;}.yui-skin-sam .yui-calendar .calweekdayrow th{padding:0;border:none;}.yui-skin-sam .yui-calendar .calweekdaycell{color:#000;font-weight:bold;text-align:center;width:2em;}.yui-skin-sam .yui-calendar .calfoot{background-color:#f2f2f2;}.yui-skin-sam .yui-calendar .calrowhead,.yui-skin-sam .yui-calendar .calrowfoot{color:#a6a6a6;font-size:85%;font-style:normal;font-weight:normal;border:none;}.yui-skin-sam .yui-calendar .calrowhead{text-align:right;padding:0 2px 0 0;}.yui-skin-sam .yui-calendar .calrowfoot{text-align:left;padding:0 0 0 2px;}.yui-skin-sam .yui-calendar td.calcell{border:1px solid #ccc;background:#fff;padding:1px;height:1.6em;line-height:1.6em;text-align:center;white-space:nowrap;}.yui-skin-sam .yui-calendar td.calcell a{color:#06c;display:block;height:100%;text-decoration:none;}.yui-skin-sam .yui-calendar td.calcell.today{background-color:#000;}.yui-skin-sam .yui-calendar td.calcell.today a{background-color:#fff;}.yui-skin-sam .yui-calendar td.calcell.oom{background-color:#ccc;color:#a6a6a6;cursor:default;}.yui-skin-sam .yui-calendar td.calcell.selected{background-color:#fff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.selected a{background-color:#b3d4ff;color:#000;}.yui-skin-sam .yui-calendar td.calcell.calcellhover{background-color:#426fd9;color:#fff;cursor:pointer;}.yui-skin-sam .yui-calendar td.calcell.calcellhover a{background-color:#426fd9;color:#fff;}.yui-skin-sam .yui-calendar td.calcell.previous{color:#e0e0e0;}.yui-skin-sam .yui-calendar td.calcell.restricted{text-decoration:line-through;}.yui-skin-sam .yui-calendar td.calcell.highlight1{background-color:#cf9;}.yui-skin-sam .yui-calendar td.calcell.highlight2{background-color:#9cf;}.yui-skin-sam .yui-calendar td.calcell.highlight3{background-color:#fcc;}.yui-skin-sam .yui-calendar td.calcell.highlight4{background-color:#cf9;}.yui-skin-sam .yui-calendar a.calnav{border:1px solid #f2f2f2;padding:0 4px;text-decoration:none;color:#000;zoom:1;}.yui-skin-sam .yui-calendar a.calnav:hover{background:url(http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/sprite.png) repeat-x 0 0;border-color:#A0A0A0;cursor:pointer;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-mask{background-color:#000;opacity:.25;filter:alpha(opacity=25);}.yui-skin-sam .yui-calcontainer .yui-cal-nav{font-family:arial,helvetica,clean,sans-serif;font-size:93%;border:1px solid #808080;left:50%;margin-left:-7em;width:14em;padding:0;top:2.5em;background-color:#f2f2f2;}.yui-skin-sam .yui-calcontainer.withtitle .yui-cal-nav{top:4.5em;}.yui-skin-sam .yui-calcontainer.multi .yui-cal-nav{width:16em;margin-left:-8em;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-y,.yui-skin-sam .yui-calcontainer .yui-cal-nav-m,.yui-skin-sam .yui-calcontainer .yui-cal-nav-b{padding:5px 10px 5px 10px;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-b{text-align:center;}.yui-skin-sam .yui-calcontainer .yui-cal-nav-e{margin-top:5px;padding:5px;background-color:#EDF5FF;border-top:1px solid black;display:none;}.yui-skin-sam .yui-calcontainer .yui-cal-nav label{display:block;font-weight:bold;} diff --git a/version.php b/version.php index bbf2968..962d302 100644 --- a/version.php +++ b/version.php @@ -5,7 +5,7 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2010122900; // The current module version (Date: YYYYMMDDXX) +$module->version = 2010123003; // The current module version (Date: YYYYMMDDXX) $module->release = '2.2.1'; $module->cron = 0; // Period for cron to check this module (secs) ?> From 5f3010df382c74673fbffa61d167bdc752e30e7d Mon Sep 17 00:00:00 2001 From: Artem Andreev Date: Thu, 13 Jan 2011 16:40:30 +0300 Subject: [PATCH 03/13] Fixed PHP notice with undefined variable. --- locallib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/locallib.php b/locallib.php index 1f42c6c..f80a08c 100644 --- a/locallib.php +++ b/locallib.php @@ -390,6 +390,7 @@ function print_filter_controls($url, $id, $studentid=0, $sort=NULL, $printselect $link = $url . "?id=$id" . ($sort ? "&sort=$sort" : "") . ($studentid ? "&student=$studentid" : ""); $currentgroup = -1; + $sessiontypeselector = ''; if ($printselector === GROUP_SELECTOR) { $groupmode = groups_get_activity_groupmode($cm); $currentgroup = groups_get_activity_group($cm, true); From d7c45d3ed813b21ab1d59c045ddd8fec0769a42c Mon Sep 17 00:00:00 2001 From: Luis Ramon Lopez Date: Sat, 15 Jan 2011 18:32:36 +0100 Subject: [PATCH 04/13] Solved installation errors. Fixed some database queries. --- CHANGES | 11 +++++++++++ attendances.php | 20 ++++++++++---------- db/install.xml | 10 ++++++---- locallib.php | 3 +++ manage.php | 2 +- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/CHANGES b/CHANGES index 44ca102..18b2e0f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,14 @@ +2011-01-15 lrlopez + + * db/install.xml: + + Bugs fixed. + + * attendances.php: locallib.php: manage.php: + + Fixed some minor bugs and code readibility issues. Now, in grid view + mode, statuses are always next to their radio buttons. + 2010-12-30 - 2011-01-04 lrlopez * lang/: es_utf8/attforblock.php: diff --git a/attendances.php b/attendances.php index 9f04b38..ee62c22 100644 --- a/attendances.php +++ b/attendances.php @@ -58,7 +58,7 @@ $i++; } } - $attforblockrecord = get_record('attforblock', 'course', $course->id); + $attforblockrecord = get_record('attforblock', 'id', $cm->instance);//'course', $course->id); foreach($students as $student) { if ($log = get_record('attendance_log', 'sessionid', $sessionid, 'studentid', $student->studentid)) { @@ -104,17 +104,17 @@ $currentgroup = groups_get_activity_group($cm, true); // get the viewmode & grid columns (default is set in module settings) - $attforblockrecord = get_record('attforblock', 'course', $course->id); - $view = optional_param('view', get_user_preferences("attforblock_viewmode",0), PARAM_INT); + $attforblockrecord = get_record('attforblock', 'id', $cm->instance);//'course', $course->id);'course', $course->id); + $view = optional_param('view', get_user_preferences("attforblock_viewmode", SORTEDLISTVIEW), PARAM_INT); $gridcols = optional_param('gridcols', get_user_preferences("attforblock_gridcolumns",5), PARAM_INT); echo '
'; - $options = array (0 => get_string('sortedlist','attforblock'), 1 => get_string('sortedgrid','attforblock')); + $options = array (SORTEDLISTVIEW => get_string('sortedlist','attforblock'), SORTEDGRIDVIEW => get_string('sortedgrid','attforblock')); $data = "attendances.php?id=$id&sessionid=$sessionid&grouptype=$grouptype&gridcols=$gridcols"; if ($group!=-1) { $data = $data . "&group=$group"; } popup_form("$data&view=", $options, 'viewmenu', $view, ''); - if ($view==1) { + if ($view == SORTEDGRIDVIEW) { set_user_preference("attforblock_viewmode", $view); set_user_preference("attforblock_gridcolumns", $gridcols); $options = array (1 => '1 '.get_string('column','attforblock'),'2 '.get_string('columns','attforblock'),'3 '.get_string('columns','attforblock'), @@ -154,10 +154,10 @@ $i = 3; foreach($statuses as $st) { switch($view) { - case 0: + case SORTEDLISTVIEW: $tabhead[] = "$st->acronym"; break; - case 1: + case SORTEDGRIDVIEW: $tabhead[] = "acronym . "', null);\">$st->acronym"; break; } @@ -179,7 +179,7 @@ unset($table); switch($view) { - case 0: // sorted list + case SORTEDLISTVIEW: // sorted list $table->width = '0%'; $table->head[] = '#'; $table->align[] = 'center'; @@ -212,7 +212,7 @@ $table->data[$student->id][] = ''; } break; - case 1: // sorted grid + case SORTEDGRIDVIEW: // sorted grid $table->width = '0%'; $data = ''; @@ -237,7 +237,7 @@ $data = "" . print_user_picture($student, $course->id, $student->picture, true, true, '', fullname($student)) . "
" . fullname($student) . "
";//, $returnstring=false, $link=true, $target=''); foreach($statuses as $st) { - $data = $data . 'id == $att->statusid ? 'checked' : '').'>' . $st->acronym; + $data = $data . 'id == $att->statusid ? 'checked' : '').'>' . $st->acronym . " "; } $table->data[($i-1) / ($gridcols)][] = $data; } diff --git a/db/install.xml b/db/install.xml index e7f83e0..c1d3578 100644 --- a/db/install.xml +++ b/db/install.xml @@ -24,7 +24,7 @@ - + @@ -38,7 +38,7 @@ - +
'; echo '
'.helpbutton('hiddensessions', '', 'attforblock', true, true, '', true); echo get_string('hiddensessions', 'attforblock').': '.$hiddensess.'
@@ -64,7 +64,8 @@
- + + @@ -75,7 +76,8 @@ - + + diff --git a/locallib.php b/locallib.php index 9114c09..1c0495a 100644 --- a/locallib.php +++ b/locallib.php @@ -12,6 +12,9 @@ define('WITHOUT_SELECTOR', 0); define('GROUP_SELECTOR', 1); define('SESSION_TYPE_SELECTOR', 2); +define('SORTEDLISTVIEW', 0); +define('SORTEDGRIDVIEW', 1); + function show_tabs($cm, $context, $currenttab='sessions') { $toprow = array(); diff --git a/manage.php b/manage.php index e9acf72..e0dc5b2 100644 --- a/manage.php +++ b/manage.php @@ -95,7 +95,7 @@ function print_sessions_list($course, $attforblock) { - global $CFG, $context, $cm, $current, $view, $id; + global $CFG, $context, $cm, $current, $view, $id, $showendtime; $strhours = get_string('hours'); $strmins = get_string('min'); From faacb6c7fb18f15932fa1e53fc77ca9679a82eca Mon Sep 17 00:00:00 2001 From: Luis Ramon Lopez Date: Sun, 16 Jan 2011 20:18:08 +0100 Subject: [PATCH 05/13] Added "Start of period" into export tab --- CHANGES | 7 +++++++ export.php | 12 +++++++----- export_form.php | 7 ++++++- lang/en_utf8/attforblock.php | 2 ++ lang/es_utf8/attforblock.php | 4 +++- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index 18b2e0f..022cc9d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +2011-01-16 lrlopez + + * export.php: export_form.php: + * lang/: en_utf8/attforblock.php: es_utf8/attforblock.php: + Added "Start of period" into export tab and two new strings for + the new fields on the form. + 2011-01-15 lrlopez * db/install.xml: diff --git a/export.php b/export.php index f152d7f..7e7a7a5 100644 --- a/export.php +++ b/export.php @@ -56,11 +56,13 @@ $data->tabhead[] = get_string('lastname'); $data->tabhead[] = get_string('firstname'); - $select = "courseid = {$course->id} AND attendanceid = {$attforblock->id} AND sessdate >= {$course->startdate}"; - if (isset($fromform->includenottaken)) { - $select .= " AND sessdate <= {$fromform->sessionenddate}"; - } else { - $select .= " AND lasttaken != 0"; + $select = "courseid = {$course->id} AND attendanceid = {$attforblock->id} "; + if (!isset($fromform->includeallsessions)) { + $finalenddate = $fromform->sessionenddate + 86400; // take into account the whole day + $select .= "AND sessdate >= {$fromform->sessionstartdate} AND sessdate < {$finalenddate} "; + } + if (!isset($fromform->includenottaken)) { + $select .= " AND lasttaken != 0"; } if ($sessions = get_records_select('attendance_sessions', $select, 'sessdate ASC')) { diff --git a/export_form.php b/export_form.php index 610a7cc..c9f5869 100644 --- a/export_form.php +++ b/export_form.php @@ -59,9 +59,14 @@ class mod_attforblock_export_form extends moodleform { // $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', 'includeallsessions', get_string('includeall','attforblock'), get_string('yes')); + $mform->setDefault('includeallsessions', true); $mform->addElement('checkbox', 'includenottaken', get_string('includenottaken','attforblock'), get_string('yes')); + $mform->addElement('date_selector', 'sessionstartdate', get_string('startofperiod','attforblock')); + $mform->setDefault('sessionstartdate', $course->startdate); + $mform->disabledIf('sessionstartdate', 'includeallsessions', 'checked'); $mform->addElement('date_selector', 'sessionenddate', get_string('endofperiod','attforblock')); - $mform->disabledIf('sessionenddate', 'includenottaken', 'notchecked'); + $mform->disabledIf('sessionenddate', 'includeallsessions', 'checked'); $mform->addElement('select', 'format', get_string('format'), array('excel' => get_string('downloadexcel','attforblock'), diff --git a/lang/en_utf8/attforblock.php b/lang/en_utf8/attforblock.php index ffcca82..2b88002 100644 --- a/lang/en_utf8/attforblock.php +++ b/lang/en_utf8/attforblock.php @@ -73,6 +73,7 @@ $string['gridcolumns'] = 'Grid columns'; $string['groupsession'] = 'Group'; $string['hiddensessions'] = 'Hidden sessions'; $string['identifyby'] = 'Identify student by'; +$string['includeall'] = 'Select all sessions'; $string['includenottaken'] = 'Include not taken sessions'; $string['indetail'] = 'In detail...'; $string['moduledescription'] = 'You can add only one module Attendance per course.
Removal of this module will not entail removal of the data!'; @@ -121,6 +122,7 @@ $string['showdefaults'] = 'Show defaults'; $string['showduration'] = 'Show duration'; $string['sortedgrid'] = 'Sorted grid'; $string['sortedlist'] = 'Sorted list'; +$string['startofperiod'] = 'Start of period'; $string['status'] = 'Status'; $string['statusdeleted'] = 'Status deleted'; $string['strftimedm'] = '%%d.%%m'; diff --git a/lang/es_utf8/attforblock.php b/lang/es_utf8/attforblock.php index 8b27014..fa5d891 100644 --- a/lang/es_utf8/attforblock.php +++ b/lang/es_utf8/attforblock.php @@ -64,7 +64,7 @@ $string['downloadooo'] = 'Descargar en Formato OpenOffice'; $string['downloadtext'] = 'Descargar en Formato de Texto'; $string['duration'] = 'Duración'; $string['editsession'] = 'Editar Sesión'; -$string['endofperiod'] = 'Fin del periodo'; +$string['endofperiod'] = 'Fecha final'; $string['endtime'] = 'Hora de finalización'; $string['errorgroupsnotselected'] = 'Elija uno o más grupos'; $string['errorinaddingsession'] = 'Error añadiendo Sesión'; @@ -73,6 +73,7 @@ $string['gridcolumns'] = 'Columnas de la rejilla'; $string['groupsession'] = 'Grupal'; $string['hiddensessions'] = 'Sesiones ocultas'; $string['identifyby'] = 'Identificar estudiantes por'; +$string['includeall'] = 'Seleccionar todas las sesiones'; $string['includenottaken'] = 'Incluir sesiones no registradas'; $string['indetail'] = 'En detalle...'; $string['moduledescription'] = 'Sólo se puede agregar una actividad \"Asistencia\" por curso.
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.'; @@ -121,6 +122,7 @@ $string['showduration'] = 'Mostrar duración'; $string['showdefaults'] = 'Mostrar opciones por defecto'; $string['sortedgrid'] = 'Rejilla alfabética'; $string['sortedlist'] = 'Lista alfabética'; +$string['startofperiod'] = 'Fecha de comienzo'; $string['status'] = 'Estado'; $string['statusdeleted'] = 'Estado eliminado'; $string['strftimedm'] = '%%d.%%m'; From b3e5bda76132e65e19cbd525652c2a5636419e0c Mon Sep 17 00:00:00 2001 From: Luis Ramon Lopez Date: Tue, 18 Jan 2011 20:07:12 +0100 Subject: [PATCH 06/13] Implemented fast session switching for same-day sessions. If there is more than one session on the same day, when taking attendance a dropdown list will allow to switch over sessions easily. Also fixed some XHTML compliance tags. --- CHANGES | 11 ++++++++++ attendances.php | 22 +++++++++++++++---- lang/en_utf8/attforblock.php | 2 ++ lang/es_utf8/attforblock.php | 2 ++ .../attforblock/createmultiplesessions.html | 2 +- lang/es_utf8/help/attforblock/report.html | 2 +- .../help/attforblock/updateattendance.html | 2 +- styles.php | 22 +++++++++++++++++++ 8 files changed, 58 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index 022cc9d..539e39a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,14 @@ +2011-01-18 lrlopez + + * attendances.php: styles.php: + + Implemented fast session switching for same-day sessions. + Fixed some XHTML compliance tags (more coming) + + * lang/: en_utf8/attforblock.php, es_utf8/attforblock.php: + + Added new strings for the dropdown menus. + 2011-01-16 lrlopez * export.php: export_form.php: diff --git a/attendances.php b/attendances.php index ee62c22..e4ec70f 100644 --- a/attendances.php +++ b/attendances.php @@ -107,12 +107,26 @@ $attforblockrecord = get_record('attforblock', 'id', $cm->instance);//'course', $course->id);'course', $course->id); $view = optional_param('view', get_user_preferences("attforblock_viewmode", SORTEDLISTVIEW), PARAM_INT); $gridcols = optional_param('gridcols', get_user_preferences("attforblock_gridcolumns",5), PARAM_INT); - echo '
'; + echo '
'; //echo '
'; $options = array (SORTEDLISTVIEW => get_string('sortedlist','attforblock'), SORTEDGRIDVIEW => get_string('sortedgrid','attforblock')); - $data = "attendances.php?id=$id&sessionid=$sessionid&grouptype=$grouptype&gridcols=$gridcols"; + $data = "attendances.php?id=$id&grouptype=$grouptype&gridcols=$gridcols"; if ($group!=-1) { $data = $data . "&group=$group"; } + $today = usergetmidnight($sessdata->sessdate); + $select = "sessdate>={$today} AND sessdate<{$today}+86400 AND attendanceid={$cm->instance}"; + $sessions = get_records_select('attendance_sessions', $select, 'sessdate ASC'); + $optionssesions = array(); + if (count($sessions)>1) { + echo '
"; + } + $data .= "&sessionid=$sessionid"; + echo '
"; + foreach($sessions as $sessdatarow) { + $optionssessions[$sessdatarow->id] = userdate($sessdatarow->sessdate, get_string('strftimehm', 'attforblock')) . "-" . userdate($sessdatarow->sessdate+$sessdata->duration, get_string('strftimehm', 'attforblock')); + } + popup_form("$data&sessionid=", $optionssessions, 'fastsessionmenu', $sessionid, ''); + echo "
"; popup_form("$data&view=", $options, 'viewmenu', $view, ''); if ($view == SORTEDGRIDVIEW) { set_user_preference("attforblock_viewmode", $view); @@ -127,7 +141,7 @@ } popup_form("$data&gridcols=", $options, 'colsmenu', $gridcols, ''); } - echo ''; + echo '
';//'; if ($grouptype === 0) { if ($currentgroup) { $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', $currentgroup, '', false); @@ -163,7 +177,7 @@ } $i++; } - if ($view == 0) { + if ($view == SORTEDLISTVIEW) { $tabhead[] = get_string('remarks','attforblock'); } diff --git a/lang/en_utf8/attforblock.php b/lang/en_utf8/attforblock.php index 2b88002..e59f567 100644 --- a/lang/en_utf8/attforblock.php +++ b/lang/en_utf8/attforblock.php @@ -76,6 +76,7 @@ $string['identifyby'] = 'Identify student by'; $string['includeall'] = 'Select all sessions'; $string['includenottaken'] = 'Include not taken sessions'; $string['indetail'] = 'In detail...'; +$string['jumpto'] = 'Jump to'; $string['moduledescription'] = 'You can add only one module Attendance per course.
Removal of this module will not entail removal of the data!'; $string['modulename'] = 'Attendance'; $string['modulenameplural'] = 'Attendances'; @@ -138,6 +139,7 @@ $string['update'] = 'Update'; $string['variable'] = 'variable'; $string['variablesupdated'] = 'Variables successfully updated'; $string['versionforprinting'] = 'version for printing'; +$string['viewmode'] = 'View mode'; $string['week'] = 'week(s)'; $string['weeks'] = 'Weeks'; $string['youcantdo'] = 'You can\'t do anything'; diff --git a/lang/es_utf8/attforblock.php b/lang/es_utf8/attforblock.php index fa5d891..9b284e1 100644 --- a/lang/es_utf8/attforblock.php +++ b/lang/es_utf8/attforblock.php @@ -76,6 +76,7 @@ $string['identifyby'] = 'Identificar estudiantes por'; $string['includeall'] = 'Seleccionar todas las sesiones'; $string['includenottaken'] = 'Incluir sesiones no registradas'; $string['indetail'] = 'En detalle...'; +$string['jumpto'] = 'Saltar a'; $string['moduledescription'] = 'Sólo se puede agregar una actividad \"Asistencia\" por curso.
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'; @@ -138,6 +139,7 @@ $string['update'] = 'Actualizar'; $string['variable'] = 'variable'; $string['variablesupdated'] = 'Variables actualizadas con éxito'; $string['versionforprinting'] = 'versión para Imprimir'; +$string['viewmode'] = 'Visualización'; $string['week'] = 'semana(s)'; $string['weeks'] = 'Semanal'; $string['youcantdo'] = 'Usted no puede hacer nada'; diff --git a/lang/es_utf8/help/attforblock/createmultiplesessions.html b/lang/es_utf8/help/attforblock/createmultiplesessions.html index 19e9c11..c2ecc53 100644 --- a/lang/es_utf8/help/attforblock/createmultiplesessions.html +++ b/lang/es_utf8/help/attforblock/createmultiplesessions.html @@ -2,7 +2,7 @@

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 asignatura + Fecha de Inicio de Sesión: seleccione la fecha de inicio de su curso o asignatura (el primer día de clase).
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.
diff --git a/lang/es_utf8/help/attforblock/report.html b/lang/es_utf8/help/attforblock/report.html index 82cb49b..d653085 100644 --- a/lang/es_utf8/help/attforblock/report.html +++ b/lang/es_utf8/help/attforblock/report.html @@ -2,4 +2,4 @@

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".



Informe individual: Si lo desea, también puede hacer click sobre el nombre del estudiante para poder ver un informe individualizado de su asistencia. En este sitio dispondrá de una opción para imprimir su informe personal o también podrá visualizar la asistencia del estudiante en todos los cursos en los que se encuentra matriculado (rol).

+que puede encontrar en la pestaña "exportar".

Informe individual: Si lo desea, también puede hacer click sobre el nombre del estudiante para poder ver un informe individualizado de su asistencia. En este sitio dispondrá de una opción para imprimir su informe personal o también podrá visualizar la asistencia del estudiante en todos los cursos en los que se encuentra matriculado (rol).

diff --git a/lang/es_utf8/help/attforblock/updateattendance.html b/lang/es_utf8/help/attforblock/updateattendance.html index fb2f8ee..f69d3f9 100644 --- a/lang/es_utf8/help/attforblock/updateattendance.html +++ b/lang/es_utf8/help/attforblock/updateattendance.html @@ -1,3 +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.



Informe individual: Si lo desea, también puede hacer click sobre el nombre del estudiante para poder ver un informe individualizado de su asistencia. En este sitio dispondrá de una opción para imprimir su informe personal o también podrá visualizar la asistencia del estudiante en todos los cursos en los que se encuentra matriculado (rol).

+

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.

Informe individual: Si lo desea, también puede hacer click sobre el nombre del estudiante para poder ver un informe individualizado de su asistencia. En este sitio dispondrá de una opción para imprimir su informe personal o también podrá visualizar la asistencia del estudiante en todos los cursos en los que se encuentra matriculado (rol).

diff --git a/styles.php b/styles.php index 57e109b..de8e8df 100644 --- a/styles.php +++ b/styles.php @@ -26,6 +26,28 @@ width:90%; } +body#mod-attforblock-attendances table.controls { + width: 100%; +} + +body#mod-attforblock-attendances table.controls { + width: 100%; +} + +body#mod-attforblock-attendances table.controls tr { + vertical-align: top; +} + +body#mod-attforblock-attendances table.controls td.right, body#mod-attforblock-attendances table.controls td.left { + padding-bottom: 4px; + padding-left: 4px; + padding-right: 4px; + padding-top: 4px; +} + +body#mod-attforblock-attendances table.controls .right { + text-align: right; +} /* for IE7*/ .attfiltercontrols td { padding:6px; From 48c49c85daa0e6fb88823155bff7068bce77c19b Mon Sep 17 00:00:00 2001 From: Luis Ramon Lopez Date: Tue, 18 Jan 2011 20:59:27 +0100 Subject: [PATCH 07/13] Implemented copying attendance data from same-day sessions --- CHANGES | 12 +++++++++ attendances.php | 51 ++++++++++++++++++++++-------------- lang/en_utf8/attforblock.php | 1 + lang/es_utf8/attforblock.php | 1 + styles.php | 5 +--- 5 files changed, 46 insertions(+), 24 deletions(-) diff --git a/CHANGES b/CHANGES index 539e39a..9836631 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,15 @@ +2011-01-18 lrlopez + + * attendances.php: styles.php: + + Implemented copy attendance data from same-day sessions. + Fixed fast session dropdown list end time inaccuracy. + Enhanced session dropdown list. + + * lang/: en_utf8/attforblock.php, es_utf8/attforblock.php: + + Added new strings for the copy dropdown menus. + 2011-01-18 lrlopez * attendances.php: styles.php: diff --git a/attendances.php b/attendances.php index e4ec70f..0927945 100644 --- a/attendances.php +++ b/attendances.php @@ -16,6 +16,7 @@ $grouptype = required_param('grouptype', PARAM_INT); $group = optional_param('group', -1, PARAM_INT); // Group to show $sort = optional_param('sort','lastname', PARAM_ALPHA); + $copyfrom = optional_param('copyfrom', -1, PARAM_INT); if (! $cm = get_record('course_modules', 'id', $id)) { error('Course Module ID was incorrect'); @@ -109,25 +110,29 @@ $gridcols = optional_param('gridcols', get_user_preferences("attforblock_gridcolumns",5), PARAM_INT); echo ''; //echo '
'; $options = array (SORTEDLISTVIEW => get_string('sortedlist','attforblock'), SORTEDGRIDVIEW => get_string('sortedgrid','attforblock')); - $data = "attendances.php?id=$id&grouptype=$grouptype&gridcols=$gridcols"; + $dataurl = "attendances.php?id=$id&grouptype=$grouptype&gridcols=$gridcols"; if ($group!=-1) { - $data = $data . "&group=$group"; + $dataurl = $dataurl . "&group=$group"; } $today = usergetmidnight($sessdata->sessdate); $select = "sessdate>={$today} AND sessdate<{$today}+86400 AND attendanceid={$cm->instance}"; - $sessions = get_records_select('attendance_sessions', $select, 'sessdate ASC'); + $todaysessions = get_records_select('attendance_sessions', $select, 'sessdate ASC'); $optionssesions = array(); - if (count($sessions)>1) { + if (count($todaysessions)>1) { echo '
"; } - $data .= "&sessionid=$sessionid"; + $dataurl .= "&sessionid=$sessionid"; echo '
"; - foreach($sessions as $sessdatarow) { - $optionssessions[$sessdatarow->id] = userdate($sessdatarow->sessdate, get_string('strftimehm', 'attforblock')) . "-" . userdate($sessdatarow->sessdate+$sessdata->duration, get_string('strftimehm', 'attforblock')); + foreach($todaysessions as $sessdatarow) { + $descr = userdate($sessdatarow->sessdate, get_string('strftimehm', 'attforblock')) . "-" . userdate($sessdatarow->sessdate+$sessdatarow->duration, get_string('strftimehm', 'attforblock')); + if ($sessdatarow->description) { + $descr = $sessdatarow->description . ' ('.$descr.')'; + } + $optionssessions[$sessdatarow->id] = $descr; } - popup_form("$data&sessionid=", $optionssessions, 'fastsessionmenu', $sessionid, ''); + popup_form("$dataurl&sessionid=", $optionssessions, 'fastsessionmenu', $sessionid, ''); echo "
"; - popup_form("$data&view=", $options, 'viewmenu', $view, ''); + popup_form("$dataurl&view=", $options, 'viewmenu', $view, ''); if ($view == SORTEDGRIDVIEW) { set_user_preference("attforblock_viewmode", $view); set_user_preference("attforblock_gridcolumns", $gridcols); @@ -135,11 +140,8 @@ '4 '.get_string('columns','attforblock'),'5 '.get_string('columns','attforblock'),'6 '.get_string('columns','attforblock'), '7 '.get_string('columns','attforblock'),'8 '.get_string('columns','attforblock'),'9 '.get_string('columns','attforblock'), '10 '.get_string('columns','attforblock')); - $data = "attendances.php?id=$id&sessionid=$sessionid&grouptype=$grouptype&view=$view"; - if ($group!=-1) { - $data = $data . "&group=$group"; - } - popup_form("$data&gridcols=", $options, 'colsmenu', $gridcols, ''); + $dataurl .= "&view=$view"; + popup_form("$dataurl&gridcols=", $options, 'colsmenu', $gridcols, ''); } echo '
';//'; if ($grouptype === 0) { @@ -163,7 +165,7 @@ $table->data[][] = ''.get_string('sessiondate','attforblock').': '.userdate($sessdata->sessdate, get_string('strftimedate').', '.get_string('strftimehm', 'attforblock')). ', "'.($sessdata->description ? $sessdata->description : get_string('nodescription', 'attforblock')).'"'; print_table($table); - + $statuses = get_statuses($attforblock->id); $i = 3; foreach($statuses as $st) { @@ -177,7 +179,7 @@ } $i++; } - if ($view == SORTEDLISTVIEW) { + if ($view == SORTEDLISTVIEW) { $tabhead[] = get_string('remarks','attforblock'); } @@ -247,11 +249,12 @@ $i = 0; foreach($students as $student) { $i++; - $att = get_record('attendance_log', 'sessionid', $sessionid, 'studentid', $student->id); - + $copyid = ($copyfrom == "-1") ? $sessionid : $copyfrom; + $att = get_record('attendance_log', 'sessionid', $copyid, 'studentid', $student->id); + $currentstatusid = $att===false ? -1 : $att->statusid; $data = "" . print_user_picture($student, $course->id, $student->picture, true, true, '', fullname($student)) . "
" . fullname($student) . "
";//, $returnstring=false, $link=true, $target=''); foreach($statuses as $st) { - $data = $data . 'id == $att->statusid ? 'checked' : '').'>' . $st->acronym . " "; + $data = $data . 'id == $currentstatusid ? 'checked' : '').'>' . $st->acronym . " "; } $table->data[($i-1) / ($gridcols)][] = $data; } @@ -266,7 +269,15 @@ echo ''; echo '
'; echo ''; - } else { + + if (count($todaysessions)>1) { + echo '
'; + echo '"; + popup_form("$dataurl©from=", $optionssessions, 'copysessionmenu', $sessionid, ''); + echo '
'; + } + + } else { print_heading(get_string('nothingtodisplay'), 'center'); } diff --git a/lang/en_utf8/attforblock.php b/lang/en_utf8/attforblock.php index e59f567..93acf7a 100644 --- a/lang/en_utf8/attforblock.php +++ b/lang/en_utf8/attforblock.php @@ -44,6 +44,7 @@ $string['columns'] = 'columns'; $string['commonsession'] = 'Common'; $string['commonsessions'] = 'Common'; $string['countofselected'] = 'Count of selected'; +$string['copyfrom'] = 'Copy attendance data from'; $string['createmultiplesessions'] = 'Create multiple sessions'; $string['createonesession'] = 'Create one session for the course'; $string['days'] = 'Day'; diff --git a/lang/es_utf8/attforblock.php b/lang/es_utf8/attforblock.php index 9b284e1..5e8ccab 100644 --- a/lang/es_utf8/attforblock.php +++ b/lang/es_utf8/attforblock.php @@ -44,6 +44,7 @@ $string['columns'] = 'columnas'; $string['commonsession'] = 'Común'; $string['commonsessions'] = 'Comunes'; $string['countofselected'] = 'Recuento de selección'; +$string['copyfrom'] = 'Copiar asistencia desde'; $string['createmultiplesessions'] = 'Crear varias sesiones'; $string['createonesession'] = 'Crear una sesión para el curso'; $string['days'] = 'Hoy'; diff --git a/styles.php b/styles.php index de8e8df..1f9e1d8 100644 --- a/styles.php +++ b/styles.php @@ -28,10 +28,7 @@ body#mod-attforblock-attendances table.controls { width: 100%; -} - -body#mod-attforblock-attendances table.controls { - width: 100%; + text-align: center; } body#mod-attforblock-attendances table.controls tr { From f6b4cd958f77022697dd29c53879f8f2031178e7 Mon Sep 17 00:00:00 2001 From: Luis Ramon Lopez Date: Tue, 18 Jan 2011 21:15:03 +0100 Subject: [PATCH 08/13] Fixed install.xml typo --- db/install.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/install.xml b/db/install.xml index c1d3578..36f9da5 100644 --- a/db/install.xml +++ b/db/install.xml @@ -66,7 +66,7 @@ - + @@ -77,8 +77,8 @@ - - + +
From 1e1a9f5e09b7d0deaa6afd1b0977ea8e08a0845e Mon Sep 17 00:00:00 2001 From: Artem Andreev Date: Thu, 20 Jan 2011 16:13:40 +0300 Subject: [PATCH 09/13] User preferences for attendances.php are now saved. --- attendances.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/attendances.php b/attendances.php index 0927945..ba33a59 100644 --- a/attendances.php +++ b/attendances.php @@ -106,8 +106,21 @@ // get the viewmode & grid columns (default is set in module settings) $attforblockrecord = get_record('attforblock', 'id', $cm->instance);//'course', $course->id);'course', $course->id); - $view = optional_param('view', get_user_preferences("attforblock_viewmode", SORTEDLISTVIEW), PARAM_INT); - $gridcols = optional_param('gridcols', get_user_preferences("attforblock_gridcolumns",5), PARAM_INT); + $view = optional_param('view', -1, PARAM_INT); + if ($view != -1) { + set_user_preference("attforblock_viewmode", $view); + } + else { + $view = get_user_preferences("attforblock_viewmode", SORTEDLISTVIEW); + } + $gridcols = optional_param('gridcols', -1, PARAM_INT); + if ($gridcols != -1) { + set_user_preference("attforblock_gridcolumns", $gridcols); + } + else { + $gridcols = get_user_preferences("attforblock_gridcolumns",5); + } + echo ''; //echo '
'; $options = array (SORTEDLISTVIEW => get_string('sortedlist','attforblock'), SORTEDGRIDVIEW => get_string('sortedgrid','attforblock')); $dataurl = "attendances.php?id=$id&grouptype=$grouptype&gridcols=$gridcols"; From 5866a44e6ab4cb33e328d3ba6d0b0230fc972328 Mon Sep 17 00:00:00 2001 From: Artem Andreev Date: Thu, 20 Jan 2011 17:10:08 +0300 Subject: [PATCH 10/13] Russian translate for new strings --- lang/ru_utf8/attforblock.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lang/ru_utf8/attforblock.php b/lang/ru_utf8/attforblock.php index bc688c3..4b03b20 100644 --- a/lang/ru_utf8/attforblock.php +++ b/lang/ru_utf8/attforblock.php @@ -38,9 +38,12 @@ $string['caltoday'] = 'Сегодня'; $string['calweekdays'] = ' \"Вс\", \"Пн\", \"Вт\", \"Ср\", \"Чт\", \"Пт\", \"Сб\"'; $string['changeduration'] = 'Изменить продолжительность'; $string['changesession'] = 'Изменить занятие'; +$string['column'] = 'колонка'; +$string['columns'] = 'колонок'; $string['commonsession'] = 'Общее'; $string['commonsessions'] = 'Общие'; $string['countofselected'] = 'Выбрано занятий'; +$string['copyfrom'] = 'Копировать данные посещаемости из занятия'; $string['createmultiplesessions'] = 'Создать несколько занятий'; $string['createonesession'] = 'Создать одно занятие для курса'; $string['days'] = 'День'; @@ -64,8 +67,10 @@ $string['erroringeneratingsessions'] = 'Ошибка при создании з $string['groupsession'] = 'Групповое'; $string['hiddensessions'] = 'Скрытых занятий'; $string['identifyby'] = 'Идентифицировать студентов по'; +$string['includeall'] = 'Выбрать все занятия'; $string['includenottaken'] = 'Включить не прошедшие занятия'; $string['indetail'] = 'Подробнее...'; +$string['jumpto'] = 'Перейти к занятию '; $string['moduledescription'] = 'Вы можете добавить только один данный модуль в каждый курс.
Удаление этого модуля не повлечет удаление данных о посещаемости!'; $string['modulename'] = 'Посещаемость'; $string['modulenameplural'] = 'Посещаемость'; @@ -89,6 +94,7 @@ $string['period'] = 'Периодичность'; $string['remarks'] = 'Заметка'; $string['report'] = 'Отчет'; $string['restoredefaults'] = 'Востановить значения по-умолчанию'; +$string['save'] = 'Сохранить посещаемость'; $string['session'] = 'Занятие'; $string['sessionadded'] = 'Занятие успешно добавлено'; $string['sessionalreadyexists'] = 'В этот день занятие уже существует'; @@ -106,6 +112,9 @@ $string['sessiontypeshort'] = 'Тип'; $string['sessionupdated'] = 'Занятие успешно изменено'; $string['settings'] = 'Настройки'; $string['showdefaults'] = 'Показать значения по-умолчанию'; +$string['sortedgrid'] = 'Таблица'; +$string['sortedlist'] = 'Список'; +$string['startofperiod'] = 'Начало периода'; $string['status'] = 'Статус'; $string['statusdeleted'] = 'Статус удален'; $string['strftimedm'] = '%%d.%%m'; @@ -120,6 +129,7 @@ $string['update'] = 'Обновить'; $string['variable'] = 'переменную'; $string['variablesupdated'] = 'Переменные успешно обновлены'; $string['versionforprinting'] = 'версия для печати'; +$string['viewmode'] = 'Вид: '; $string['week'] = 'неделя(и)'; $string['weeks'] = 'Неделя'; $string['youcantdo'] = 'Вы ничего не можете сделать'; From 90506e4543c50798bc383d27475eefc62fa5d768 Mon Sep 17 00:00:00 2001 From: Artem Andreev Date: Fri, 21 Jan 2011 14:34:00 +0300 Subject: [PATCH 11/13] Fixed warning for group sessions for students which are not member of any group --- report.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/report.php b/report.php index 5141999..c37a66d 100644 --- a/report.php +++ b/report.php @@ -165,12 +165,15 @@ $table->data[$student->id][] = ''.$allstatuses[$att->statusid]->acronym.''; } } else { - if ($sessdata->groupid && !array_key_exists($sessdata->groupid, $studgroups)) + if (!$studgroups || $sessdata->groupid && !array_key_exists($sessdata->groupid, $studgroups)) + // student is not memeber of any group OR it is session of other group $table->data[$student->id][] = ''; else if($sessdata->lasttaken > 0) { + // student began to study in the group later this session $table->data[$student->id][] = '–'; } else { + // no attendance data for session $table->data[$student->id][] = '?'; } } From dbfaa849edbb602ca176d4d639026301ec6058d6 Mon Sep 17 00:00:00 2001 From: Luis Ramon Lopez Date: Fri, 21 Jan 2011 17:36:08 +0100 Subject: [PATCH 12/13] In some cases view mode user preferences where saved twice. Fixed. --- attendances.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/attendances.php b/attendances.php index ba33a59..00b2eed 100644 --- a/attendances.php +++ b/attendances.php @@ -104,7 +104,7 @@ $groupmode = groups_get_activity_groupmode($cm); $currentgroup = groups_get_activity_group($cm, true); - // get the viewmode & grid columns (default is set in module settings) + // get the viewmode & grid columns $attforblockrecord = get_record('attforblock', 'id', $cm->instance);//'course', $course->id);'course', $course->id); $view = optional_param('view', -1, PARAM_INT); if ($view != -1) { @@ -147,8 +147,6 @@ echo '
"; popup_form("$dataurl&view=", $options, 'viewmenu', $view, ''); if ($view == SORTEDGRIDVIEW) { - set_user_preference("attforblock_viewmode", $view); - set_user_preference("attforblock_gridcolumns", $gridcols); $options = array (1 => '1 '.get_string('column','attforblock'),'2 '.get_string('columns','attforblock'),'3 '.get_string('columns','attforblock'), '4 '.get_string('columns','attforblock'),'5 '.get_string('columns','attforblock'),'6 '.get_string('columns','attforblock'), '7 '.get_string('columns','attforblock'),'8 '.get_string('columns','attforblock'),'9 '.get_string('columns','attforblock'), From 77fed6adbe9db97246963ee3b95fadc93fb73a91 Mon Sep 17 00:00:00 2001 From: Luis Ramon Lopez Date: Fri, 21 Jan 2011 18:03:03 +0100 Subject: [PATCH 13/13] Copy from other sessions now also works in list view mode --- attendances.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/attendances.php b/attendances.php index 00b2eed..e56084a 100644 --- a/attendances.php +++ b/attendances.php @@ -234,7 +234,10 @@ $table->data[$student->id][] = "id}\">".((!$att && $update) ? '' : '').fullname($student).((!$att && $update) ? '' : '').''; foreach($statuses as $st) { - @$table->data[$student->id][] = 'id == $att->statusid ? 'checked' : '').'>'; + $copyid = ($copyfrom == "-1") ? $sessionid : $copyfrom; + $att = get_record('attendance_log', 'sessionid', $copyid, 'studentid', $student->id); + $currentstatusid = $att===false ? -1 : $att->statusid; + @$table->data[$student->id][] = 'id == $currentstatusid ? 'checked' : '').'>'; } $table->data[$student->id][] = ''; }