diff --git a/CHANGES b/CHANGES index b4f181c..9836631 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,75 @@ +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: + + 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: + * 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: + + 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: + + 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: + 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 77c642c..fa2588f 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 = $DB->get_record('course_modules', array('id'=>$id))) { error('Course Module ID was incorrect'); @@ -38,7 +39,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; @@ -103,6 +104,58 @@ $groupmode = groups_get_activity_groupmode($cm); $currentgroup = groups_get_activity_group($cm, true); + // 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) { + 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"; + if ($group!=-1) { + $dataurl = $dataurl . "&group=$group"; + } + $today = usergetmidnight($sessdata->sessdate); + $select = "sessdate>=? AND sessdateget_records_select('attendance_sessions', $select, array($today, $tomorrow, $cm->instance), 'sessdate ASC'); + $optionssesions = array(); + if (count($todaysessions)>1) { + echo '
"; + } + $dataurl .= "&sessionid=$sessionid"; + echo '
"; + foreach($todaysessions as $sessdatarow) { + $descr = userdate($sessdatarow->sessdate, get_string('strftimehm', 'attforblock')) . "-" . userdate($sessdatarow->sessdate+$sessdatarow->duration, get_string('strftimehm', 'attforblock')); + if ($sessdatarow->description) { + $descr = $sessdatarow->description . ' ('.$descr.')'; + } + $optionssessions[$sessdatarow->id] = $descr; + } + popup_form("$dataurl&sessionid=", $optionssessions, 'fastsessionmenu', $sessionid, ''); + echo "
"; + popup_form("$dataurl&view=", $options, 'viewmenu', $view, ''); + if ($view == SORTEDGRIDVIEW) { + $options = array (1 => '1 '.get_string('column','attforblock'),'2 '.get_string('columns','attforblock'),'3 '.get_string('columns','attforblock'), + '4 '.get_string('columns','attforblock'),'5 '.get_string('columns','attforblock'),'6 '.get_string('columns','attforblock'), + '7 '.get_string('columns','attforblock'),'8 '.get_string('columns','attforblock'),'9 '.get_string('columns','attforblock'), + '10 '.get_string('columns','attforblock')); + $dataurl .= "&view=$view"; + popup_form("$dataurl&gridcols=", $options, 'colsmenu', $gridcols, ''); + } + echo '
';//'; if ($grouptype === 0) { if ($currentgroup) { $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', $currentgroup, '', false); @@ -124,14 +177,23 @@ $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($course->id); + + $statuses = get_statuses($attforblock->id); $i = 3; foreach($statuses as $st) { + switch($view) { + case SORTEDLISTVIEW: $tabhead[] = "$st->acronym"; + break; + case SORTEDGRIDVIEW: + $tabhead[] = "acronym . "', null);\">$st->acronym"; + break; + } $i++; } + if ($view == SORTEDLISTVIEW) { $tabhead[] = get_string('remarks','attforblock'); + } $firstname = "".get_string('firstname').''; $lastname = "".get_string('lastname').''; @@ -143,6 +205,9 @@ if ($students) { unset($table); + + switch($view) { + case SORTEDLISTVIEW: // sorted list $table->width = '0%'; $table->head[] = '#'; $table->align[] = 'center'; @@ -170,10 +235,46 @@ $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 = $DB->get_record('attendance_log', array('sessionid'=> $copyid, 'studentid'=> $student->id)); + $currentstatusid = $att===false ? -1 : $att->statusid; + @$table->data[$student->id][] = 'id == $currentstatusid ? 'checked' : '').'>'; } $table->data[$student->id][] = ''; } + break; + case SORTEDGRIDVIEW: // sorted grid + $table->width = '0%'; + + $data = ''; + foreach ($tabhead as $hd) { + $data = $data . $hd . ' '; + } + print_heading($data,'center'); + + $i = 0; + // sanity check + $gridcols = $gridcols < 1 ? 1 : $gridcols; + for ($i=0; $i<$gridcols; $i++) { + $table->head[] = ' '; + $table->align[] = 'center'; + $table->size[] = '110px'; + } + + $i = 0; + foreach($students as $student) { + $i++; + $copyid = ($copyfrom == "-1") ? $sessionid : $copyfrom; + $att = $DB->get_record('attendance_log', array('sessionid'=> $copyid, 'studentid'=> $student->id)); + $currentstatusid = $att===false ? -1 : $att->statusid; + $data = "" . print_user_picture($student, $course->id, $student->picture, true, true, '', fullname($student)) . "
" . fullname($student) . "
";//, $returnstring=false, $link=true, $target=''); + foreach($statuses as $st) { + $data = $data . 'id == $currentstatusid ? 'checked' : '').'>' . $st->acronym . " "; + } + $table->data[($i-1) / ($gridcols)][] = $data; + } + break; + } echo '
'; print_table($table); @@ -181,9 +282,17 @@ echo ''; echo ''; echo ''; - 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/attsettings.php b/attsettings.php index a7bc7f0..5c2b8c1 100644 --- a/attsettings.php +++ b/attsettings.php @@ -20,7 +20,10 @@ error("Course module is incorrect"); } } - $attforblockrecord = $DB->get_record('attforblock',array('course'=>$course->id)); + //$attforblockrecord = get_record('attforblock','course',$course->id); + if (! $attforblockrecord = $DB->get_record('attforblock', array('id'=> $cm->instance))) { + error("Course module is incorrect"); + } require_login($course->id); @@ -45,7 +48,7 @@ if (!empty($action)) { switch ($action) { case 'delete': - if (!$rec = $DB->get_record('attendance_statuses', array('courseid'=> $course->id, 'id'=> $stid))) { + if (!$rec = $DB->get_record('attendance_statuses', array('attendanceid'=> $$attforblockrecord->id, 'id'=> $stid))) { print_error('notfoundstatus', 'attforblock', "attsettings.php?id=$id"); } if ($DB->count_records('attendance_log', array('statusid'=> $stid))) { @@ -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 2912007..23aa51f 100644 --- a/backuplib.php +++ b/backuplib.php @@ -100,7 +100,7 @@ $status = true; - $datas = $DB->get_records('attendance_sessions', array('courseid'=> $attforblock->course)); + $datas = $DB->get_records('attendance_sessions', array('attendanceid'=> $attforblock->id)); if ($datas) { //Write start tag $status =fwrite ($bf,start_tag('SESSIONS',4,true)); @@ -139,7 +139,7 @@ $status = true; - $datas = $DB->get_records('attendance_statuses', array('courseid'=> $attforblock->course)); + $datas = $DB->get_records('attendance_statuses', array('courseid'=> $attforblock->course, 'attendanceid' => $attforblock->id)); //If there is levels if ($datas) { //Write start tag @@ -173,7 +173,7 @@ $status = true; - $sessions = $DB->get_records_menu('attendance_sessions', array('courseid'=> $attforblock->course)); + $sessions = $DB->get_records_menu('attendance_sessions', array('courseid'=> $attforblock->course, 'attendanceid' => $attforblock->id)); $sesslist = implode(',', array_keys($sessions)); $datas = $DB->get_records_list('attendance_log', array('sessionid'=> $sesslist)); //If there is levels diff --git a/db/install.xml b/db/install.xml index 3e7ae64..36f9da5 100644 --- a/db/install.xml +++ b/db/install.xml @@ -6,10 +6,10 @@ - - - - + + + + @@ -20,35 +20,37 @@
- - - - - - - - - + + + + + + + + + + - - + + +
- - - - - - - - + + + + + + + + @@ -61,20 +63,22 @@
- - - - - - - + + + + + + + + - - + + +
diff --git a/db/upgrade.php b/db/upgrade.php index 884438a..997470f 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -236,7 +236,34 @@ function xmldb_attforblock_upgrade($oldversion=0) { upgrade_mod_savepoint(true, 2010070900, 'attforblock'); } - return true; + if ($oldversion < 2010123003) { + + $table = new xmldb_table('attendance_sessions'); + + $field = new xmldb_field('attendanceid'); + $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'groupid'); + $dbman->add_field($table, $field); + + $index = new xmldb_table('attendanceid'); + $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('attendanceid')); + $dbman->add_index($table, $index); + + $sql = "UPDATE {attendance_sessions} AS ses,{attforblock} AS att SET ses.attendanceid=att.id WHERE att.course=ses.courseid"; + $dbman->execute($sql); + + $table = new xmldb_table('attendance_statuses'); + + $field = new xmldb_field('attendanceid'); + $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'courseid'); + $dbman->add_field($table, $field); + $index = new xmldb_index('attendanceid'); + $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('attendanceid')); + $dbman->add_index($table, $index); + + $sql = "UPDATE {attendance_statuses} AS sta,{attforblock} AS att SET sta.attendanceid=att.id WHERE att.course=sta.courseid"; + execute($sql); + } + return $result; } ?> diff --git a/export.php b/export.php index 9c19021..9ab8a90 100644 --- a/export.php +++ b/export.php @@ -75,7 +75,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; @@ -92,7 +92,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/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/attforblock.php b/lang/en/attforblock.php index 28eb00f..718d49b 100644 --- a/lang/en/attforblock.php +++ b/lang/en/attforblock.php @@ -39,13 +39,17 @@ $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'; +$string['copyfrom'] = 'Copy attendance data from'; $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,20 +59,25 @@ $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'; $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'; $string['erroringeneratingsessions'] = 'Error in generating sessions '; +$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['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'; @@ -94,6 +103,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'; @@ -111,6 +121,10 @@ $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['startofperiod'] = 'Start of period'; $string['status'] = 'Status'; $string['statusdeleted'] = 'Status deleted'; $string['strftimedm'] = '%%d.%%m'; @@ -126,6 +140,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/attforblock.php b/lang/es/attforblock.php index 3016381..37335de 100644 --- a/lang/es/attforblock.php +++ b/lang/es/attforblock.php @@ -3,12 +3,12 @@ $string['all'] = 'Todas'; -$string['Aacronym'] = 'A'; -$string['Afull'] = 'Ausente'; -$string['Eacronym'] = 'E'; -$string['Efull'] = 'Excusa'; -$string['Lacronym'] = 'T'; -$string['Lfull'] = 'Tarde'; +$string['Aacronym'] = 'I'; +$string['Afull'] = 'Falta injustificada'; +$string['Eacronym'] = 'J'; +$string['Efull'] = 'Falta justificada'; +$string['Lacronym'] = 'R'; +$string['Lfull'] = 'Retraso'; $string['Pacronym'] = 'P'; $string['Pfull'] = 'Presente'; $string['acronym'] = 'Acrónimo'; @@ -24,8 +24,8 @@ $string['attendancepercent'] = 'Porcentaje'; $string['attendancereport'] = 'Informe de Asistencia'; $string['attendancesuccess'] = 'Asistencia tomada con éxito'; $string['attendanceupdated'] = 'Asistencia actualizada con éxito'; -$string['attforblock:changeattendances'] = 'Cambiar asistencias'; -$string['attforblock:changepreferences'] = 'Cambiar Preferencias'; +$string['attforblock:changeattendances'] = 'Cambiar Asistencias'; +$string['attforblock:changepreferences'] = 'Cambiar preferencias'; $string['attforblock:export'] = 'Exportar Informes'; $string['attforblock:manageattendances'] = 'Gestionar Asistencias'; $string['attforblock:takeattendances'] = 'Tomar Asistencias'; @@ -39,13 +39,17 @@ $string['caltoday'] = 'Hoy'; $string['calweekdays'] = '\"Do\", \"Lu\", \"Ma\", \"Mi\", \"Ju\", \"Vi\", \"Sá\"'; $string['changeduration'] = 'Cambiar duración'; $string['changesession'] = 'Cambiar Sesión'; +$string['column'] = 'columna'; +$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'; $string['defaults'] = 'Por Defecto'; +$string['defaultdisplaymode'] = 'Visualización por defecto'; $string['delete'] = 'Eliminar'; $string['deletelogs'] = 'Eliminar datos de asistencia'; $string['deleteselected'] = 'Eliminar selección'; @@ -55,20 +59,25 @@ $string['deletingsession'] = 'Eliminando Sesión para el Curso/Asignatura'; $string['deletingstatus'] = 'Eliminando estatus del curso'; $string['description'] = 'Descripción'; $string['display'] = 'Mostrar'; -$string['downloadexcel'] = 'Descargar en Formato Excell'; +$string['displaymode'] = 'Modo de visualización'; +$string['downloadexcel'] = 'Descargar en Formato Excel'; $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'; $string['erroringeneratingsessions'] = 'Error generando sesión'; +$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['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'; @@ -95,6 +104,7 @@ $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'; @@ -111,9 +121,13 @@ $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['startofperiod'] = 'Fecha de comienzo'; $string['status'] = 'Estado'; -$string['statusdeleted'] = 'Estatus eliminado'; +$string['statusdeleted'] = 'Estado eliminado'; $string['strftimedm'] = '%%d.%%m'; $string['strftimedmy'] = '%%d.%%m.%%Y'; $string['strftimedmyhm'] = '%%d.%%m.%%Y %%H.%%M'; @@ -127,6 +141,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/help/attforblock/createmultiplesessions.html b/lang/es/help/attforblock/createmultiplesessions.html index 19e9c11..c2ecc53 100644 --- a/lang/es/help/attforblock/createmultiplesessions.html +++ b/lang/es/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/help/attforblock/report.html b/lang/es/help/attforblock/report.html index 82cb49b..d653085 100644 --- a/lang/es/help/attforblock/report.html +++ b/lang/es/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/help/attforblock/updateattendance.html b/lang/es/help/attforblock/updateattendance.html index fb2f8ee..f69d3f9 100644 --- a/lang/es/help/attforblock/updateattendance.html +++ b/lang/es/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/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'] = 'Вы ничего не можете сделать'; diff --git a/lib.php b/lib.php index cf04335..8d1d883 100644 --- a/lib.php +++ b/lib.php @@ -33,27 +33,27 @@ function attforblock_add_instance($attforblock) { $attforblock->timemodified = time(); - if ($att = $DB->get_record('attforblock', array('course'=> $attforblock->course))) { - $modnum = $DB->get_field('modules', 'id', array('name'=> 'attforblock')); - if (!$DB->get_record('course_modules', array('course'=> $attforblock->course, 'module'=> $modnum))) { - $DB->delete_records('attforblock', array('course'=> $attforblock->course)); - $attforblock->id = $DB->insert_record('attforblock', $attforblock); - } else { + /*if ($att = get_record('attforblock', 'course', $attforblock->course)) { + $modnum = get_field('modules', 'id', 'name', 'attforblock'); + if (!get_record('course_modules', 'course', $attforblock->course, 'module', $modnum)) { + delete_records('attforblock', 'course', $attforblock->course); + $attforblock->id = insert_record('attforblock', $attforblock); + /*} else { return false; } - } else { - $attforblock->id = $DB->insert_record('attforblock', $attforblock); - } + } else {*/ + $attforblock->id = insert_record('attforblock', $attforblock); + //} //Copy statuses for new instance from defaults - if (!$DB->get_records('attendance_statuses', array('courseid'=> $attforblock->course))) { + //if (!$DB->get_records('attendance_statuses', array('courseid'=> $attforblock->course))) { $statuses = $DB->get_records('attendance_statuses', array('courseid'=> 0), 'id'); foreach($statuses as $stat) { $rec = $stat; $rec->courseid = $attforblock->course; $DB->insert_record('attendance_statuses', $rec); } - } + //} // attforblock_grade_item_update($attforblock); // attforblock_update_grades($attforblock); @@ -177,11 +177,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%)"; } } @@ -241,13 +241,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; } } } @@ -325,7 +325,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 aa27d36..8a8e298 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(); @@ -46,14 +49,14 @@ function show_tabs($cm, $context, $currenttab='sessions') //getting settings for course -function get_statuses($courseid, $onlyvisible = true) +function get_statuses($attendanceid, $onlyvisible = true) { global $DB; - if ($onlyvisible) { - $result = $DB->get_records_select('attendance_statuses', "courseid = ? AND visible = 1 AND deleted = 0", array( $courseid ), 'grade DESC'); + if ($onlyvisible) { + $result = get_records_select('attendance_statuses', "attendanceid = $attendanceid AND visible = 1 AND deleted = 0", 'grade DESC'); } else { - $result = $DB->get_records_select('attendance_statuses', "courseid = ? AND deleted = 0", array( $courseid ), '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; @@ -61,24 +64,24 @@ 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, $DB; $qry = "SELECT count(*) as cnt FROM {attendance_log} al JOIN {attendance_sessions} ats ON al.sessionid = ats.id - WHERE ats.courseid = $course->id - AND ats.sessdate >= $course->startdate - AND al.studentid = $userid"; + WHERE ats.attendanceid = :aid + AND ats.sessdate >= :cstartdate + AND al.studentid = :uid"; if ($statusid) { - $qry .= " AND al.statusid = $statusid"; + $qry .= " AND al.statusid = :sid"; } - return $DB->count_records_sql($qry); + return $DB->count_records_sql($qry, array('aid' => $attendance->id, 'cstartdate' => $course->startdate, 'uid'=>$userid, 'sid'=>$statusid )); } -function get_grade($userid, $course) +function get_grade($userid, $course, $attendance) { global $CFG, $DB; $logs = $DB->get_records_sql("SELECT l.id, l.statusid, l.statusset @@ -86,11 +89,12 @@ function get_grade($userid, $course) JOIN {attendance_sessions} s ON l.sessionid = s.id WHERE l.studentid = :usid + AND s.attendanceid = :aid AND s.courseid = :cid - AND s.sessdate >= :cstartdate", array('usid' => $userid, 'cid' => $course->id, 'cstartdate' => $course->startdate )); + AND s.sessdate >= :cstartdate", array('usid' => $userid, 'aid' => $attendance->id, 'cid' => $course->id, 'cstartdate' => $course->startdate )); $result = 0; if ($logs) { - $stat_grades = $DB->records_to_menu($DB->get_records('attendance_statuses', array('courseid'=> $course->id)), 'id', 'grade'); + $stat_grades = $DB->records_to_menu($DB->get_records('attendance_statuses', array('attendanceid'=> $attendance->id)), 'id', 'grade'); foreach ($logs as $log) { $result += $stat_grades[$log->statusid]; } @@ -110,7 +114,7 @@ function local_array_intersect_key($array1, $array2) { return $result; } -function get_maxgrade($userid, $course) +function get_maxgrade($userid, $course, $attendance) { global $CFG, $DB; $logs = $DB->get_records_sql("SELECT l.id, l.statusid, l.statusset @@ -118,12 +122,13 @@ function get_maxgrade($userid, $course) JOIN {attendance_sessions} s ON l.sessionid = s.id WHERE l.studentid = :usid + AND s.attendanceid = :aid AND s.courseid = :cid - AND s.sessdate >= :cstartdate", array('usid' => $userid, 'cid' => $course->id, 'cstartdate' => $course->startdate )); + AND s.sessdate >= :cstartdate", array('usid' => $userid, 'aid' => $attendance->id, 'cid' => $course->id, 'cstartdate' => $course->startdate )); $maxgrade = 0; if ($logs) { - $stat_grades = $DB->records_to_menu($DB->get_records('attendance_statuses', array('courseid'=> $course->id)), 'id', 'grade'); + $stat_grades = records_to_menu(get_records('attendance_statuses', array('attendanceid'=> $attendance->id)), 'id', 'grade'); foreach ($logs as $log) { $ids = array_flip(explode(',', $log->statusset)); // $grades = array_intersect_key($stat_grades, $ids); // require PHP 5.1.0 and higher @@ -143,11 +148,12 @@ function get_percent_adaptive($userid, $course) // NOT USED JOIN {attendance_sessions} s ON l.sessionid = s.id WHERE l.studentid = :usid + AND s.attendanceid = :aid AND s.courseid = :cid - AND s.sessdate >= :cstartdate", array('usid' => $userid, 'cid' => $course->id, 'cstartdate' => $course->startdate )); + AND s.sessdate >= :cstartdate", array('usid' => $userid, 'aid' => $attendance->id, 'cid' => $course->id, 'cstartdate' => $course->startdate )); $result = 0; if ($logs) { - $stat_grades = $DB->records_to_menu($DB->get_records('attendance_statuses', array('courseid'=> $course->id)), 'id', 'grade'); + $stat_grades = $DB->records_to_menu($DB->get_records('attendance_statuses', array('attendanceid'=> $attendance->id)), 'id', 'grade'); $percent = 0; foreach ($logs as $log) { @@ -165,15 +171,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; @@ -221,20 +227,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 '
'; @@ -263,30 +269,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 {attendance_log} al JOIN {attendance_sessions} ats ON al.sessionid = ats.id - WHERE al.studentid = {$user->id} - GROUP BY ats.courseid - ORDER BY ats.courseid asc"; - $recs = $DB->get_records_sql_menu($stqry); - foreach ($recs as $id => $courseid) { + WHERE al.studentid = ? + GROUP BY cid + ORDER BY cid,aid asc"; + $recs = get_records_sql($stqry, array($user->id)); + foreach ($recs as $rec) { echo '
'; echo ''; - $nextcourse = $DB->get_record('course', array('id'=> $courseid)); - echo ''; + $nextcourse = $DB->get_record('course', array('id'=> $rec['cid'])); + $nextattendance = $DB->get_record('attforblock', array('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'); } @@ -393,6 +400,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); diff --git a/manage.php b/manage.php index c1c48da..7852630 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 = $DB->get_record('course_modules', array('id'=> $id))) { error('Course Module ID was incorrect'); } @@ -43,15 +43,17 @@ !has_capability('mod/attforblock:changeattendances', $context)) { redirect("view.php?id=$cm->id"); } - + + set_user_preference("attforblock_showendtime",$showendtime); + //if teacher is coming from block, then check for a session exists for today if($from === 'block') { $today = time(); // because we compare with database, we don't need to use usertime() $sql = "SELECT id, groupid, lasttaken FROM {attendance_sessions} WHERE ? BETWEEN sessdate AND (sessdate + duration) - AND courseid = $course->id"; - if($atts = $DB->get_records_sql($sql, array($today))) { + AND courseid = ? AND attendanceid = ?"; + if($atts = $DB->get_records_sql($sql, array($today, $course->id, $attforblock->id))) { $size = count($atts); if ($size == 1) { $att = reset($atts); @@ -76,24 +78,24 @@ print_heading(get_string('attendanceforthecourse','attforblock').' :: ' .$course->fullname); - if(!$DB->count_records_select('attendance_sessions', "courseid = ? AND sessdate >= ?", array($course->id, $course->startdate))) { // no session exists for this course + if(!$DB->count_records_select('attendance_sessions', "courseid = ? AND attendanceid = ? AND sessdate >= ?", array($course->id, $attforblock->id, $course->startdate))) { // no session exists for this course show_tabs($cm, $context); print_heading(get_string('nosessionexists','attforblock')); - $hiddensess = $DB->count_records_select('attendance_sessions', "courseid = ? AND sessdate < ?", array($course->id, $course->startdate)); + $hiddensess = $DB->count_records_select('attendance_sessions', "courseid = ? AND attendanceid = ? AND sessdate < ?", array($course->id, $attforblock->id, $course->startdate)); echo '
'.helpbutton('hiddensessions', '--', 'attforblock', true, true, '', true); //TODO: fix '--' echo get_string('hiddensessions', 'attforblock').': '.$hiddensess.'
'; } else { //sessions generated , display them add_to_log($course->id, 'attendance', 'manage attendances', 'mod/attforblock/manage.php?course='.$course->id, $user->lastname.' '.$user->firstname); show_tabs($cm, $context); - print_sessions_list($course); + print_sessions_list($course, $attforblock); } // require_once('lib.php'); // $t = attforblock_get_user_grades($attforblock); //////////////////////////////////////////// print_footer($course); -function print_sessions_list($course) { - global $CFG, $context, $cm, $current, $view, $id, $DB; +function print_sessions_list($course, $attforblock) { + global $CFG, $context, $cm, $current, $view, $id, $showendtime, $DB; $strhours = get_string('hours'); $strmins = get_string('min'); @@ -109,20 +111,20 @@ function print_sessions_list($course) { $currentgroup = $ret['currentgroup']; if ($startdate && $enddate) { - $where = "courseid=:cid AND sessdate >= :sdate AND sessdate >= :sdate2 AND sessdate < :edate"; + $where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :sdate AND sessdate >= :sdate2 AND sessdate < :edate"; } else { - $where = "courseid=:cid AND sessdate >= :sdate"; + $where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :sdate"; } if ($currentgroup > -1) { $where .= " AND groupid=:cgroup"; } - $qry = $DB->get_records_select('attendance_sessions', $where, array('cid' => $course->id, 'sdate' => $course->startdate,'sdate2' => $startdate, 'edate'=> $enddate, 'cgroup'=> $currentgroup), 'sessdate asc'); + $qry = $DB->get_records_select('attendance_sessions', $where, array('cid' => $course->id, 'aid' => $attforblock->id, 'sdate' => $course->startdate,'sdate2' => $startdate, 'edate'=> $enddate, 'cgroup'=> $currentgroup), 'sessdate asc'); $i = 0; $table->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 = $DB->count_records_select('attendance_sessions', "courseid = ? AND sessdate < ?", array($course->id,$course->startdate)); + $hiddensess = $DB->count_records_select('attendance_sessions', "courseid = ? AND attendanceid = ? AND sessdate < ?", array($course->id, $attforblock->id, $course->startdate)); echo ''; diff --git a/report.php b/report.php index 81ed56b..1ed27cc 100644 --- a/report.php +++ b/report.php @@ -74,9 +74,9 @@ $currentgroup = $ret['currentgroup']; if ($startdate && $enddate) { - $where = "courseid=:cid AND sessdate >= :sdate AND sessdate >= :sdate2 AND sessdate < :edate"; + $where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :sdate AND sessdate >= :sdate2 AND sessdate < :edate"; } else { - $where = "courseid=:cid AND sessdate >= :sdate"; + $where = "courseid=:cid AND attendanceid = :aid AND sessdate >= :sdate"; } if ($currentgroup) { @@ -86,12 +86,12 @@ $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 - ($course_sess = $DB->get_records_select('attendance_sessions', $where, array('cid' => $course->id, 'sdate' => $course->startdate,'sdate2' => $startdate, 'edate'=> $enddate, 'cgroup'=> $currentgroup), 'sessdate ASC'))) { + ($course_sess = $DB->get_records_select('attendance_sessions', $where, array('cid' => $course->id, 'aid'=> $attforblock->id, 'sdate' => $course->startdate,'sdate2' => $startdate, 'edate'=> $enddate, 'cgroup'=> $currentgroup), 'sessdate ASC'))) { $firstname = "".get_string('firstname').''; $lastname = "".get_string('lastname').''; @@ -179,11 +179,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 5d70761..6dcf162 100644 --- a/restorelib.php +++ b/restorelib.php @@ -13,9 +13,9 @@ //Now get completed xmlized object $info = $data->info; - if ($DB->count_records('attforblock', array('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 = $DB->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 = $DB->get_records_menu('attendance_statuses', array('courseid'=> $restore->course_id)); + $stats = $DB->get_records_menu('attendance_statuses', array('attendanceid'=> $new_attforblock_id)); $statslist = implode(',', array_keys($stats)); - $sessions = $DB->get_records('attendance_sessions', 'courseid', $restore->course_id); + $sessions = $DB->get_records('attendance_sessions', array('attendanceid'=> $new_attforblock_id)); //Iterate over logs for($i = 0; $i < sizeof($logs); $i++) { diff --git a/sessions.php b/sessions.php index 15e112d..f2e70e9 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 57e109b..1f9e1d8 100644 --- a/styles.php +++ b/styles.php @@ -26,6 +26,25 @@ width:90%; } +body#mod-attforblock-attendances table.controls { + width: 100%; + text-align: center; +} + +body#mod-attforblock-attendances table.controls tr { + vertical-align: top; +} + +body#mod-attforblock-attendances table.controls td.right, body#mod-attforblock-attendances table.controls td.left { + padding-bottom: 4px; + padding-left: 4px; + padding-right: 4px; + padding-top: 4px; +} + +body#mod-attforblock-attendances table.controls .right { + text-align: right; +} /* for IE7*/ .attfiltercontrols td { padding:6px; diff --git a/version.php b/version.php index f2b017b..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 = 2010070900; // The current module version (Date: YYYYMMDDXX) -$module->release = '2.2.0'; +$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) ?>
'; echo '
'.helpbutton('hiddensessions', '--', 'attforblock', true, true, '', true); //TODO: Change '--' echo get_string('hiddensessions', 'attforblock').': '.$hiddensess.'