Skip to content

Commit

Permalink
Merge branch '42350-24' of git://github.com/samhemelryk/moodle into M…
Browse files Browse the repository at this point in the history
…OODLE_24_STABLE
  • Loading branch information
danpoltawski committed Nov 4, 2013
2 parents 8cd148e + 71a5c48 commit dcb6e41
Showing 1 changed file with 38 additions and 16 deletions.
54 changes: 38 additions & 16 deletions mod/assign/locallib.php
Expand Up @@ -2922,22 +2922,9 @@ public function view_student_summary($user, $showlinks) {
}
}

$showsubmit = ($submission || $teamsubmission) && $showlinks && $this->submissions_open($user->id);
if ($teamsubmission && ($teamsubmission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED)) {
$showsubmit = false;
}
if ($teamsubmission && $this->submission_empty($teamsubmission)) {
$showsubmit = false;
}
if ($submission && ($submission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED)) {
$showsubmit = false;
}
if ($submission && $this->submission_empty($submission)) {
$showsubmit = false;
}
if (!$this->get_instance()->submissiondrafts) {
$showsubmit = false;
}
$showsubmit = ($showlinks && $this->submissions_open($user->id));
$showsubmit = ($showsubmit && $this->show_submit_button($submission, $teamsubmission));

$extensionduedate = null;
if ($grade) {
$extensionduedate = $grade->extensionduedate;
Expand Down Expand Up @@ -3042,6 +3029,41 @@ public function view_student_summary($user, $showlinks) {
return $o;
}

/**
* Returns true if the submit subsission button should be shown to the user.
*
* @param stdClass $submission The users own submission record.
* @param stdClass $teamsubmission The users team submission record if there is one
* @return bool
*/
protected function show_submit_button($submission = null, $teamsubmission = null) {
if ($teamsubmission) {
if ($teamsubmission->status === ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
// The assignment submission has been completed.
return false;
} else if ($this->submission_empty($teamsubmission)) {
// There is nothing to submit yet.
return false;
} else if ($submission && $submission->status === ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
// The user has already clicked the submit button on the team submission.
return false;
}
} else if ($submission) {
if ($submission->status === ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
// The assignment submission has been completed.
return false;
} else if ($this->submission_empty($submission)) {
// There is nothing to submit.
return false;
}
} else {
// We've not got a valid submission or team submission.
return false;
}
// Last check is that this instance allows drafts.
return $this->get_instance()->submissiondrafts;
}

/**
* View submissions page (contains details of current submission).
*
Expand Down

0 comments on commit dcb6e41

Please sign in to comment.