mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-45296 mod_assign: Revert changes to lock_submission and unlock_submission events
This commit is contained in:
parent
2fe085b284
commit
6d90ef2b4a
@ -47,14 +47,13 @@ class submission_locked extends base {
|
||||
* @since Moodle 2.7
|
||||
*
|
||||
* @param \assign $assign
|
||||
* @param \stdClass $submission
|
||||
* @param \stdClass $user
|
||||
* @return submission_locked
|
||||
*/
|
||||
public static function create_from_submission(\assign $assign, \stdClass $submission, \stdClass $user) {
|
||||
public static function create_from_user(\assign $assign, \stdClass $user) {
|
||||
$data = array(
|
||||
'context' => $assign->get_context(),
|
||||
'objectid' => $submission->id,
|
||||
'objectid' => $assign->get_instance()->id,
|
||||
'relateduserid' => $user->id,
|
||||
);
|
||||
self::$preventcreatecall = false;
|
||||
@ -93,7 +92,7 @@ class submission_locked extends base {
|
||||
protected function init() {
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_TEACHING;
|
||||
$this->data['objecttable'] = 'assign_submission';
|
||||
$this->data['objecttable'] = 'assign';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,7 +114,7 @@ class submission_locked extends base {
|
||||
*/
|
||||
protected function validate_data() {
|
||||
if (self::$preventcreatecall) {
|
||||
throw new \coding_exception('cannot call submission_locked::create() directly, use submission_locked::create_from_submission() instead.');
|
||||
throw new \coding_exception('cannot call submission_locked::create() directly, use submission_locked::create_from_user() instead.');
|
||||
}
|
||||
|
||||
parent::validate_data();
|
||||
|
@ -47,14 +47,13 @@ class submission_unlocked extends base {
|
||||
* @since Moodle 2.7
|
||||
*
|
||||
* @param \assign $assign
|
||||
* @param \stdClass $submission
|
||||
* @param \stdClass $user
|
||||
* @return submission_unlocked
|
||||
*/
|
||||
public static function create_from_submission(\assign $assign, \stdClass $submission, \stdClass $user) {
|
||||
public static function create_from_user(\assign $assign, \stdClass $user) {
|
||||
$data = array(
|
||||
'context' => $assign->get_context(),
|
||||
'objectid' => $submission->id,
|
||||
'objectid' => $assign->get_instance()->id,
|
||||
'relateduserid' => $user->id,
|
||||
);
|
||||
self::$preventcreatecall = false;
|
||||
@ -93,7 +92,7 @@ class submission_unlocked extends base {
|
||||
protected function init() {
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_TEACHING;
|
||||
$this->data['objecttable'] = 'assign_submission';
|
||||
$this->data['objecttable'] = 'assign';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,7 +114,7 @@ class submission_unlocked extends base {
|
||||
*/
|
||||
protected function validate_data() {
|
||||
if (self::$preventcreatecall) {
|
||||
throw new \coding_exception('cannot call submission_unlocked::create() directly, use submission_unlocked::create_from_submission() instead.');
|
||||
throw new \coding_exception('cannot call submission_unlocked::create() directly, use submission_unlocked::create_from_user() instead.');
|
||||
}
|
||||
|
||||
parent::validate_data();
|
||||
|
@ -6106,7 +6106,7 @@ class assign {
|
||||
}
|
||||
|
||||
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
|
||||
\mod_assign\event\submission_locked::create_from_submission($this, $submission, $user)->trigger();
|
||||
\mod_assign\event\submission_locked::create_from_user($this, $user)->trigger();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -6231,7 +6231,7 @@ class assign {
|
||||
}
|
||||
|
||||
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
|
||||
\mod_assign\event\submission_unlocked::create_from_submission($this, $submission, $user)->trigger();
|
||||
\mod_assign\event\submission_unlocked::create_from_user($this, $user)->trigger();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,6 @@ class assign_events_testcase extends mod_assign_base_testcase {
|
||||
$assign = $this->create_instance();
|
||||
$sink = $this->redirectEvents();
|
||||
|
||||
$submission = $assign->get_user_submission($this->students[0]->id, true);
|
||||
$assign->lock_submission($this->students[0]->id);
|
||||
|
||||
$events = $sink->get_events();
|
||||
@ -447,7 +446,6 @@ class assign_events_testcase extends mod_assign_base_testcase {
|
||||
$assign = $this->create_instance();
|
||||
$sink = $this->redirectEvents();
|
||||
|
||||
$submission = $assign->get_user_submission($this->students[0]->id, true);
|
||||
$assign->unlock_submission($this->students[0]->id);
|
||||
|
||||
$events = $sink->get_events();
|
||||
|
@ -470,7 +470,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$course->id,
|
||||
$teacherrole->id);
|
||||
|
||||
// Create a student1 and student2 with an online text submission.
|
||||
// Create a student1 with an online text submission.
|
||||
// Simulate a submission.
|
||||
$this->setUser($student1);
|
||||
$submission = $assign->get_user_submission($student1->id, true);
|
||||
@ -481,15 +481,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
||||
$plugin->save($submission, $data);
|
||||
|
||||
$this->setUser($student2);
|
||||
$submission = $assign->get_user_submission($student2->id, true);
|
||||
$data = new stdClass();
|
||||
$data->onlinetext_editor = array('itemid'=>file_get_unused_draft_itemid(),
|
||||
'text'=>'Submission text',
|
||||
'format'=>FORMAT_MOODLE);
|
||||
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
||||
$plugin->save($submission, $data);
|
||||
|
||||
// Ready to test.
|
||||
$this->setUser($teacher);
|
||||
$students = array($student1->id, $student2->id);
|
||||
@ -543,7 +534,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$course->id,
|
||||
$teacherrole->id);
|
||||
|
||||
// Create a student1 and student2 with an online text submission.
|
||||
// Create a student1 with an online text submission.
|
||||
// Simulate a submission.
|
||||
$this->setUser($student1);
|
||||
$submission = $assign->get_user_submission($student1->id, true);
|
||||
@ -554,15 +545,6 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
||||
$plugin->save($submission, $data);
|
||||
|
||||
$this->setUser($student2);
|
||||
$submission = $assign->get_user_submission($student2->id, true);
|
||||
$data = new stdClass();
|
||||
$data->onlinetext_editor = array('itemid'=>file_get_unused_draft_itemid(),
|
||||
'text'=>'Submission text',
|
||||
'format'=>FORMAT_MOODLE);
|
||||
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
||||
$plugin->save($submission, $data);
|
||||
|
||||
// Ready to test.
|
||||
$this->setUser($teacher);
|
||||
$students = array($student1->id, $student2->id);
|
||||
|
@ -9,7 +9,6 @@ This files describes API changes in the assign code.
|
||||
* A new web service function mod_assign_save_grades has been added which allows multiple grades to be processed.
|
||||
* The event submission_updated() [mod/assign/classes/event/submission_updated.php] has been altered to now be an abstract class
|
||||
for submission events in the submission plug-ins.
|
||||
* The subscription_created and subscription_deleted event's objecttables have been changed from 'assign' to 'assign_submission'
|
||||
|
||||
=== 2.6.1 ===
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user