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) ?>