original_string: public static function grade_competency_in_course($courseid, $userid, $competencyid, $grade, $note = null) {
          global $USER, $PAGE, $DB;
  
          $params = self::validate_parameters(self::grade_competency_in_course_parameters(), array(
              'courseid' => $courseid,
              'userid' => $userid,
              'competencyid' => $competencyid,
              'grade' => $grade,
              'note' => $note
          ));
  
          $course = $DB->get_record('course', array('id' => $params['courseid']));
          $context = context_course::instance($course->id);
          self::validate_context($context);
          $output = $PAGE->get_renderer('core');
  
          $evidence = api::grade_competency_in_course(
                  $params['courseid'],
                  $params['userid'],
                  $params['competencyid'],
                  $params['grade'],
                  $params['note']
          );
          $competency = api::read_competency($params['competencyid']);
          $scale = $competency->get_scale();
          $exporter = new evidence_exporter($evidence, array(
              'actionuser' => $USER,
              'scale' => $scale,
              'usercompetency' => null,
              'usercompetencyplan' => null,
              'context' => $evidence->get_context(),
          ));
          return $exporter->export($output);
      }
code: public static function grade_competency_in_course($courseid, $userid, $competencyid, $grade, $note = null) {
          global $USER, $PAGE, $DB;
  
          $params = self::validate_parameters(self::grade_competency_in_course_parameters(), array(
              'courseid' => $courseid,
              'userid' => $userid,
              'competencyid' => $competencyid,
              'grade' => $grade,
              'note' => $note
          ));
  
          $course = $DB->get_record('course', array('id' => $params['courseid']));
          $context = context_course::instance($course->id);
          self::validate_context($context);
          $output = $PAGE->get_renderer('core');
  
          $evidence = api::grade_competency_in_course(
                  $params['courseid'],
                  $params['userid'],
                  $params['competencyid'],
                  $params['grade'],
                  $params['note']
          );
          $competency = api::read_competency($params['competencyid']);
          $scale = $competency->get_scale();
          $exporter = new evidence_exporter($evidence, array(
              'actionuser' => $USER,
              'scale' => $scale,
              'usercompetency' => null,
              'usercompetencyplan' => null,
              'context' => $evidence->get_context(),
          ));
          return $exporter->export($output);
      }
code_tokens: public static function grade_competency_in_course ( $ courseid , $ userid , $ competencyid , $ grade , $ note = null ) { global $ USER , $ PAGE , $ DB ; $ params = self :: validate_parameters ( self :: grade_competency_in_course_parameters ( ) , array ( 'courseid' => $ courseid , 'userid' => $ userid , 'competencyid' => $ competencyid , 'grade' => $ grade , 'note' => $ note ) ) ; $ course = $ DB -> get_record ( 'course' , array ( 'id' => $ params [ 'courseid' ] ) ) ; $ context = context_course :: instance ( $ course -> id ) ; self :: validate_context ( $ context ) ; $ output = $ PAGE -> get_renderer ( 'core' ) ; $ evidence = api :: grade_competency_in_course ( $ params [ 'courseid' ] , $ params [ 'userid' ] , $ params [ 'competencyid' ] , $ params [ 'grade' ] , $ params [ 'note' ] ) ; $ competency = api :: read_competency ( $ params [ 'competencyid' ] ) ; $ scale = $ competency -> get_scale ( ) ; $ exporter = new evidence_exporter ( $ evidence , array ( 'actionuser' => $ USER , 'scale' => $ scale , 'usercompetency' => null , 'usercompetencyplan' => null , 'context' => $ evidence -> get_context ( ) , ) ) ; return $ exporter -> export ( $ output ) ; }
docstring: Grade a competency in a course.
  
  @param int $courseid The course id
  @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 add to the evidence
  @return bool
docstring_tokens: Grade a competency in a course .