Browse Source

Some interface improvements (sessions filtering by different criteries) for manage.php, report.php, view.php

MOODLE_23_STABLE
Artem Andreev 15 years ago
parent
commit
7678a49767
  1. 96
      calendar.js
  2. 2
      lang/en_utf8/attforblock.php
  3. 11
      lang/ru_utf8/attforblock.php
  4. 191
      locallib.php
  5. 27
      manage.php
  6. 95
      report.php
  7. 2
      sessions.php
  8. 47
      styles.php
  9. 7
      view.php

96
calendar.js

@ -0,0 +1,96 @@
document.body.className += ' yui-skin-sam';
YAHOO.util.Event.onDOMReady(function(){
var Event = YAHOO.util.Event,
Dom = YAHOO.util.Dom,
dialog, calendar;
var showBtn = Dom.get("show");
Event.on(showBtn, "click", function() {
// Lazy Dialog Creation - Wait to create the Dialog, and setup document click listeners, until the first time the button is clicked.
if (!dialog) {
// Hide Calendar if we click anywhere in the document other than the calendar
Event.on(document, "click", function(e) {
var el = Event.getTarget(e);
var dialogEl = dialog.element;
if (el != dialogEl && !Dom.isAncestor(dialogEl, el) && el != showBtn && !Dom.isAncestor(showBtn, el)) {
dialog.hide();
}
});
function resetHandler() {
calendar.cfg.setProperty("pagedate", calendar.today);
calendar.render();
}
function closeHandler() {
dialog.hide();
}
dialog = new YAHOO.widget.Dialog("container", {
visible:false,
context:["show", "tl", "bl"],
buttons:[{text: cal_today, handler: resetHandler, isDefault:true}, {text: cal_close, handler: closeHandler}],
draggable:false,
close:false
});
dialog.setHeader('');
dialog.setBody('<div id="cal"></div>');
dialog.render(document.body);
dialog.showEvent.subscribe(function() {
if (YAHOO.env.ua.ie) {
// Since we're hiding the table using yui-overlay-hidden, we
// want to let the dialog know that the content size has changed, when
// shown
dialog.fireEvent("changeContent");
}
});
}
// Lazy Calendar Creation - Wait to create the Calendar until the first time the button is clicked.
if (!calendar) {
calendar = new YAHOO.widget.Calendar("cal", {
iframe:false, // Turn iframe off, since container has iframe support.
hide_blank_weeks:true // Enable, to demonstrate how we handle changing height, using changeContent
});
calendar.cfg.setProperty("start_weekday", cal_start_weekday);
calendar.cfg.setProperty("MONTHS_LONG", cal_months);
calendar.cfg.setProperty("WEEKDAYS_SHORT", cal_week_days);
calendar.select(new Date(cal_cur_date*1000));
calendar.render();
calendar.selectEvent.subscribe(function() {
if (calendar.getSelectedDates().length > 0) {
Dom.get("current").value = calendar.getSelectedDates()[0] / 1000;
Dom.get("currentdate").submit();
}
dialog.hide();
});
calendar.renderEvent.subscribe(function() {
// Tell Dialog it's contents have changed, which allows
// container to redraw the underlay (for IE6/Safari2)
dialog.fireEvent("changeContent");
});
}
var seldate = calendar.getSelectedDates();
if (seldate.length > 0) {
// Set the pagedate to show the selected date if it exists
calendar.cfg.setProperty("pagedate", seldate[0]);
calendar.render();
}
dialog.show();
});
});

2
lang/en_utf8/attforblock.php

