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;
    }