Browse Source

Implemented grid display mode

MOODLE_23_STABLE
Luis Ramon Lopez 14 years ago
parent
commit
28ab5c77a2
  1. 9
      CHANGES
  2. 56
      attendances.php
  3. 2
      db/install.xml
  4. 12
      db/upgrade.php
  5. 5
      lang/en_utf8/attforblock.php
  6. 5
      lang/es_utf8/attforblock.php
  7. 4
      mod_form.php
  8. 4
      version.php

9
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 2010-07-10 - 2010-09-17 andreev.artem
Implemented ability to add two types of sessions: common and group Implemented ability to add two types of sessions: common and group

56
attendances.php

@ -103,6 +103,18 @@
$groupmode = groups_get_activity_groupmode($cm); $groupmode = groups_get_activity_groupmode($cm);
$currentgroup = groups_get_activity_group($cm, true); $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 '<center>';
$options = array (get_string('sortedlist','attforblock'), get_string('sortedgrid','attforblock'));
$data = "attendances.php?id=$id&amp;sessionid=$sessionid&grouptype=$grouptype";
if ($group!=-1) {
$data = $data . "&group=$group";
}
popup_form("$data&view=", $options, 'viewmenu', $view, '');
echo '</center>';
if ($grouptype === 0) { if ($grouptype === 0) {
if ($currentgroup) { if ($currentgroup) {
$students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', $currentgroup, '', false); $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', $currentgroup, '', false);
@ -128,10 +140,19 @@
$statuses = get_statuses($course->id); $statuses = get_statuses($course->id);
$i = 3; $i = 3;
foreach($statuses as $st) { foreach($statuses as $st) {
switch($view) {
case 0:
$tabhead[] = "<a href=\"javascript:select_all_in('TD', 'cell c{$i}', null);\"><u>$st->acronym</u></a>"; $tabhead[] = "<a href=\"javascript:select_all_in('TD', 'cell c{$i}', null);\"><u>$st->acronym</u></a>";
break;
case 1:
$tabhead[] = "<a href=\"javascript:select_all_in('INPUT', '". $st->acronym . "', null);\"><u>$st->acronym</u></a>";
break;
}
$i++; $i++;
} }
if ($view == 0) {
$tabhead[] = get_string('remarks','attforblock'); $tabhead[] = get_string('remarks','attforblock');
}
$firstname = "<a href=\"attendances.php?id=$id&amp;sessionid=$sessionid&amp;sort=firstname\">".get_string('firstname').'</a>'; $firstname = "<a href=\"attendances.php?id=$id&amp;sessionid=$sessionid&amp;sort=firstname\">".get_string('firstname').'</a>';
$lastname = "<a href=\"attendances.php?id=$id&amp;sessionid=$sessionid&amp;sort=lastname\">".get_string('lastname').'</a>'; $lastname = "<a href=\"attendances.php?id=$id&amp;sessionid=$sessionid&amp;sort=lastname\">".get_string('lastname').'</a>';
@ -143,6 +164,9 @@
if ($students) { if ($students) {
unset($table); unset($table);
switch($view) {
case 0: // sorted list
$table->width = '0%'; $table->width = '0%';
$table->head[] = '#'; $table->head[] = '#';
$table->align[] = 'center'; $table->align[] = 'center';
@ -174,6 +198,38 @@
} }
$table->data[$student->id][] = '<input type="text" name="remarks'.$student->id.'" size="" value="'.($att ? $att->remarks : '').'">'; $table->data[$student->id][] = '<input type="text" name="remarks'.$student->id.'" size="" value="'.($att ? $att->remarks : '').'">';
} }
break;
case 1: // sorted grid
$table->width = '0%';
$data = '';
foreach ($tabhead as $hd) {
$data = $data . $hd . '&nbsp';
}
print_heading($data,'center');
$i = 0;
// sanity check
$gridcols = $gridcols < 0 ? 0 : $gridcols;
for ($i=0; $i<=$gridcols; $i++) {
$table->head[] = '&nbsp;';
$table->align[] = 'center';
$table->size[] = '110px';
}
$i = 0;
foreach($students as $student) {
$i++;
$att = get_record('attendance_log', 'sessionid', $sessionid, 'studentid', $student->id);
$data = "<span class='userinfobox' style='font-size:80%;border:none'>" . print_user_picture($student, $course->id, $student->picture, true, true, '', fullname($student)) . "<br/>" . fullname($student) . "<br/></span>";//, $returnstring=false, $link=true, $target='');
foreach($statuses as $st) {
$data = $data . '<input name="student'.$student->id.'" type="radio" class="' . $st->acronym . '" value="'.$st->id.'" '.($st->id == $att->statusid ? 'checked' : '').'>' . $st->acronym;
}
$table->data[($i-1) / ($gridcols+1)][] = $data;
}
break;
}
echo '<form name="takeattendance" method="post" action="attendances.php">'; echo '<form name="takeattendance" method="post" action="attendances.php">';
print_table($table); print_table($table);

2
db/install.xml

@ -10,6 +10,8 @@
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/> <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="grade"/> <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="grade"/>
<FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="100" SEQUENCE="false" ENUM="false" COMMENT="This is maximum grade for instance" PREVIOUS="name"/> <FIELD NAME="grade" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="100" SEQUENCE="false" ENUM="false" COMMENT="This is maximum grade for instance" PREVIOUS="name"/>
<FIELD NAME="displaymode" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Default display mode" PREVIOUS="grade"/>
<FIELD NAME="gridcolumns" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" DEFAULT="4" SEQUENCE="false" ENUM="false" COMMENT="Default columns number for grid view" PREVIOUS="displaymode"/>
</FIELDS> </FIELDS>
<KEYS> <KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attforblock"/> <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for attforblock"/>

12
db/upgrade.php

@ -228,6 +228,18 @@ function xmldb_attforblock_upgrade($oldversion=0) {
$result = $result && add_index($table, $index); $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; return $result;
} }

