original_string: public function load_questions_usages_question_state_summary(
              qubaid_condition $qubaids, $slots) {
          list($slottest, $params) = $this->db->get_in_or_equal($slots, SQL_PARAMS_NAMED, 'slot');
  
          $rs = $this->db->get_recordset_sql("
  SELECT
      qa.slot,
      qa.questionid,
      q.name,
      CASE qas.state
          {$this->full_states_to_summary_state_sql()}
      END AS summarystate,
      COUNT(1) AS numattempts
  
  FROM {$qubaids->from_question_attempts('qa')}
  JOIN {question_attempt_steps} qas ON qas.questionattemptid = qa.id
          AND qas.sequencenumber = {$this->latest_step_for_qa_subquery()}
  JOIN {question} q ON q.id = qa.questionid
  
  WHERE
      {$qubaids->where()} AND
      qa.slot $slottest
  
  GROUP BY
      qa.slot,
      qa.questionid,
      q.name,
      q.id,
      CASE qas.state
          {$this->full_states_to_summary_state_sql()}
      END
  
  ORDER BY
      qa.slot,
      qa.questionid,
      q.name,
      q.id
          ", $params + $qubaids->from_where_params());
  
          $results = array();
          foreach ($rs as $row) {
              $index = $row->slot . ',' . $row->questionid;
  
              if (!array_key_exists($index, $results)) {
                  $res = new stdClass();
                  $res->slot = $row->slot;
                  $res->questionid = $row->questionid;
                  $res->name = $row->name;
                  $res->inprogress = 0;
                  $res->needsgrading = 0;
                  $res->autograded = 0;
                  $res->manuallygraded = 0;
                  $res->all = 0;
                  $results[$index] = $res;
              }
  
              $results[$index]->{$row->summarystate} = $row->numattempts;
              $results[$index]->all += $row->numattempts;
          }
          $rs->close();
  
          return $results;
      }
code: public function load_questions_usages_question_state_summary(
              qubaid_condition $qubaids, $slots) {
          list($slottest, $params) = $this->db->get_in_or_equal($slots, SQL_PARAMS_NAMED, 'slot');
  
          $rs = $this->db->get_recordset_sql("
  SELECT
      qa.slot,
      qa.questionid,
      q.name,
      CASE qas.state
          {$this->full_states_to_summary_state_sql()}
      END AS summarystate,
      COUNT(1) AS numattempts
  
  FROM {$qubaids->from_question_attempts('qa')}
  JOIN {question_attempt_steps} qas ON qas.questionattemptid = qa.id
          AND qas.sequencenumber = {$this->latest_step_for_qa_subquery()}
  JOIN {question} q ON q.id = qa.questionid
  
  WHERE
      {$qubaids->where()} AND
      qa.slot $slottest
  
  GROUP BY
      qa.slot,
      qa.questionid,
      q.name,
      q.id,
      CASE qas.state
          {$this->full_states_to_summary_state_sql()}
      END
  
  ORDER BY
      qa.slot,
      qa.questionid,
      q.name,
      q.id
          ", $params + $qubaids->from_where_params());
  
          $results = array();
          foreach ($rs as $row) {
              $index = $row->slot . ',' . $row->questionid;
  
              if (!array_key_exists($index, $results)) {
                  $res = new stdClass();
                  $res->slot = $row->slot;
                  $res->questionid = $row->questionid;
                  $res->name = $row->name;
                  $res->inprogress = 0;
                  $res->needsgrading = 0;
                  $res->autograded = 0;
                  $res->manuallygraded = 0;
                  $res->all = 0;
                  $results[$index] = $res;
              }
  
              $results[$index]->{$row->summarystate} = $row->numattempts;
              $results[$index]->all += $row->numattempts;
          }
          $rs->close();
  
          return $results;
      }
code_tokens: public function load_questions_usages_question_state_summary ( qubaid_condition $ qubaids , $ slots ) { list ( $ slottest , $ params ) = $ this -> db -> get_in_or_equal ( $ slots , SQL_PARAMS_NAMED , 'slot' ) ; $ rs = $ this -> db -> get_recordset_sql ( "
  SELECT
      qa.slot,
      qa.questionid,
      q.name,
      CASE qas.state
          {$this->full_states_to_summary_state_sql()}
      END AS summarystate,
      COUNT(1) AS numattempts
  
  FROM {$qubaids->from_question_attempts('qa')}
  JOIN {question_attempt_steps} qas ON qas.questionattemptid = qa.id
          AND qas.sequencenumber = {$this->latest_step_for_qa_subquery()}
  JOIN {question} q ON q.id = qa.questionid
  
  WHERE
      {$qubaids->where()} AND
      qa.slot $slottest
  
  GROUP BY
      qa.slot,
      qa.questionid,
      q.name,
      q.id,
      CASE qas.state
          {$this->full_states_to_summary_state_sql()}
      END
  
  ORDER BY
      qa.slot,
      qa.questionid,
      q.name,
      q.id
          " , $ params + $ qubaids -> from_where_params ( ) ) ; $ results = array ( ) ; foreach ( $ rs as $ row ) { $ index = $ row -> slot . ',' . $ row -> questionid ; if ( ! array_key_exists ( $ index , $ results ) ) { $ res = new stdClass ( ) ; $ res -> slot = $ row -> slot ; $ res -> questionid = $ row -> questionid ; $ res -> name = $ row -> name ; $ res -> inprogress = 0 ; $ res -> needsgrading = 0 ; $ res -> autograded = 0 ; $ res -> manuallygraded = 0 ; $ res -> all = 0 ; $ results [ $ index ] = $ res ; } $ results [ $ index ] -> { $ row -> summarystate } = $ row -> numattempts ; $ results [ $ index ] -> all += $ row -> numattempts ; } $ rs -> close ( ) ; return $ results ; }
docstring: Load summary information about the state of each question in a group of
  attempts. This is used, for example, by the quiz manual grading report,
  to show how many attempts at each question need to be graded.
  
  This method may be called publicly.
  
  @param qubaid_condition $qubaids used to restrict which usages are included
  in the query. See {@link qubaid_condition}.
  @param array $slots A list of slots for the questions you want to konw about.
  @return array The array keys are slot,qestionid. The values are objects with
  fields $slot, $questionid, $inprogress, $name, $needsgrading, $autograded,
  $manuallygraded and $all.
docstring_tokens: Load summary information about the state of each question in a group of attempts . This is used for example by the quiz manual grading report to show how many attempts at each question need to be graded .