original_string: public static function grade_competency($userid, $competencyid, $grade, $note = null) {
          global $USER, $PAGE;
          $params = self::validate_parameters(self::grade_competency_parameters(), array(
              'userid' => $userid,
              'competencyid' => $competencyid,
              'grade' => $grade,
              'note' => $note
          ));
  
          $uc = api::get_user_competency($params['userid'], $params['competencyid']);
          self::validate_context($uc->get_context());
  
          $output = $PAGE->get_renderer('core');
          $evidence = api::grade_competency(
                  $uc->get('userid'),
                  $uc->get('competencyid'),
                  $params['grade'],
                  $params['note']
          );
  
          $scale = $uc->get_competency()->get_scale();
          $exporter = new evidence_exporter($evidence, [
              'actionuser' => $USER,
              'scale' => $scale,
              'usercompetency' => $uc,
              'usercompetencyplan' => null,
              'context' => $evidence->get_context()
          ]);
          return $exporter->export($output);
      }
code: public static function grade_competency($userid, $competencyid, $grade, $note = null) {
          global $USER, $PAGE;
          $params = self::validate_parameters(self::grade_competency_parameters(), array(
              'userid' => $userid,
              'competencyid' => $competencyid,
              'grade' => $grade,
              'note' => $note
          ));
  
          $uc = api::get_user_competency($params['userid'], $params['competencyid']);
          self::validate_context($uc->get_context());
  
          $output = $PAGE->get_renderer('core');
          $evidence = api::grade_competency(
                  $uc->get('userid'),
                  $uc->get('competencyid'),
                  $params['grade'],
                  $params['note']
          );
  
          $scale = $uc->get_competency()->get_scale();
          $exporter = new evidence_exporter($evidence, [
              'actionuser' => $USER,
              'scale' => $scale,
              'usercompetency' => $uc,
              'usercompetencyplan' => null,
              'context' => $evidence->get_context()
          ]);
          return $exporter->export($output);
      }
code_tokens: public static function grade_competency ( $ userid , $ competencyid , $ grade , $ note = null ) { global $ USER , $ PAGE ; $ params = self :: validate_parameters ( self :: grade_competency_parameters ( ) , array ( 'userid' => $ userid , 'competencyid' => $ competencyid , 'grade' => $ grade , 'note' => $ note ) ) ; $ uc = api :: get_user_competency ( $ params [ 'userid' ] , $ params [ 'competencyid' ] ) ; self :: validate_context ( $ uc -> get_context ( ) ) ; $ output = $ PAGE -> get_renderer ( 'core' ) ; $ evidence = api :: grade_competency ( $ uc -> get ( 'userid' ) , $ uc -> get ( 'competencyid' ) , $ params [ 'grade' ] , $ params [ 'note' ] ) ; $ scale = $ uc -> get_competency ( ) -> get_scale ( ) ; $ exporter = new evidence_exporter ( $ evidence , [ 'actionuser' => $ USER , 'scale' => $ scale , 'usercompetency' => $ uc , 'usercompetencyplan' => null , 'context' => $ evidence -> get_context ( ) ] ) ; return $ exporter -> export ( $ output ) ; }
docstring: Grade a competency.
  
  @param int $userid The user ID.
  @param int $competencyid The competency id
  @param int $grade The new grade value
  @param string $note A note to attach to the evidence
  @return bool
docstring_tokens: Grade a competency .