original_string: public function process_user_competency_course($data) {
          global $USER, $DB;
          $data = (object) $data;
  
          $data->competencyid = $this->get_mappingid(\core_competency\competency::TABLE, $data->competencyid);
          if (!$data->competencyid) {
              // This is strange, the competency does not belong to the course.
              return;
          } else if ($data->grade === null) {
              // We do not need to do anything when there is no grade.
              return;
          }
  
          $data->userid = $this->get_mappingid('user', $data->userid);
          $shortname = $DB->get_field('course', 'shortname', array('id' => $this->task->get_courseid()), MUST_EXIST);
  
          // The method add_evidence also sets the course rating.
          \core_competency\api::add_evidence($data->userid,
                                             $data->competencyid,
                                             $this->task->get_contextid(),
                                             \core_competency\evidence::ACTION_OVERRIDE,
                                             'evidence_courserestored',
                                             'core_competency',
                                             $shortname,
                                             false,
                                             null,
                                             $data->grade,
                                             $USER->id);
      }
code: public function process_user_competency_course($data) {
          global $USER, $DB;
          $data = (object) $data;
  
          $data->competencyid = $this->get_mappingid(\core_competency\competency::TABLE, $data->competencyid);
          if (!$data->competencyid) {
              // This is strange, the competency does not belong to the course.
              return;
          } else if ($data->grade === null) {
              // We do not need to do anything when there is no grade.
              return;
          }
  
          $data->userid = $this->get_mappingid('user', $data->userid);
          $shortname = $DB->get_field('course', 'shortname', array('id' => $this->task->get_courseid()), MUST_EXIST);
  
          // The method add_evidence also sets the course rating.
          \core_competency\api::add_evidence($data->userid,
                                             $data->competencyid,
                                             $this->task->get_contextid(),
                                             \core_competency\evidence::ACTION_OVERRIDE,
                                             'evidence_courserestored',
                                             'core_competency',
                                             $shortname,
                                             false,
                                             null,
                                             $data->grade,
                                             $USER->id);
      }
code_tokens: public function process_user_competency_course ( $ data ) { global $ USER , $ DB ; $ data = ( object ) $ data ; $ data -> competencyid = $ this -> get_mappingid ( \ core_competency \ competency :: TABLE , $ data -> competencyid ) ; if ( ! $ data -> competencyid ) { // This is strange, the competency does not belong to the course. return ; } else if ( $ data -> grade === null ) { // We do not need to do anything when there is no grade. return ; } $ data -> userid = $ this -> get_mappingid ( 'user' , $ data -> userid ) ; $ shortname = $ DB -> get_field ( 'course' , 'shortname' , array ( 'id' => $ this -> task -> get_courseid ( ) ) , MUST_EXIST ) ; // The method add_evidence also sets the course rating. \ core_competency \ api :: add_evidence ( $ data -> userid , $ data -> competencyid , $ this -> task -> get_contextid ( ) , \ core_competency \ evidence :: ACTION_OVERRIDE , 'evidence_courserestored' , 'core_competency' , $ shortname , false , null , $ data -> grade , $ USER -> id ) ; }
docstring: Process the user competency course.
  
  @param array $data The data.
docstring_tokens: Process the user competency course .