Skip to content
Browse files

MDL-2283: Display number of assignment submissions that need grading …

…in the grading summary
  • Loading branch information...
1 parent 28ea78b commit 392ee02d6c53e3a9f497308f1e15591e0a345211 Damyon Wiese committed with Sam Hemelryk Jul 13, 2012
Showing with 32 additions and 2 deletions.
  1. +1 −0 mod/assign/lang/en/assign.php
  2. +23 −1 mod/assign/locallib.php
  3. +6 −1 mod/assign/renderable.php
  4. +2 −0 mod/assign/renderer.php
View
1 mod/assign/lang/en/assign.php
@@ -173,6 +173,7 @@
$string['numberofdraftsubmissions'] = 'Drafts';
$string['numberofparticipants'] = 'Participants';
$string['numberofsubmittedassignments'] = 'Submitted';
+$string['numberofsubmissionsneedgrading'] = 'Needs grading';
$string['offline'] = 'No online submissions required';
$string['overdue'] = '<font color="red">Assignment is overdue by: {$a}</font>';
$string['outlinegrade'] = 'Grade: {$a}';
View
24 mod/assign/locallib.php
@@ -968,6 +968,27 @@ public function count_participants($currentgroup) {
}
/**
+ * Load a count of users submissions in the current module that require grading
+ * This means the submission modification time is more recent than the
+ * grading modification time.
+ *
+ * @return int number of matching submissions
+ */
+ public function count_submissions_need_grading() {
+ global $DB;
+
+ $params = array($this->get_course_module()->instance);
+
+ return $DB->count_records_sql("SELECT COUNT('x')
+ FROM {assign_submission} s
+ LEFT JOIN {assign_grades} g ON s.assignment = g.assignment AND s.userid = g.userid
+ WHERE s.assignment = ?
+ AND s.timemodified IS NOT NULL
+ AND (s.timemodified > g.timemodified OR g.timemodified IS NULL)",
+ $params);
+ }
+
+ /**
* Load a count of users enrolled in the current course with the specified permission and group (optional)
*
* @param string $status The submission status - should match one of the constants
@@ -2091,7 +2112,8 @@ private function view_submission_page() {
$this->is_any_submission_plugin_enabled(),
$this->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED),
$this->get_instance()->duedate,
- $this->get_course_module()->id
+ $this->get_course_module()->id,
+ $this->count_submissions_need_grading()
));
}
$grade = $this->get_user_grade($USER->id, false);
View
7 mod/assign/renderable.php
@@ -405,6 +405,8 @@ class assign_grading_summary implements renderable {
var $submissionsenabled = false;
/** @var int submissionssubmittedcount - The number of submissions in submitted status */
var $submissionssubmittedcount = 0;
+ /** @var int submissionsneedgradingcount - The number of submissions that need grading */
+ var $submissionsneedgradingcount = 0;
/** @var int duedate - The assignment due date (if one is set) */
var $duedate = 0;
/** @var int coursemoduleid - The assignment course module id */
@@ -421,14 +423,17 @@ class assign_grading_summary implements renderable {
* @param int $duedate
* @param int $coursemoduleid
*/
- public function __construct($participantcount, $submissiondraftsenabled, $submissiondraftscount, $submissionsenabled, $submissionssubmittedcount, $duedate, $coursemoduleid) {
+ public function __construct($participantcount, $submissiondraftsenabled, $submissiondraftscount,
+ $submissionsenabled, $submissionssubmittedcount,
+ $duedate, $coursemoduleid, $submissionsneedgradingcount) {
$this->participantcount = $participantcount;
$this->submissiondraftsenabled = $submissiondraftsenabled;
$this->submissiondraftscount = $submissiondraftscount;
$this->submissionsenabled = $submissionsenabled;
$this->submissionssubmittedcount = $submissionssubmittedcount;
$this->duedate = $duedate;
$this->coursemoduleid = $coursemoduleid;
+ $this->submissionsneedgradingcount = $submissionsneedgradingcount;
}
View
2 mod/assign/renderer.php
@@ -248,6 +248,8 @@ public function render_assign_grading_summary(assign_grading_summary $summary) {
if ($summary->submissionsenabled) {
$this->add_table_row_tuple($t, get_string('numberofsubmittedassignments', 'assign'),
$summary->submissionssubmittedcount);
+ $this->add_table_row_tuple($t, get_string('numberofsubmissionsneedgrading', 'assign'),
+ $summary->submissionsneedgradingcount);
}
$time = time();

0 comments on commit 392ee02

Please sign in to comment.
Something went wrong with that request. Please try again.