mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
MDL-36804 mod_assign - allow students to resubmit work and display a submission + grading history
This is based on work by Davo Smith with input from Fernando Oliveira (Thanks guys!).
This commit is contained in:
parent
bf6c1d0997
commit
df211804f1
26 changed files with 1839 additions and 262 deletions
|
@ -62,7 +62,18 @@ class backup_assign_activity_structure_step extends backup_activity_structure_st
|
|||
'requireallteammemberssubmit',
|
||||
'teamsubmissiongroupingid',
|
||||
'blindmarking',
|
||||
'revealidentities'));
|
||||
'revealidentities',
|
||||
'attemptreopenmethod',
|
||||
'maxattempts'));
|
||||
|
||||
$userflags = new backup_nested_element('userflags');
|
||||
|
||||
$userflag = new backup_nested_element('userflag', array('id'),
|
||||
array('userid',
|
||||
'assignment',
|
||||
'mailed',
|
||||
'locked',
|
||||
'extensionduedate'));
|
||||
|
||||
$submissions = new backup_nested_element('submissions');
|
||||
|
||||
|
@ -71,7 +82,8 @@ class backup_assign_activity_structure_step extends backup_activity_structure_st
|
|||
'timecreated',
|
||||
'timemodified',
|
||||
'status',
|
||||
'groupid'));
|
||||
'groupid',
|
||||
'attemptnumber'));
|
||||
|
||||
$grades = new backup_nested_element('grades');
|
||||
|
||||
|
@ -81,9 +93,7 @@ class backup_assign_activity_structure_step extends backup_activity_structure_st
|
|||
'timemodified',
|
||||
'grader',
|
||||
'grade',
|
||||
'locked',
|
||||
'mailed',
|
||||
'extensionduedate'));
|
||||
'attemptnumber'));
|
||||
|
||||
$pluginconfigs = new backup_nested_element('plugin_configs');
|
||||
|
||||
|
@ -94,7 +104,8 @@ class backup_assign_activity_structure_step extends backup_activity_structure_st
|
|||
'value'));
|
||||
|
||||
// Build the tree.
|
||||
|
||||
$assign->add_child($userflags);
|
||||
$userflags->add_child($userflag);
|
||||
$assign->add_child($submissions);
|
||||
$submissions->add_child($submission);
|
||||
$assign->add_child($grades);
|
||||
|
@ -108,6 +119,9 @@ class backup_assign_activity_structure_step extends backup_activity_structure_st
|
|||
array('assignment' => backup::VAR_PARENTID));
|
||||
|
||||
if ($userinfo) {
|
||||
$userflag->set_source_table('assign_user_flags',
|
||||
array('assignment' => backup::VAR_PARENTID));
|
||||
|
||||
$submission->set_source_table('assign_submission',
|
||||
array('assignment' => backup::VAR_PARENTID));
|
||||
|
||||
|
@ -120,6 +134,7 @@ class backup_assign_activity_structure_step extends backup_activity_structure_st
|
|||
}
|
||||
|
||||
// Define id annotations.
|
||||
$userflag->annotate_ids('user', 'userid');
|
||||
$submission->annotate_ids('user', 'userid');
|
||||
$submission->annotate_ids('group', 'groupid');
|
||||
$grade->annotate_ids('user', 'userid');
|
||||
|
|
|
@ -130,6 +130,30 @@ class restore_assign_activity_structure_step extends restore_activity_structure_
|
|||
$this->set_mapping('submission', $oldid, $newitemid, false, null, $this->task->get_old_contextid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a user_flags restore
|
||||
* @param object $data The data in object form
|
||||
* @return void
|
||||
*/
|
||||
protected function process_assign_userflags($data) {
|
||||
global $DB;
|
||||
|
||||
$data = (object)$data;
|
||||
$oldid = $data->id;
|
||||
|
||||
$data->assignment = $this->get_new_parentid('assign');
|
||||
|
||||
$data->userid = $this->get_mappingid('user', $data->userid);
|
||||
if (!empty($data->extensionduedate)) {
|
||||
$data->extensionduedate = $this->apply_date_offset($data->extensionduedate);
|
||||
} else {
|
||||
$data->extensionduedate = 0;
|
||||
}
|
||||
// Flags mailed and locked need no translation on restore.
|
||||
|
||||
$newitemid = $DB->insert_record('assign_user_flags', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a grade restore
|
||||
* @param object $data The data in object form
|
||||
|
@ -147,11 +171,20 @@ class restore_assign_activity_structure_step extends restore_activity_structure_
|
|||
$data->timecreated = $this->apply_date_offset($data->timecreated);
|
||||
$data->userid = $this->get_mappingid('user', $data->userid);
|
||||
$data->grader = $this->get_mappingid('user', $data->grader);
|
||||
|
||||
// Handle flags restore to a different table.
|
||||
$flags = new stdClass();
|
||||
$flags->assignment = $this->get_new_parentid('assign');
|
||||
if (!empty($data->extensionduedate)) {
|
||||
$data->extensionduedate = $this->apply_date_offset($data->extensionduedate);
|
||||
} else {
|
||||
$data->extensionduedate = 0;
|
||||
$flags->extensionduedate = $this->apply_date_offset($data->extensionduedate);
|
||||
}
|
||||
if (!empty($data->mailed)) {
|
||||
$flags->mailed = $data->mailed;
|
||||
}
|
||||
if (!empty($data->locked)) {
|
||||
$flags->locked = $data->locked;
|
||||
}
|
||||
$DB->insert_record('assign_user_flags', $flags);
|
||||
|
||||
$newitemid = $DB->insert_record('assign_grades', $data);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue