original_string: protected function get_data($scoid, $allowedlist = []) {
          global $DB;
          $data = array_fill(0, self::BANDS, 0);
          if (empty($allowedlist)) {
              return $data;
          }
  
          list($usql, $params) = $DB->get_in_or_equal($allowedlist);
          $params[] = $scoid;
  
          // Construct the SQL.
          $sql = "SELECT DISTINCT " . $DB->sql_concat('st.userid', '\'#\'', 'COALESCE(st.attempt, 0)') . " AS uniqueid,
                         st.userid AS userid,
                         st.scormid AS scormid,
                         st.attempt AS attempt,
                         st.scoid AS scoid
                    FROM {scorm_scoes_track} st
                   WHERE st.userid $usql AND st.scoid = ?";
          $attempts = $DB->get_records_sql($sql, $params);
  
          $usergrades = [];
          foreach ($attempts as $attempt) {
              if ($trackdata = scorm_get_tracks($scoid, $attempt->userid, $attempt->attempt)) {
                  if (isset($trackdata->score_raw)) {
                      $score = (int) $trackdata->score_raw;
                      if (empty($trackdata->score_min)) {
                          $minmark = 0;
                      } else {
                          $minmark = $trackdata->score_min;
                      }
                      // TODO MDL-55004: Get this value from elsewhere?
                      if (empty($trackdata->score_max)) {
                          $maxmark = 100;
                      } else {
                          $maxmark = $trackdata->score_max;
                      }
                      $range = ($maxmark - $minmark);
                      if (empty($range)) {
                          continue;
                      }
                      $percent = round((($score * 100) / $range), 2);
                      if (empty($usergrades[$attempt->userid]) || !isset($usergrades[$attempt->userid])
                              || ($percent > $usergrades[$attempt->userid]) || ($usergrades[$attempt->userid] === '*')) {
                          $usergrades[$attempt->userid] = $percent;
                      }
                      unset($percent);
                  } else {
                      // User has made an attempt but either SCO was not able to record the score or something else is broken in SCO.
                      if (!isset($usergrades[$attempt->userid])) {
                          $usergrades[$attempt->userid] = '*';
                      }
                  }
              }
          }
  
          // Recording all users who attempted the SCO, but resulting data was invalid.
          foreach ($usergrades as $userpercent) {
              if ($userpercent === '*') {
                  $data[0]++;
              } else {
                  $gradeband = floor($userpercent / self::BANDWIDTH);
                  if ($gradeband != (self::BANDS - 1)) {
                      $gradeband++;
                  }
                  $data[$gradeband]++;
              }
          }
  
          return $data;
      }
code: protected function get_data($scoid, $allowedlist = []) {
          global $DB;
          $data = array_fill(0, self::BANDS, 0);
          if (empty($allowedlist)) {
              return $data;
          }
  
          list($usql, $params) = $DB->get_in_or_equal($allowedlist);
          $params[] = $scoid;
  
          // Construct the SQL.
          $sql = "SELECT DISTINCT " . $DB->sql_concat('st.userid', '\'#\'', 'COALESCE(st.attempt, 0)') . " AS uniqueid,
                         st.userid AS userid,
                         st.scormid AS scormid,
                         st.attempt AS attempt,
                         st.scoid AS scoid
                    FROM {scorm_scoes_track} st
                   WHERE st.userid $usql AND st.scoid = ?";
          $attempts = $DB->get_records_sql($sql, $params);
  
          $usergrades = [];
          foreach ($attempts as $attempt) {
              if ($trackdata = scorm_get_tracks($scoid, $attempt->userid, $attempt->attempt)) {
                  if (isset($trackdata->score_raw)) {
                      $score = (int) $trackdata->score_raw;
                      if (empty($trackdata->score_min)) {
                          $minmark = 0;
                      } else {
                          $minmark = $trackdata->score_min;
                      }
                      // TODO MDL-55004: Get this value from elsewhere?
                      if (empty($trackdata->score_max)) {
                          $maxmark = 100;
                      } else {
                          $maxmark = $trackdata->score_max;
                      }
                      $range = ($maxmark - $minmark);
                      if (empty($range)) {
                          continue;
                      }
                      $percent = round((($score * 100) / $range), 2);
                      if (empty($usergrades[$attempt->userid]) || !isset($usergrades[$attempt->userid])
                              || ($percent > $usergrades[$attempt->userid]) || ($usergrades[$attempt->userid] === '*')) {
                          $usergrades[$attempt->userid] = $percent;
                      }
                      unset($percent);
                  } else {
                      // User has made an attempt but either SCO was not able to record the score or something else is broken in SCO.
                      if (!isset($usergrades[$attempt->userid])) {
                          $usergrades[$attempt->userid] = '*';
                      }
                  }
              }
          }
  
          // Recording all users who attempted the SCO, but resulting data was invalid.
          foreach ($usergrades as $userpercent) {
              if ($userpercent === '*') {
                  $data[0]++;
              } else {
                  $gradeband = floor($userpercent / self::BANDWIDTH);
                  if ($gradeband != (self::BANDS - 1)) {
                      $gradeband++;
                  }
                  $data[$gradeband]++;
              }
          }
  
          return $data;
      }
