From 486f78b51f5d6dc9bdb1a7360a52b47b1c10fe3d Mon Sep 17 00:00:00 2001 From: moodler Date: Sat, 14 Feb 2004 07:57:48 +0000 Subject: [PATCH] Group support for assignment submissions, and some cleanups. I really hate this interface - it's not scalable - but this will have to wait for another day. --- mod/assignment/submissions.php | 109 ++++++++++++++++++++++++--------- 1 file changed, 81 insertions(+), 28 deletions(-) diff --git a/mod/assignment/submissions.php b/mod/assignment/submissions.php index b7267248d0..4d7cc19838 100644 --- a/mod/assignment/submissions.php +++ b/mod/assignment/submissions.php @@ -4,8 +4,8 @@ require_once("lib.php"); require_variable($id); // Assignment - optional_variable($sort, ""); - optional_variable($dir, ""); + optional_variable($sort, "lastname"); + optional_variable($dir, "ASC"); $timewas = $_POST['timenow']; $timenow = time(); @@ -27,7 +27,7 @@ } if ($course->category) { - $navigation = "id\">$course->shortname ->"; + $navigation = "id\">$course->shortname ->"; } $strassignments = get_string("modulenameplural", "assignment"); @@ -36,14 +36,47 @@ $strsaveallfeedback = get_string("saveallfeedback", "assignment"); print_header("$course->shortname: $assignment->name", "$course->fullname", - "$navigation id>$strassignments -> - id\">$assignment->name -> $strsubmissions", + "$navigation id\">$strassignments -> + id\">$assignment->name -> $strsubmissions", "", "", true); +/// Check to see if groups are being used in this forum +/// and if so, set $currentgroup to reflect the current group + + $groupmode = groupmode($course, $cm); // Groups are being used + $currentgroup = get_and_set_current_group($course, $groupmode, $_GET['group']); + + if (!isteacheredit($course->id) and $groupmode and !$currentgroup) { + print_heading("Sorry, but you can't see this group"); + print_footer(); + exit; + } + + if ($groupmode == VISIBLEGROUPS or ($groupmode and isteacheredit($course->id))) { + if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) { + echo '
'; + if ($groupmode == VISIBLEGROUPS) { + print_string('groupsvisible'); + } else { + print_string('groupsseparate'); + } + echo ':'; + echo ''; + popup_form("submissions.php?id=$assignment->id&group=", $groups, 'selectgroup', $currentgroup, "", "", "", false, "self"); + echo '
'; + } + } + + /// Get all teachers and students $teachers = get_course_teachers($course->id); - if (!$users = get_course_students($course->id)) { + if ($currentgroup) { + $users = get_course_students($course->id, "", "", 0, 99999, "", "", $currentgroup); + } else { + $users = get_course_students($course->id); + } + if (!$users) { print_heading(get_string("nostudentsyet")); print_footer($course); exit; @@ -128,37 +161,57 @@ } // Submission sorting - print_simple_box_start("CENTER", "50%"); - echo "

"; - print_string("order"); - - if ($dir == "ASC") - $dir = "DESC"; - else - $dir = "ASC"; - - echo ": id&sort=lastname&dir=$dir\">".get_string("name")." - "; - echo "id&sort=timemodified&dir=$dir\">".get_string("lastmodified")." - "; - echo "id&sort=grade&dir=$dir\">".get_string("feedback").""; - echo "

"; + + + $sorttypes = array('firstname', 'lastname', 'timemodified', 'grade'); + + print_simple_box_start("center", "50%"); + echo '

'.get_string('order').':  '; + + foreach ($sorttypes as $sorttype) { + if ($sorttype == 'timemodified') { + $label = get_string("lastmodified"); + } else { + $label = get_string($sorttype); + } + if ($sort == $sorttype) { // Current sort + $newdir = $dir == 'ASC' ? 'DESC' : 'ASC'; + } else { + $newdir = 'ASC'; + } + echo "id&sort=$sorttype&dir=$newdir\">$label"; + if ($sort == $sorttype) { // Current sort + $diricon = $dir == 'ASC' ? 'down' : 'up'; + echo " pixpath/t/$diricon.gif\" />"; + } + echo "    "; + } + + echo "

"; print_simple_box_end(); + print_spacer(8,1); - echo "
\n"; + echo ''; $grades = make_grades_menu($assignment->grade); foreach ($submissions as $submission) { - $user = $users[$submission->userid]; - assignment_print_submission($assignment, $user, $submission, $teachers, $grades); + if (isset($users[$submission->userid])) { + $user = $users[$submission->userid]; + assignment_print_submission($assignment, $user, $submission, $teachers, $grades); + } } - echo "
"; - echo ""; - echo "id\">"; - echo ""; - echo "
"; - echo "
"; + if ($groupmode != VISIBLEGROUPS or isteacheredit($course->id) or ismember($currentgroup)) { + echo "
"; + echo ""; + echo ""; + echo "id\">"; + echo ""; + echo "
"; + echo ""; + } print_footer($course); -- 2.39.5