Permalink
Browse files

MDL-36908 Assignment: Additional fixes for preventing empty submissions

  • Loading branch information...
damyon authored and Sam Hemelryk committed Nov 29, 2012
1 parent 473eadf commit 5b2313c26c48c39787ced95f331192a941bd340e
@@ -592,7 +592,7 @@ public function view_page($action) {
/**
* If this plugin should not include a column in the grading table or a row on the summary page
- * return false
+ * then return false
*
* @return bool
*/
View
@@ -1131,21 +1131,22 @@ 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.
+ * grading modification time and the status is SUBMITTED.
*
* @return int number of matching submissions
*/
public function count_submissions_need_grading() {
global $DB;
- $params = array($this->get_course_module()->instance);
+ $params = array($this->get_course_module()->instance, ASSIGN_SUBMISSION_STATUS_SUBMITTED);
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)",
+ AND (s.timemodified > g.timemodified OR g.timemodified IS NULL)
+ AND s.status = ?",
$params);
}
@@ -1972,12 +1973,7 @@ public function get_user_submission($userid, $create) {
$submission->userid = $userid;
$submission->timecreated = time();
$submission->timemodified = $submission->timecreated;
-
- if ($this->get_instance()->submissiondrafts) {
- $submission->status = ASSIGN_SUBMISSION_STATUS_DRAFT;
- } else {
- $submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
- }
+ $submission->status = ASSIGN_SUBMISSION_STATUS_DRAFT;
$sid = $DB->insert_record('assign_submission', $submission);
$submission->id = $sid;
return $submission;
@@ -2122,6 +2118,9 @@ private function view_single_grade_page($mform, $offset=0) {
} else {
$showsubmit = $showedit && $submission && ($submission->status == ASSIGN_SUBMISSION_STATUS_DRAFT);
}
+ if (!$this->get_instance()->submissiondrafts) {
+ $showsubmit = false;
+ }
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_course_context());
$o .= $this->get_renderer()->render(new assign_submission_status($this->get_instance()->allowsubmissionsfromdate,
@@ -2661,6 +2660,9 @@ public function view_student_summary($user, $showlinks) {
if ($submission && ($submission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED)) {
$showsubmit = false;
}
+ if (!$this->get_instance()->submissiondrafts) {
+ $showsubmit = false;
+ }
$extensionduedate = null;
if ($grade) {
$extensionduedate = $grade->extensionduedate;
View
@@ -572,10 +572,11 @@ public function render_assign_submission_status(assign_submission_status $status
$t->data[] = $row;
foreach ($status->submissionplugins as $plugin) {
+ $pluginshowsummary = !$plugin->is_empty($submission) || !$plugin->allow_submissions();
if ($plugin->is_enabled() &&
$plugin->is_visible() &&
$plugin->has_user_summary() &&
- !$plugin->is_empty($submission)) {
+ $pluginshowsummary) {
$row = new html_table_row();
$cell1 = new html_table_cell($plugin->get_name());
@@ -78,12 +78,13 @@ public function view_summary(stdClass $submission, & $showviewlink) {
}
/**
- * Always return false because at a minimum there is the comments control
+ * Always return true because the submission comments are not part of the submission form.
+ *
* @param stdClass $submission
* @return bool
*/
public function is_empty(stdClass $submission) {
- return false;
+ return true;
}
/**
@@ -422,7 +422,9 @@ public function delete_instance() {
* @return bool
*/
public function is_empty(stdClass $submission) {
- return $this->view($submission) == '';
+ $onlinetextsubmission = $this->get_onlinetext_submission($submission->id);
+
+ return empty($onlinetextsubmission->onlinetext);
}
/**

0 comments on commit 5b2313c

Please sign in to comment.