MDL-41101 assign: Add relateduserid to some events

When events are acting on another users submission, it makes
sense to put the submission->userid in the relateduserid field.
This commit is contained in:
Damyon Wiese 2014-04-17 13:25:45 +08:00 committed by Marina Glancy
parent 43a7ac723d
commit 5cfa441ba7
3 changed files with 11 additions and 0 deletions

View File

@ -52,6 +52,8 @@ class assessable_submitted extends base {
* @return assessable_submitted
*/
public static function create_from_submission(\assign $assign, \stdClass $submission, $editable) {
global $USER;
$data = array(
'context' => $assign->get_context(),
'objectid' => $submission->id,
@ -59,6 +61,9 @@ class assessable_submitted extends base {
'submission_editable' => $editable,
),
);
if (!empty($submission->userid) && ($submission->userid != $USER->id)) {
$data['relateduserid'] = $submission->userid;
}
/** @var assessable_submitted $event */
$event = self::create($data);
$event->set_assign($assign);

View File

@ -227,6 +227,9 @@ class assign_submission_file extends assign_submission_plugin {
'pathnamehashes' => array_keys($files)
)
);
if (!empty($submission->userid) && ($submission->userid != $USER->id)) {
$params->relateduserid = $submission->userid;
}
$event = \assignsubmission_file\event\assessable_uploaded::create($params);
$event->set_legacy_files($files);
$event->trigger();

View File

@ -228,6 +228,9 @@ class assign_submission_onlinetext extends assign_submission_plugin {
'format' => $data->onlinetext_editor['format']
)
);
if (!empty($submission->userid) && ($submission->userid != $USER->id)) {
$params['relateduserid'] = $submission->userid;
}
$event = \assignsubmission_onlinetext\event\assessable_uploaded::create($params);
$event->trigger();