public function process_course_competency($data) {
        $data = (object) $data;

        // Mapping the competency by ID numbers.
        $framework = \core_competency\competency_framework::get_record(array('idnumber' => $data->frameworkidnumber));
        if (!$framework) {
            return;
        }
        $competency = \core_competency\competency::get_record(array('idnumber' => $data->idnumber,
            'competencyframeworkid' => $framework->get('id')));
        if (!$competency) {
            return;
        }
        $this->set_mapping(\core_competency\competency::TABLE, $data->id, $competency->get('id'));

        $params = array(
            'competencyid' => $competency->get('id'),
            'courseid' => $this->task->get_courseid()
        );
        $query = 'competencyid = :competencyid AND courseid = :courseid';
        $existing = \core_competency\course_competency::record_exists_select($query, $params);

        if (!$existing) {
            // Sortorder is ignored by precaution, anyway we should walk through the records in the right order.
            $record = (object) $params;
            $record->ruleoutcome = $data->ruleoutcome;
            $coursecompetency = new \core_competency\course_competency(0, $record);
            $coursecompetency->create();
        }
    }