|
@ -95,84 +95,86 @@ |
|
|
function print_sessions_list($course) { |
|
|
function print_sessions_list($course) { |
|
|
global $CFG, $context, $cm, $current, $view, $id; |
|
|
global $CFG, $context, $cm, $current, $view, $id; |
|
|
|
|
|
|
|
|
$strhours = get_string('hours'); |
|
|
$strhours = get_string('hours'); |
|
|
$strmins = get_string('min'); |
|
|
$strmins = get_string('min'); |
|
|
|
|
|
|
|
|
if ($current == 0) |
|
|
|
|
|
$current = get_current_date($course->id); |
|
|
|
|
|
else |
|
|
|
|
|
set_current_date ($course->id, $current); |
|
|
|
|
|
|
|
|
|
|
|
list($startdate, $enddate, $currentgroup) = |
|
|
if ($current == 0) |
|
|
print_filter_controls("manage.php", $id, 0, NULL, SESSION_TYPE_SELECTOR); |
|
|
$current = get_current_date($course->id); |
|
|
|
|
|
else |
|
|
|
|
|
set_current_date ($course->id, $current); |
|
|
|
|
|
|
|
|
if ($startdate && $enddate) { |
|
|
list($startdate, $enddate, $currentgroup) = |
|
|
$where = "courseid={$course->id} AND sessdate >= $course->startdate AND sessdate >= $startdate AND sessdate < $enddate"; |
|
|
print_filter_controls("manage.php", $id, 0, NULL, SESSION_TYPE_SELECTOR); |
|
|
} else { |
|
|
|
|
|
$where = "courseid={$course->id} AND sessdate >= $course->startdate"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($currentgroup > -1) { |
|
|
if ($startdate && $enddate) { |
|
|
$where .= " AND groupid=$currentgroup"; |
|
|
$where = "courseid={$course->id} AND sessdate >= $course->startdate AND sessdate >= $startdate AND sessdate < $enddate"; |
|
|
} |
|
|
} else { |
|
|
|
|
|
$where = "courseid={$course->id} AND sessdate >= $course->startdate"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($currentgroup > -1) { |
|
|
|
|
|
$where .= " AND groupid=$currentgroup"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$qry = get_records_select('attendance_sessions', $where/*"courseid = $course->id AND sessdate >= $course->startdate"*/, 'sessdate asc'); |
|
|
$qry = get_records_select('attendance_sessions', $where, 'sessdate asc'); |
|
|
$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('time'), get_string('duration', 'attforblock'), 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'); |
|
|
|
|
|
|
|
|
$allowtake = has_capability('mod/attforblock:takeattendances', $context); |
|
|
$allowtake = has_capability('mod/attforblock:takeattendances', $context); |
|
|
$allowchange = has_capability('mod/attforblock:changeattendances', $context); |
|
|
$allowchange = has_capability('mod/attforblock:changeattendances', $context); |
|
|
$allowmanage = has_capability('mod/attforblock:manageattendances', $context); |
|
|
$allowmanage = has_capability('mod/attforblock:manageattendances', $context); |
|
|
$groups = groups_get_all_groups($course->id); |
|
|
$groups = groups_get_all_groups($course->id); |
|
|
foreach($qry as $key=>$sessdata) |
|
|
if ($qry) { |
|
|
{ |
|
|
foreach($qry as $key=>$sessdata) |
|
|
$i++; |
|
|
{ |
|
|
$actions = ''; |
|
|
$i++; |
|
|
|
|
|
$actions = ''; |
|
|
// if ($allowtake) { |
|
|
// if ($allowtake) { |
|
|
if($sessdata->lasttaken > 0) //attendance has taken |
|
|
if($sessdata->lasttaken > 0) //attendance has taken |
|
|
{ |
|
|
{ |
|
|
if ($allowchange) { |
|
|
if ($allowchange) { |
|
|
$desc = "<a href=\"attendances.php?id=$cm->id&sessionid={$sessdata->id}&grouptype={$sessdata->groupid}\">". |
|
|
$desc = "<a href=\"attendances.php?id=$cm->id&sessionid={$sessdata->id}&grouptype={$sessdata->groupid}\">". |
|
|
($sessdata->description ? $sessdata->description : get_string('nodescription', 'attforblock')). |
|
|
($sessdata->description ? $sessdata->description : get_string('nodescription', 'attforblock')). |
|
|
'</a>'; |
|
|
'</a>'; |
|
|
} else { |
|
|
} else { |
|
|
$desc = '<i>'.(empty($sessdata->description) ? get_string('nodescription', 'attforblock') : $sessdata->description).'</i>'; |
|
|
$desc = '<i>'.(empty($sessdata->description) ? get_string('nodescription', 'attforblock') : $sessdata->description).'</i>'; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
$desc = empty($sessdata->description) ? get_string('nodescription', 'attforblock') : $sessdata->description; |
|
|
$desc = empty($sessdata->description) ? get_string('nodescription', 'attforblock') : $sessdata->description; |
|
|
if ($allowtake) { |
|
|
if ($allowtake) { |
|
|
$title = get_string('takeattendance','attforblock'); |
|
|
$title = get_string('takeattendance','attforblock'); |
|
|
$actions = "<a title=\"$title\" href=\"attendances.php?id=$cm->id&sessionid={$sessdata->id}&grouptype={$sessdata->groupid}\">". |
|
|
$actions = "<a title=\"$title\" href=\"attendances.php?id=$cm->id&sessionid={$sessdata->id}&grouptype={$sessdata->groupid}\">". |
|
|
"<img src=\"{$CFG->pixpath}/t/go.gif\" alt=\"$title\" /></a> "; |
|
|
"<img src=\"{$CFG->pixpath}/t/go.gif\" alt=\"$title\" /></a> "; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// } |
|
|
// } |
|
|
if($allowmanage) { |
|
|
if($allowmanage) { |
|
|
$title = get_string('editsession','attforblock'); |
|
|
$title = get_string('editsession','attforblock'); |
|
|
$actions .= "<a title=\"$title\" href=\"sessions.php?id=$cm->id&sessionid={$sessdata->id}&action=update\">". |
|
|
$actions .= "<a title=\"$title\" href=\"sessions.php?id=$cm->id&sessionid={$sessdata->id}&action=update\">". |
|
|
"<img src=\"{$CFG->pixpath}/t/edit.gif\" alt=\"$title\" /></a> "; |
|
|
"<img src=\"{$CFG->pixpath}/t/edit.gif\" alt=\"$title\" /></a> "; |
|
|
$title = get_string('deletesession','attforblock'); |
|
|
$title = get_string('deletesession','attforblock'); |
|
|
$actions .= "<a title=\"$title\" href=\"sessions.php?id=$cm->id&sessionid={$sessdata->id}&action=delete\">". |
|
|
$actions .= "<a title=\"$title\" href=\"sessions.php?id=$cm->id&sessionid={$sessdata->id}&action=delete\">". |
|
|
"<img src=\"{$CFG->pixpath}/t/delete.gif\" alt=\"$title\" /></a> "; |
|
|
"<img src=\"{$CFG->pixpath}/t/delete.gif\" alt=\"$title\" /></a> "; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$table->data[$sessdata->id][] = $i; |
|
|
$table->data[$sessdata->id][] = $i; |
|
|
$table->data[$sessdata->id][] = $sessdata->groupid ? $groups[$sessdata->groupid]->name : get_string('commonsession', 'attforblock'); |
|
|
$table->data[$sessdata->id][] = $sessdata->groupid ? $groups[$sessdata->groupid]->name : get_string('commonsession', 'attforblock'); |
|
|
$table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimedmyw', 'attforblock')); |
|
|
$table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimedmyw', 'attforblock')); |
|
|
$table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimehm', 'attforblock')); |
|
|
$table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimehm', 'attforblock')); |
|
|
$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} {$strhours} {$mins} {$strmins}" : "{$mins} {$strmins}"; |
|
|
$table->data[$sessdata->id][] = $hours ? "{$hours} {$strhours} {$mins} {$strmins}" : "{$mins} {$strmins}"; |
|
|
$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}\">"; //&sessionid={$sessdata->id} |
|
|
echo "<form method=\"post\" action=\"sessions.php?id={$cm->id}\">"; //&sessionid={$sessdata->id} |
|
|
print_table($table); |
|
|
print_table($table); |
|
|