Browse Source

Grid view support. Multiple instances in the same course now allowed. Updated es_utf8 language strings

MOODLE_23_STABLE
Luis Ramon Lopez 14 years ago
parent
commit
2bf9f94c8f
  1. 28
      CHANGES
  2. 33
      attendances.php
  3. 8
      attsettings.php
  4. 6
      backuplib.php
  5. 8
      db/install.xml
  6. 29
      db/upgrade.php
  7. 6
      export.php
  8. 5
      lang/en_utf8/attforblock.php
  9. 59
      lang/es_utf8/attforblock.php
  10. 15
      lang/es_utf8/help/attforblock/hiddensessions.html
  11. 17
      lang/es_utf8/help/attforblock/sessiontypes.html
  12. 27
      lib.php
  13. 65
      locallib.php
  14. 25
      manage.php
  15. 4
      mod_form.php
  16. 16
      report.php
  17. 12
      restorelib.php
  18. 5
      sessions.php
  19. 2
      styles.php
  20. 2
      version.php

28
CHANGES

@ -1,7 +1,29 @@
2010-12-29 - 2010-12-30 lrlopez 2010-12-30 - 2011-01-04 lrlopez
* db/install.xml: * lang/: es_utf8/attforblock.php:
* db/upgrade.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) Implemented display modes (list and grid)
* lang/: en_utf8/attforblock.php, es_utf8/attforblock.php: * lang/: en_utf8/attforblock.php, es_utf8/attforblock.php:

33
attendances.php

