Fixes for displaying numbers of assignment submissions when

groups are active
This commit is contained in:
moodler 2004-03-16 13:54:29 +00:00
parent b3f2aad71c
commit 9fa8271283
3 changed files with 37 additions and 14 deletions

View File

@ -45,6 +45,14 @@
$table->align = array ("left", "left", "left");
}
$currentgroup = get_current_group($course->id);
if ($currentgroup and isteacheredit($course->id)) {
$group = get_record("groups", "id", $currentgroup);
$groupname = " ($group->name)";
} else {
$groupname = "";
}
$currentsection = "";
foreach ($assignments as $assignment) {
@ -53,9 +61,9 @@
$submitted = "<a href=\"submissions.php?id=$assignment->id\">" .
get_string("viewfeedback", "assignment") . "</a>";
} else {
$count = assignment_count_real_submissions($assignment);
$count = assignment_count_real_submissions($assignment, $currentgroup);
$submitted = "<a href=\"submissions.php?id=$assignment->id\">" .
get_string("viewsubmissions", "assignment", $count) . "</A>";
get_string("viewsubmissions", "assignment", $count) . "</a>$groupname";
}
} else {
if ($submission = assignment_get_submission($assignment, $USER)) {

View File

@ -308,19 +308,27 @@ function assignment_log_info($log) {
AND u.id = '$log->userid'");
}
function assignment_count_real_submissions($assignment) {
function assignment_count_real_submissions($assignment, $groupid=0) {
/// Return all real assignment submissions by ENROLLED students (not empty ones)
global $CFG;
return count_records_sql("SELECT count(a.id)
FROM {$CFG->prefix}assignment_submissions a,
{$CFG->prefix}user_students s,
{$CFG->prefix}user u
WHERE a.userid = s.userid
AND u.id = a.userid
AND s.course = '$assignment->course'
AND a.assignment = '$assignment->id'
AND a.timemodified > 0");
if ($groupid) { /// How many in a particular group?
return count_records_sql("SELECT COUNT(*)
FROM {$CFG->prefix}assignment_submissions a,
{$CFG->prefix}groups_members g
WHERE a.assignment = $assignment->id
AND a.timemodified > 0
AND g.groupid = '$groupid'
AND a.userid = g.userid ");
} else {
return count_records_sql("SELECT COUNT(*)
FROM {$CFG->prefix}assignment_submissions a,
{$CFG->prefix}user_students s
WHERE a.assignment = '$assignment->id'
AND a.timemodified > 0
AND s.course = '$assignment->course'
AND a.userid = s.userid ");
}
}
function assignment_get_all_submissions($assignment, $sort="", $dir="DESC") {

View File

@ -52,9 +52,16 @@
echo "<a href=\"submissions.php?id=$assignment->id\">".
get_string("viewfeedback", "assignment")."</a>";
} else {
$count = assignment_count_real_submissions($assignment);
$currentgroup = get_current_group($course->id);
if ($currentgroup and isteacheredit($course->id)) {
$group = get_record("groups", "id", $currentgroup);
$groupname = " ($group->name)";
} else {
$groupname = "";
}
$count = assignment_count_real_submissions($assignment, $currentgroup);
echo "<a href=\"submissions.php?id=$assignment->id\">".
get_string("viewsubmissions", "assignment", $count)."</a>";
get_string("viewsubmissions", "assignment", $count)."</a>$groupname";
}
echo '</p>';
} else if (!$cm->visible) {