mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
Fixes for displaying numbers of assignment submissions when
groups are active
This commit is contained in:
parent
b3f2aad71c
commit
9fa8271283
@ -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)) {
|
||||
|
@ -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") {
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user