Lots of things going on:
1. Added a dropdown box at the top right which allows you to manually choose the display mode for the user lists. 2. Fixed the bug where "Show all X users" was displayed when it shouldn't. 3. Merged the latest changes from the MOODLE_14_STABLE branch. This wasn't done before and it gave me the creeps. All changes seem to be good, so I hope I didn't checkin anything dangerous. Will synchronize the MERGED tag on the branch, too.
This commit is contained in:
+70
-39
@@ -14,7 +14,9 @@
|
||||
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($_GET['format'], 'brief'); // what kind of view
|
||||
|
||||
$compactmode = ($_GET['format'] == 'brief');
|
||||
|
||||
if (! $course = get_record("course", "id", $id)) {
|
||||
error("Course ID is incorrect");
|
||||
@@ -22,6 +24,15 @@
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
if (!$course->category) {
|
||||
if (!$CFG->showsiteparticipantslist and !isteacher(SITEID)) {
|
||||
notice(get_string('sitepartlist0'));
|
||||
}
|
||||
if ($CFG->showsiteparticipantslist < 2 and !isteacher()) {
|
||||
notice(get_string('sitepartlist1'));
|
||||
}
|
||||
}
|
||||
|
||||
add_to_log($course->id, "user", "view all", "index.php?id=$course->id", "");
|
||||
|
||||
$isteacher = isteacher($course->id);
|
||||
@@ -33,7 +44,7 @@
|
||||
$participantslink = "<a href=\"index.php?id=$course->id\">".get_string("participants")."</a>";
|
||||
}
|
||||
|
||||
$isseparategroups = ($course->groupmode == SEPARATEGROUPS and $course->groupmodeforce and
|
||||
$isseparategroups = ($course->groupmode == SEPARATEGROUPS and $course->groupmodeforce and
|
||||
!isteacheredit($course->id));
|
||||
|
||||
$currentgroup = $isseparategroups ? get_current_group($course->id) : NULL;
|
||||
@@ -43,31 +54,47 @@
|
||||
"<A HREF=../course/view.php?id=$course->id>$course->shortname</A> -> ".
|
||||
"$participantslink", "", "", true, " ", navmenu($course));
|
||||
} else {
|
||||
print_header("$course->shortname: ".get_string("participants"), "$course->fullname",
|
||||
print_header("$course->shortname: ".get_string("participants"), "$course->fullname",
|
||||
"$participantslink", "", "", true, " ", navmenu($course));
|
||||
}
|
||||
|
||||
echo '<div style="text-align: right;">';
|
||||
echo get_string('userlist').': ';
|
||||
$formatmenu = array(
|
||||
'' => get_string('detailedmore'),
|
||||
'brief' => get_string('detailedless'),
|
||||
);
|
||||
// [pj] Oh, the things I do to put it in one line... :P
|
||||
echo str_replace('<form', '<form style="display: inline;"', popup_form ("index.php?id=$id&format=", $formatmenu, 'formatmenu', $_GET['format'], '', '', '', true));
|
||||
echo '</div>';
|
||||
|
||||
$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.
|
||||
if ($showteachers) {
|
||||
if ($teachers = get_course_teachers($course->id)) {
|
||||
echo "<h2 align=\"center\">$course->teachers</h2>";
|
||||
foreach ($teachers as $teacher) {
|
||||
if ($isseparategroups) {
|
||||
if ($teacher->editall or ismember($currentgroup, $teacher->id)) {
|
||||
if($compactmode) {
|
||||
$exceptions .= implode(',', array_keys($teachers));
|
||||
print_user_table($teachers, $isteacher);
|
||||
}
|
||||
else {
|
||||
foreach ($teachers as $teacher) {
|
||||
if ($isseparategroups) {
|
||||
if ($teacher->editall or ismember($currentgroup, $teacher->id)) {
|
||||
print_user($teacher, $course);
|
||||
$exceptions .= "$teacher->id,";
|
||||
}
|
||||
} else if ($teacher->authority > 0) { // Don't print teachers with no authority
|
||||
print_user($teacher, $course);
|
||||
$exceptions .= "$teacher->id,";
|
||||
}
|
||||
} else if ($teacher->authority > 0) { // Don't print teachers with no authority
|
||||
print_user($teacher, $course);
|
||||
$exceptions .= "$teacher->id,";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$guest = get_guest();
|
||||
$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
|
||||
@@ -82,7 +109,7 @@
|
||||
} else {
|
||||
$dsort = "u.$sort";
|
||||
}
|
||||
$students = get_course_students($course->id, $dsort, $dir, $page*$perpage,
|
||||
$students = get_course_students($course->id, $dsort, $dir, $page*$perpage,
|
||||
$perpage, $firstinitial, $lastinitial, $currentgroup);
|
||||
$totalcount = count_course_students($course, "", "", "", $currentgroup);
|
||||
if ($firstinitial or $lastinitial) {
|
||||
@@ -147,7 +174,7 @@
|
||||
echo "</p>";
|
||||
echo "</center>";
|
||||
|
||||
print_paging_bar($matchcount, $page, $perpage,
|
||||
print_paging_bar($matchcount, $page, $perpage,
|
||||
"index.php?id=$course->id&sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&");
|
||||
|
||||
}
|
||||
@@ -155,14 +182,29 @@
|
||||
if ($matchcount < 1) {
|
||||
print_heading(get_string("nostudentsfound", "", $course->students));
|
||||
|
||||
} if (0 < $matchcount and $matchcount < USER_SMALL_CLASS) { // Print simple listing
|
||||
} if (!$compactmode && (0 < $matchcount and $matchcount < USER_SMALL_CLASS)) { // 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&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&");
|
||||
|
||||
if ($perpage < $totalcount) {
|
||||
echo "<center><p>";
|
||||
echo "<a href=\"index.php?id=$course->id&sort=$sort&dir=$dir&perpage=99999\">".get_string("showall", "", $totalcount)."</a>";
|
||||
echo "</p></center>";
|
||||
}
|
||||
}
|
||||
|
||||
print_footer($course);
|
||||
|
||||
function print_user_table($users, $isteacher) {
|
||||
// Print one big table with abbreviated info
|
||||
global $sort, $course, $dir, $CFG;
|
||||
|
||||
$columns = array("firstname", "lastname", "city", "country", "lastaccess");
|
||||
|
||||
$countries = get_list_of_countries();
|
||||
@@ -199,18 +241,18 @@
|
||||
$$column = "<a href=\"index.php?id=$course->id&sort=$column&dir=$columndir\">".$colname["$column"]."</a>$columnicon";
|
||||
}
|
||||
|
||||
foreach ($students as $key => $student) {
|
||||
$students[$key]->country = ($student->country) ? $countries[$student->country] : '';
|
||||
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 ($students as $student) {
|
||||
$sstudents[$student->id] = $student->country;
|
||||
foreach ($users as $user) {
|
||||
$sstudents[$user->id] = $user->country;
|
||||
}
|
||||
asort($sstudents);
|
||||
foreach ($sstudents as $key => $value) {
|
||||
$nstudents[] = $students[$key];
|
||||
$nstudents[] = $users[$key];
|
||||
}
|
||||
$students = $nstudents;
|
||||
$users = $nstudents;
|
||||
}
|
||||
|
||||
|
||||
@@ -220,37 +262,26 @@
|
||||
$table->size = array ("10", "*", "*", "*", "*");
|
||||
$table->cellpadding = 4;
|
||||
$table->cellspacing = 0;
|
||||
|
||||
foreach ($students as $student) {
|
||||
|
||||
if ($student->lastaccess) {
|
||||
$lastaccess = format_time(time() - $student->lastaccess, $datestring);
|
||||
foreach ($users as $user) {
|
||||
|
||||
if ($user->lastaccess) {
|
||||
$lastaccess = format_time(time() - $user->lastaccess, $datestring);
|
||||
} else {
|
||||
$lastaccess = $strnever;
|
||||
}
|
||||
|
||||
$picture = print_user_picture($student->id, $course->id, $student->picture, false, true);
|
||||
$picture = print_user_picture($user->id, $course->id, $user->picture, false, true);
|
||||
|
||||
$fullname = fullname($student, $isteacher);
|
||||
$fullname = fullname($user, $isteacher);
|
||||
|
||||
$table->data[] = array ($picture,
|
||||
"<b><a href=\"$CFG->wwwroot/user/view.php?id=$student->id&course=$course->id\">$fullname</a></b>",
|
||||
"<font size=2>$student->city</font>",
|
||||
"<font size=2>$student->country</font>",
|
||||
"<b><a href=\"$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id\">$fullname</a></b>",
|
||||
"<font size=2>$user->city</font>",
|
||||
"<font size=2>$user->country</font>",
|
||||
"<font size=2>$lastaccess</font>");
|
||||
}
|
||||
print_table($table);
|
||||
|
||||
print_paging_bar($matchcount, $page, $perpage,
|
||||
"index.php?id=$course->id&sort=$sort&dir=$dir&perpage=$perpage&firstinitial=$firstinitial&lastinitial=$lastinitial&");
|
||||
|
||||
if ($perpage != 99999) {
|
||||
echo "<center><p>";
|
||||
echo "<a href=\"index.php?id=$course->id&sort=$sort&dir=$dir&perpage=99999\">".get_string("showall", "", $totalcount)."</a>";
|
||||
echo "</p></center>";
|
||||
}
|
||||
}
|
||||
|
||||
print_footer($course);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user