@ -15,6 +15,7 @@ $string['add'] = 'Add';
$string['addmultiplesessions'] = 'Add multiple sessions'; $string['addmultiplesessions'] = 'Add multiple sessions';
$string['addsession'] = 'Add session'; $string['addsession'] = 'Add session';
$string['allcourses'] = 'All courses'; $string['allcourses'] = 'All courses';
$string['all'] = 'All';
$string['alltaken'] = 'All taken'; $string['alltaken'] = 'All taken';
$string['attendanceforthecourse'] = 'Attendance for the course'; $string['attendanceforthecourse'] = 'Attendance for the course';
$string['attendancegrade'] = 'Attendance grade'; $string['attendancegrade'] = 'Attendance grade';
@ -37,6 +38,7 @@ $string['commonsession'] = 'Common';
$string['countofselected'] = 'Count of selected'; $string['countofselected'] = 'Count of selected';
$string['createmultiplesessions'] = 'Create multiple sessions'; $string['createmultiplesessions'] = 'Create multiple sessions';
$string['createonesession'] = 'Create one session for the course'; $string['createonesession'] = 'Create one session for the course';
$string['days'] = 'Day';
$string['defaults'] = 'Defaults'; $string['defaults'] = 'Defaults';
$string['delete'] = 'Delete'; $string['delete'] = 'Delete';
$string['deletelogs'] = 'Delete attendance data'; $string['deletelogs'] = 'Delete attendance data';

11
lang/ru_utf8/attforblock.php

@ -14,6 +14,7 @@ $string['acronym'] = 'Сокращ.';
$string['add'] = 'Добавить'; $string['add'] = 'Добавить';
$string['addmultiplesessions'] = 'Добавить несколько занятий'; $string['addmultiplesessions'] = 'Добавить несколько занятий';
$string['addsession'] = 'Добавить занятие'; $string['addsession'] = 'Добавить занятие';
$string['all'] = 'Все';
$string['alltaken'] = 'Все прошедшие'; $string['alltaken'] = 'Все прошедшие';
$string['attendanceforthecourse'] = 'Посещаемость для курса'; $string['attendanceforthecourse'] = 'Посещаемость для курса';
$string['attendancegrade'] = 'Оценка за посещаемость'; $string['attendancegrade'] = 'Оценка за посещаемость';
@ -30,12 +31,18 @@ $string['attforblock:takeattendances'] = 'Отметка посещаемост
$string['attforblock:view'] = 'Просмотр посещаемости'; $string['attforblock:view'] = 'Просмотр посещаемости';
$string['attforblock:viewreports'] = 'Просмотр отчетов'; $string['attforblock:viewreports'] = 'Просмотр отчетов';
$string['attrecords'] = 'Отметок о посещаемости'; $string['attrecords'] = 'Отметок о посещаемости';
$string['calclose'] = 'Закрыть';
$string['calmonths'] = '\"Январь\", \"Февраль\", \"Март\", \"Апрель\", \"Май\", \"Июнь\", \"Июль\", \"Август\", \"Сентябрь\", \"Октябрь\", \"Ноябрь\", \"Декабрь\"';
$string['calshow'] = 'Выбрать дату';
$string['caltoday'] = 'Сегодня';
$string['calweekdays'] = ' \"Вс\", \"Пн\", \"Вт\", \"Ср\", \"Чт\", \"Пт\", \"Сб\"';
$string['changeduration'] = 'Изменить продолжительность'; $string['changeduration'] = 'Изменить продолжительность';
$string['changesession'] = 'Изменить занятие'; $string['changesession'] = 'Изменить занятие';
$string['commonsession'] = 'Общее'; $string['commonsession'] = 'Общее';
$string['countofselected'] = 'Выбрано занятий'; $string['countofselected'] = 'Выбрано занятий';
$string['createmultiplesessions'] = 'Создать несколько занятий'; $string['createmultiplesessions'] = 'Создать несколько занятий';
$string['createonesession'] = 'Создать одно занятие для курса'; $string['createonesession'] = 'Создать одно занятие для курса';
$string['days'] = 'День';
$string['defaults'] = 'По умолчанию'; $string['defaults'] = 'По умолчанию';
$string['delete'] = 'Удалить'; $string['delete'] = 'Удалить';
$string['deleteselected'] = 'Удалить выбранные'; $string['deleteselected'] = 'Удалить выбранные';
@ -61,7 +68,7 @@ $string['indetail'] = 'Подробнее...';
$string['moduledescription'] = 'Вы можете добавить только один данный модуль в каждый курс.<br />Удаление этого модуля не повлечет удаление данных о посещаемости!'; $string['moduledescription'] = 'Вы можете добавить только один данный модуль в каждый курс.<br />Удаление этого модуля не повлечет удаление данных о посещаемости!';
$string['modulename'] = 'Посещаемость'; $string['modulename'] = 'Посещаемость';
$string['modulenameplural'] = 'Посещаемость'; $string['modulenameplural'] = 'Посещаемость';
$string['months'] = 'По месяцам'; $string['months'] = 'Месяц';
$string['myvariables'] = 'Мои переменные'; $string['myvariables'] = 'Мои переменные';
$string['newdate'] = 'Новая дата'; $string['newdate'] = 'Новая дата';
$string['newduration'] = 'New duration'; $string['newduration'] = 'New duration';
@ -113,7 +120,7 @@ $string['variable'] = 'переменную';
$string['variablesupdated'] = 'Переменные успешно обновлены'; $string['variablesupdated'] = 'Переменные успешно обновлены';
$string['versionforprinting'] = 'версия для печати'; $string['versionforprinting'] = 'версия для печати';
$string['week'] = 'неделя(и)'; $string['week'] = 'неделя(и)';
$string['weeks'] = 'По неделям'; $string['weeks'] = 'Неделя';
$string['youcantdo'] = 'Вы ничего не можете сделать'; $string['youcantdo'] = 'Вы ничего не можете сделать';
?> ?>