@ -38,7 +38,7 @@
print_error('badcontext'); 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()) { if ($form = data_submitted()) {
$students = array(); // stores students ids $students = array(); // stores students ids
$formarr = (array)$form; $formarr = (array)$form;
@ -105,15 +105,28 @@
// get the viewmode & grid columns (default is set in module settings) // get the viewmode & grid columns (default is set in module settings)
$attforblockrecord = get_record('attforblock', 'course', $course->id); $attforblockrecord = get_record('attforblock', 'course', $course->id);
$view = optional_param('view', $attforblockrecord->displaymode, PARAM_INT); $view = optional_param('view', get_user_preferences("attforblock_viewmode",0), PARAM_INT);
$gridcols = optional_param('gridcols', $attforblockrecord->gridcolumns, PARAM_INT); $gridcols = optional_param('gridcols', get_user_preferences("attforblock_gridcolumns",5), PARAM_INT);
echo '<center>'; echo '<center>';
$options = array (get_string('sortedlist','attforblock'), get_string('sortedgrid','attforblock')); $options = array (0 => get_string('sortedlist','attforblock'), 1 => get_string('sortedgrid','attforblock'));
$data = "attendances.php?id=$id&amp;sessionid=$sessionid&grouptype=$grouptype"; $data = "attendances.php?id=$id&sessionid=$sessionid&grouptype=$grouptype&gridcols=$gridcols";
if ($group!=-1) { if ($group!=-1) {
$data = $data . "&group=$group"; $data = $data . "&group=$group";
} }
popup_form("$data&view=", $options, 'viewmenu', $view, ''); 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 '</center>'; echo '</center>';
if ($grouptype === 0) { if ($grouptype === 0) {
if ($currentgroup) { if ($currentgroup) {
@ -137,7 +150,7 @@
', "'.($sessdata->description ? $sessdata->description : get_string('nodescription', 'attforblock')).'"</b>'; ', "'.($sessdata->description ? $sessdata->description : get_string('nodescription', 'attforblock')).'"</b>';
print_table($table); print_table($table);
$statuses = get_statuses($course->id); $statuses = get_statuses($attforblock->id);
$i = 3; $i = 3;
foreach($statuses as $st) { foreach($statuses as $st) {
switch($view) { switch($view) {
@ -210,8 +223,8 @@
$i = 0; $i = 0;
// sanity check // sanity check
$gridcols = $gridcols < 0 ? 0 : $gridcols; $gridcols = $gridcols < 1 ? 1 : $gridcols;
for ($i=0; $i<=$gridcols; $i++) { for ($i=0; $i<$gridcols; $i++) {
$table->head[] = '&nbsp;'; $table->head[] = '&nbsp;';
$table->align[] = 'center'; $table->align[] = 'center';
$table->size[] = '110px'; $table->size[] = '110px';
@ -226,7 +239,7 @@
foreach($statuses as $st) { 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; $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; $table->data[($i-1) / ($gridcols)][] = $data;
} }
break; break;
} }
@ -237,7 +250,7 @@
echo '<input type="hidden" name="sessionid" value="'.$sessionid.'">'; echo '<input type="hidden" name="sessionid" value="'.$sessionid.'">';
echo '<input type="hidden" name="grouptype" value="'.$grouptype.'">'; echo '<input type="hidden" name="grouptype" value="'.$grouptype.'">';
echo '<input type="hidden" name="formfrom" value="editsessvals">'; echo '<input type="hidden" name="formfrom" value="editsessvals">';
echo '<center><input type="submit" name="esv" value="'.get_string('ok').'"></center>'; echo '<center><input type="submit" name="esv" value="'.get_string('save','attforblock').'"></center>';
echo '</form>'; echo '</form>';
} else { } else {
print_heading(get_string('nothingtodisplay'), 'center'); print_heading(get_string('nothingtodisplay'), 'center');

8
attsettings.php

@ -20,7 +20,10 @@
error("Course module is incorrect"); 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); require_login($course->id);
@ -84,6 +87,7 @@
if (!empty($newacronym) && !empty($newdescription)) { if (!empty($newacronym) && !empty($newdescription)) {
unset($rec); unset($rec);
$rec->courseid = $course->id; $rec->courseid = $course->id;
$rec->attendanceid = $attforblock->id;
$rec->acronym = $newacronym; $rec->acronym = $newacronym;
$rec->description = $newdescription; $rec->description = $newdescription;
$rec->grade = $newgrade; $rec->grade = $newgrade;
@ -113,7 +117,7 @@
get_string('action')); get_string('action'));
$table->align = array('center', 'center', 'center', 'center', 'center', 'center'); $table->align = array('center', 'center', 'center', 'center', 'center', 'center');
//$table->size = array('1px', '1px', '*', '1px', '1px', '1px'); //$table->size = array('1px', '1px', '*', '1px', '1px', '1px');
$statuses = get_statuses($course->id, false); $statuses = get_statuses($attforblockrecord->id, false);
$deltitle = get_string('delete'); $deltitle = get_string('delete');
foreach($statuses as $st) foreach($statuses as $st)
{ {

6
backuplib.php

@ -97,7 +97,7 @@
$status = true; $status = true;
$datas = get_records('attendance_sessions', 'courseid', $attforblock->course); $datas = get_records('attendance_sessions', 'attendanceid', $attforblock->id);
if ($datas) { if ($datas) {
//Write start tag //Write start tag
$status =fwrite ($bf,start_tag('SESSIONS',4,true)); $status =fwrite ($bf,start_tag('SESSIONS',4,true));
@ -136,7 +136,7 @@
$status = true; $status = true;
$datas = get_records('attendance_statuses', 'courseid', $attforblock->course); $datas = get_records('attendance_statuses', 'attendanceid', $attforblock->id);
//If there is levels //If there is levels
if ($datas) { if ($datas) {
//Write start tag //Write start tag
@ -170,7 +170,7 @@
$status = true; $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)); $sesslist = implode(',', array_keys($sessions));
$datas = get_records_list('attendance_log', 'sessionid', $sesslist); $datas = get_records_list('attendance_log', 'sessionid', $sesslist);
//If there is levels //If there is levels

8
db/install.xml

@ -10,8 +10,6 @@
<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"/>
@ -24,7 +22,8 @@
<FIELDS> <FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="courseid"/> <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="courseid"/>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="groupid"/> <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="groupid"/>
<FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="courseid" NEXT="sessdate"/> <FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="courseid" NEXT="attendanceid"/>
<FIELD NAME="attendanceid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="groupid" NEXT="sessdate"/>
<FIELD NAME="sessdate" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="groupid" NEXT="duration"/> <FIELD NAME="sessdate" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="groupid" NEXT="duration"/>
<FIELD NAME="duration" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="sessdate" NEXT="lasttaken"/> <FIELD NAME="duration" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="sessdate" NEXT="lasttaken"/>
<FIELD NAME="lasttaken" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="duration" NEXT="lasttakenby"/> <FIELD NAME="lasttaken" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="duration" NEXT="lasttakenby"/>
@ -37,7 +36,8 @@
</KEYS> </KEYS>
<INDEXES> <INDEXES>
<INDEX NAME="courseid" UNIQUE="false" FIELDS="courseid" NEXT="groupid"/> <INDEX NAME="courseid" UNIQUE="false" FIELDS="courseid" NEXT="groupid"/>
<INDEX NAME="groupid" UNIQUE="false" FIELDS="groupid" PREVIOUS="courseid" NEXT="sessdate"/> <INDEX NAME="groupid" UNIQUE="false" FIELDS="groupid" PREVIOUS="courseid" NEXT="attendanceid"/>
<INDEX NAME="attendanceid" UNIQUE="false" FIELDS="attendanceid" PREVIOUS="groupid" NEXT="sessdate"/>
<INDEX NAME="sessdate" UNIQUE="false" FIELDS="sessdate" PREVIOUS="groupid"/> <INDEX NAME="sessdate" UNIQUE="false" FIELDS="sessdate" PREVIOUS="groupid"/>
</INDEXES> </INDEXES>
</TABLE> </TABLE>

29
db/upgrade.php

@ -228,18 +228,33 @@ function xmldb_attforblock_upgrade($oldversion=0) {
$result = $result && add_index($table, $index); $result = $result && add_index($table, $index);
} }
if ($oldversion < 2010122900 and $result) { if ($oldversion < 2010123003 and $result) {
$table = new XMLDBTable('attforblock');
$table = new XMLDBTable('attendance_sessions');
$field = new XMLDBField('displaymode'); $field = new XMLDBField('attendanceid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'grade'); $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'groupid');
$result = $result && add_field($table, $field); $result = $result && add_field($table, $field);
$field = new XMLDBField('gridcolumns'); $index = new XMLDBIndex('attendanceid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '4', 'displaymode'); $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); $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; return $result;
} }

6
export.php

@ -56,7 +56,7 @@
$data->tabhead[] = get_string('lastname'); $data->tabhead[] = get_string('lastname');
$data->tabhead[] = get_string('firstname'); $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)) { if (isset($fromform->includenottaken)) {
$select .= " AND sessdate <= {$fromform->sessionenddate}"; $select .= " AND sessdate <= {$fromform->sessionenddate}";
} else { } else {
@ -74,7 +74,7 @@
$i = 0; $i = 0;
$data->table = array(); $data->table = array();
$statuses = get_statuses($course->id); $statuses = get_statuses($attforblock->id);
foreach($students as $student) { foreach($students as $student) {
if (isset($fromform->ident['id'])) { if (isset($fromform->ident['id'])) {
$data->table[$i][] = $student->id; $data->table[$i][] = $student->id;
@ -91,7 +91,7 @@
$data->table[$i][] = '-'; $data->table[$i][] = '-';
} }
} }
$data->table[$i][] = get_percent($student->id, $course).'%'; $data->table[$i][] = get_percent($student->id, $course, $attforblock).'%';
$i++; $i++;
} }

5
lang/en_utf8/attforblock.php

@ -39,6 +39,8 @@ $string['caltoday'] = 'Today';
$string['calweekdays'] = ' \"Su\", \"Mo\", \"Tu\", \"We\", \"Th\", \"Fr\", \"Sa\"'; $string['calweekdays'] = ' \"Su\", \"Mo\", \"Tu\", \"We\", \"Th\", \"Fr\", \"Sa\"';
$string['changeduration'] = 'Change duration'; $string['changeduration'] = 'Change duration';
$string['changesession'] = 'Change session'; $string['changesession'] = 'Change session';
$string['column'] = 'column';
$string['columns'] = 'columns';
$string['commonsession'] = 'Common'; $string['commonsession'] = 'Common';
$string['commonsessions'] = 'Common'; $string['commonsessions'] = 'Common';
$string['countofselected'] = 'Count of selected'; $string['countofselected'] = 'Count of selected';
@ -62,6 +64,7 @@ $string['downloadooo'] = 'Download in OpenOffice format';
$string['downloadtext'] = 'Download in text format'; $string['downloadtext'] = 'Download in text format';
$string['duration'] = 'Duration'; $string['duration'] = 'Duration';
$string['editsession'] = 'Edit Session'; $string['editsession'] = 'Edit Session';
$string['endtime'] = 'Session end time';
$string['endofperiod'] = 'End of period'; $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';
@ -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['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['resetstatuses'] = 'Reset statuses to default';
$string['restoredefaults'] = 'Restore defaults'; $string['restoredefaults'] = 'Restore defaults';
$string['save'] = 'Save attendance';
$string['session'] = 'Session'; $string['session'] = 'Session';
$string['sessionadded'] = 'Session successfully added'; $string['sessionadded'] = 'Session successfully added';
$string['sessionalreadyexists'] = 'Session already exists for this date'; $string['sessionalreadyexists'] = 'Session already exists for this date';
@ -114,6 +118,7 @@ $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['showduration'] = 'Show duration';
$string['sortedgrid'] = 'Sorted grid'; $string['sortedgrid'] = 'Sorted grid';
$string['sortedlist'] = 'Sorted list'; $string['sortedlist'] = 'Sorted list';
$string['status'] = 'Status'; $string['status'] = 'Status';

59
lang/es_utf8/attforblock.php

@ -1,13 +1,21 @@
<?PHP // $Id: attforblock.php,v 1.1.2.3 2009/02/25 10:30:58 dlnsk Exp $ <?PHP // $Id: attforblock.php,v 1.5 2009/08/08 12:39:52 barias Exp $
// attendanceblk.php - created with Moodle 1.5.3+ (2005060230) // attforblock.php - created with Moodle 1.9.3+ (Build: 20081126) (2007101532)
$string['allcourses'] = 'Todos los cursos';
$string['Aacronym'] = 'A'; $string['all'] = 'Todas';
$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'; $string['acronym'] = 'Acrónimo';
$string['add'] = 'Añadir'; $string['add'] = 'Añadir';
$string['addmultiplesessions'] = 'Añadir varias sesiones'; $string['addmultiplesessions'] = 'Añadir varias sesiones';
$string['addsession'] = 'Añadir sesión'; $string['addsession'] = 'Añadir sesión';
$string['Afull'] = 'Ausente'; $string['allcourses'] = 'Todos los cursos';
$string['alltaken'] = 'Hasta hoy'; $string['alltaken'] = 'Hasta hoy';
$string['attendanceforthecourse'] = 'Asistencia para el Curso/Asignatura'; $string['attendanceforthecourse'] = 'Asistencia para el Curso/Asignatura';
$string['attendancegrade'] = 'Puntación Asistencia'; $string['attendancegrade'] = 'Puntación Asistencia';
@ -16,19 +24,29 @@ $string['attendancepercent'] = 'Porcentaje';
$string['attendancereport'] = 'Informe de Asistencia'; $string['attendancereport'] = 'Informe de Asistencia';
$string['attendancesuccess'] = 'Asistencia tomada con éxito'; $string['attendancesuccess'] = 'Asistencia tomada con éxito';
$string['attendanceupdated'] = 'Asistencia actualizada con éxito'; $string['attendanceupdated'] = 'Asistencia actualizada con éxito';
$string['attforblock:changeattendances'] = 'Cambiar asistencias'; $string['attforblock:changeattendances'] = 'Cambiar Asistencias';
$string['attforblock:changepreferences'] = 'Cambiar Preferencias'; $string['attforblock:changepreferences'] = 'Cambiar preferencias';
$string['attforblock:export'] = 'Exportar Informes'; $string['attforblock:export'] = 'Exportar Informes';
$string['attforblock:manageattendances'] = 'Gestionar Asistencias'; $string['attforblock:manageattendances'] = 'Gestionar Asistencias';
$string['attforblock:takeattendances'] = 'Tomar Asistencias'; $string['attforblock:takeattendances'] = 'Tomar Asistencias';
$string['attforblock:view'] = 'Ver Asistencias'; $string['attforblock:view'] = 'Ver Asistencias';
$string['attforblock:viewreports'] = 'Ver Informes'; $string['attforblock:viewreports'] = 'Ver Informes';
$string['attrecords'] = 'Asistencias tomadas'; $string['attrecords'] = 'Asistencias tomadas';
$string['calclose'] = 'Cerrar';
$string['calmonths'] = '\"Enero\", \"Febrero\", \"Marzo\", \"Abril\", \"Mayo\", \"Junio\", \"Julio\", \"Agosto\", \"Septiembre\", \"Octubre\", \"Noviembre\", \"Diciembre\"';
$string['calshow'] = 'Seleccione fecha';
$string['caltoday'] = 'Hoy';
$string['calweekdays'] = '\"Do\", \"Lu\", \"Ma\", \"Mi\", \"Ju\", \"Vi\", \"Sá\"';
$string['changeduration'] = 'Cambiar duración'; $string['changeduration'] = 'Cambiar duración';
$string['changesession'] = 'Cambiar Sesió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['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['days'] = 'Hoy';
$string['defaults'] = 'Por Defecto'; $string['defaults'] = 'Por Defecto';
$string['defaultdisplaymode'] = 'Visualización por defecto'; $string['defaultdisplaymode'] = 'Visualización por defecto';
$string['delete'] = 'Eliminar'; $string['delete'] = 'Eliminar';
@ -37,34 +55,36 @@ $string['deleteselected'] = 'Eliminar selección';
$string['deletesession'] = 'Eliminar Sesión'; $string['deletesession'] = 'Eliminar Sesión';
$string['deletesessions'] = 'Eliminar todas las sesiones'; $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['deletingstatus'] = 'Eliminando estatus del curso';
$string['description'] = 'Descripción'; $string['description'] = 'Descripción';
$string['display'] = 'Mostrar'; $string['display'] = 'Mostrar';
$string['displaymode'] = 'Modo de visualización'; $string['displaymode'] = 'Modo de visualización';
$string['downloadexcel'] = 'Descargar en Formato Excell'; $string['downloadexcel'] = 'Descargar en Formato Excel';
$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';
$string['duration'] = 'Duración'; $string['duration'] = 'Duración';
$string['Eacronym'] = 'J';
$string['editsession'] = 'Editar Sesión'; $string['editsession'] = 'Editar Sesión';
$string['Efull'] = 'Justificado';
$string['endofperiod'] = 'Fin del periodo'; $string['endofperiod'] = 'Fin del periodo';
$string['endtime'] = 'Hora de finalización';
$string['errorgroupsnotselected'] = 'Elija uno o más grupos';
$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['gridcolumns'] = 'Columnas de la rejilla';
$string['groupsession'] = 'Grupal';
$string['hiddensessions'] = 'Sesiones ocultas';
$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...';
$string['Lacronym'] = 'T';
$string['Lfull'] = 'Tarde';
$string['moduledescription'] = 'Sólo se puede agregar una actividad \"Asistencia\" por curso.<br>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['moduledescription'] = 'Sólo se puede agregar una actividad \"Asistencia\" por curso.<br>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['modulename'] = 'Asistencia';
$string['modulenameplural'] = 'Asistencias'; $string['modulenameplural'] = 'Asistencias';
$string['months'] = 'Meses'; $string['months'] = 'Mensual';
$string['myvariables'] = 'Mis Variables'; $string['myvariables'] = 'Mis Variables';
$string['newdate'] = 'Nueva Fecha'; $string['newdate'] = 'Nueva Fecha';
$string['newduration'] = 'Nueva duración'; $string['newduration'] = 'Nueva duración';
$string['noattforuser'] = 'No existen registros de asistencia para el usuario'; $string['noattforuser'] = 'No existen registros de asistencia para el usuario';
$string['nodescription'] = 'Sesión de Clase Normal'; $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['noguest'] = 'Los invitados no pueden ver la asistencia';
$string['noofdaysabsent'] = 'Nº de días de ausencia'; $string['noofdaysabsent'] = 'Nº de días de ausencia';
$string['noofdaysexcused'] = 'Nº de días con faltas justificadas'; $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['nosessionexists'] = 'No existen Sesiones para este curso';
$string['notfound'] = 'No se ha encontrado ninguna actividad Asistencia en este curso'; $string['notfound'] = 'No se ha encontrado ninguna actividad Asistencia en este curso';
$string['olddate'] = 'Fecha Anterior'; $string['olddate'] = 'Fecha Anterior';
$string['Pacronym'] = 'P';
$string['period'] = 'Frecuencia'; $string['period'] = 'Frecuencia';
$string['Pfull'] = 'Presente';
$string['remarks'] = 'Observaciones'; $string['remarks'] = 'Observaciones';
$string['report'] = 'Informe'; $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['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['resetstatuses'] = 'Reinicar la configuración por defecto';
$string['restoredefaults'] = 'Restarurar valores por defecto'; $string['restoredefaults'] = 'Restarurar valores por defecto';
$string['save'] = 'Guardar asistencia';
$string['session'] = 'Sesión'; $string['session'] = 'Sesión';
$string['sessionadded'] = 'Sesión añadida con éxito'; $string['sessionadded'] = 'Sesión añadida con éxito';
$string['sessionalreadyexists'] = 'Ya existe una sesión para la fecha indicada'; $string['sessionalreadyexists'] = 'Ya existe una sesión para la fecha indicada';
@ -94,12 +113,16 @@ $string['sessions'] = 'Sesiones';
$string['sessionscompleted'] = 'Sesiones completadas'; $string['sessionscompleted'] = 'Sesiones completadas';
$string['sessionsgenerated'] = 'Sesiones generadas con éxito'; $string['sessionsgenerated'] = 'Sesiones generadas con éxito';
$string['sessionstartdate'] = 'Fecha de Inicio de la Sesión'; $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['sessionupdated'] = 'Sesión actualizada con éxito';
$string['settings'] = 'Configuración'; $string['settings'] = 'Configuración';
$string['showduration'] = 'Mostrar duración';
$string['showdefaults'] = 'Mostrar opciones por defecto'; $string['showdefaults'] = 'Mostrar opciones por defecto';
$string['sortedgrid'] = 'Rejilla alfabética'; $string['sortedgrid'] = 'Rejilla alfabética';
$string['sortedlist'] = 'Lista alfabética'; $string['sortedlist'] = 'Lista alfabética';
$string['status'] = 'Estado'; $string['status'] = 'Estado';
$string['statusdeleted'] = 'Estado eliminado';
$string['strftimedm'] = '%%d.%%m'; $string['strftimedm'] = '%%d.%%m';
$string['strftimedmy'] = '%%d.%%m.%%Y'; $string['strftimedmy'] = '%%d.%%m.%%Y';
$string['strftimedmyhm'] = '%%d.%%m.%%Y %%H.%%M'; $string['strftimedmyhm'] = '%%d.%%m.%%Y %%H.%%M';
@ -110,9 +133,11 @@ $string['studentid'] = 'ID de Estudiante';
$string['takeattendance'] = 'Iniciar Asistencia'; $string['takeattendance'] = 'Iniciar Asistencia';
$string['thiscourse'] = 'Este curso'; $string['thiscourse'] = 'Este curso';
$string['update'] = 'Actualizar'; $string['update'] = 'Actualizar';
$string['variable'] = 'variable';
$string['variablesupdated'] = 'Variables actualizadas con éxito'; $string['variablesupdated'] = 'Variables actualizadas con éxito';
$string['versionforprinting'] = 'versión para Imprimir'; $string['versionforprinting'] = 'versión para Imprimir';
$string['week'] = 'semana(s)'; $string['week'] = 'semana(s)';
$string['weeks'] = 'Semanas'; $string['weeks'] = 'Semanal';
$string['youcantdo'] = 'Usted no puede hacer nada'; $string['youcantdo'] = 'Usted no puede hacer nada';
?> ?>

15
lang/es_utf8/help/attforblock/hiddensessions.html

@ -0,0 +1,15 @@
<p align="center"><b>Asistencia</b></p>
<p align="left"><strong>Ocultar sesiones</strong></p>
<p align="center">
<?php
$temp = $module;
unset($module);
require_once($CFG->dirroot.'/mod/attforblock/version.php');
echo get_string('version').": $module->release ($module->version)";
unset($module);
$module = $temp;
?>
</p>
<p align="left">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.</p>
<p align="left">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.</p>

17
lang/es_utf8/help/attforblock/sessiontypes.html

@ -0,0 +1,17 @@
<p align="center"><b>Asistencia</b></p>
<p align="center">
<?php
$temp = $module;
unset($module);
require_once($CFG->dirroot.'/mod/attforblock/version.php');
echo get_string('version').": $module->release ($module->version)";
unset($module);
$module = $temp;
?>
</p>
<p align="left">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. </p>
<p align="left">Modo de grupo &quot;No hay grupos&quot; únicamente se pueden elegir sesiones comunes. </p>
<p align="left">Modo de grupo &quot;Grupos visible&quot; es posible elegir sesiones grupales o comunes. </p>
<p align="left">Modo de grupo &quot;Grupos Separados&quot; únicamente es posible elegir sesiones grupales. </p>
<p align="left">En caso de que fuese necesario, es posible seleccionar varios grupos simultáneos o alternos utilizando la tecla ctrl </p>

27
lib.php

@ -29,27 +29,28 @@ function attforblock_add_instance($attforblock) {
$attforblock->timemodified = time(); $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'); $modnum = get_field('modules', 'id', 'name', 'attforblock');
if (!get_record('course_modules', 'course', $attforblock->course, 'module', $modnum)) { if (!get_record('course_modules', 'course', $attforblock->course, 'module', $modnum)) {
delete_records('attforblock', 'course', $attforblock->course); delete_records('attforblock', 'course', $attforblock->course);
$attforblock->id = insert_record('attforblock', $attforblock); $attforblock->id = insert_record('attforblock', $attforblock);
} else { /*} else {
return false; return false;
} }
} else { } else {*/
$attforblock->id = insert_record('attforblock', $attforblock); $attforblock->id = insert_record('attforblock', $attforblock);
} //}
//Copy statuses for new instance from defaults //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'); $statuses = get_records('attendance_statuses', 'courseid', 0, 'id');
foreach($statuses as $stat) { foreach($statuses as $stat) {
$rec = $stat; $rec = $stat;
$rec->courseid = $attforblock->course; $rec->courseid = $attforblock->course;
$rec->attendanceid = $attforblock->id;
insert_record('attendance_statuses', $rec); insert_record('attendance_statuses', $rec);
} }
} //}
// attforblock_grade_item_update($attforblock); // attforblock_grade_item_update($attforblock);
// attforblock_update_grades($attforblock); // attforblock_update_grades($attforblock);
@ -165,11 +166,11 @@ function attforblock_user_outline($course, $user, $mod, $attforblock) {
require_once('locallib.php'); require_once('locallib.php');
if (isstudent($course->id, $user->id)) { 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'); $strgrade = get_string('grade');
$maxgrade = get_maxgrade($user->id, $course); $maxgrade = get_maxgrade($user->id, $course,$attforblock);
$usergrade = get_grade($user->id, $course); $usergrade = get_grade($user->id, $course,$attforblock);
$percent = get_percent($user->id,$course); $percent = get_percent($user->id,$course, $attforblock);
$result->info = "$strgrade: $usergrade / $maxgrade ($percent%)"; $result->info = "$strgrade: $usergrade / $maxgrade ($percent%)";
} }
} }
@ -229,13 +230,13 @@ function attforblock_get_user_grades($attforblock, $userid=0) {
if ($userid) { if ($userid) {
$result = array(); $result = array();
$result[$userid]->userid = $userid; $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 { } else {
if ($students = get_course_students($course->id)) { if ($students = get_course_students($course->id)) {
$result = array(); $result = array();
foreach ($students as $student) { foreach ($students as $student) {
$result[$student->id]->userid = $student->id; $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{ }else{
// MDL-14303 // MDL-14303
$cm = get_coursemodule_from_instance('attforblock', $attforblock->id); $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) { if ($attforblock->grade > 0) {

65
locallib.php

@ -46,12 +46,12 @@ function show_tabs($cm, $context, $currenttab='sessions')
//getting settings for course //getting settings for course
function get_statuses($courseid, $onlyvisible = true) function get_statuses($attendanceid, $onlyvisible = true)
{ {
if ($onlyvisible) { 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 { } 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'); // $result = get_records('attendance_statuses', 'courseid', $courseid, 'grade DESC');
} }
return $result; return $result;
@ -59,14 +59,14 @@ function get_statuses($courseid, $onlyvisible = true)
//gets attendance status for a student, returns count //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; global $CFG;
$qry = "SELECT count(*) as cnt $qry = "SELECT count(*) as cnt
FROM {$CFG->prefix}attendance_log al FROM {$CFG->prefix}attendance_log al
JOIN {$CFG->prefix}attendance_sessions ats JOIN {$CFG->prefix}attendance_sessions ats
ON al.sessionid = ats.id ON al.sessionid = ats.id
WHERE ats.courseid = $course->id WHERE ats.attendanceid = $attendance->id
AND ats.sessdate >= $course->startdate AND ats.sessdate >= $course->startdate
AND al.studentid = $userid"; AND al.studentid = $userid";
if ($statusid) { if ($statusid) {
@ -76,7 +76,7 @@ function get_attendance($userid, $course, $statusid=0)
return count_records_sql($qry); return count_records_sql($qry);
} }
function get_grade($userid, $course) function get_grade($userid, $course, $attendance)
{ {
global $CFG; global $CFG;
$logs = get_records_sql("SELECT l.id, l.statusid, l.statusset $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 ON l.sessionid = s.id
WHERE l.studentid = $userid WHERE l.studentid = $userid
AND s.courseid = $course->id AND s.courseid = $course->id
AND s.attendanceid = $attendance->id
AND s.sessdate >= $course->startdate"); AND s.sessdate >= $course->startdate");
$result = 0; $result = 0;
if ($logs) { 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) { foreach ($logs as $log) {
$result += $stat_grades[$log->statusid]; $result += $stat_grades[$log->statusid];
} }
@ -108,7 +109,7 @@ function local_array_intersect_key($array1, $array2) {
return $result; return $result;
} }
function get_maxgrade($userid, $course) function get_maxgrade($userid, $course, $attendance)
{ {
global $CFG; global $CFG;
$logs = get_records_sql("SELECT l.id, l.statusid, l.statusset $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 ON l.sessionid = s.id
WHERE l.studentid = $userid WHERE l.studentid = $userid
AND s.courseid = $course->id AND s.courseid = $course->id
AND s.attendanceid = $attendance->id
AND s.sessdate >= $course->startdate"); AND s.sessdate >= $course->startdate");
$maxgrade = 0; $maxgrade = 0;
if ($logs) { 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) { foreach ($logs as $log) {
$ids = array_flip(explode(',', $log->statusset)); $ids = array_flip(explode(',', $log->statusset));
// $grades = array_intersect_key($stat_grades, $ids); // require PHP 5.1.0 and higher // $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); return sprintf("%0.{$dp}f", $result);
} }
function get_percent($userid, $course) function get_percent($userid, $course, $attforblock)
{ {
global $CFG; global $CFG;
$maxgrd = get_maxgrade($userid, $course); $maxgrd = get_maxgrade($userid, $course, $attforblock);
if ($maxgrd == 0) { if ($maxgrd == 0) {
$result = 0; $result = 0;
} else { } else {
$result = get_grade($userid, $course) / $maxgrd * 100; $result = get_grade($userid, $course, $attforblock) / $maxgrd * 100;
} }
if ($result < 0) { if ($result < 0) {
$result = 0; $result = 0;
@ -218,20 +220,20 @@ function print_row($left, $right) {
function print_attendance_table($user, $course, $attforblock) { function print_attendance_table($user, $course, $attforblock) {
$complete = get_attendance($user->id, $course); $complete = get_attendance($user->id, $course, $attforblock);
echo '<table border="0" cellpadding="0" cellspacing="0" class="list">'; echo '<table border="0" cellpadding="0" cellspacing="0" class="list">';
print_row(get_string('sessionscompleted','attforblock').':', "<strong>$complete</strong>"); print_row(get_string('sessionscompleted','attforblock').':', "<strong>$complete</strong>");
$statuses = get_statuses($course->id); $statuses = get_statuses($attforblock->id);
foreach($statuses as $st) { foreach($statuses as $st) {
print_row($st->description.': ', '<strong>'.get_attendance($user->id, $course, $st->id).'</strong>'); print_row($st->description.': ', '<strong>'.get_attendance($user->id, $course, $attforblock, $st->id).'</strong>');
} }
if ($attforblock->grade) { if ($attforblock->grade) {
$percent = get_percent($user->id, $course).'&nbsp;%'; $percent = get_percent($user->id, $course, $attforblock).'&nbsp;%';
$grade = get_grade($user->id, $course); $grade = get_grade($user->id, $course, $attforblock);
print_row(get_string('attendancepercent','attforblock').':', "<strong>$percent</strong>"); print_row(get_string('attendancepercent','attforblock').':', "<strong>$percent</strong>");
print_row(get_string('attendancegrade','attforblock').':', "<strong>$grade</strong> / ".get_maxgrade($user->id, $course)); print_row(get_string('attendancegrade','attforblock').':', "<strong>$grade</strong> / ".get_maxgrade($user->id, $course, $attforblock));
} }
print_row('&nbsp;', '&nbsp;'); print_row('&nbsp;', '&nbsp;');
echo '</table>'; echo '</table>';
@ -260,30 +262,31 @@ function print_user_attendaces($user, $cm, $attforblock, $course = 0, $printing
echo '<font size="+1"><b>'.fullname($user).'</b></font>'; echo '<font size="+1"><b>'.fullname($user).'</b></font>';
if ($course) { if ($course) {
echo '<hr />'; echo '<hr />';
$complete = get_attendance($user->id, $course); $complete = get_attendance($user->id, $course, $attforblock);
if($complete) { if($complete) {
print_attendance_table($user, $course, $attforblock); print_attendance_table($user, $course, $attforblock);
} else { } else {
echo get_string('attendancenotstarted','attforblock'); echo get_string('attendancenotstarted','attforblock');
} }
} else { } 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 FROM {$CFG->prefix}attendance_log al
JOIN {$CFG->prefix}attendance_sessions ats JOIN {$CFG->prefix}attendance_sessions ats
ON al.sessionid = ats.id ON al.sessionid = ats.id
WHERE al.studentid = {$user->id} WHERE al.studentid = {$user->id}
GROUP BY ats.courseid GROUP BY cid
ORDER BY ats.courseid asc"; ORDER BY cid,aid asc";
$recs = get_records_sql_menu($stqry); $recs = get_records_sql($stqry);
foreach ($recs as $id => $courseid) { foreach ($recs as $rec) {
echo '<hr />'; echo '<hr />';
echo '<table border="0" cellpadding="0" cellspacing="0" width="100%" class="list1">'; echo '<table border="0" cellpadding="0" cellspacing="0" width="100%" class="list1">';
$nextcourse = get_record('course', 'id', $courseid); $nextcourse = get_record('course', 'id', $rec['cid']);
echo '<tr><td valign="top"><strong>'.$nextcourse->fullname.'</strong></td>'; $nextattendance = get_record('attforblock', 'id', $rec['aid']);
echo '<tr><td valign="top"><strong>'.$nextcourse->fullname.' - '.$nextattendance->name . '</strong></td>';
echo '<td align="right">'; echo '<td align="right">';
$complete = get_attendance($user->id, $nextcourse); $complete = get_attendance($user->id, $nextcourse, $nextattendance);
if($complete) { if($complete) {
print_attendance_table($user, $nextcourse, $attforblock); print_attendance_table($user, $nextcourse, $nextattendance);
} else { } else {
echo get_string('attendancenotstarted','attforblock'); echo get_string('attendancenotstarted','attforblock');
} }
@ -304,9 +307,9 @@ function print_user_attendaces($user, $cm, $attforblock, $course = 0, $printing
$enddate = $ret['enddate']; $enddate = $ret['enddate'];
if ($startdate && $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 { } 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 $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"; $stqry .= " ORDER BY ats.sessdate asc";
if ($sessions = get_records_sql($stqry)) { if ($sessions = get_records_sql($stqry)) {
$statuses = get_statuses($course->id); $statuses = get_statuses($attforblock->id);
$i = 0; $i = 0;
$table->head = array('#', get_string('date'), get_string('time'), get_string('description','attforblock'), get_string('status','attforblock'), get_string('remarks','attforblock')); $table->head = array('#', get_string('date'), get_string('time'), get_string('description','attforblock'), get_string('status','attforblock'), get_string('remarks','attforblock'));

25
manage.php

@ -10,7 +10,7 @@
$from = optional_param('from', PARAM_ACTION); $from = optional_param('from', PARAM_ACTION);
$view = optional_param('view', NULL, PARAM_ALPHA); // which page to show $view = optional_param('view', NULL, PARAM_ALPHA); // which page to show
$current = optional_param('current', 0, PARAM_INT); $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)) { if (! $cm = get_record('course_modules', 'id', $id)) {
error('Course Module ID was incorrect'); error('Course Module ID was incorrect');
} }
@ -44,13 +44,15 @@
redirect("view.php?id=$cm->id"); 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 teacher is coming from block, then check for a session exists for today
if($from === 'block') { if($from === 'block') {
$today = time(); // because we compare with database, we don't need to use usertime() $today = time(); // because we compare with database, we don't need to use usertime()
$sql = "SELECT id, groupid, lasttaken $sql = "SELECT id, groupid, lasttaken
FROM {$CFG->prefix}attendance_sessions FROM {$CFG->prefix}attendance_sessions
WHERE $today BETWEEN sessdate AND (sessdate + duration) 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)) { if($atts = get_records_sql($sql)) {
$size = count($atts); $size = count($atts);
if ($size == 1) { if ($size == 1) {
@ -76,23 +78,23 @@
print_heading(get_string('attendanceforthecourse','attforblock').' :: ' .$course->fullname); 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); show_tabs($cm, $context);
print_heading(get_string('nosessionexists','attforblock')); 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 '<div align="left">'.helpbutton('hiddensessions', '', 'attforblock', true, true, '', true); echo '<div align="left">'.helpbutton('hiddensessions', '', 'attforblock', true, true, '', true);
echo get_string('hiddensessions', 'attforblock').': '.$hiddensess.'</div>'; echo get_string('hiddensessions', 'attforblock').': '.$hiddensess.'</div>';
} else { //sessions generated , display them } else { //sessions generated , display them
add_to_log($course->id, 'attendance', 'manage attendances', 'mod/attforblock/manage.php?course='.$course->id, $user->lastname.' '.$user->firstname); add_to_log($course->id, 'attendance', 'manage attendances', 'mod/attforblock/manage.php?course='.$course->id, $user->lastname.' '.$user->firstname);
show_tabs($cm, $context); show_tabs($cm, $context);
print_sessions_list($course); print_sessions_list($course, $attforblock);
} }
// require_once('lib.php'); // require_once('lib.php');
// $t = attforblock_get_user_grades($attforblock); //////////////////////////////////////////// // $t = attforblock_get_user_grades($attforblock); ////////////////////////////////////////////
print_footer($course); print_footer($course);
function print_sessions_list($course) { function print_sessions_list($course, $attforblock) {
global $CFG, $context, $cm, $current, $view, $id; global $CFG, $context, $cm, $current, $view, $id;
$strhours = get_string('hours'); $strhours = get_string('hours');
@ -109,9 +111,9 @@ function print_sessions_list($course) {
$currentgroup = $ret['currentgroup']; $currentgroup = $ret['currentgroup'];
if ($startdate && $enddate) { 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 { } else {
$where = "courseid={$course->id} AND sessdate >= $course->startdate"; $where = "courseid={$course->id} AND attendanceid = $attforblock->id AND sessdate >= $course->startdate";
} }
if ($currentgroup > -1) { if ($currentgroup > -1) {
@ -122,7 +124,7 @@ function print_sessions_list($course) {
$i = 0; $i = 0;
$table->width = '100%'; $table->width = '100%';
//$table->tablealign = 'center'; //$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->align = array('', '', '', 'right', 'left', 'center', 'center');
$table->size = array('1px', '', '1px', '1px', '1px', '*', '1px', '1px'); $table->size = array('1px', '', '1px', '1px', '1px', '*', '1px', '1px');
@ -170,17 +172,18 @@ function print_sessions_list($course) {
$hours = floor($sessdata->duration / HOURSECS); $hours = floor($sessdata->duration / HOURSECS);
$mins = floor(($sessdata->duration - $hours * HOURSECS) / MINSECS); $mins = floor(($sessdata->duration - $hours * HOURSECS) / MINSECS);
$mins = $mins < 10 ? "0$mins" : "$mins"; $mins = $mins < 10 ? "0$mins" : "$mins";
$table->data[$sessdata->id][] = $hours ? "{$hours}&nbsp;{$strhours}&nbsp;{$mins}&nbsp;{$strmins}" : "{$mins}&nbsp;{$strmins}"; $table->data[$sessdata->id][] = ($showendtime=='0') ? ($hours ? "{$hours}&nbsp;{$strhours}&nbsp;{$mins}&nbsp;{$strmins}" : "{$mins}&nbsp;{$strmins}") : userdate($sessdata->sessdate+$sessdata->duration, get_string('strftimehm', 'attforblock'));;
$table->data[$sessdata->id][] = $desc; $table->data[$sessdata->id][] = $desc;
$table->data[$sessdata->id][] = $actions; $table->data[$sessdata->id][] = $actions;
$table->data[$sessdata->id][] = '<input type="checkbox" name="sessid['.$sessdata->id.']" />'; $table->data[$sessdata->id][] = '<input type="checkbox" name="sessid['.$sessdata->id.']" />';
unset($desc, $actions); unset($desc, $actions);
} }
} }
echo '<div align="center"><div class="generalbox attwidth">'; echo '<div align="center"><div class="generalbox attwidth">';
echo "<form method=\"post\" action=\"sessions.php?id={$cm->id}\">"; //&amp;sessionid={$sessdata->id} echo "<form method=\"post\" action=\"sessions.php?id={$cm->id}\">"; //&amp;sessionid={$sessdata->id}
print_table($table); 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 '<table width="100%"><tr><td valign="top">'; echo '<table width="100%"><tr><td valign="top">';
echo '<div align="left">'.helpbutton('hiddensessions', '', 'attforblock', true, true, '', true); echo '<div align="left">'.helpbutton('hiddensessions', '', 'attforblock', true, true, '', true);
echo get_string('hiddensessions', 'attforblock').': '.$hiddensess.'</div></td>'; echo get_string('hiddensessions', 'attforblock').': '.$hiddensess.'</div></td>';

4
mod_form.php

@ -21,10 +21,6 @@ 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);
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------

16
report.php

@ -60,7 +60,7 @@
$sort = $sort == 'firstname' ? 'firstname' : 'lastname'; $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&amp;action=add"); redirect("sessions.php?id=$cm->id&amp;action=add");
} else { } else {
if ($current == 0) if ($current == 0)
@ -74,9 +74,9 @@
$currentgroup = $ret['currentgroup']; $currentgroup = $ret['currentgroup'];
if ($startdate && $enddate) { 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 { } else {
$where = "courseid={$course->id} AND sessdate >= $course->startdate"; $where = "courseid={$course->id} AND attendanceid = {$attforblock->id} AND sessdate >= $course->startdate";
} }
if ($currentgroup) { if ($currentgroup) {
@ -86,8 +86,8 @@
$students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', '', '', false); $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', '', '', false);
} }
$statuses = get_statuses($course->id); $statuses = get_statuses($attforblock->id);
$allstatuses = get_statuses($course->id, false); $allstatuses = get_statuses($attforblock->id, false);
if ($students and if ($students and
@ -176,11 +176,11 @@
} }
} }
foreach($statuses as $st) { 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) { if ($attforblock->grade) {
$table->data[$student->id][] = get_grade($student->id, $course).'&nbsp;/&nbsp;'.get_maxgrade($student->id, $course); $table->data[$student->id][] = get_grade($student->id, $course, $attforblock).'&nbsp;/&nbsp;'.get_maxgrade($student->id, $course, $attforblock);
$table->data[$student->id][] = get_percent($student->id, $course).'%'; $table->data[$student->id][] = get_percent($student->id, $course, $attforblock).'%';
} }
} }
print_table($table); print_table($table);

12
restorelib.php

@ -13,9 +13,9 @@
//Now get completed xmlized object //Now get completed xmlized object
$info = $data->info; $info = $data->info;
if (count_records('attforblock', 'course', $restore->course_id)) { /*if (count_records('attforblock', 'course', $restore->course_id)) {
return false; return false;
} }*/
//Now, build the attforblock record structure //Now, build the attforblock record structure
$attforblock->course = $restore->course_id; $attforblock->course = $restore->course_id;
@ -67,6 +67,7 @@
//Now, build the attforblock_SESSIONS record structure //Now, build the attforblock_SESSIONS record structure
$stat->courseid = $restore->course_id; $stat->courseid = $restore->course_id;
$stat->attendanceid = $new_attforblock_id;
$stat->groupid = backup_todb($stat_info['#']['GROUPID']['0']['#']); $stat->groupid = backup_todb($stat_info['#']['GROUPID']['0']['#']);
$group = restore_group_getid($restore, $stat->groupid); $group = restore_group_getid($restore, $stat->groupid);
if ($group) { if ($group) {
@ -117,6 +118,7 @@
//Now, build the attforblock_STATUS record structure //Now, build the attforblock_STATUS record structure
$stat->courseid = $restore->course_id; $stat->courseid = $restore->course_id;
$stat->attendanceid = $new_attforblock_id;
$stat->acronym = backup_todb($stat_info['#']['ACRONYM']['0']['#']); $stat->acronym = backup_todb($stat_info['#']['ACRONYM']['0']['#']);
$stat->description = backup_todb($stat_info['#']['DESCRIPTION']['0']['#']); $stat->description = backup_todb($stat_info['#']['DESCRIPTION']['0']['#']);
$stat->grade = backup_todb($stat_info['#']['GRADE']['0']['#']); $stat->grade = backup_todb($stat_info['#']['GRADE']['0']['#']);
@ -139,6 +141,7 @@
//Now, build the attforblock_STATUS record structure //Now, build the attforblock_STATUS record structure
$stat->courseid = $restore->course_id; $stat->courseid = $restore->course_id;
$stat->attendanceid = $new_attforblock_id;
$stat->acronym = backup_todb($stat_info['#']['ACRONYM']['0']['#']); $stat->acronym = backup_todb($stat_info['#']['ACRONYM']['0']['#']);
$stat->description = backup_todb($stat_info['#']['DESCRIPTION']['0']['#']); $stat->description = backup_todb($stat_info['#']['DESCRIPTION']['0']['#']);
$stat->grade = backup_todb($stat_info['#']['GRADE']['0']['#']); $stat->grade = backup_todb($stat_info['#']['GRADE']['0']['#']);
@ -159,6 +162,7 @@
foreach($stats as $stat) { foreach($stats as $stat) {
// $stat = $stats[$i]; // $stat = $stats[$i];
$stat->courseid = $restore->course_id; $stat->courseid = $restore->course_id;
$stat->attendanceid = $new_attforblock_id;
$newid = insert_record('attendance_statuses', $stat); $newid = insert_record('attendance_statuses', $stat);
$oldidarray[$old_attforblock_id]['attendance_statuses'][$oldstats[$i++]] = $newid; $oldidarray[$old_attforblock_id]['attendance_statuses'][$oldstats[$i++]] = $newid;
// $i++; // $i++;
@ -182,9 +186,9 @@
@$logs = $info['MOD']['#']['ATTFORBLOCK_LOG']['0']['#']['ROWS']; @$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)); $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 //Iterate over logs
for($i = 0; $i < sizeof($logs); $i++) { for($i = 0; $i < sizeof($logs); $i++) {

5
sessions.php

@ -60,6 +60,7 @@
if (isset($fromform->addmultiply)) { if (isset($fromform->addmultiply)) {
$startdate = $fromform->sessiondate;// + $fromform->stime['hour']*3600 + $fromform->stime['minute']*60; $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 $enddate = $fromform->sessionenddate + ONE_DAY; // because enddate in 0:0am
//get number of days //get number of days
@ -91,7 +92,8 @@
// continue; // continue;
// } // }
$rec->courseid = $course->id; $rec->courseid = $course->id;
$rec->sessdate = $sdate; $rec->attendanceid = $attforblock->id;
$rec->sessdate = usergetmidnight($sdate) + $starttime;
$rec->duration = $duration; $rec->duration = $duration;
$rec->description = $fromform->sdescription; $rec->description = $fromform->sdescription;
$rec->timemodified = $now; $rec->timemodified = $now;
@ -117,6 +119,7 @@
} else { } else {
// insert one session // insert one session
$rec->courseid = $course->id; $rec->courseid = $course->id;
$rec->attendanceid = $attforblock->id;
$rec->sessdate = $fromform->sessiondate; $rec->sessdate = $fromform->sessiondate;
$rec->duration = $duration; $rec->duration = $duration;
$rec->description = $fromform->sdescription; $rec->description = $fromform->sdescription;

2
styles.php

File diff suppressed because one or more lines are too long

2
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 = 2010122900; // The current module version (Date: YYYYMMDDXX) $module->version = 2010123003; // The current module version (Date: YYYYMMDDXX)
$module->release = '2.2.1'; $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