forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-43557 fix BC issue in \core\event\course_completed and incorrect …
…description
- Loading branch information
Showing
2 changed files
with
39 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,12 +29,37 @@ | |
/** | ||
* Course completed event class. | ||
* | ||
* @property-read int $relateduserid user who completed the course | ||
* @property-read array $other { | ||
* Extra information about event. | ||
* | ||
* - int relateduserid: deprecated since 2.7, please use property relateduserid | ||
* } | ||
* | ||
* @package core | ||
* @since Moodle 2.6 | ||
* @copyright 2013 Rajesh Taneja <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class course_completed extends base { | ||
/** | ||
* Create event from course_completion record. | ||
* @param \stdClass $completion | ||
* @return course_completed | ||
*/ | ||
public static function create_from_completion(\stdClass $completion) { | ||
$event = self::create( | ||
array( | ||
'objectid' => $completion->id, | ||
'relateduserid' => $completion->userid, | ||
'context' => \context_course::instance($completion->course), | ||
'courseid' => $completion->course, | ||
'other' => array('relateduserid' => $completion->userid), // Deprecated since 2.7, please use property relateduserid. | ||
) | ||
); | ||
$event->add_record_snapshot('course_completions', $completion); | ||
return $event; | ||
} | ||
|
||
/** | ||
* Initialise required event data properties. | ||
|
@@ -60,7 +85,7 @@ public static function get_name() { | |
* @return string | ||
*/ | ||
public function get_description() { | ||
return "The course with the id '$this->courseid' was completed by the user with the id '$this->userid'."; | ||
return "The course with the id '$this->courseid' was completed for the user with the id '$this->relateduserid'."; | ||
} | ||
|
||
/** | ||
|
@@ -89,4 +114,16 @@ public static function get_legacy_eventname() { | |
protected function get_legacy_eventdata() { | ||
return $this->get_record_snapshot('course_completions', $this->objectid); | ||
} | ||
|
||
/** | ||
* Custom validation. | ||
* | ||
* @throws \coding_exception | ||
* @return void | ||
*/ | ||
protected function validate_data() { | ||
parent::validate_data(); | ||
|
||
// TODO: MDL-45319 add validation of relateduserid and other['relateduserid']. | ||
} | ||
} |