participants list last access filter should only show for teachers! I noticed this on moodle.org this morning :|
This commit is contained in:
+49
-42
@@ -145,49 +145,51 @@
|
||||
}
|
||||
}
|
||||
|
||||
// get minimum lastaccess for this course and display a dropbox to filter by lastaccess going back this far.
|
||||
$minlastaccess = get_field_sql('SELECT min(timeaccess) FROM '.$CFG->prefix.'user_students WHERE course = '.$course->id.' AND timeaccess != 0');
|
||||
|
||||
$lastaccess0exists = record_exists('user_students','course',$course->id,'timeaccess',0);
|
||||
$now = usergetmidnight(time());
|
||||
$timeaccess = array();
|
||||
|
||||
// makes sense for this to go first.
|
||||
$timeoptions[0] = get_string('selectperiod');
|
||||
|
||||
// days
|
||||
for ($i = 1; $i < 7; $i++) {
|
||||
if (strtotime('-'.$i.' days',$now) >= $minlastaccess) {
|
||||
$timeoptions[strtotime('-'.$i.' days',$now)] = get_string('numdays','moodle',$i);
|
||||
if (!empty($isteacher)) {
|
||||
// get minimum lastaccess for this course and display a dropbox to filter by lastaccess going back this far.
|
||||
$minlastaccess = get_field_sql('SELECT min(timeaccess) FROM '.$CFG->prefix.'user_students WHERE course = '.$course->id.' AND timeaccess != 0');
|
||||
|
||||
$lastaccess0exists = record_exists('user_students','course',$course->id,'timeaccess',0);
|
||||
$now = usergetmidnight(time());
|
||||
$timeaccess = array();
|
||||
|
||||
// makes sense for this to go first.
|
||||
$timeoptions[0] = get_string('selectperiod');
|
||||
|
||||
// days
|
||||
for ($i = 1; $i < 7; $i++) {
|
||||
if (strtotime('-'.$i.' days',$now) >= $minlastaccess) {
|
||||
$timeoptions[strtotime('-'.$i.' days',$now)] = get_string('numdays','moodle',$i);
|
||||
}
|
||||
}
|
||||
}
|
||||
// weeks
|
||||
for ($i = 1; $i < 10; $i++) {
|
||||
if (strtotime('-'.$i.' weeks',$now) >= $minlastaccess) {
|
||||
$timeoptions[strtotime('-'.$i.' weeks',$now)] = get_string('numweeks','moodle',$i);
|
||||
// weeks
|
||||
for ($i = 1; $i < 10; $i++) {
|
||||
if (strtotime('-'.$i.' weeks',$now) >= $minlastaccess) {
|
||||
$timeoptions[strtotime('-'.$i.' weeks',$now)] = get_string('numweeks','moodle',$i);
|
||||
}
|
||||
}
|
||||
}
|
||||
// months
|
||||
for ($i = 2; $i < 12; $i++) {
|
||||
if (strtotime('-'.$i.' months',$now) >= $minlastaccess) {
|
||||
$timeoptions[strtotime('-'.$i.' months',$now)] = get_string('nummonths','moodle',$i);
|
||||
// months
|
||||
for ($i = 2; $i < 12; $i++) {
|
||||
if (strtotime('-'.$i.' months',$now) >= $minlastaccess) {
|
||||
$timeoptions[strtotime('-'.$i.' months',$now)] = get_string('nummonths','moodle',$i);
|
||||
}
|
||||
}
|
||||
// try a year
|
||||
if (strtotime('-1 year',$now) >= $minlastaccess) {
|
||||
$timeoptions[strtotime('-1 year',$now)] = get_string('lastyear');
|
||||
}
|
||||
|
||||
if (!empty($lastaccess0exists)) {
|
||||
$timeoptions[-1] = get_string('never');
|
||||
}
|
||||
|
||||
if (count($timeoptions) > 1) {
|
||||
echo '<td class="left">';
|
||||
echo get_string('usersnoaccesssince').': ';
|
||||
$baseurl = preg_replace('/&accesssince='.$accesssince.'/','',$baseurl);
|
||||
echo popup_form($baseurl.'&accesssince=',$timeoptions,'timeoptions',$accesssince,'','','',true);
|
||||
echo '</td>';
|
||||
}
|
||||
}
|
||||
// try a year
|
||||
if (strtotime('-1 year',$now) >= $minlastaccess) {
|
||||
$timeoptions[strtotime('-1 year',$now)] = get_string('lastyear');
|
||||
}
|
||||
|
||||
if (!empty($lastaccess0exists)) {
|
||||
$timeoptions[-1] = get_string('never');
|
||||
}
|
||||
|
||||
if (count($timeoptions) > 1) {
|
||||
echo '<td class="left">';
|
||||
echo get_string('usersnoaccesssince').': ';
|
||||
$baseurl = preg_replace('/&accesssince='.$accesssince.'/','',$baseurl);
|
||||
echo popup_form($baseurl.'&accesssince=',$timeoptions,'timeoptions',$accesssince,'','','',true);
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
echo '<td class="right">';
|
||||
@@ -313,7 +315,9 @@ function checkchecked(form) {
|
||||
$teachersql .= ' AND t.authority > 0';
|
||||
}
|
||||
|
||||
$teachersql .= get_lastaccess_sql($accesssince);
|
||||
if ($isteacher) {
|
||||
$teachersql .= get_lastaccess_sql($accesssince);
|
||||
}
|
||||
|
||||
if($sortclause = $table->get_sql_sort()) {
|
||||
$teachersql .= ' ORDER BY '.$sortclause;
|
||||
@@ -458,7 +462,10 @@ function checkchecked(form) {
|
||||
$where = 'WHERE s.course = '.$course->id.' AND u.deleted = 0 ';
|
||||
}
|
||||
|
||||
$where .= get_lastaccess_sql($accesssince);
|
||||
if ($isteacher) {
|
||||
$where .= get_lastaccess_sql($accesssince);
|
||||
}
|
||||
|
||||
$wheresearch = '';
|
||||
|
||||
if (!empty($search)) {
|
||||
|
||||
Reference in New Issue
Block a user