mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-46455 mod_*: added restore mapping to events
This commit is contained in:
parent
ef15eae433
commit
0bfafc5ba0
170 changed files with 1364 additions and 19 deletions
|
@ -93,6 +93,10 @@ class answer_submitted extends \core\event\base {
|
|||
* @return void
|
||||
*/
|
||||
protected function init() {
|
||||
// The objecttable here is wrong. We are submitting an answer, not a choice activity.
|
||||
// This also makes the description misleading as it states we made a choice with id
|
||||
// '$this->objectid' which just refers to the 'choice' table. The trigger for
|
||||
// this event should be triggered after we insert to the 'choice_answers' table.
|
||||
$this->data['crud'] = 'c';
|
||||
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
|
||||
$this->data['objecttable'] = 'choice';
|
||||
|
@ -111,4 +115,22 @@ class answer_submitted extends \core\event\base {
|
|||
throw new \coding_exception('The \'choiceid\' value must be set in other.');
|
||||
}
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'choice', 'restore' => 'choice');
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['choiceid'] = array('db' => 'choice', 'restore' => 'choice');
|
||||
|
||||
// The 'optionid' is being passed as an array, so we can't map it. The event is
|
||||
// triggered each time a choice is answered, where it may be possible to select
|
||||
// multiple choices, so the value is converted to an array, which is then passed
|
||||
// to the event. Ideally this event should be triggered every time we insert to the
|
||||
// 'choice_answers' table so this will only be an int.
|
||||
// $othermapped['optionid'] = array('db' => 'choice_options', 'restore' => 'choice_option');
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,6 +93,10 @@ class answer_updated extends \core\event\base {
|
|||
* @return void
|
||||
*/
|
||||
protected function init() {
|
||||
// The objecttable here is wrong. We are updating an answer, not a choice activity.
|
||||
// This also makes the description misleading as it states we made a choice with id
|
||||
// '$this->objectid' which just refers to the 'choice' table. The trigger for
|
||||
// this event should be triggered after we update the 'choice_answers' table.
|
||||
$this->data['crud'] = 'u';
|
||||
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
|
||||
$this->data['objecttable'] = 'choice';
|
||||
|
@ -111,4 +115,22 @@ class answer_updated extends \core\event\base {
|
|||
throw new \coding_exception('The \'choiceid\' value must be set in other.');
|
||||
}
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'choice', 'restore' => 'choice');
|
||||
}
|
||||
|
||||
public static function get_other_mapping() {
|
||||
$othermapped = array();
|
||||
$othermapped['choiceid'] = array('db' => 'choice', 'restore' => 'choice');
|
||||
|
||||
// The 'optionid' is being passed as an array, so we can't map it. The event is
|
||||
// triggered each time a choice is answered, where it may be possible to select
|
||||
// multiple choices, so the value is converted to an array, which is then passed
|
||||
// to the event. Ideally this event should be triggered every time we update the
|
||||
// 'choice_answers' table so this will only be an int.
|
||||
// $othermapped['optionid'] = array('db' => 'choice_options', 'restore' => 'choice_option');
|
||||
|
||||
return $othermapped;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,4 +43,8 @@ class course_module_viewed extends \core\event\course_module_viewed {
|
|||
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
|
||||
$this->data['objecttable'] = 'choice';
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'choice', 'restore' => 'choice');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,4 +80,8 @@ class report_viewed extends \core\event\base {
|
|||
$url = new \moodle_url('report.php', array('id' => $this->contextinstanceid));
|
||||
return array($this->courseid, 'choice', 'report', $url->out(), $this->objectid, $this->contextinstanceid);
|
||||
}
|
||||
|
||||
public static function get_objectid_mapping() {
|
||||
return array('db' => 'choice', 'restore' => 'choice');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue