public function process_question_category_context($data) {

        switch ($data['level']) {
        case 'module':
            $this->currentcategory['contextid'] = $this->converter->get_contextid(CONTEXT_MODULE, $data['instance']);
            $this->currentcategory['contextlevel'] = CONTEXT_MODULE;
            $this->currentcategory['contextinstanceid'] = $data['instance'];
            break;
        case 'course':
            $originalcourseinfo = $this->converter->get_stash('original_course_info');
            $originalcourseid   = $originalcourseinfo['original_course_id'];
            $this->currentcategory['contextid'] = $this->converter->get_contextid(CONTEXT_COURSE);
            $this->currentcategory['contextlevel'] = CONTEXT_COURSE;
            $this->currentcategory['contextinstanceid'] = $originalcourseid;
            break;
        case 'coursecategory':
            // this is a bit hacky. the source moodle.xml defines COURSECATEGORYLEVEL as a distance
            // of the course category (1 = parent category, 2 = grand-parent category etc). We pretend
            // that this level*10 is the id of that category and create an artifical contextid for it
            $this->currentcategory['contextid'] = $this->converter->get_contextid(CONTEXT_COURSECAT, $data['coursecategorylevel'] * 10);
            $this->currentcategory['contextlevel'] = CONTEXT_COURSECAT;
            $this->currentcategory['contextinstanceid'] = $data['coursecategorylevel'] * 10;
            break;
        case 'system':
            $this->currentcategory['contextid'] = $this->converter->get_contextid(CONTEXT_SYSTEM);
            $this->currentcategory['contextlevel'] = CONTEXT_SYSTEM;
            $this->currentcategory['contextinstanceid'] = 0;
            break;
        }
    }
public function process_question_category_context($data) {

        switch ($data['level']) {
        case 'module':
            $this->currentcategory['contextid'] = $this->converter->get_contextid(CONTEXT_MODULE, $data['instance']);
            $this->currentcategory['contextlevel'] = CONTEXT_MODULE;
            $this->currentcategory['contextinstanceid'] = $data['instance'];
            break;
        case 'course':
            $originalcourseinfo = $this->converter->get_stash('original_course_info');
            $originalcourseid   = $originalcourseinfo['original_course_id'];
            $this->currentcategory['contextid'] = $this->converter->get_contextid(CONTEXT_COURSE);
            $this->currentcategory['contextlevel'] = CONTEXT_COURSE;
            $this->currentcategory['contextinstanceid'] = $originalcourseid;
            break;
        case 'coursecategory':
            // this is a bit hacky. the source moodle.xml defines COURSECATEGORYLEVEL as a distance
            // of the course category (1 = parent category, 2 = grand-parent category etc). We pretend
            // that this level*10 is the id of that category and create an artifical contextid for it
            $this->currentcategory['contextid'] = $this->converter->get_contextid(CONTEXT_COURSECAT, $data['coursecategorylevel'] * 10);
            $this->currentcategory['contextlevel'] = CONTEXT_COURSECAT;
            $this->currentcategory['contextinstanceid'] = $data['coursecategorylevel'] * 10;
            break;
        case 'system':
            $this->currentcategory['contextid'] = $this->converter->get_contextid(CONTEXT_SYSTEM);
            $this->currentcategory['contextlevel'] = CONTEXT_SYSTEM;
            $this->currentcategory['contextinstanceid'] = 0;
            break;
        }
    }
public function process_question_category_context ( $ data ) { switch ( $ data [ 'level' ] ) { case 'module' : $ this -> currentcategory [ 'contextid' ] = $ this -> converter -> get_contextid ( CONTEXT_MODULE , $ data [ 'instance' ] ) ; $ this -> currentcategory [ 'contextlevel' ] = CONTEXT_MODULE ; $ this -> currentcategory [ 'contextinstanceid' ] = $ data [ 'instance' ] ; break ; case 'course' : $ originalcourseinfo = $ this -> converter -> get_stash ( 'original_course_info' ) ; $ originalcourseid = $ originalcourseinfo [ 'original_course_id' ] ; $ this -> currentcategory [ 'contextid' ] = $ this -> converter -> get_contextid ( CONTEXT_COURSE ) ; $ this -> currentcategory [ 'contextlevel' ] = CONTEXT_COURSE ; $ this -> currentcategory [ 'contextinstanceid' ] = $ originalcourseid ; break ; case 'coursecategory' : // this is a bit hacky. the source moodle.xml defines COURSECATEGORYLEVEL as a distance // of the course category (1 = parent category, 2 = grand-parent category etc). We pretend // that this level*10 is the id of that category and create an artifical contextid for it $ this -> currentcategory [ 'contextid' ] = $ this -> converter -> get_contextid ( CONTEXT_COURSECAT , $ data [ 'coursecategorylevel' ] * 10 ) ; $ this -> currentcategory [ 'contextlevel' ] = CONTEXT_COURSECAT ; $ this -> currentcategory [ 'contextinstanceid' ] = $ data [ 'coursecategorylevel' ] * 10 ; break ; case 'system' : $ this -> currentcategory [ 'contextid' ] = $ this -> converter -> get_contextid ( CONTEXT_SYSTEM ) ; $ this -> currentcategory [ 'contextlevel' ] = CONTEXT_SYSTEM ; $ this -> currentcategory [ 'contextinstanceid' ] = 0 ; break ; } }
Inject the context related information into the current category
Inject the context related information into the current category