original_string: protected function secondary_steps_walker($step, $stats, $summarks) {
          $markdifference = $step->mark - $stats->markaverage;
          if ($stats->subquestion) {
              $othermarkdifference = $summarks[$step->questionusageid] - $stats->othermarkaverage;
          } else {
              $othermarkdifference = $summarks[$step->questionusageid] - $step->mark - $stats->othermarkaverage;
          }
          $overallmarkdifference = $summarks[$step->questionusageid] - $stats->summarksaverage;
  
          $sortedmarkdifference = array_shift($stats->markarray) - $stats->markaverage;
          $sortedothermarkdifference = array_shift($stats->othermarksarray) - $stats->othermarkaverage;
  
          $stats->markvariancesum += pow($markdifference, 2);
          $stats->othermarkvariancesum += pow($othermarkdifference, 2);
          $stats->covariancesum += $markdifference * $othermarkdifference;
          $stats->covariancemaxsum += $sortedmarkdifference * $sortedothermarkdifference;
          $stats->covariancewithoverallmarksum += $markdifference * $overallmarkdifference;
  
          if (isset($stats->variantstats[$step->variant])) {
              $this->secondary_steps_walker($step, $stats->variantstats[$step->variant], $summarks);
          }
      }
code: protected function secondary_steps_walker($step, $stats, $summarks) {
          $markdifference = $step->mark - $stats->markaverage;
          if ($stats->subquestion) {
              $othermarkdifference = $summarks[$step->questionusageid] - $stats->othermarkaverage;
          } else {
              $othermarkdifference = $summarks[$step->questionusageid] - $step->mark - $stats->othermarkaverage;
          }
          $overallmarkdifference = $summarks[$step->questionusageid] - $stats->summarksaverage;
  
          $sortedmarkdifference = array_shift($stats->markarray) - $stats->markaverage;
          $sortedothermarkdifference = array_shift($stats->othermarksarray) - $stats->othermarkaverage;
  
          $stats->markvariancesum += pow($markdifference, 2);
          $stats->othermarkvariancesum += pow($othermarkdifference, 2);
          $stats->covariancesum += $markdifference * $othermarkdifference;
          $stats->covariancemaxsum += $sortedmarkdifference * $sortedothermarkdifference;
          $stats->covariancewithoverallmarksum += $markdifference * $overallmarkdifference;
  
          if (isset($stats->variantstats[$step->variant])) {
              $this->secondary_steps_walker($step, $stats->variantstats[$step->variant], $summarks);
          }
      }
code_tokens: protected function secondary_steps_walker ( $ step , $ stats , $ summarks ) { $ markdifference = $ step -> mark - $ stats -> markaverage ; if ( $ stats -> subquestion ) { $ othermarkdifference = $ summarks [ $ step -> questionusageid ] - $ stats -> othermarkaverage ; } else { $ othermarkdifference = $ summarks [ $ step -> questionusageid ] - $ step -> mark - $ stats -> othermarkaverage ; } $ overallmarkdifference = $ summarks [ $ step -> questionusageid ] - $ stats -> summarksaverage ; $ sortedmarkdifference = array_shift ( $ stats -> markarray ) - $ stats -> markaverage ; $ sortedothermarkdifference = array_shift ( $ stats -> othermarksarray ) - $ stats -> othermarkaverage ; $ stats -> markvariancesum += pow ( $ markdifference , 2 ) ; $ stats -> othermarkvariancesum += pow ( $ othermarkdifference , 2 ) ; $ stats -> covariancesum += $ markdifference * $ othermarkdifference ; $ stats -> covariancemaxsum += $ sortedmarkdifference * $ sortedothermarkdifference ; $ stats -> covariancewithoverallmarksum += $ markdifference * $ overallmarkdifference ; if ( isset ( $ stats -> variantstats [ $ step -> variant ] ) ) { $ this -> secondary_steps_walker ( $ step , $ stats -> variantstats [ $ step -> variant ] , $ summarks ) ; } }
docstring: Loop through all last step data again.
  
  Now we know the averages, accumulate the date needed to compute the higher
  moments of the question scores.
  
  @param object $step        the state to add to the statistics.
  @param calculated $stats       the question statistics we are accumulating.
  @param float[]  $summarks    of the sum of marks for each question usage, indexed by question usage id
docstring_tokens: Loop through all last step data again .