Пример #1
0
        } else {
            if (empty($formdata->id) or empty($submission->id) or $formdata->id != $submission->id) {
                throw new moodle_exception('err_submissionid', 'workshop');
            }
        }
        $params['objectid'] = $submission->id;
        // save and relink embedded images and save attachments
        $formdata = file_postupdate_standard_editor($formdata, 'content', $contentopts, $workshop->context, 'mod_workshop', 'submission_content', $submission->id);
        $formdata = file_postupdate_standard_filemanager($formdata, 'attachment', $attachmentopts, $workshop->context, 'mod_workshop', 'submission_attachment', $submission->id);
        if (empty($formdata->attachment)) {
            // explicit cast to zero integer
            $formdata->attachment = 0;
        }
        // store the updated values or re-save the new submission (re-saving needed because URLs are now rewritten)
        $DB->update_record('workshop_submissions', $formdata);
        $event = \mod_workshop\event\submission_updated::create($params);
        $event->add_record_snapshot('workshop', $workshoprecord);
        $event->trigger();
        // send submitted content for plagiarism detection
        $fs = get_file_storage();
        $files = $fs->get_area_files($workshop->context->id, 'mod_workshop', 'submission_attachment', $submission->id);
        $params['other']['content'] = $formdata->content;
        $params['other']['pathnamehashes'] = array_keys($files);
        $event = \mod_workshop\event\assessable_uploaded::create($params);
        $event->set_legacy_logdata($logdata);
        $event->trigger();
        redirect($workshop->submission_url($formdata->id));
    }
}
// load the form to override grade and/or publish the submission and process the submitted data eventually
if (!$edit and ($canoverride or $canpublish)) {
Пример #2
0
 /**
  * There is no api involved so the best we can do is test legacy data by triggering event manually.
  */
 public function test_submission_updated_event()
 {
     $this->resetAfterTest();
     $this->setAdminUser();
     $user = $this->getDataGenerator()->create_user();
     $submissionid = 48;
     $event = \mod_workshop\event\submission_updated::create(array('objectid' => $submissionid, 'context' => $this->context, 'courseid' => $this->course->id, 'relateduserid' => $user->id, 'other' => array('submissiontitle' => 'The submission title')));
     // Trigger and capture the event.
     $sink = $this->redirectEvents();
     $event->trigger();
     $events = $sink->get_events();
     $event = reset($events);
     // Check that the legacy log data is valid.
     $expected = array($this->course->id, 'workshop', 'update submission', 'submission.php?cmid=' . $this->cm->id . '&id=' . $submissionid, $submissionid, $this->cm->id);
     $this->assertEventLegacyLogData($expected, $event);
     $this->assertEventContextNotUsed($event);
     $sink->close();
 }