original_string: public static function get_scorm_sco_tracks($scoid, $userid, $attempt = 0) {
          global $USER, $DB;
  
          $params = self::validate_parameters(self::get_scorm_sco_tracks_parameters(),
                                              array('scoid' => $scoid, 'userid' => $userid, 'attempt' => $attempt));
  
          $tracks = array();
          $warnings = array();
  
          $sco = scorm_get_sco($params['scoid'], SCO_ONLY);
          if (!$sco) {
              throw new moodle_exception('cannotfindsco', 'scorm');
          }
  
          $scorm = $DB->get_record('scorm', array('id' => $sco->scorm), '*', MUST_EXIST);
          $cm = get_coursemodule_from_instance('scorm', $scorm->id);
  
          $context = context_module::instance($cm->id);
          self::validate_context($context);
  
          $user = core_user::get_user($params['userid'], '*', MUST_EXIST);
          core_user::require_active_user($user);
  
          // Extra checks so only users with permissions can view other users attempts.
          if ($USER->id != $user->id) {
              require_capability('mod/scorm:viewreport', $context);
          }
  
          scorm_require_available($scorm, true, $context);
  
          if (empty($params['attempt'])) {
              $params['attempt'] = scorm_get_last_attempt($scorm->id, $user->id);
          }
  
          $attempted = false;
          if ($scormtracks = scorm_get_tracks($sco->id, $params['userid'], $params['attempt'])) {
              // Check if attempted.
              if ($scormtracks->status != '') {
                  $attempted = true;
                  foreach ($scormtracks as $element => $value) {
                      $tracks[] = array(
                          'element' => $element,
                          'value' => $value,
                      );
                  }
              }
          }
  
          if (!$attempted) {
              $warnings[] = array(
                  'item' => 'attempt',
                  'itemid' => $params['attempt'],
                  'warningcode' => 'notattempted',
                  'message' => get_string('notattempted', 'scorm')
              );
          }
  
          $result = array();
          $result['data']['attempt'] = $params['attempt'];
          $result['data']['tracks'] = $tracks;
          $result['warnings'] = $warnings;
          return $result;
      }
code: public static function get_scorm_sco_tracks($scoid, $userid, $attempt = 0) {
          global $USER, $DB;
  
          $params = self::validate_parameters(self::get_scorm_sco_tracks_parameters(),
                                              array('scoid' => $scoid, 'userid' => $userid, 'attempt' => $attempt));
  
          $tracks = array();
          $warnings = array();
  
          $sco = scorm_get_sco($params['scoid'], SCO_ONLY);
          if (!$sco) {
              throw new moodle_exception('cannotfindsco', 'scorm');
          }
  
          $scorm = $DB->get_record('scorm', array('id' => $sco->scorm), '*', MUST_EXIST);
          $cm = get_coursemodule_from_instance('scorm', $scorm->id);
  
          $context = context_module::instance($cm->id);
          self::validate_context($context);
  
          $user = core_user::get_user($params['userid'], '*', MUST_EXIST);
          core_user::require_active_user($user);
  
          // Extra checks so only users with permissions can view other users attempts.
          if ($USER->id != $user->id) {
              require_capability('mod/scorm:viewreport', $context);
          }
  
          scorm_require_available($scorm, true, $context);
  
          if (empty($params['attempt'])) {
              $params['attempt'] = scorm_get_last_attempt($scorm->id, $user->id);
          }
  
          $attempted = false;
          if ($scormtracks = scorm_get_tracks($sco->id, $params['userid'], $params['attempt'])) {
              // Check if attempted.
              if ($scormtracks->status != '') {
                  $attempted = true;
                  foreach ($scormtracks as $element => $value) {
                      $tracks[] = array(
                          'element' => $element,
                          'value' => $value,
                      );
                  }
              }
          }
  
          if (!$attempted) {
              $warnings[] = array(
                  'item' => 'attempt',
                  'itemid' => $params['attempt'],
                  'warningcode' => 'notattempted',
                  'message' => get_string('notattempted', 'scorm')
              );
          }
  
          $result = array();
          $result['data']['attempt'] = $params['attempt'];
          $result['data']['tracks'] = $tracks;
          $result['warnings'] = $warnings;
          return $result;
      }
code_tokens: public static function get_scorm_sco_tracks ( $ scoid , $ userid , $ attempt = 0 ) { global $ USER , $ DB ; $ params = self :: validate_parameters ( self :: get_scorm_sco_tracks_parameters ( ) , array ( 'scoid' => $ scoid , 'userid' => $ userid , 'attempt' => $ attempt ) ) ; $ tracks = array ( ) ; $ warnings = array ( ) ; $ sco = scorm_get_sco ( $ params [ 'scoid' ] , SCO_ONLY ) ; if ( ! $ sco ) { throw new moodle_exception ( 'cannotfindsco' , 'scorm' ) ; } $ scorm = $ DB -> get_record ( 'scorm' , array ( 'id' => $ sco -> scorm ) , '*' , MUST_EXIST ) ; $ cm = get_coursemodule_from_instance ( 'scorm' , $ scorm -> id ) ; $ context = context_module :: instance ( $ cm -> id ) ; self :: validate_context ( $ context ) ; $ user = core_user :: get_user ( $ params [ 'userid' ] , '*' , MUST_EXIST ) ; core_user :: require_active_user ( $ user ) ; // Extra checks so only users with permissions can view other users attempts. if ( $ USER -> id != $ user -> id ) { require_capability ( 'mod/scorm:viewreport' , $ context ) ; } scorm_require_available ( $ scorm , true , $ context ) ; if ( empty ( $ params [ 'attempt' ] ) ) { $ params [ 'attempt' ] = scorm_get_last_attempt ( $ scorm -> id , $ user -> id ) ; } $ attempted = false ; if ( $ scormtracks = scorm_get_tracks ( $ sco -> id , $ params [ 'userid' ] , $ params [ 'attempt' ] ) ) { // Check if attempted. if ( $ scormtracks -> status != '' ) { $ attempted = true ; foreach ( $ scormtracks as $ element => $ value ) { $ tracks [ ] = array ( 'element' => $ element , 'value' => $ value , ) ; } } } if ( ! $ attempted ) { $ warnings [ ] = array ( 'item' => 'attempt' , 'itemid' => $ params [ 'attempt' ] , 'warningcode' => 'notattempted' , 'message' => get_string ( 'notattempted' , 'scorm' ) ) ; } $ result = array ( ) ; $ result [ 'data' ] [ 'attempt' ] = $ params [ 'attempt' ] ; $ result [ 'data' ] [ 'tracks' ] = $ tracks ; $ result [ 'warnings' ] = $ warnings ; return $ result ; }
docstring: Retrieves SCO tracking data for the given user id and attempt number
  
  @param int $scoid the sco id
  @param int $userid the user id
  @param int $attempt the attempt number
  @return array warnings and the scoes data
  @since Moodle 3.0
docstring_tokens: Retrieves SCO tracking data for the given user id and attempt number