191
locallib.php

@ -184,13 +184,28 @@ function set_current_view($courseid, $view) {
return $SESSION->currentattview[$courseid] = $view; return $SESSION->currentattview[$courseid] = $view;
} }
function get_current_view($courseid) { function get_current_view($courseid, $defaultview='weeks') {
global $SESSION; global $SESSION;
if (isset($SESSION->currentattview[$courseid])) if (isset($SESSION->currentattview[$courseid]))
return $SESSION->currentattview[$courseid]; return $SESSION->currentattview[$courseid];
else else
return 'all'; return $defaultview;
}
function set_current_date($courseid, $date) {
global $SESSION;
return $SESSION->currentattdate[$courseid] = $date;
}
function get_current_date($courseid) {
global $SESSION;
if (isset($SESSION->currentattdate[$courseid]))
return $SESSION->currentattdate[$courseid];
else
return time();
} }
function print_row($left, $right) { function print_row($left, $right) {
@ -220,7 +235,7 @@ function print_attendance_table($user, $course, $attforblock) {
} }
function print_user_attendaces($user, $cm, $attforblock, $course = 0, $printing = null) { function print_user_attendaces($user, $cm, $attforblock, $course = 0, $printing = null) {
global $CFG, $COURSE, $mode; global $CFG, $COURSE, $mode, $current, $view, $id;
echo '<table class="userinfobox">'; echo '<table class="userinfobox">';
if (!$printing) { if (!$printing) {
@ -275,44 +290,158 @@ function print_user_attendaces($user, $cm, $attforblock, $course = 0, $printing
if ($course) { if ($course) {
if ($current == 0)
$current = get_current_date($course->id);
else
set_current_date ($course->id, $current);
list($startdate, $enddate) =
print_filter_controls("view.php", $id);
if ($startdate && $enddate) {
$where = "ats.courseid={$course->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}";
}
$stqry = "SELECT ats.sessdate,ats.description,al.statusid,al.remarks $stqry = "SELECT ats.sessdate,ats.description,al.statusid,al.remarks
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} AND al.studentid = {$user->id} $stqry .= " WHERE " . $where;
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($course->id);
?>
<div id="mod-assignment-submissions"> $i = 0;
<table align="left" cellpadding="3" cellspacing="0" class="submissions"> $table->head = array('#', get_string('date'), get_string('time'), get_string('description','attforblock'), get_string('status','attforblock'), get_string('remarks','attforblock'));
<tr> $table->align = array('', '', 'left', 'left', 'center', 'left');
<th>#</th> $table->size = array('1px', '1px', '1px', '*', '1px', '1px');
<th align="center"><?php print_string('date')?></th> $table->class = 'generaltable attwidth';
<th align="center"><?php print_string('time')?></th> foreach($sessions as $key=>$sessdata)
<th align="center"><?php print_string('description','attforblock')?></th>
<th align="center"><?php print_string('status','attforblock')?></th>
<th align="center"><?php print_string('remarks','attforblock')?></th>
</tr>
<?php
$i = 1;
foreach($sessions as $key=>$session)
{ {
?> $i++;
<tr> $table->data[$sessdata->id][] = $i;
<td align="center"><?php echo $i++;?></td> $table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimedmyw', 'attforblock'));
<td><?php echo userdate($session->sessdate, get_string('strftimedmyw', 'attforblock')); //userdate($students->sessdate,'%d.%m.%y&nbsp;(%a)', 99, false);?></td> $table->data[$sessdata->id][] = userdate($sessdata->sessdate, get_string('strftimehm', 'attforblock'));
<td><?php echo userdate($session->sessdate, get_string('strftimehm', 'attforblock')); ?></td> $table->data[$sessdata->id][] = empty($sessdata->description) ? get_string('nodescription', 'attforblock') : $sessdata->description;
<td><?php echo empty($session->description) ? get_string('nodescription', 'attforblock') : $session->description; ?></td> $table->data[$sessdata->id][] = $statuses[$sessdata->statusid]->description;
<td><?php echo $statuses[$session->statusid]->description ?></td> $table->data[$sessdata->id][] = $sessdata->remarks;
<td><?php echo $session->remarks;?></td>
</tr>
<?php
} }
echo '</table>'; print_table($table);
} }
} }
echo '</td></tr><tr><td>&nbsp;</td></tr></table></div>'; echo '</td></tr><tr><td>&nbsp;</td></tr></table></div>';
} }
function print_filter_controls($url, $id, $sort=NULL, $printgroupselector=false) {
global $current, $view, $cm;
list(,,,$mday, $wday, $month, $year) = array_values(usergetdate($current));
$currentdatecontrols = '';
switch ($view) {
case 'days':
$format = get_string('strftimedm', 'attforblock');
$startdate = make_timestamp($year, $month, $mday);
$enddate = make_timestamp($year, $month, $mday + 1);
$prevcur = make_timestamp($year, $month, $mday - 1);
$nextcur = make_timestamp($year, $month, $mday + 1);
$curdatetxt = userdate($startdate, $format);
break;
case 'weeks':
$format = get_string('strftimedm', 'attforblock');
$startdate = make_timestamp($year, $month, $mday - $wday + 1);
$enddate = make_timestamp($year, $month, $mday + 7 - $wday);
$prevcur = $startdate - WEEKSECS;
$nextcur = $startdate + WEEKSECS;
$curdatetxt = userdate($startdate, $format)." - ".userdate($enddate, $format);
break;
case 'months':
$format = '%B';
$startdate = make_timestamp($year, $month);
$enddate = make_timestamp($year, $month + 1);
$prevcur = make_timestamp($year, $month - 1);
$nextcur = make_timestamp($year, $month + 1);
$curdatetxt = userdate($startdate, $format);
break;
case 'alltaken':
$startdate = 1;
$enddate = $current;
break;
case 'all':
$startdate = 0;
$enddate = 0;
break;
}
$link = $url . "?id=$id" . ($sort ? "&amp;sort=$sort" : "");
if ($printgroupselector) {
$groupmode = groups_get_activity_groupmode($cm);
$currentgroup = groups_get_activity_group($cm, true);
$groupselector = '';
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if ($groupmode == VISIBLEGROUPS ||
($groupmode && has_capability('moodle/site:accessallgroups', $context))) {
$groupselector = groups_print_activity_menu($cm, $link, true);
}
}
$views['all'] = get_string('all','attforblock');
$views['alltaken'] = get_string('alltaken','attforblock');
$views['months'] = get_string('months','attforblock');
$views['weeks'] = get_string('weeks','attforblock');
$views['days'] = get_string('days','attforblock');
$viewcontrols = '<nobr>';
foreach ($views as $key => $sview) {
if ($key != $view)
$viewcontrols .= "<span class=\"attbtn\"><a href=\"{$link}&amp;view={$key}\">$sview</a></span>";
else
$viewcontrols .= "<span class=\"attcurbtn\">$sview</span>";
}
$viewcontrols .= '</nobr>';
echo "<div class=\"attfiltercontrols attwidth\">";
echo "<table width=\"100%\"><tr>";
echo "<td width=\"45%\">$groupselector</td>";
if ($curdatetxt) {
$curdatecontrols = "<a href=\"{$link}&amp;current=$prevcur\"><span class=\"arrow \"></span></a>";
$curdatecontrols .= "<form id =\"currentdate\" action=\"$url\" method=\"get\" style=\"display:inline;\">";
$curdatecontrols .= " <button title=\"" . get_string('calshow','attforblock') . "\" id=\"show\" type=\"button\">$curdatetxt</button> ";
$curdatecontrols .= "<input type=\"hidden\" name=\"id\" value=\"$id\" />";
if ($sort)
$curdatecontrols .= "<input type=\"hidden\" name=\"sort\" value=\"$sort\" />";
$curdatecontrols .= "<input type=\"hidden\" id=\"current\" name=\"current\" value=\"\" />";
$curdatecontrols .= "</form>";
$curdatecontrols .= "<a href=\"{$link}&amp;current=$nextcur\"><span class=\"arrow \"></span></a>";
plug_yui_calendar($current);
}
echo "<td width=\"20%\" align=\"center\">$curdatecontrols</td>";
echo "<td width=\"35%\" align=\"right\">$viewcontrols</td></tr></table>";
echo "</div>";
return array($startdate, $enddate, $currentgroup);
}
function plug_yui_calendar($current) {
global $CFG;
require_js(array('yui_dom-event', 'yui_dragdrop', 'yui_element', 'yui_button', 'yui_container', 'yui_calendar'));
echo "<script type=\"text/javascript\">\n";
echo "var cal_close = \"" . get_string('calclose','attforblock') . "\";";
echo "var cal_today = \"" . get_string('caltoday','attforblock') . "\";";
echo "var cal_months = [" . get_string('calmonths','attforblock') . "];";
echo "var cal_week_days = [" . get_string('calweekdays','attforblock') . "];";
echo "var cal_start_weekday = " . $CFG->calendar_startwday . ";";
echo "var cal_cur_date = " . $current . ";";
echo "</script>\n";
require_js($CFG->wwwroot . '/mod/attforblock/calendar.js');
}
?> ?>

27
manage.php

@ -8,6 +8,8 @@
$id = required_param('id', PARAM_INT); // Course Module ID, or $id = required_param('id', PARAM_INT); // Course Module ID, or
$from = optional_param('from', PARAM_ACTION); $from = optional_param('from', PARAM_ACTION);
$view = optional_param('view', NULL, PARAM_ALPHA); // which page to show
$current = optional_param('current', 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');
@ -31,6 +33,11 @@
print_error('badcontext'); print_error('badcontext');
} }
if ($view)
set_current_view($course->id, $_GET['view']);
else
$view = get_current_view($course->id);
if (!has_capability('mod/attforblock:manageattendances', $context) AND if (!has_capability('mod/attforblock:manageattendances', $context) AND
!has_capability('mod/attforblock:takeattendances', $context) AND !has_capability('mod/attforblock:takeattendances', $context) AND
!has_capability('mod/attforblock:changeattendances', $context)) { !has_capability('mod/attforblock:changeattendances', $context)) {
@ -78,12 +85,26 @@
function print_sessions_list($course) { function print_sessions_list($course) {
global $CFG, $context, $cm; global $CFG, $context, $cm, $current, $view, $id;
$strhours = get_string('hours'); $strhours = get_string('hours');
$strmins = get_string('min'); $strmins = get_string('min');
$qry = get_records_select('attendance_sessions', "courseid = $course->id AND sessdate >= $course->startdate", 'sessdate asc'); if ($current == 0)
$current = get_current_date($course->id);
else
set_current_date ($course->id, $current);
list($startdate, $enddate) =
print_filter_controls("manage.php", $id);
if ($startdate && $enddate) {
$where = "courseid={$course->id} AND sessdate >= $course->startdate AND sessdate >= $startdate AND sessdate < $enddate";
} else {
$where = "courseid={$course->id} AND sessdate >= $course->startdate";
}
$qry = get_records_select('attendance_sessions', $where/*"courseid = $course->id AND sessdate >= $course->startdate"*/, 'sessdate asc');
$i = 0; $i = 0;
$table->width = '100%'; $table->width = '100%';
//$table->tablealign = 'center'; //$table->tablealign = 'center';
@ -140,7 +161,7 @@ function print_sessions_list($course) {
$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 boxwidthwide">'; 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 sessdate < $course->startdate");

95
report.php

@ -12,7 +12,7 @@
$id = required_param('id', PARAM_INT); $id = required_param('id', PARAM_INT);
$group = optional_param('group', -1, PARAM_INT); // Group to show $group = optional_param('group', -1, PARAM_INT); // Group to show
$view = optional_param('view', 'weeks', 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);
$sort = optional_param('sort', 'lastname', PARAM_ALPHA); $sort = optional_param('sort', 'lastname', PARAM_ALPHA);
@ -38,6 +38,12 @@
print_error('badcontext'); print_error('badcontext');
} }
if ($view)
set_current_view($course->id, $_GET['view']);
else
$view = get_current_view($course->id);
require_capability('mod/attforblock:viewreports', $context); require_capability('mod/attforblock:viewreports', $context);
//add info to log //add info to log
@ -56,87 +62,32 @@
if(!count_records('attendance_sessions', 'courseid', $course->id)) { // no session exists for this course if(!count_records('attendance_sessions', 'courseid', $course->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 { // display attendance report } else {
/// find out current groups mode if ($current == 0)
$groupmode = groups_get_activity_groupmode($cm); $current = get_current_date($course->id);
$currentgroup = groups_get_activity_group($cm, true); else
if ($groupmode == VISIBLEGROUPS || set_current_date ($course->id, $current);
($groupmode && has_capability('moodle/site:accessallgroups', $context))) {
groups_print_activity_menu($cm, "report.php?id=$id&amp;sort=$sort");
}
echo '<div align="right">'.helpbutton ('report', get_string('help'), 'attforblock', true, true, '', true).'</div>'; list($startdate, $enddate, $currentgroup) =
print_filter_controls("report.php", $id, $sort, true);
if ($currentgroup) { if ($startdate && $enddate) {
$students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', $currentgroup, '', false); $where = "courseid={$course->id} AND sessdate >= $course->startdate AND sessdate >= $startdate AND sessdate < $enddate";
} else { } else {
$students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', '', '', false); $where = "courseid={$course->id} AND sessdate >= $course->startdate";
} }
// display date interval selector if ($currentgroup) {
$rec = get_record_sql("SELECT MIN(sessdate) AS min, MAX(sessdate) AS max $where .= " AND (groupid=0 OR groupid=".$currentgroup.")";
FROM {$CFG->prefix}attendance_sessions $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', $currentgroup, '', false);
WHERE courseid=$course->id AND sessdate >= $course->startdate");
$firstdate = $rec->min;
$lastdate = $rec->max;
$now = time();
$current = $current == 0 ? $now : $current;
list(,,,$wday, $syear, $smonth, $sday) = array_values(usergetdate($firstdate));
$wday = $wday == 0 ? 7 : $wday; //////////////////////////////////////////////////// Нужна проверка настройки календаря
$startdate = make_timestamp($syear, $smonth, $sday-$wday+1); //GMT timestamp but for local midnight of monday
$options['all'] = get_string('alltaken','attforblock');
$options['weeks'] = get_string('weeks','attforblock');
$options['months'] = get_string('months','attforblock');
echo '<center>'.helpbutton ('display', get_string('display','attforblock'), 'attforblock', true, false, '', true).get_string('display','attforblock').': ';
if (isset($_GET['view'])) //{
set_current_view($course->id, $_GET['view']);
$view = get_current_view($course->id);
popup_form("report.php?id=$id&amp;sort=$sort&amp;view=", $options, 'viewmenu', $view, '');
$out = '';
$list = array();
if ($view === 'weeks') {
$format = get_string('strftimedm', 'attforblock');
for ($i = 0, $monday = $startdate; $monday <= $lastdate; $i++, $monday += ONE_WEEK) {
if (count_records_select('attendance_sessions', "courseid={$course->id} AND sessdate >= ".$monday." AND sessdate < ".($monday + ONE_WEEK))) {
$list[] = $monday;
}
}
} elseif ($view === 'months') {
$startdate = make_timestamp($syear, $smonth, 1);
$format = '%B';
for ($i = 0, $month = $startdate; $month <= $lastdate; $i++, $month = make_timestamp($syear, $smonth+$i, 1)) {
if (count_records_select('attendance_sessions', "courseid={$course->id} AND sessdate >= ".$month." AND sessdate < ".make_timestamp($syear, $smonth+$i+1, 1))) {
$list[] = $month;
}
}
}
$found = false;
for ($i = count($list)-1; $i >= 0; $i--) {
if ($list[$i] <= $current && !$found) {
$found = true;
$current = $list[$i];
$out = '<b>'.userdate($list[$i], $format).'</b> / '.$out;
} else { } else {
$out = "\n<a href=\"report.php?id=$id&amp;current={$list[$i]}&amp;sort=$sort\">".userdate($list[$i], $format)."</a> / ".$out; $students = get_users_by_capability($context, 'moodle/legacy:student', '', "u.$sort ASC", '', '', '', '', false);
}
} }
echo substr($out, 0, -2)."</center>\n";
$statuses = get_statuses($course->id); $statuses = get_statuses($course->id);
$allstatuses = get_statuses($course->id, false); $allstatuses = get_statuses($course->id, false);
if ($view === 'weeks') {
$where = "courseid={$course->id} AND sessdate >= $course->startdate AND sessdate >= $current AND sessdate < ".($current + ONE_WEEK);
} elseif ($view === 'months') {
list(,,,, $syear, $smonth, $sday) = array_values(usergetdate($current));
$where = "courseid={$course->id} AND sessdate >= $course->startdate AND sessdate >= $current AND sessdate < ".make_timestamp($syear, $smonth+1, 1);
} else {
$where = "courseid={$course->id} AND sessdate >= $course->startdate AND sessdate <= ".time();
}
if ($currentgroup)
$where .= " AND (groupid=0 OR groupid=".$currentgroup.")";
if ($students and if ($students and
($course_sess = get_records_select('attendance_sessions', $where, 'sessdate ASC'))) { ($course_sess = get_records_select('attendance_sessions', $where, 'sessdate ASC'))) {
@ -154,6 +105,7 @@
$table->head[] = $fullnamehead; $table->head[] = $fullnamehead;
$table->align[] = 'left'; $table->align[] = 'left';
$table->size[] = ''; $table->size[] = '';
$table->class = 'generaltable attwidth';
$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);
$groups = groups_get_all_groups($course->id); $groups = groups_get_all_groups($course->id);
@ -225,7 +177,6 @@
$table->data[$student->id][] = get_percent($student->id, $course).'%'; $table->data[$student->id][] = get_percent($student->id, $course).'%';
} }
} }
echo '<br />';
print_table($table); print_table($table);
} else { } else {
print_heading(get_string('nothingtodisplay'), 'center'); print_heading(get_string('nothingtodisplay'), 'center');

2
sessions.php

@ -95,7 +95,7 @@
$rec->duration = $duration; $rec->duration = $duration;
$rec->description = $fromform->sdescription; $rec->description = $fromform->sdescription;
$rec->timemodified = $now; $rec->timemodified = $now;
if ($fromform->sessiontype === COMMONSESSION) { if ($fromform->sessiontype == COMMONSESSION) {
if(!insert_record('attendance_sessions', $rec)) if(!insert_record('attendance_sessions', $rec))
error(get_string('erroringeneratingsessions','attforblock'), "sessions.php?id=$id&amp;action=add"); error(get_string('erroringeneratingsessions','attforblock'), "sessions.php?id=$id&amp;action=add");
} else { } else {

47
styles.php

File diff suppressed because one or more lines are too long

7
view.php

@ -11,6 +11,8 @@
$studentid = optional_param('student', 0, PARAM_INT); $studentid = optional_param('student', 0, PARAM_INT);
$printing = optional_param('printing'); $printing = optional_param('printing');
$mode = optional_param('mode', 'thiscourse'); $mode = optional_param('mode', 'thiscourse');
$view = optional_param('view', NULL, PARAM_ALPHA); // which page to show
$current = optional_param('current', 0, PARAM_INT);
if ($id) { if ($id) {
if (! $cm = get_record("course_modules", "id", $id)) { if (! $cm = get_record("course_modules", "id", $id)) {
@ -57,6 +59,11 @@
error("No such user in this course"); error("No such user in this course");
} }
if ($view)
set_current_view($course->id, $_GET['view']);
else
$view = get_current_view($course->id, 'months');
require_capability('mod/attforblock:view', $context); require_capability('mod/attforblock:view', $context);
$student = false; $student = false;

Loading…
Cancel
Save