original_string: public function process_course_completion_crit_compl($data) {
          global $DB;
  
          $data = (object)$data;
  
          // This may be empty if criteria could not be restored
          $data->criteriaid = $this->get_mappingid('course_completion_criteria', $data->criteriaid);
  
          $data->course = $this->get_courseid();
          $data->userid = $this->get_mappingid('user', $data->userid);
  
          if (!empty($data->criteriaid) && !empty($data->userid)) {
              $params = array(
                  'userid' => $data->userid,
                  'course' => $data->course,
                  'criteriaid' => $data->criteriaid,
                  'timecompleted' => $data->timecompleted
              );
              if (isset($data->gradefinal)) {
                  $params['gradefinal'] = $data->gradefinal;
              }
              if (isset($data->unenroled)) {
                  $params['unenroled'] = $data->unenroled;
              }
              $DB->insert_record('course_completion_crit_compl', $params);
          }
      }
code: public function process_course_completion_crit_compl($data) {
          global $DB;
  
          $data = (object)$data;
  
          // This may be empty if criteria could not be restored
          $data->criteriaid = $this->get_mappingid('course_completion_criteria', $data->criteriaid);
  
          $data->course = $this->get_courseid();
          $data->userid = $this->get_mappingid('user', $data->userid);
  
          if (!empty($data->criteriaid) && !empty($data->userid)) {
              $params = array(
                  'userid' => $data->userid,
                  'course' => $data->course,
                  'criteriaid' => $data->criteriaid,
                  'timecompleted' => $data->timecompleted
              );
              if (isset($data->gradefinal)) {
                  $params['gradefinal'] = $data->gradefinal;
              }
              if (isset($data->unenroled)) {
                  $params['unenroled'] = $data->unenroled;
              }
              $DB->insert_record('course_completion_crit_compl', $params);
          }
      }
code_tokens: public function process_course_completion_crit_compl ( $ data ) { global $ DB ; $ data = ( object ) $ data ; // This may be empty if criteria could not be restored $ data -> criteriaid = $ this -> get_mappingid ( 'course_completion_criteria' , $ data -> criteriaid ) ; $ data -> course = $ this -> get_courseid ( ) ; $ data -> userid = $ this -> get_mappingid ( 'user' , $ data -> userid ) ; if ( ! empty ( $ data -> criteriaid ) && ! empty ( $ data -> userid ) ) { $ params = array ( 'userid' => $ data -> userid , 'course' => $ data -> course , 'criteriaid' => $ data -> criteriaid , 'timecompleted' => $ data -> timecompleted ) ; if ( isset ( $ data -> gradefinal ) ) { $ params [ 'gradefinal' ] = $ data -> gradefinal ; } if ( isset ( $ data -> unenroled ) ) { $ params [ 'unenroled' ] = $ data -> unenroled ; } $ DB -> insert_record ( 'course_completion_crit_compl' , $ params ) ; } }
docstring: Processes course compltion criteria complete records
  
  @global moodle_database $DB
  @param stdClass $data
docstring_tokens: Processes course compltion criteria complete records