5
lang/en_utf8/attforblock.php

@ -46,6 +46,7 @@ $string['createmultiplesessions'] = 'Create multiple sessions';
$string['createonesession'] = 'Create one session for the course'; $string['createonesession'] = 'Create one session for the course';
$string['days'] = 'Day'; $string['days'] = 'Day';
$string['defaults'] = 'Defaults'; $string['defaults'] = 'Defaults';
$string['defaultdisplaymode'] = 'Default display mode';
$string['delete'] = 'Delete'; $string['delete'] = 'Delete';
$string['deletelogs'] = 'Delete attendance data'; $string['deletelogs'] = 'Delete attendance data';
$string['deleteselected'] = 'Delete selected'; $string['deleteselected'] = 'Delete selected';
@ -55,6 +56,7 @@ $string['deletingsession'] = 'Deleting session for the course';
$string['deletingstatus'] = 'Deleting status for the course'; $string['deletingstatus'] = 'Deleting status for the course';
$string['description'] = 'Description'; $string['description'] = 'Description';
$string['display'] = 'Display'; $string['display'] = 'Display';
$string['displaymode'] = 'Display mode';
$string['downloadexcel'] = 'Download in Excel format'; $string['downloadexcel'] = 'Download in Excel format';
$string['downloadooo'] = 'Download in OpenOffice format'; $string['downloadooo'] = 'Download in OpenOffice format';
$string['downloadtext'] = 'Download in text format'; $string['downloadtext'] = 'Download in text format';
@ -64,6 +66,7 @@ $string['endofperiod'] = 'End of period';
$string['errorgroupsnotselected'] = 'Select one or more groups'; $string['errorgroupsnotselected'] = 'Select one or more groups';
$string['errorinaddingsession'] = 'Error in adding session'; $string['errorinaddingsession'] = 'Error in adding session';
$string['erroringeneratingsessions'] = 'Error in generating sessions '; $string['erroringeneratingsessions'] = 'Error in generating sessions ';
$string['gridcolumns'] = 'Grid columns';
$string['groupsession'] = 'Group'; $string['groupsession'] = 'Group';
$string['hiddensessions'] = 'Hidden sessions'; $string['hiddensessions'] = 'Hidden sessions';
$string['identifyby'] = 'Identify student by'; $string['identifyby'] = 'Identify student by';
@ -111,6 +114,8 @@ $string['sessiontypeshort'] = 'Type';
$string['sessionupdated'] = 'Session successfully updated'; $string['sessionupdated'] = 'Session successfully updated';
$string['settings'] = 'Settings'; $string['settings'] = 'Settings';
$string['showdefaults'] = 'Show defaults'; $string['showdefaults'] = 'Show defaults';
$string['sortedgrid'] = 'Sorted grid';
$string['sortedlist'] = 'Sorted list';
$string['status'] = 'Status'; $string['status'] = 'Status';
$string['statusdeleted'] = 'Status deleted'; $string['statusdeleted'] = 'Status deleted';
$string['strftimedm'] = '%%d.%%m'; $string['strftimedm'] = '%%d.%%m';

