original_string: public static function get_scorm_attempt_count($scormid, $userid, $ignoremissingcompletion = false) {
          global $USER, $DB;
  
          $params = self::validate_parameters(self::get_scorm_attempt_count_parameters(),
                                              array('scormid' => $scormid, 'userid' => $userid,
                                                  'ignoremissingcompletion' => $ignoremissingcompletion));
  
          $attempts = array();
          $warnings = array();
  
          $scorm = $DB->get_record('scorm', array('id' => $params['scormid']), '*', 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);
          }
  
          // If the SCORM is not open this function will throw exceptions.
          scorm_require_available($scorm);
  
          $attemptscount = scorm_get_attempt_count($user->id, $scorm, false, $params['ignoremissingcompletion']);
  
          $result = array();
          $result['attemptscount'] = $attemptscount;
          $result['warnings'] = $warnings;
          return $result;
      }
code: public static function get_scorm_attempt_count($scormid, $userid, $ignoremissingcompletion = false) {
          global $USER, $DB;
  
          $params = self::validate_parameters(self::get_scorm_attempt_count_parameters(),
                                              array('scormid' => $scormid, 'userid' => $userid,
                                                  'ignoremissingcompletion' => $ignoremissingcompletion));
  
          $attempts = array();
          $warnings = array();
  
          $scorm = $DB->get_record('scorm', array('id' => $params['scormid']), '*', 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);
          }
  
          // If the SCORM is not open this function will throw exceptions.
          scorm_require_available($scorm);
  
          $attemptscount = scorm_get_attempt_count($user->id, $scorm, false, $params['ignoremissingcompletion']);
  
          $result = array();
          $result['attemptscount'] = $attemptscount;
          $result['warnings'] = $warnings;
          return $result;
      }
code_tokens: public static function get_scorm_attempt_count ( $ scormid , $ userid , $ ignoremissingcompletion = false ) { global $ USER , $ DB ; $ params = self :: validate_parameters ( self :: get_scorm_attempt_count_parameters ( ) , array ( 'scormid' => $ scormid , 'userid' => $ userid , 'ignoremissingcompletion' => $ ignoremissingcompletion ) ) ; $ attempts = array ( ) ; $ warnings = array ( ) ; $ scorm = $ DB -> get_record ( 'scorm' , array ( 'id' => $ params [ 'scormid' ] ) , '*' , 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 ) ; } // If the SCORM is not open this function will throw exceptions. scorm_require_available ( $ scorm ) ; $ attemptscount = scorm_get_attempt_count ( $ user -> id , $ scorm , false , $ params [ 'ignoremissingcompletion' ] ) ; $ result = array ( ) ; $ result [ 'attemptscount' ] = $ attemptscount ; $ result [ 'warnings' ] = $ warnings ; return $ result ; }
docstring: Return the number of attempts done by a user in the given SCORM.
  
  @param int $scormid the scorm id
  @param int $userid the user id
  @param bool $ignoremissingcompletion ignores attempts that haven't reported a grade/completion
  @return array of warnings and the attempts count
  @since Moodle 3.0
docstring_tokens: Return the number of attempts done by a user in the given SCORM .