Merge branch 'MDL-38973-master' of https://github.com/damyon/moodle

This commit is contained in:
Dan Poltawski 2013-04-10 14:48:49 +08:00
commit a4b524e931
3 changed files with 46 additions and 29 deletions

View file

@ -468,7 +468,7 @@ class assign_grading_table extends table_sql implements renderable {
public function col_team(stdClass $row) { public function col_team(stdClass $row) {
$submission = false; $submission = false;
$group = false; $group = false;
$this->get_group_and_submission($row->id, $group, $submission); $this->get_group_and_submission($row->id, $group, $submission, -1);
if ($group) { if ($group) {
return $group->name; return $group->name;
} }
@ -481,8 +481,9 @@ class assign_grading_table extends table_sql implements renderable {
* @param int $userid The user id for this submission * @param int $userid The user id for this submission
* @param int $groupid The groupid (returned) * @param int $groupid The groupid (returned)
* @param mixed $submission The stdClass submission or false (returned) * @param mixed $submission The stdClass submission or false (returned)
* @param int $attemptnumber Return a specific attempt number (-1 for latest)
*/ */
public function get_group_and_submission($userid, &$group, &$submission) { protected function get_group_and_submission($userid, &$group, &$submission, $attemptnumber) {
$group = false; $group = false;
if (isset($this->submissiongroups[$userid])) { if (isset($this->submissiongroups[$userid])) {
$group = $this->submissiongroups[$userid]; $group = $this->submissiongroups[$userid];
@ -496,11 +497,13 @@ class assign_grading_table extends table_sql implements renderable {
$groupid = $group->id; $groupid = $group->id;
} }
if (isset($this->groupsubmissions[$groupid])) { // Static cache is keyed by groupid and attemptnumber.
$submission = $this->groupsubmissions[$groupid]; // We may need both the latest and previous attempt in the same page.
if (isset($this->groupsubmissions[$groupid . ':' . $attemptnumber])) {
$submission = $this->groupsubmissions[$groupid . ':' . $attemptnumber];
} else { } else {
$submission = $this->assignment->get_group_submission($userid, $groupid, false); $submission = $this->assignment->get_group_submission($userid, $groupid, false, $attemptnumber);
$this->groupsubmissions[$groupid] = $submission; $this->groupsubmissions[$groupid . ':' . $attemptnumber] = $submission;
} }
} }
@ -514,7 +517,7 @@ class assign_grading_table extends table_sql implements renderable {
public function col_teamstatus(stdClass $row) { public function col_teamstatus(stdClass $row) {
$submission = false; $submission = false;
$group = false; $group = false;
$this->get_group_and_submission($row->id, $group, $submission); $this->get_group_and_submission($row->id, $group, $submission, -1);
$status = ''; $status = '';
if ($submission) { if ($submission) {
@ -965,8 +968,13 @@ class assign_grading_table extends table_sql implements renderable {
if ($this->assignment->get_instance()->teamsubmission) { if ($this->assignment->get_instance()->teamsubmission) {
$group = false; $group = false;
$submission = false; $submission = false;
$this->get_group_and_submission($row->id, $group, $submission);
$this->get_group_and_submission($row->id, $group, $submission, -1);
if ($submission) { if ($submission) {
if ($submission->status == ASSIGN_SUBMISSION_STATUS_REOPENED) {
// For a newly reopened submission - we want to show the previous submission in the table.
$this->get_group_and_submission($row->id, $group, $submission, $submission->attemptnumber-1);
}
if (isset($field)) { if (isset($field)) {
return $plugin->get_editor_text($field, $submission->id); return $plugin->get_editor_text($field, $submission->id);
} }
@ -976,15 +984,21 @@ class assign_grading_table extends table_sql implements renderable {
array()); array());
} }
} else if ($row->submissionid) { } else if ($row->submissionid) {
if (isset($field)) { if ($row->status == ASSIGN_SUBMISSION_STATUS_REOPENED) {
return $plugin->get_editor_text($field, $row->submissionid); // For a newly reopened submission - we want to show the previous submission in the table.
$submission = $this->assignment->get_user_submission($row->userid, false, $row->attemptnumber - 1);
} else {
$submission = new stdClass();
$submission->id = $row->submissionid;
$submission->timecreated = $row->firstsubmission;
$submission->timemodified = $row->timesubmitted;
$submission->assignment = $this->assignment->get_instance()->id;
$submission->userid = $row->userid;
}
// Field is used for only for import/export and refers the the fieldname for the text editor.
if (isset($field)) {
return $plugin->get_editor_text($field, $submission->id);
} }
$submission = new stdClass();
$submission->id = $row->submissionid;
$submission->timecreated = $row->firstsubmission;
$submission->timemodified = $row->timesubmitted;
$submission->assignment = $this->assignment->get_instance()->id;
$submission->userid = $row->userid;
return $this->format_plugin_summary_with_link($plugin, return $this->format_plugin_summary_with_link($plugin,
$submission, $submission,
'grading', 'grading',

View file

@ -3407,22 +3407,22 @@ class assign {
$this->get_return_params()); $this->get_return_params());
$o .= $this->get_renderer()->render($feedbackstatus); $o .= $this->get_renderer()->render($feedbackstatus);
}
$allsubmissions = $this->get_all_submissions($user->id); $allsubmissions = $this->get_all_submissions($user->id);
if (count($allsubmissions) > 1) { if (count($allsubmissions) > 1) {
$allgrades = $this->get_all_grades($user->id); $allgrades = $this->get_all_grades($user->id);
$history = new assign_attempt_history($allsubmissions, $history = new assign_attempt_history($allsubmissions,
$allgrades, $allgrades,
$this->get_submission_plugins(), $this->get_submission_plugins(),
$this->get_feedback_plugins(), $this->get_feedback_plugins(),
$this->get_course_module()->id, $this->get_course_module()->id,
$this->get_return_action(), $this->get_return_action(),
$this->get_return_params(), $this->get_return_params(),
false); false);
$o .= $this->get_renderer()->render($history); $o .= $this->get_renderer()->render($history);
}
} }
} }

View file

@ -37,6 +37,9 @@ This files describes API changes in the assign code.
New renderable object "assign_attempt_history" for rendering the list of previous submissions. New renderable object "assign_attempt_history" for rendering the list of previous submissions.
New renderable object "assign_gradingmessage" for rendering a generic grading message. New renderable object "assign_gradingmessage" for rendering a generic grading message.
assign_grading_table changes:
get_group_and_submission is now protected and should not be called from outside this class.
=== Earlier changes === === Earlier changes ===