A big big big patch:
Converted the students table to use the new table class Fixed bug 3114: when sorting by country, prepend country code to the country name Fixed behavior of autohiding teacher list; now there is a hide/show icon to be consistent with the rest of Moodle Fixed "show all" option so that the user can control it instead of relying on auto behavior Fixed HTML, removed all inline styles Improved accessibility (alt tags for images) Updated obsolete optional_variable calls to optional_param Several cosmetic and other improvements I 've already forgotten :P
This commit is contained in:
+234
-237
@@ -2,23 +2,21 @@
|
||||
|
||||
// Lists all the users within a given course
|
||||
|
||||
require_once("../config.php");
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
define('USER_SMALL_CLASS', 20); // Below this is considered small
|
||||
define('USER_LARGE_CLASS', 200); // Above this is considered large
|
||||
define('DEFAULT_PAGE_SIZE', 20);
|
||||
|
||||
require_variable($id); //course
|
||||
optional_variable($sort, "lastaccess"); //how to sort students
|
||||
optional_variable($dir,"desc"); //how to sort students
|
||||
optional_variable($page, "0"); // which page to show
|
||||
optional_variable($lastinitial, ""); // only show students with this last initial
|
||||
optional_variable($firstinitial, ""); // only show students with this first initial
|
||||
optional_variable($perpage, "20"); // how many per page
|
||||
optional_variable($group, "-1"); // Group to show
|
||||
$mode = optional_param('mode', NULL); // '0' for less details, '1' for more
|
||||
$id = required_param('id', PARAM_INT); // Course id
|
||||
$group = optional_param('group', -1, PARAM_INT); // Group to show
|
||||
$page = optional_param('page', 0, PARAM_INT); // which page to show
|
||||
$perpage = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT); // how many per page
|
||||
$mode = optional_param('mode', NULL); // '0' for less details, '1' for more
|
||||
$showteachers = optional_param('teachers', 1, PARAM_INT); // do we want to see the teacher list?
|
||||
|
||||
if (! $course = get_record("course", "id", $id)) {
|
||||
if (! $course = get_record('course', 'id', $id)) {
|
||||
error("Course ID is incorrect");
|
||||
}
|
||||
|
||||
@@ -33,29 +31,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
add_to_log($course->id, "user", "view all", "index.php?id=$course->id", "");
|
||||
add_to_log($course->id, 'user', 'view all', 'index.php?id='.$course->id, '');
|
||||
|
||||
$isteacher = isteacher($course->id);
|
||||
$showteachers = ($page == 0 and $sort == "lastaccess" and $dir == "desc");
|
||||
|
||||
$countries = get_list_of_countries();
|
||||
|
||||
$strnever = get_string("never");
|
||||
$strnever = get_string('never');
|
||||
|
||||
$datestring->day = get_string("day");
|
||||
$datestring->days = get_string("days");
|
||||
$datestring->hour = get_string("hour");
|
||||
$datestring->hours = get_string("hours");
|
||||
$datestring->min = get_string("min");
|
||||
$datestring->mins = get_string("mins");
|
||||
$datestring->sec = get_string("sec");
|
||||
$datestring->secs = get_string("secs");
|
||||
|
||||
if ($showteachers) {
|
||||
$participantslink = get_string("participants");
|
||||
} else {
|
||||
$participantslink = "<a href=\"index.php?id=$course->id\">".get_string("participants")."</a>";
|
||||
}
|
||||
$datestring->day = get_string('day');
|
||||
$datestring->days = get_string('days');
|
||||
$datestring->hour = get_string('hour');
|
||||
$datestring->hours = get_string('hours');
|
||||
$datestring->min = get_string('min');
|
||||
$datestring->mins = get_string('mins');
|
||||
$datestring->sec = get_string('sec');
|
||||
$datestring->secs = get_string('secs');
|
||||
|
||||
if ($mode !== NULL) {
|
||||
$SESSION->userindexmode = $fullmode = ($mode == 1);
|
||||
@@ -65,15 +56,15 @@
|
||||
$fullmode = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Check to see if groups are being used in this forum
|
||||
/// and if so, set $currentgroup to reflect the current group
|
||||
|
||||
$changegroup = isset($_GET['group']) ? $_GET['group'] : -1; // Group change requested?
|
||||
$groupmode = groupmode($course); // Groups are being used
|
||||
$currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);
|
||||
$currentgroup = get_and_set_current_group($course, $groupmode, $group);
|
||||
|
||||
if (!$currentgroup) { // To make some other functions work better later
|
||||
$currentgroup = NULL;
|
||||
}
|
||||
|
||||
$isseparategroups = ($course->groupmode == SEPARATEGROUPS and $course->groupmodeforce and
|
||||
!isteacheredit($course->id));
|
||||
@@ -84,39 +75,37 @@
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$currentgroup) { // To make some other functions work better later
|
||||
$currentgroup = NULL;
|
||||
}
|
||||
|
||||
// Should use this variable so that we don't break stuff every time a variable is added or changed.
|
||||
$baseurl = $CFG->wwwroot.'/user/index.php?id='.$course->id.'&group='.$currentgroup.'&perpage='.$perpage.'&teachers='.$showteachers;
|
||||
|
||||
/// Print headers
|
||||
|
||||
if ($course->category) {
|
||||
print_header("$course->shortname: ".get_string("participants"), "$course->fullname",
|
||||
print_header("$course->shortname: ".get_string('participants'), $course->fullname,
|
||||
"<a href=\"../course/view.php?id=$course->id\">$course->shortname</a> -> ".
|
||||
"$participantslink", "", "", true, " ", navmenu($course));
|
||||
get_string('participants'), "", "", true, " ", navmenu($course));
|
||||
} else {
|
||||
print_header("$course->shortname: ".get_string("participants"), "$course->fullname",
|
||||
"$participantslink", "", "", true, " ", navmenu($course));
|
||||
print_header("$course->shortname: ".get_string('participants'), $course->fullname,
|
||||
get_string('participants'), "", "", true, " ", navmenu($course));
|
||||
}
|
||||
|
||||
/// Print settings and things in a table across the top
|
||||
|
||||
echo '<table width="100%" border="0" cellpadding="3" cellspacing="0"><tr valign="top">';
|
||||
echo '<table class="controls" cellspacing="0"><tr>';
|
||||
|
||||
if ($groupmode == VISIBLEGROUPS or ($groupmode and isteacheredit($course->id))) {
|
||||
if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) {
|
||||
echo '<td class="left">';
|
||||
print_group_menu($groups, $groupmode, $currentgroup, "index.php?id=$course->id");
|
||||
print_group_menu($groups, $groupmode, $currentgroup, $baseurl);
|
||||
echo '</td>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '<td class="right" align="right">';
|
||||
echo '<td class="right">';
|
||||
echo get_string('userlist').': ';
|
||||
$formatmenu = array( '0' => get_string('detailedless'),
|
||||
'1' => get_string('detailedmore'));
|
||||
echo popup_form("index.php?id=$id&sort=$sort&dir=$dir&perpage=$perpage&lastinitial=$lastinitial&mode=", $formatmenu, 'formatmenu', $fullmode, '', '', '', true);
|
||||
echo popup_form($baseurl.'&mode=', $formatmenu, 'formatmenu', $fullmode, '', '', '', true);
|
||||
echo '</td></tr></table>';
|
||||
|
||||
if ($currentgroup and (!$isseparategroups or isteacheredit($course->id))) { /// Display info about the group
|
||||
@@ -139,21 +128,19 @@
|
||||
}
|
||||
|
||||
|
||||
$exceptions = ''; // This will be a list of userids that are shown as teachers and thus
|
||||
// do not have to be shown as users as well. Only relevant on site course.
|
||||
$exceptions = array(); // This will be an array of userids that are shown as teachers and thus
|
||||
// do not have to be shown as users as well. Only relevant on site course.
|
||||
|
||||
if($showteachers) {
|
||||
|
||||
echo '<style type="text/css"> body#user-index table#teachers { margin: auto; width: 80%; } body#user-index table#teachers td, body#user-index table#teachers th {vertical-align: middle; padding: 4px;}</style>';
|
||||
|
||||
$tablecolumns = array('picture', 'fullname', 'city', 'country', 'lastaccess');
|
||||
$tableheaders = array('', get_string('fullname'), get_string('city'), get_string('country'), get_string('lastaccess'));
|
||||
|
||||
$table = new flexible_table('user-index-teacher');
|
||||
$table = new flexible_table('user-index-teachers');
|
||||
|
||||
$table->define_columns($tablecolumns);
|
||||
$table->define_headers($tableheaders);
|
||||
$table->define_baseurl($CFG->wwwroot.'/user/index.php?id='.$course->id);
|
||||
$table->define_baseurl($baseurl);
|
||||
|
||||
$table->sortable(true);
|
||||
|
||||
@@ -168,7 +155,7 @@ echo '<style type="text/css"> body#user-index table#teachers { margin: auto; wid
|
||||
}
|
||||
|
||||
$teachersql = "SELECT u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat, u.maildigest,
|
||||
u.email, u.city, u.country, u.lastlogin, u.picture, u.lang, u.timezone,
|
||||
u.email, u.maildisplay, u.city, u.country, u.lastlogin, u.picture, u.lang, u.timezone,
|
||||
u.emailstop, t.authority,t.role,t.editall,t.timeaccess as lastaccess, m.groupid
|
||||
FROM {$CFG->prefix}user u
|
||||
LEFT JOIN {$CFG->prefix}user_teachers t ON t.userid = u.id
|
||||
@@ -191,14 +178,16 @@ echo '<style type="text/css"> body#user-index table#teachers { margin: auto; wid
|
||||
|
||||
if(!empty($teachers)) {
|
||||
|
||||
echo "<h2 align=\"center\">$course->teachers";
|
||||
echo '<h2>'.$course->teachers;
|
||||
echo ' <a href="'.$baseurl.'&teachers=0">';
|
||||
echo '<img src="'.$CFG->pixpath.'/i/hide.gif" height="16" width="16" alt="'.get_string('hide').'" /></a>';
|
||||
if (isadmin() or ($course->category and (iscreator() or (isteacheredit($course->id) and !empty($CFG->teacherassignteachers))))) {
|
||||
echo ' <a href="../course/teacher.php?id='.$course->id.'">';
|
||||
echo '<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="" /></a>';
|
||||
echo ' <a href="'.$CFG->wwwroot.'/course/teacher.php?id='.$course->id.'">';
|
||||
echo '<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="'.get_string('edit').'" /></a>';
|
||||
}
|
||||
echo '</h2>';
|
||||
|
||||
$exceptions .= implode(',', array_keys($teachers));
|
||||
$exceptions = array_keys($teachers);
|
||||
|
||||
if ($fullmode) {
|
||||
foreach ($teachers as $key => $teacher) {
|
||||
@@ -221,217 +210,225 @@ echo '<style type="text/css"> body#user-index table#teachers { margin: auto; wid
|
||||
$teacher->country ? $countries[$teacher->country] : '',
|
||||
$lastaccess));
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Don't show teachers
|
||||
echo '<h2>'.$course->teachers;
|
||||
echo ' <a href="'.$baseurl.'&teachers=1">';
|
||||
echo '<img src="'.$CFG->pixpath.'/i/show.gif" height="16" width="16" alt="'.get_string('show').'" /></a>';
|
||||
if (isadmin() or ($course->category and (iscreator() or (isteacheredit($course->id) and !empty($CFG->teacherassignteachers))))) {
|
||||
echo ' <a href="'.$CFG->wwwroot.'/course/teacher.php?id='.$course->id.'">';
|
||||
echo '<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="'.get_string('edit').'" /></a>';
|
||||
}
|
||||
echo '</h2>';
|
||||
}
|
||||
|
||||
$guest = get_guest();
|
||||
$exceptions .= $guest->id;
|
||||
$exceptions[] = $guest->id;
|
||||
|
||||
if ($course->id == SITEID) { // Show all site users (even unconfirmed)
|
||||
$students = get_users(true, '', true, $exceptions, $sort.' '.$dir,
|
||||
$firstinitial, $lastinitial, $page*$perpage, $perpage);
|
||||
$totalcount = get_users(false, '', true, '', '', '', '') - 1; // -1 to not count guest user
|
||||
if ($firstinitial or $lastinitial) {
|
||||
$matchcount = get_users(false, '', true, '', '', $firstinitial, $lastinitial) - 1;
|
||||
} else {
|
||||
$matchcount = $totalcount;
|
||||
}
|
||||
} else {
|
||||
if ($sort == "lastaccess") {
|
||||
$dsort = "s.timeaccess";
|
||||
} else {
|
||||
$dsort = "u.$sort";
|
||||
}
|
||||
$students = get_course_students($course->id, $dsort, $dir, $page*$perpage, $perpage,
|
||||
$firstinitial, $lastinitial, $currentgroup);
|
||||
$totalcount = count_course_students($course, "", "", "", $currentgroup);
|
||||
if ($firstinitial or $lastinitial) {
|
||||
$matchcount = count_course_students($course, "", $firstinitial, $lastinitial, $currentgroup);
|
||||
} else {
|
||||
$matchcount = $totalcount;
|
||||
}
|
||||
$tablecolumns = array('picture', 'fullname', 'city', 'country', 'lastaccess');
|
||||
$tableheaders = array('', get_string('fullname'), get_string('city'), get_string('country'), get_string('lastaccess'));
|
||||
|
||||
$table = new flexible_table('user-index-students');
|
||||
|
||||
$table->define_columns($tablecolumns);
|
||||
$table->define_headers($tableheaders);
|
||||
$table->define_baseurl($baseurl);
|
||||
|
||||
$table->sortable(true);
|
||||
|
||||
$table->set_attribute('cellspacing', '0');
|
||||
$table->set_attribute('id', 'students');
|
||||
$table->set_attribute('class', 'generaltable generalbox');
|
||||
|
||||
$table->set_control_variables(array(
|
||||
TABLE_VAR_SORT => 'ssort',
|
||||
TABLE_VAR_HIDE => 'shide',
|
||||
TABLE_VAR_SHOW => 'sshow',
|
||||
TABLE_VAR_IFIRST => 'sifirst',
|
||||
TABLE_VAR_ILAST => 'silast',
|
||||
TABLE_VAR_PAGE => 'spage'
|
||||
));
|
||||
$table->setup();
|
||||
|
||||
if(SITEID == $course->id) {
|
||||
$select = 'SELECT u.id, u.username, u.firstname, u.lastname, u.email, u.city, u.country,
|
||||
u.picture, u.lang, u.timezone, u.emailstop, u.maildisplay, u.lastaccess ';
|
||||
$from = 'FROM '.$CFG->prefix.'user u ';
|
||||
$where = 'WHERE confirmed = 1 AND u.deleted = 0 ';
|
||||
}
|
||||
else {
|
||||
$select = 'SELECT u.id, u.username, u.firstname, u.lastname, u.email, u.city, u.country,
|
||||
u.picture, u.lang, u.timezone, u.emailstop, u.maildisplay, s.timeaccess AS lastaccess ';
|
||||
$from = 'FROM '.$CFG->prefix.'user u LEFT JOIN '.$CFG->prefix.'user_students s ON s.userid = u.id ';
|
||||
$where = 'WHERE s.course = '.$course->id.' AND u.deleted = 0 ';
|
||||
}
|
||||
|
||||
if ($currentgroup) { // Displaying a group by choice
|
||||
// FIX: TODO: This will not work if $currentgroup == 0, i.e. "those not in a group"
|
||||
$from .= 'LEFT JOIN '.$CFG->prefix.'groups_members gm ON u.id = gm.userid ';
|
||||
$where .= ' AND gm.groupid = '.$currentgroup;
|
||||
}
|
||||
|
||||
if($course->id == SITEID) {
|
||||
$where .= ' AND u.id NOT IN ('.implode(',', $exceptions).')';
|
||||
}
|
||||
|
||||
$totalcount = count_records_sql('SELECT COUNT(*) '.$from.$where);
|
||||
|
||||
if($table->get_sql_where()) {
|
||||
$where .= ' AND '.$table->get_sql_where();
|
||||
}
|
||||
|
||||
if($table->get_sql_sort()) {
|
||||
$sort = ' ORDER BY '.$table->get_sql_sort();
|
||||
}
|
||||
else {
|
||||
$sort = '';
|
||||
}
|
||||
|
||||
if($table->get_sql_sort()) {
|
||||
$sort = ' ORDER BY '.$table->get_sql_sort();
|
||||
}
|
||||
else {
|
||||
$sort = '';
|
||||
}
|
||||
|
||||
$matchcount = count_records_sql('SELECT COUNT(*) '.$from.$where);
|
||||
|
||||
$table->initialbars($totalcount > $perpage);
|
||||
$table->pagesize($perpage, $matchcount);
|
||||
|
||||
if($table->get_page_start() !== '' && $table->get_page_size() !== '') {
|
||||
$limit = ' '.sql_paging_limit($table->get_page_start(), $table->get_page_size());
|
||||
}
|
||||
else {
|
||||
$limit = '';
|
||||
}
|
||||
|
||||
$students = get_records_sql($select.$from.$where.$sort.$limit);
|
||||
|
||||
$a->count = $totalcount;
|
||||
$a->items = $course->students;
|
||||
echo '<h2 align="center">'.get_string('counteditems', '', $a);
|
||||
$a->items = $totalcount == 1 ? $course->student : $course->students;
|
||||
echo '<h2>'.get_string('counteditems', '', $a);
|
||||
if (isteacheredit($course->id)) {
|
||||
echo ' <a href="../course/student.php?id='.$course->id.'">';
|
||||
echo '<img src="'.$CFG->pixpath.'/i/edit.gif" height="16" width="16" alt="" /></a>';
|
||||
}
|
||||
echo '</h2>';
|
||||
|
||||
if (($CFG->longtimenosee > 0) and ($CFG->longtimenosee < 1000) and (!$page) and ($sort == "lastaccess")) {
|
||||
if ($CFG->longtimenosee > 0 && $CFG->longtimenosee < 1000 && $totalcount > 0) {
|
||||
echo '<p id="longtimenosee">('.get_string('unusedaccounts', '', $CFG->longtimenosee).')</p>';
|
||||
}
|
||||
|
||||
/// Print paging bars if necessary
|
||||
|
||||
if ($totalcount > $perpage) {
|
||||
$alphabet = explode(',', get_string('alphabet'));
|
||||
$strall = get_string("all");
|
||||
|
||||
|
||||
/// Bar of first initials
|
||||
|
||||
echo "<center><p align=\"center\">";
|
||||
echo get_string("firstname")." : ";
|
||||
if ($firstinitial) {
|
||||
echo " <a href=\"index.php?id=$course->id&sort=firstname&dir=ASC&group=$currentgroup&".
|
||||
"perpage=$perpage&lastinitial=$lastinitial\">$strall</a> ";
|
||||
} else {
|
||||
echo " <b>$strall</b> ";
|
||||
if ($fullmode) { // Print simple listing
|
||||
if ($totalcount < 1) {
|
||||
print_heading(get_string("nostudentsfound", "", $course->students));
|
||||
}
|
||||
foreach ($alphabet as $letter) {
|
||||
if ($letter == $firstinitial) {
|
||||
echo " <b>$letter</b> ";
|
||||
} else {
|
||||
echo " <a href=\"index.php?id=$course->id&sort=firstname&dir=ASC&group=$currentgroup&".
|
||||
"perpage=$perpage&lastinitial=$lastinitial&firstinitial=$letter\">$letter</a> ";
|
||||
else {
|
||||
|
||||
if($totalcount > $perpage) {
|
||||
|
||||
$firstinitial = $table->get_initial_first();
|
||||
$lastinitial = $table->get_initial_last();
|
||||
$strall = get_string('all');
|
||||
$alpha = explode(',', get_string('alphabet'));
|
||||
|
||||
// Bar of first initials
|
||||
|
||||
echo '<div class="initialbar firstinitial">'.get_string('firstname').' : ';
|
||||
if(!empty($firstinitial)) {
|
||||
echo '<a href="'.$baseurl.'&sifirst=">'.$strall.'</a>';
|
||||
} else {
|
||||
echo '<strong>'.$strall.'</strong>';
|
||||
}
|
||||
foreach ($alpha as $letter) {
|
||||
if ($letter == $firstinitial) {
|
||||
echo ' <strong>'.$letter.'</strong>';
|
||||
} else {
|
||||
echo ' <a href="'.$baseurl.'&sifirst='.$letter.'">'.$letter.'</a>';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
// Bar of last initials
|
||||
|
||||
echo '<div class="initialbar lastinitial">'.get_string('lastname').' : ';
|
||||
if(!empty($lastinitial)) {
|
||||
echo '<a href="'.$baseurl.'&silast=">'.$strall.'</a>';
|
||||
} else {
|
||||
echo '<strong>'.$strall.'</strong>';
|
||||
}
|
||||
foreach ($alpha as $letter) {
|
||||
if ($letter == $lastinitial) {
|
||||
echo ' <strong>'.$letter.'</strong>';
|
||||
} else {
|
||||
echo ' <a href="'.$baseurl.'&silast='.$letter.'">'.$letter.'</a>';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
print_paging_bar($matchcount, intval($table->get_page_start() / $perpage), $perpage, $baseurl.'&', 'spage');
|
||||
|
||||
}
|
||||
|
||||
if($matchcount > 0) {
|
||||
foreach ($students as $student) {
|
||||
print_user($student, $course);
|
||||
}
|
||||
}
|
||||
else {
|
||||
print_heading(get_string('nothingtodisplay'));
|
||||
}
|
||||
}
|
||||
echo "<br />";
|
||||
}
|
||||
else {
|
||||
$countrysort = (strpos($sort, 'country') !== false);
|
||||
if (!empty($students)) {
|
||||
foreach ($students as $student) {
|
||||
if ($student->lastaccess) {
|
||||
$lastaccess = format_time(time() - $student->lastaccess, $datestring);
|
||||
} else {
|
||||
$lastaccess = $strnever;
|
||||
}
|
||||
|
||||
if (empty($student->country)) {
|
||||
$country = '';
|
||||
}
|
||||
else {
|
||||
if($countrysort) {
|
||||
$country = '('.$student->country.') '.$countries[$student->country];
|
||||
}
|
||||
else {
|
||||
$country = $countries[$student->country];
|
||||
}
|
||||
}
|
||||
|
||||
/// Bar of last initials
|
||||
|
||||
echo get_string("lastname")." : ";
|
||||
if ($lastinitial) {
|
||||
echo " <a href=\"index.php?id=$course->id&sort=lastname&dir=ASC&group=$currentgroup&".
|
||||
"perpage=$perpage&firstinitial=$firstinitial\">$strall</a> ";
|
||||
} else {
|
||||
echo " <b>$strall</b> ";
|
||||
}
|
||||
foreach ($alphabet as $letter) {
|
||||
if ($letter == $lastinitial) {
|
||||
echo " <b>$letter</b> ";
|
||||
} else {
|
||||
echo " <a href=\"index.php?id=$course->id&sort=lastname&dir=ASC&group=$currentgroup&".
|
||||
"perpage=$perpage&firstinitial=$firstinitial&lastinitial=$letter\">$letter</a> ";
|
||||
$table->add_data(array (
|
||||
//'<input type="checkbox" name="userid[]" value="'.$teacher->id.'" />',
|
||||
print_user_picture($student->id, $course->id, $student->picture, false, true),
|
||||
'<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$student->id.'&course='.$course->id.'">'.fullname($student).'</a></strong>',
|
||||
$student->city,
|
||||
$country,
|
||||
$lastaccess));
|
||||
}
|
||||
}
|
||||
echo "</p>";
|
||||
echo "</center>";
|
||||
|
||||
print_paging_bar($matchcount, $page, $perpage,
|
||||
"index.php?id=$course->id&sort=$sort&dir=$dir&group=$currentgroup&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&");
|
||||
$table->print_html();
|
||||
|
||||
}
|
||||
|
||||
if ($matchcount < 1) {
|
||||
print_heading(get_string("nostudentsfound", "", $course->students));
|
||||
|
||||
} else if ($fullmode) { // Print simple listing
|
||||
foreach ($students as $student) {
|
||||
print_user($student, $course);
|
||||
}
|
||||
|
||||
} else if ($matchcount > 0) {
|
||||
print_user_table($students, $isteacher);
|
||||
|
||||
print_paging_bar($matchcount, $page, $perpage,
|
||||
"index.php?id=$course->id&sort=$sort&dir=$dir&group=$currentgroup&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&");
|
||||
|
||||
if ($perpage < $totalcount) {
|
||||
echo "<center><p>";
|
||||
echo "<a href=\"index.php?id=$course->id&sort=$sort&dir=$dir&group=$currentgroup&perpage=99999\">".get_string("showall", "", $totalcount)."</a>";
|
||||
echo "</p></center>";
|
||||
}
|
||||
if ($perpage == 99999) {
|
||||
echo '<div id="showall"><a href="'.$baseurl.'&perpage='.DEFAULT_PAGE_SIZE.'">'.get_string('showperpage', '', DEFAULT_PAGE_SIZE).'</a></div>';
|
||||
}
|
||||
|
||||
else if ($matchcount > 0 && $perpage < $matchcount) {
|
||||
echo '<div id="showall"><a href="'.$baseurl.'&perpage=99999">'.get_string('showall', '', $matchcount).'</a></div>';
|
||||
}
|
||||
|
||||
print_footer($course);
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
||||
function print_user_table($users, $isteacher) {
|
||||
// Print one big table with abbreviated info
|
||||
global $mode, $sort, $course, $dir, $CFG;
|
||||
if (isset($_GET['group'])) {
|
||||
$group_param = "&group=".$_GET['group'];
|
||||
} else {
|
||||
$group_param = "";
|
||||
}
|
||||
$columns = array("firstname", "lastname", "city", "country", "lastaccess");
|
||||
|
||||
$countries = get_list_of_countries();
|
||||
|
||||
$strnever = get_string("never");
|
||||
|
||||
$datestring->day = get_string("day");
|
||||
$datestring->days = get_string("days");
|
||||
$datestring->hour = get_string("hour");
|
||||
$datestring->hours = get_string("hours");
|
||||
$datestring->min = get_string("min");
|
||||
$datestring->mins = get_string("mins");
|
||||
$datestring->sec = get_string("sec");
|
||||
$datestring->secs = get_string("secs");
|
||||
|
||||
foreach ($columns as $column) {
|
||||
$colname[$column] = get_string($column);
|
||||
if ($sort != $column) {
|
||||
$columnicon = "";
|
||||
if ($column == "lastaccess") {
|
||||
$columndir = "desc";
|
||||
} else {
|
||||
$columndir = "asc";
|
||||
}
|
||||
} else {
|
||||
$columndir = $dir == "asc" ? "desc":"asc";
|
||||
if ($column == "lastaccess") {
|
||||
$columnicon = $dir == "asc" ? "up":"down";
|
||||
} else {
|
||||
$columnicon = $dir == "asc" ? "down":"up";
|
||||
}
|
||||
$columnicon = " <img src=\"$CFG->pixpath/t/$columnicon.gif\" alt=\"\"/>";
|
||||
}
|
||||
$$column = "<a href=\"index.php?id=$course->id&sort=$column&dir=$columndir$group_param\">".$colname["$column"]."</a>$columnicon";
|
||||
}
|
||||
|
||||
foreach ($users as $key => $user) {
|
||||
$users[$key]->country = ($user->country) ? $countries[$user->country] : '';
|
||||
}
|
||||
if ($sort == "country") { // Need to re-sort by full country name, not code
|
||||
foreach ($users as $user) {
|
||||
$sstudents[$user->id] = $user->country;
|
||||
}
|
||||
asort($sstudents);
|
||||
foreach ($sstudents as $key => $value) {
|
||||
$nstudents[] = $users[$key];
|
||||
}
|
||||
$users = $nstudents;
|
||||
}
|
||||
|
||||
|
||||
$table->head = array (" ", "$firstname / $lastname", $city, $country, $lastaccess);
|
||||
$table->align = array ("left", "left", "left", "left", "left");
|
||||
$table->size = array ("10", "*", "*", "*", "*");
|
||||
$table->size = array ("10", "*", "*", "*", "*");
|
||||
$table->cellpadding = 4;
|
||||
$table->cellspacing = 0;
|
||||
|
||||
foreach ($users as $user) {
|
||||
|
||||
if ($user->lastaccess) {
|
||||
$lastaccess = format_time(time() - $user->lastaccess, $datestring);
|
||||
} else {
|
||||
$lastaccess = $strnever;
|
||||
}
|
||||
|
||||
$picture = print_user_picture($user->id, $course->id, $user->picture, false, true);
|
||||
|
||||
$fullname = fullname($user, $isteacher);
|
||||
|
||||
$table->data[] = array ($picture,
|
||||
"<b><a href=\"$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id\">$fullname</a></b>",
|
||||
$user->city,
|
||||
$user->country,
|
||||
$lastaccess);
|
||||
}
|
||||
print_table($table);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user