code_tokens: protected function get_data ( $ scoid , $ allowedlist = [ ] ) { global $ DB ; $ data = array_fill ( 0 , self :: BANDS , 0 ) ; if ( empty ( $ allowedlist ) ) { return $ data ; } list ( $ usql , $ params ) = $ DB -> get_in_or_equal ( $ allowedlist ) ; $ params [ ] = $ scoid ; // Construct the SQL. $ sql = "SELECT DISTINCT " . $ DB -> sql_concat ( 'st.userid' , '\'#\'' , 'COALESCE(st.attempt, 0)' ) . " AS uniqueid,
                         st.userid AS userid,
                         st.scormid AS scormid,
                         st.attempt AS attempt,
                         st.scoid AS scoid
                    FROM {scorm_scoes_track} st
                   WHERE st.userid $usql AND st.scoid = ?" ; $ attempts = $ DB -> get_records_sql ( $ sql , $ params ) ; $ usergrades = [ ] ; foreach ( $ attempts as $ attempt ) { if ( $ trackdata = scorm_get_tracks ( $ scoid , $ attempt -> userid , $ attempt -> attempt ) ) { if ( isset ( $ trackdata -> score_raw ) ) { $ score = ( int ) $ trackdata -> score_raw ; if ( empty ( $ trackdata -> score_min ) ) { $ minmark = 0 ; } else { $ minmark = $ trackdata -> score_min ; } // TODO MDL-55004: Get this value from elsewhere? if ( empty ( $ trackdata -> score_max ) ) { $ maxmark = 100 ; } else { $ maxmark = $ trackdata -> score_max ; } $ range = ( $ maxmark - $ minmark ) ; if ( empty ( $ range ) ) { continue ; } $ percent = round ( ( ( $ score * 100 ) / $ range ) , 2 ) ; if ( empty ( $ usergrades [ $ attempt -> userid ] ) || ! isset ( $ usergrades [ $ attempt -> userid ] ) || ( $ percent > $ usergrades [ $ attempt -> userid ] ) || ( $ usergrades [ $ attempt -> userid ] === '*' ) ) { $ usergrades [ $ attempt -> userid ] = $ percent ; } unset ( $ percent ) ; } else { // User has made an attempt but either SCO was not able to record the score or something else is broken in SCO. if ( ! isset ( $ usergrades [ $ attempt -> userid ] ) ) { $ usergrades [ $ attempt -> userid ] = '*' ; } } } } // Recording all users who attempted the SCO, but resulting data was invalid. foreach ( $ usergrades as $ userpercent ) { if ( $ userpercent === '*' ) { $ data [ 0 ] ++ ; } else { $ gradeband = floor ( $ userpercent / self :: BANDWIDTH ) ; if ( $ gradeband != ( self :: BANDS - 1 ) ) { $ gradeband ++ ; } $ data [ $ gradeband ] ++ ; } } return $ data ; }
docstring: Get the data for the report.
  
  @param int $scoid The sco ID.
  @param array $allowedlist The list of user IDs allowed to be displayed.
  @return array of data indexed per bar.
docstring_tokens: Get the data for the report .