public static function create_from_question_instance($question, $context = null, $other = null) {

        $params = ['objectid' => $question->id, 'other' => ['categoryid' => $question->category]];

        if (!empty($question->contextid)) {
            $params['contextid'] = $question->contextid;
        }

        $params['context'] = $context;

        if (!empty($other)) {
            $params['other'] = $other;
        }

        $event = self::create($params);
        return $event;
    }
public static function create_from_question_instance($question, $context = null, $other = null) {

        $params = ['objectid' => $question->id, 'other' => ['categoryid' => $question->category]];

        if (!empty($question->contextid)) {
            $params['contextid'] = $question->contextid;
        }

        $params['context'] = $context;

        if (!empty($other)) {
            $params['other'] = $other;
        }

        $event = self::create($params);
        return $event;
    }
public static function create_from_question_instance ( $ question , $ context = null , $ other = null ) { $ params = [ 'objectid' => $ question -> id , 'other' => [ 'categoryid' => $ question -> category ] ] ; if ( ! empty ( $ question -> contextid ) ) { $ params [ 'contextid' ] = $ question -> contextid ; } $ params [ 'context' ] = $ context ; if ( ! empty ( $ other ) ) { $ params [ 'other' ] = $ other ; } $ event = self :: create ( $ params ) ; return $ event ; }
Create a event from question object

@param object $question
@param object|null $context
@param array|null $other will override the categoryid pre-filled out on the first line.
@return base
@throws \coding_exception
Create a event from question object