diff --git a/CHANGES b/CHANGES index 1c6da13..44ca102 100644 --- a/CHANGES +++ b/CHANGES @@ -1,7 +1,29 @@ -2010-12-29 - 2010-12-30 lrlopez +2010-12-30 - 2011-01-04 lrlopez - * db/install.xml: - * db/upgrade.php: + * lang/: es_utf8/attforblock.php: + + Updated and fixed Spanish translation (Enrique Robredo) + + * styles.php: + + Fixed yui-calendar CSS modifying global CSS behaviour. + + * manage.php: + + Added an option for choosing between show session duration or show end + time in session list. + + * db/: install.xml: upgrade.php: version.php: + * attsettings.php: lib.php: locallib.php: manage.php: report.php: + + Added support to allow more than one attendance in the same course. + + * sessions.php: + + Fixed DST bug (adding multiple sessions could generate invalid start + times if any DST change occur in-between) + + * attendances.php: Implemented display modes (list and grid) * lang/: en_utf8/attforblock.php, es_utf8/attforblock.php: diff --git a/attendances.php b/attendances.php index 7c5aa6d..9f04b38 100644 --- a/attendances.php +++ b/attendances.php @@ -38,7 +38,7 @@ print_error('badcontext'); } - $statlist = implode(',', array_keys( (array)get_statuses($course->id) )); + $statlist = implode(',', array_keys( (array)get_statuses($attforblock->id) )); if ($form = data_submitted()) { $students = array(); // stores students ids $formarr = (array)$form; @@ -105,15 +105,28 @@ // 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); + $view = optional_param('view', get_user_preferences("attforblock_viewmode",0), PARAM_INT); + $gridcols = optional_param('gridcols', get_user_preferences("attforblock_gridcolumns",5), PARAM_INT); echo '
Asistencia
+Ocultar sesiones
++ dirroot.'/mod/attforblock/version.php'); + echo get_string('version').": $module->release ($module->version)"; + unset($module); + $module = $temp; + ?> +
+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.
+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.
diff --git a/lang/es_utf8/help/attforblock/sessiontypes.html b/lang/es_utf8/help/attforblock/sessiontypes.html new file mode 100644 index 0000000..99f35c9 --- /dev/null +++ b/lang/es_utf8/help/attforblock/sessiontypes.html @@ -0,0 +1,17 @@ +Asistencia
++ dirroot.'/mod/attforblock/version.php'); + echo get_string('version').": $module->release ($module->version)"; + unset($module); + $module = $temp; + ?> +
+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.
+Modo de grupo "No hay grupos" únicamente se pueden elegir sesiones comunes.
+Modo de grupo "Grupos visible" es posible elegir sesiones grupales o comunes.
+Modo de grupo "Grupos Separados" únicamente es posible elegir sesiones grupales.
+En caso de que fuese necesario, es posible seleccionar varios grupos simultáneos o alternos utilizando la tecla ctrl
diff --git a/lib.php b/lib.php index e1bc832..5a2f987 100644 --- a/lib.php +++ b/lib.php @@ -29,27 +29,28 @@ function attforblock_add_instance($attforblock) { $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'); if (!get_record('course_modules', 'course', $attforblock->course, 'module', $modnum)) { delete_records('attforblock', 'course', $attforblock->course); $attforblock->id = insert_record('attforblock', $attforblock); - } else { + /*} else { return false; } - } else { + } else {*/ $attforblock->id = insert_record('attforblock', $attforblock); - } + //} //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'); foreach($statuses as $stat) { $rec = $stat; $rec->courseid = $attforblock->course; + $rec->attendanceid = $attforblock->id; insert_record('attendance_statuses', $rec); } - } + //} // attforblock_grade_item_update($attforblock); // attforblock_update_grades($attforblock); @@ -165,11 +166,11 @@ function attforblock_user_outline($course, $user, $mod, $attforblock) { require_once('locallib.php'); if (isstudent($course->id, $user->id)) { - if ($sescount = get_attendance($user->id,$course)) { + if ($sescount = get_attendance($user->id,$course, $attforblock)) { $strgrade = get_string('grade'); - $maxgrade = get_maxgrade($user->id, $course); - $usergrade = get_grade($user->id, $course); - $percent = get_percent($user->id,$course); + $maxgrade = get_maxgrade($user->id, $course,$attforblock); + $usergrade = get_grade($user->id, $course,$attforblock); + $percent = get_percent($user->id,$course, $attforblock); $result->info = "$strgrade: $usergrade / $maxgrade ($percent%)"; } } @@ -229,13 +230,13 @@ function attforblock_get_user_grades($attforblock, $userid=0) { if ($userid) { $result = array(); $result[$userid]->userid = $userid; - $result[$userid]->rawgrade = $attforblock->grade * get_percent($userid, $course) / 100; + $result[$userid]->rawgrade = $attforblock->grade * get_percent($userid, $course, $attforblock) / 100; } else { if ($students = get_course_students($course->id)) { $result = array(); foreach ($students as $student) { $result[$student->id]->userid = $student->id; - $result[$student->id]->rawgrade = $attforblock->grade * get_percent($student->id, $course) / 100; + $result[$student->id]->rawgrade = $attforblock->grade * get_percent($student->id, $course, $attforblock) / 100; } } } @@ -313,7 +314,7 @@ function attforblock_grade_item_update($attforblock, $grades=NULL) { }else{ // MDL-14303 $cm = get_coursemodule_from_instance('attforblock', $attforblock->id); - $params = array('itemname'=>$attforblock->name, 'idnumber'=>$cm->id); + $params = array('itemname'=>$attforblock->name/*, 'idnumber'=>$attforblock->id*/); } if ($attforblock->grade > 0) { diff --git a/locallib.php b/locallib.php index 1f42c6c..9114c09 100644 --- a/locallib.php +++ b/locallib.php @@ -46,12 +46,12 @@ function show_tabs($cm, $context, $currenttab='sessions') //getting settings for course -function get_statuses($courseid, $onlyvisible = true) +function get_statuses($attendanceid, $onlyvisible = true) { 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 { - $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'); } return $result; @@ -59,14 +59,14 @@ function get_statuses($courseid, $onlyvisible = true) //gets attendance status for a student, returns count -function get_attendance($userid, $course, $statusid=0) +function get_attendance($userid, $course, $attendance, $statusid=0) { global $CFG; $qry = "SELECT count(*) as cnt FROM {$CFG->prefix}attendance_log al JOIN {$CFG->prefix}attendance_sessions ats ON al.sessionid = ats.id - WHERE ats.courseid = $course->id + WHERE ats.attendanceid = $attendance->id AND ats.sessdate >= $course->startdate AND al.studentid = $userid"; if ($statusid) { @@ -76,7 +76,7 @@ function get_attendance($userid, $course, $statusid=0) return count_records_sql($qry); } -function get_grade($userid, $course) +function get_grade($userid, $course, $attendance) { global $CFG; $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 WHERE l.studentid = $userid AND s.courseid = $course->id + AND s.attendanceid = $attendance->id AND s.sessdate >= $course->startdate"); $result = 0; 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) { $result += $stat_grades[$log->statusid]; } @@ -108,7 +109,7 @@ function local_array_intersect_key($array1, $array2) { return $result; } -function get_maxgrade($userid, $course) +function get_maxgrade($userid, $course, $attendance) { global $CFG; $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 WHERE l.studentid = $userid AND s.courseid = $course->id + AND s.attendanceid = $attendance->id AND s.sessdate >= $course->startdate"); $maxgrade = 0; 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) { $ids = array_flip(explode(',', $log->statusset)); // $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); } -function get_percent($userid, $course) +function get_percent($userid, $course, $attforblock) { global $CFG; - $maxgrd = get_maxgrade($userid, $course); + $maxgrd = get_maxgrade($userid, $course, $attforblock); if ($maxgrd == 0) { $result = 0; } else { - $result = get_grade($userid, $course) / $maxgrd * 100; + $result = get_grade($userid, $course, $attforblock) / $maxgrd * 100; } if ($result < 0) { $result = 0; @@ -218,20 +220,20 @@ function print_row($left, $right) { function print_attendance_table($user, $course, $attforblock) { - $complete = get_attendance($user->id, $course); + $complete = get_attendance($user->id, $course, $attforblock); echo ''.$nextcourse->fullname.' | '; + $nextcourse = get_record('course', 'id', $rec['cid']); + $nextattendance = get_record('attforblock', 'id', $rec['aid']); + echo '|
'.$nextcourse->fullname.' - '.$nextattendance->name . ' | '; echo '';
- $complete = get_attendance($user->id, $nextcourse);
+ $complete = get_attendance($user->id, $nextcourse, $nextattendance);
if($complete) {
- print_attendance_table($user, $nextcourse, $attforblock);
+ print_attendance_table($user, $nextcourse, $nextattendance);
} else {
echo get_string('attendancenotstarted','attforblock');
}
@@ -304,9 +307,9 @@ function print_user_attendaces($user, $cm, $attforblock, $course = 0, $printing
$enddate = $ret['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 {
- $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
@@ -317,7 +320,7 @@ function print_user_attendaces($user, $cm, $attforblock, $course = 0, $printing
$stqry .= " ORDER BY ats.sessdate asc";
if ($sessions = get_records_sql($stqry)) {
- $statuses = get_statuses($course->id);
+ $statuses = get_statuses($attforblock->id);
$i = 0;
$table->head = array('#', get_string('date'), get_string('time'), get_string('description','attforblock'), get_string('status','attforblock'), get_string('remarks','attforblock'));
diff --git a/manage.php b/manage.php
index d61952a..e9acf72 100644
--- a/manage.php
+++ b/manage.php
@@ -10,7 +10,7 @@
$from = optional_param('from', PARAM_ACTION);
$view = optional_param('view', NULL, PARAM_ALPHA); // which page to show
$current = optional_param('current', 0, PARAM_INT);
-
+ $showendtime = optional_param('showendtime', get_user_preferences("attforblock_showendtime",0), PARAM_INT);
if (! $cm = get_record('course_modules', 'id', $id)) {
error('Course Module ID was incorrect');
}
@@ -43,14 +43,16 @@
!has_capability('mod/attforblock:changeattendances', $context)) {
redirect("view.php?id=$cm->id");
}
-
+
+ set_user_preference("attforblock_showendtime",$showendtime);
+
//if teacher is coming from block, then check for a session exists for today
if($from === 'block') {
$today = time(); // because we compare with database, we don't need to use usertime()
$sql = "SELECT id, groupid, lasttaken
FROM {$CFG->prefix}attendance_sessions
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)) {
$size = count($atts);
if ($size == 1) {
@@ -76,23 +78,23 @@
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);
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 ' '.helpbutton('hiddensessions', '', 'attforblock', true, true, '', true);
echo get_string('hiddensessions', 'attforblock').': '.$hiddensess.' ';
} else { //sessions generated , display them
add_to_log($course->id, 'attendance', 'manage attendances', 'mod/attforblock/manage.php?course='.$course->id, $user->lastname.' '.$user->firstname);
show_tabs($cm, $context);
- print_sessions_list($course);
+ print_sessions_list($course, $attforblock);
}
// require_once('lib.php');
// $t = attforblock_get_user_grades($attforblock); ////////////////////////////////////////////
print_footer($course);
-function print_sessions_list($course) {
+function print_sessions_list($course, $attforblock) {
global $CFG, $context, $cm, $current, $view, $id;
$strhours = get_string('hours');
@@ -109,9 +111,9 @@ function print_sessions_list($course) {
$currentgroup = $ret['currentgroup'];
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 {
- $where = "courseid={$course->id} AND sessdate >= $course->startdate";
+ $where = "courseid={$course->id} AND attendanceid = $attforblock->id AND sessdate >= $course->startdate";
}
if ($currentgroup > -1) {
@@ -122,7 +124,7 @@ function print_sessions_list($course) {
$i = 0;
$table->width = '100%';
//$table->tablealign = 'center';
- $table->head = array('#', get_string('sessiontypeshort', 'attforblock'), get_string('date'), get_string('time'), get_string('duration', 'attforblock'), get_string('description','attforblock'), get_string('actions'), get_string('select'));
+ $table->head = array('#', get_string('sessiontypeshort', 'attforblock'), get_string('date'), get_string('from'), ($showendtime=='0') ? get_string('duration', 'attforblock') : get_string('to'), get_string('description','attforblock'), get_string('actions'), get_string('select'));
$table->align = array('', '', '', 'right', 'left', 'center', 'center');
$table->size = array('1px', '', '1px', '1px', '1px', '*', '1px', '1px');
@@ -170,17 +172,18 @@ function print_sessions_list($course) {
$hours = floor($sessdata->duration / HOURSECS);
$mins = floor(($sessdata->duration - $hours * HOURSECS) / MINSECS);
$mins = $mins < 10 ? "0$mins" : "$mins";
- $table->data[$sessdata->id][] = $hours ? "{$hours} {$strhours} {$mins} {$strmins}" : "{$mins} {$strmins}";
+ $table->data[$sessdata->id][] = ($showendtime=='0') ? ($hours ? "{$hours} {$strhours} {$mins} {$strmins}" : "{$mins} {$strmins}") : userdate($sessdata->sessdate+$sessdata->duration, get_string('strftimehm', 'attforblock'));;
$table->data[$sessdata->id][] = $desc;
$table->data[$sessdata->id][] = $actions;
$table->data[$sessdata->id][] = '';
unset($desc, $actions);
}
}
+
echo '';
echo " |