Index: lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/assignment/lib.php,v
retrieving revision 1.219.2.17
diff -c -r1.219.2.17 lib.php
*** lib.php 24 Sep 2007 06:32:19 -0000 1.219.2.17
--- lib.php 25 Oct 2007 18:06:27 -0000
***************
*** 292,302 ****
// then he can only see/mark submission in his own groups
if (!has_capability('moodle/course:managegroups', $context) and (groupmode($this->course, $this->cm) == SEPARATEGROUPS)) {
$count = $this->count_real_submissions($this->currentgroup); // Only their groups
} else {
$count = $this->count_real_submissions(); // Everyone
}
$submitted = ''.
! get_string('viewsubmissions', 'assignment', $count).'';
} else {
if (!empty($USER->id)) {
if ($submission = $this->get_submission($USER->id)) {
--- 292,304 ----
// then he can only see/mark submission in his own groups
if (!has_capability('moodle/course:managegroups', $context) and (groupmode($this->course, $this->cm) == SEPARATEGROUPS)) {
$count = $this->count_real_submissions($this->currentgroup); // Only their groups
+ $ungraded = $this->count_real_ungraded_submissions($this->currentgroup);
} else {
$count = $this->count_real_submissions(); // Everyone
+ $ungraded = $this->count_real_ungraded_submissions();
}
$submitted = ''.
! get_string('viewsubmissions', 'assignment', $count).'
('.get_string('submissionsnotgraded', 'assignment', $ungraded).')';
} else {
if (!empty($USER->id)) {
if ($submission = $this->get_submission($USER->id)) {
***************
*** 1352,1357 ****
--- 1376,1439 ----
return assignment_count_real_submissions($this->assignment, $groupid);
}
+ /** Counts all ungraded real assignment submissions by ENROLLED students (not empty ones)
+ *
+ * @param $groupid int optional If nonzero then count is restricted to this group
+ * @return int The number of submissions
+ */
+ function count_real_ungraded_submissions($groupid=0) {
+ return assignment_count_real_submissions($this->assignment, $groupid, 1);
+ }
+
+
***************
*** 2250,2267 ****
* There are also assignment type methods count_real_submissions() wich in the default
* implementation simply call this function.
* @param $groupid int optional If nonzero then count is restricted to this group
* @return int The number of submissions
*/
! function assignment_count_real_submissions($assignment, $groupid=0) {
global $CFG;
if ($groupid) { /// How many in a particular group?
return count_records_sql("SELECT COUNT(DISTINCT gm.userid, gm.groupid)
FROM {$CFG->prefix}assignment_submissions a,
".groups_members_from_sql()."
WHERE a.assignment = $assignment->id
AND a.timemodified > 0
! AND ".groups_members_where_sql($groupid, 'a.userid'));
} else {
$cm = get_coursemodule_from_instance('assignment', $assignment->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
--- 2338,2362 ----
* There are also assignment type methods count_real_submissions() wich in the default
* implementation simply call this function.
* @param $groupid int optional If nonzero then count is restricted to this group
+ * @param $ungraded int optional If nonzero then count is restricted to ungraded submissions
* @return int The number of submissions
*/
! function assignment_count_real_submissions($assignment, $groupid=0, $ungraded=0) {
global $CFG;
+ $ungraded_where = '';
+
if ($groupid) { /// How many in a particular group?
+ if ($ungraded) {
+ $ungraded_where = ' AND a.timemarked = 0 ';
+ }
return count_records_sql("SELECT COUNT(DISTINCT gm.userid, gm.groupid)
FROM {$CFG->prefix}assignment_submissions a,
".groups_members_from_sql()."
WHERE a.assignment = $assignment->id
AND a.timemodified > 0
! AND ".groups_members_where_sql($groupid, 'a.userid')
! . $ungraded_where );
} else {
$cm = get_coursemodule_from_instance('assignment', $assignment->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
***************
*** 2274,2284 ****
$userlists = '('.implode(',',$array).')';
return count_records_sql("SELECT COUNT(*)
FROM {$CFG->prefix}assignment_submissions
WHERE assignment = '$assignment->id'
AND timemodified > 0
! AND userid IN $userlists ");
} else {
return 0; // no users enroled in course
}
--- 2369,2383 ----
$userlists = '('.implode(',',$array).')';
+ if ($ungraded) {
+ $ungraded_where = ' AND timemarked = 0 ';
+ }
return count_records_sql("SELECT COUNT(*)
FROM {$CFG->prefix}assignment_submissions
WHERE assignment = '$assignment->id'
AND timemodified > 0
! AND userid IN $userlists "
! . $ungraded_where );
} else {
return 0; // no users enroled in course
}