5
lang/es_utf8/attforblock.php

@ -30,6 +30,7 @@ $string['countofselected'] = 'Recuento de selección';
$string['createmultiplesessions'] = 'Crear varias sesiones'; $string['createmultiplesessions'] = 'Crear varias sesiones';
$string['createonesession'] = 'Crear una sesión para el curso'; $string['createonesession'] = 'Crear una sesión para el curso';
$string['defaults'] = 'Por Defecto'; $string['defaults'] = 'Por Defecto';
$string['defaultdisplaymode'] = 'Visualización por defecto';
$string['delete'] = 'Eliminar'; $string['delete'] = 'Eliminar';
$string['deletelogs'] = 'Eliminar datos de asistencia'; $string['deletelogs'] = 'Eliminar datos de asistencia';
$string['deleteselected'] = 'Eliminar selección'; $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['deletingsession'] = 'Eliminando Sesión para el Curso/Asignatura';
$string['description'] = 'Descripción'; $string['description'] = 'Descripción';
$string['display'] = 'Mostrar'; $string['display'] = 'Mostrar';
$string['displaymode'] = 'Modo de visualización';
$string['downloadexcel'] = 'Descargar en Formato Excell'; $string['downloadexcel'] = 'Descargar en Formato Excell';
$string['downloadooo'] = 'Descargar en Formato OpenOffice'; $string['downloadooo'] = 'Descargar en Formato OpenOffice';
$string['downloadtext'] = 'Descargar en Formato de Texto'; $string['downloadtext'] = 'Descargar en Formato de Texto';
@ -48,6 +50,7 @@ $string['Efull'] = 'Justificado';
$string['endofperiod'] = 'Fin del periodo'; $string['endofperiod'] = 'Fin del periodo';
$string['errorinaddingsession'] = 'Error añadiendo Sesión'; $string['errorinaddingsession'] = 'Error añadiendo Sesión';
$string['erroringeneratingsessions'] = 'Error generando sesión '; $string['erroringeneratingsessions'] = 'Error generando sesión ';
$string['gridcolumns'] = 'Columnas de la rejilla';
$string['identifyby'] = 'Identificar estudiantes por'; $string['identifyby'] = 'Identificar estudiantes por';
$string['includenottaken'] = 'Incluir sesiones no registradas'; $string['includenottaken'] = 'Incluir sesiones no registradas';
$string['indetail'] = 'En Detalle...'; $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['sessionupdated'] = 'Sesión actualizada con éxito';
$string['settings'] = 'Configuración'; $string['settings'] = 'Configuración';
$string['showdefaults'] = 'Mostrar opciones por defecto'; $string['showdefaults'] = 'Mostrar opciones por defecto';
$string['sortedgrid'] = 'Rejilla alfabética';
$string['sortedlist'] = 'Lista alfabética';
$string['status'] = 'Estado'; $string['status'] = 'Estado';
$string['strftimedm'] = '%%d.%%m'; $string['strftimedm'] = '%%d.%%m';
$string['strftimedmy'] = '%%d.%%m.%%Y'; $string['strftimedmy'] = '%%d.%%m.%%Y';

4
mod_form.php

@ -21,6 +21,10 @@ class mod_attforblock_mod_form extends moodleform_mod {
$mform->addElement('modgrade', 'grade', get_string('grade')); $mform->addElement('modgrade', 'grade', get_string('grade'));
$mform->setDefault('grade', 100); $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); $this->standard_coursemodule_elements(true);
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------

4
version.php

@ -5,7 +5,7 @@
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php /// This fragment is called by moodle_needs_upgrading() and /admin/index.php
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
$module->version = 2010070900; // The current module version (Date: YYYYMMDDXX) $module->version = 2010122900; // The current module version (Date: YYYYMMDDXX)
$module->release = '2.2.0'; $module->release = '2.2.1';
$module->cron = 0; // Period for cron to check this module (secs) $module->cron = 0; // Period for cron to check this module (secs)
?> ?>

Loading…
Cancel
Save