Index: lang/en_utf8/assignment.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lang/en_utf8/assignment.php,v
retrieving revision 1.14.2.11
diff -u -r1.14.2.11 assignment.php
--- lang/en_utf8/assignment.php 27 Feb 2008 05:05:01 -0000 1.14.2.11
+++ lang/en_utf8/assignment.php 11 Dec 2008 10:25:23 -0000
@@ -138,5 +138,6 @@
$string['viewfeedback'] = 'View assignment grades and feedback';
$string['viewsubmissions'] = 'View $a submitted assignments';
$string['yoursubmission'] = 'Your submission';
+$string['countrealsubmissions'] = '$a->needgrade of $a->total submissions await grading';
?>
Index: mod/assignment/lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/assignment/lib.php,v
retrieving revision 1.277.2.46
diff -u -r1.277.2.46 lib.php
--- mod/assignment/lib.php 23 Sep 2008 07:46:53 -0000 1.277.2.46
+++ mod/assignment/lib.php 11 Dec 2008 21:18:36 -0000
@@ -297,9 +297,10 @@
} else {
$group = groups_get_activity_group($this->cm);
}
- if ($count = $this->count_real_submissions($group)) {
+ $count = $this->count_real_submissions($group,true);
+ if ($count->total) {
$submitted = ''.
- get_string('viewsubmissions', 'assignment', $count).'';
+ get_string('countrealsubmissions', 'assignment', $count).'';
} else {
$submitted = ''.
get_string('noattempts', 'assignment').'';
@@ -1539,10 +1540,11 @@
* Counts all real assignment submissions by ENROLLED students (not empty ones)
*
* @param $groupid int optional If nonzero then count is restricted to this group
+ * @param $countungraded optional if true then function return two numbers as object - total count of submissions and count submissions needs grading
* @return int The number of submissions
*/
- function count_real_submissions($groupid=0) {
- return assignment_count_real_submissions($this->cm, $groupid);
+ function count_real_submissions($groupid=0,$countungraded = false) {
+ return assignment_count_real_submissions($this->cm, $groupid,$countungraded);
}
/**
@@ -2688,9 +2690,10 @@
* 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 $countungraded optional if true then function return two numbers as object - total count of submissions and count submissions needs grading
* @return int The number of submissions
*/
-function assignment_count_real_submissions($cm, $groupid=0) {
+function assignment_count_real_submissions($cm, $groupid=0,$countungraded = false) {
global $CFG;
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
@@ -2713,11 +2716,23 @@
$userlists = implode(',', $users);
- return count_records_sql("SELECT COUNT('x')
+ $count = new stdClass();
+
+ $count->total = count_records_sql("SELECT COUNT('x')
FROM {$CFG->prefix}assignment_submissions
WHERE assignment = $cm->instance AND
timemodified > 0 AND
userid IN ($userlists)");
+ if($countungraded) {
+ $count->needgrade = count_records_sql("SELECT COUNT('x')
+ FROM {$CFG->prefix}assignment_submissions
+ WHERE assignment = $cm->instance AND
+ timemarked < timemodified AND
+ userid IN ($userlists)");
+ return $count;
+ } else {
+ return $count->total;
+ }
}