public static function grade_competency_in_plan($planid, $competencyid, $grade, $note = null) {
        global $USER, $PAGE;

        $params = self::validate_parameters(self::grade_competency_in_plan_parameters(), array(
            'planid' => $planid,
            'competencyid' => $competencyid,
            'grade' => $grade,
            'note' => $note
        ));

        $plan = new plan($params['planid']);
        $context = $plan->get_context();
        self::validate_context($context);
        $output = $PAGE->get_renderer('core');

        $evidence = api::grade_competency_in_plan(
                $plan->get('id'),
                $params['competencyid'],
                $params['grade'],
                $params['note']
        );
        $competency = api::read_competency($params['competencyid']);
        $scale = $competency->get_scale();
        $exporter = new evidence_exporter($evidence, [
            'actionuser' => $USER,
            'scale' => $scale,
            'usercompetency' => null,
            'usercompetencyplan' => null,
            'context' => $evidence->get_context()
        ]);
        return $exporter->export($output);
    }