original_string: public function get_all_stats_and_analysis(
              $quiz, $whichattempts, $whichtries, \core\dml\sql_join $groupstudentsjoins, $questions, $progress = null) {
  
          if ($progress === null) {
              $progress = new \core\progress\none();
          }
  
          $qubaids = quiz_statistics_qubaids_condition($quiz->id, $groupstudentsjoins, $whichattempts);
  
          $qcalc = new \core_question\statistics\questions\calculator($questions, $progress);
  
          $quizcalc = new \quiz_statistics\calculator($progress);
  
          $progress->start_progress('', 3);
          if ($quizcalc->get_last_calculated_time($qubaids) === false) {
  
              // Recalculate now.
              $questionstats = $qcalc->calculate($qubaids);
              $progress->progress(1);
  
              $quizstats = $quizcalc->calculate($quiz->id, $whichattempts, $groupstudentsjoins, count($questions),
                                                $qcalc->get_sum_of_mark_variance());
              $progress->progress(2);
          } else {
              $quizstats = $quizcalc->get_cached($qubaids);
              $progress->progress(1);
              $questionstats = $qcalc->get_cached($qubaids);
              $progress->progress(2);
          }
  
          if ($quizstats->s()) {
              $subquestions = $questionstats->get_sub_questions();
              $this->analyse_responses_for_all_questions_and_subquestions($questions,
                                                                          $subquestions,
                                                                          $qubaids,
                                                                          $whichtries,
                                                                          $progress);
          }
          $progress->progress(3);
          $progress->end_progress();
  
          return array($quizstats, $questionstats);
      }
code: public function get_all_stats_and_analysis(
              $quiz, $whichattempts, $whichtries, \core\dml\sql_join $groupstudentsjoins, $questions, $progress = null) {
  
          if ($progress === null) {
              $progress = new \core\progress\none();
          }
  
          $qubaids = quiz_statistics_qubaids_condition($quiz->id, $groupstudentsjoins, $whichattempts);
  
          $qcalc = new \core_question\statistics\questions\calculator($questions, $progress);
  
          $quizcalc = new \quiz_statistics\calculator($progress);
  
          $progress->start_progress('', 3);
          if ($quizcalc->get_last_calculated_time($qubaids) === false) {
  
              // Recalculate now.
              $questionstats = $qcalc->calculate($qubaids);
              $progress->progress(1);
  
              $quizstats = $quizcalc->calculate($quiz->id, $whichattempts, $groupstudentsjoins, count($questions),
                                                $qcalc->get_sum_of_mark_variance());
              $progress->progress(2);
          } else {
              $quizstats = $quizcalc->get_cached($qubaids);
              $progress->progress(1);
              $questionstats = $qcalc->get_cached($qubaids);
              $progress->progress(2);
          }
  
          if ($quizstats->s()) {
              $subquestions = $questionstats->get_sub_questions();
              $this->analyse_responses_for_all_questions_and_subquestions($questions,
                                                                          $subquestions,
                                                                          $qubaids,
                                                                          $whichtries,
                                                                          $progress);
          }
          $progress->progress(3);
          $progress->end_progress();
  
          return array($quizstats, $questionstats);
      }
code_tokens: public function get_all_stats_and_analysis ( $ quiz , $ whichattempts , $ whichtries , \ core \ dml \ sql_join $ groupstudentsjoins , $ questions , $ progress = null ) { if ( $ progress === null ) { $ progress = new \ core \ progress \ none ( ) ; } $ qubaids = quiz_statistics_qubaids_condition ( $ quiz -> id , $ groupstudentsjoins , $ whichattempts ) ; $ qcalc = new \ core_question \ statistics \ questions \ calculator ( $ questions , $ progress ) ; $ quizcalc = new \ quiz_statistics \ calculator ( $ progress ) ; $ progress -> start_progress ( '' , 3 ) ; if ( $ quizcalc -> get_last_calculated_time ( $ qubaids ) === false ) { // Recalculate now. $ questionstats = $ qcalc -> calculate ( $ qubaids ) ; $ progress -> progress ( 1 ) ; $ quizstats = $ quizcalc -> calculate ( $ quiz -> id , $ whichattempts , $ groupstudentsjoins , count ( $ questions ) , $ qcalc -> get_sum_of_mark_variance ( ) ) ; $ progress -> progress ( 2 ) ; } else { $ quizstats = $ quizcalc -> get_cached ( $ qubaids ) ; $ progress -> progress ( 1 ) ; $ questionstats = $ qcalc -> get_cached ( $ qubaids ) ; $ progress -> progress ( 2 ) ; } if ( $ quizstats -> s ( ) ) { $ subquestions = $ questionstats -> get_sub_questions ( ) ; $ this -> analyse_responses_for_all_questions_and_subquestions ( $ questions , $ subquestions , $ qubaids , $ whichtries , $ progress ) ; } $ progress -> progress ( 3 ) ; $ progress -> end_progress ( ) ; return array ( $ quizstats , $ questionstats ) ; }
docstring: Get the quiz and question statistics, either by loading the cached results,
  or by recomputing them.
  
  @param object $quiz               the quiz settings.
  @param string $whichattempts      which attempts to use, represented internally as one of the constants as used in
  $quiz->grademethod ie.
  QUIZ_GRADEAVERAGE, QUIZ_GRADEHIGHEST, QUIZ_ATTEMPTLAST or QUIZ_ATTEMPTFIRST
  we calculate stats based on which attempts would affect the grade for each student.
  @param string $whichtries         which tries to analyse for response analysis. Will be one of
  question_attempt::FIRST_TRY, LAST_TRY or ALL_TRIES.
  @param \core\dml\sql_join $groupstudentsjoins Contains joins, wheres, params for students in this group.
  @param array  $questions          full question data.
  @param \core\progress\base|null   $progress
  @return array with 2 elements:    - $quizstats The statistics for overall attempt scores.
  - $questionstats \core_question\statistics\questions\all_calculated_for_qubaid_condition
docstring_tokens: Get the quiz and question statistics either by loading the cached results or by recomputing them .