diff --git a/CHANGES b/CHANGES index 539e39a..9836631 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,15 @@ +2011-01-18 lrlopez + + * attendances.php: styles.php: + + Implemented copy attendance data from same-day sessions. + Fixed fast session dropdown list end time inaccuracy. + Enhanced session dropdown list. + + * lang/: en_utf8/attforblock.php, es_utf8/attforblock.php: + + Added new strings for the copy dropdown menus. + 2011-01-18 lrlopez * attendances.php: styles.php: diff --git a/attendances.php b/attendances.php index e4ec70f..0927945 100644 --- a/attendances.php +++ b/attendances.php @@ -16,6 +16,7 @@ $grouptype = required_param('grouptype', PARAM_INT); $group = optional_param('group', -1, PARAM_INT); // Group to show $sort = optional_param('sort','lastname', PARAM_ALPHA); + $copyfrom = optional_param('copyfrom', -1, PARAM_INT); if (! $cm = get_record('course_modules', 'id', $id)) { error('Course Module ID was incorrect'); @@ -109,25 +110,29 @@ $gridcols = optional_param('gridcols', get_user_preferences("attforblock_gridcolumns",5), PARAM_INT); echo ''; //echo '
'; $options = array (SORTEDLISTVIEW => get_string('sortedlist','attforblock'), SORTEDGRIDVIEW => get_string('sortedgrid','attforblock')); - $data = "attendances.php?id=$id&grouptype=$grouptype&gridcols=$gridcols"; + $dataurl = "attendances.php?id=$id&grouptype=$grouptype&gridcols=$gridcols"; if ($group!=-1) { - $data = $data . "&group=$group"; + $dataurl = $dataurl . "&group=$group"; } $today = usergetmidnight($sessdata->sessdate); $select = "sessdate>={$today} AND sessdate<{$today}+86400 AND attendanceid={$cm->instance}"; - $sessions = get_records_select('attendance_sessions', $select, 'sessdate ASC'); + $todaysessions = get_records_select('attendance_sessions', $select, 'sessdate ASC'); $optionssesions = array(); - if (count($sessions)>1) { + if (count($todaysessions)>1) { echo '
"; } - $data .= "&sessionid=$sessionid"; + $dataurl .= "&sessionid=$sessionid"; echo '
"; - foreach($sessions as $sessdatarow) { - $optionssessions[$sessdatarow->id] = userdate($sessdatarow->sessdate, get_string('strftimehm', 'attforblock')) . "-" . userdate($sessdatarow->sessdate+$sessdata->duration, get_string('strftimehm', 'attforblock')); + foreach($todaysessions as $sessdatarow) { + $descr = userdate($sessdatarow->sessdate, get_string('strftimehm', 'attforblock')) . "-" . userdate($sessdatarow->sessdate+$sessdatarow->duration, get_string('strftimehm', 'attforblock')); + if ($sessdatarow->description) { + $descr = $sessdatarow->description . ' ('.$descr.')'; + } + $optionssessions[$sessdatarow->id] = $descr; } - popup_form("$data&sessionid=", $optionssessions, 'fastsessionmenu', $sessionid, ''); + popup_form("$dataurl&sessionid=", $optionssessions, 'fastsessionmenu', $sessionid, ''); echo "
"; - popup_form("$data&view=", $options, 'viewmenu', $view, ''); + popup_form("$dataurl&view=", $options, 'viewmenu', $view, ''); if ($view == SORTEDGRIDVIEW) { set_user_preference("attforblock_viewmode", $view); set_user_preference("attforblock_gridcolumns", $gridcols); @@ -135,11 +140,8 @@ '4 '.get_string('columns','attforblock'),'5 '.get_string('columns','attforblock'),'6 '.get_string('columns','attforblock'), '7 '.get_string('columns','attforblock'),'8 '.get_string('columns','attforblock'),'9 '.get_string('columns','attforblock'), '10 '.get_string('columns','attforblock')); - $data = "attendances.php?id=$id&sessionid=$sessionid&grouptype=$grouptype&view=$view"; - if ($group!=-1) { - $data = $data . "&group=$group"; - } - popup_form("$data&gridcols=", $options, 'colsmenu', $gridcols, ''); + $dataurl .= "&view=$view"; + popup_form("$dataurl&gridcols=", $options, 'colsmenu', $gridcols, ''); } echo '
';//'; if ($grouptype === 0) { @@ -163,7 +165,7 @@ $table->data[][] = ''.get_string('sessiondate','attforblock').': '.userdate($sessdata->sessdate, get_string('strftimedate').', '.get_string('strftimehm', 'attforblock')). ', "'.($sessdata->description ? $sessdata->description : get_string('nodescription', 'attforblock')).'"'; print_table($table); - + $statuses = get_statuses($attforblock->id); $i = 3; foreach($statuses as $st) { @@ -177,7 +179,7 @@ } $i++; } - if ($view == SORTEDLISTVIEW) { + if ($view == SORTEDLISTVIEW) { $tabhead[] = get_string('remarks','attforblock'); } @@ -247,11 +249,12 @@ $i = 0; foreach($students as $student) { $i++; - $att = get_record('attendance_log', 'sessionid', $sessionid, 'studentid', $student->id); - + $copyid = ($copyfrom == "-1") ? $sessionid : $copyfrom; + $att = get_record('attendance_log', 'sessionid', $copyid, 'studentid', $student->id); + $currentstatusid = $att===false ? -1 : $att->statusid; $data = "" . print_user_picture($student, $course->id, $student->picture, true, true, '', fullname($student)) . "
" . fullname($student) . "
";//, $returnstring=false, $link=true, $target=''); foreach($statuses as $st) { - $data = $data . 'id == $att->statusid ? 'checked' : '').'>' . $st->acronym . " "; + $data = $data . 'id == $currentstatusid ? 'checked' : '').'>' . $st->acronym . " "; } $table->data[($i-1) / ($gridcols)][] = $data; } @@ -266,7 +269,15 @@ echo ''; echo '
'; echo ''; - } else { + + if (count($todaysessions)>1) { + echo '
'; + echo '"; + popup_form("$dataurl©from=", $optionssessions, 'copysessionmenu', $sessionid, ''); + echo '
'; + } + + } else { print_heading(get_string('nothingtodisplay'), 'center'); } diff --git a/lang/en_utf8/attforblock.php b/lang/en_utf8/attforblock.php index e59f567..93acf7a 100644 --- a/lang/en_utf8/attforblock.php +++ b/lang/en_utf8/attforblock.php @@ -44,6 +44,7 @@ $string['columns'] = 'columns'; $string['commonsession'] = 'Common'; $string['commonsessions'] = 'Common'; $string['countofselected'] = 'Count of selected'; +$string['copyfrom'] = 'Copy attendance data from'; $string['createmultiplesessions'] = 'Create multiple sessions'; $string['createonesession'] = 'Create one session for the course'; $string['days'] = 'Day'; diff --git a/lang/es_utf8/attforblock.php b/lang/es_utf8/attforblock.php index 9b284e1..5e8ccab 100644 --- a/lang/es_utf8/attforblock.php +++ b/lang/es_utf8/attforblock.php @@ -44,6 +44,7 @@ $string['columns'] = 'columnas'; $string['commonsession'] = 'Común'; $string['commonsessions'] = 'Comunes'; $string['countofselected'] = 'Recuento de selección'; +$string['copyfrom'] = 'Copiar asistencia desde'; $string['createmultiplesessions'] = 'Crear varias sesiones'; $string['createonesession'] = 'Crear una sesión para el curso'; $string['days'] = 'Hoy'; diff --git a/styles.php b/styles.php index de8e8df..1f9e1d8 100644 --- a/styles.php +++ b/styles.php @@ -28,10 +28,7 @@ body#mod-attforblock-attendances table.controls { width: 100%; -} - -body#mod-attforblock-attendances table.controls { - width: 100%; + text-align: center; } body#mod-attforblock-attendances table.controls tr {