Advertisement
Guest User

Untitled

a guest
Apr 30th, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1.     public function compute_final_grade($responses, $totaltries) {
  2.         $fractionsum = 0;
  3.         $fractionmax = 0;
  4.         foreach ($this->subquestions as $i => $subq) {
  5.             $fractionmax += $subq->defaultmark;
  6.  
  7.             $subqa = new question_attempt($subq, 0, null, $subq->defaultmark);
  8.             $initdata = array(); // TODO need to get this from somewhere, but I can't think where.
  9.             $initdata['_triesleft'] = count($this->hints) + 1;
  10.             $subqa->start('interactive', 0, $initdata);
  11.  
  12.             foreach ($responses as $response) {
  13.                 $substep = $this->get_substep(null, $i);
  14.                 $subresp = $substep->filter_array($response);
  15.                 $subresp['-submit'] = 1;
  16.                 $subqa->process_action($subresp);
  17.                 // This will fail if a student submits 'right', 'wrong', 'right' to one subquestion.
  18.             }
  19.  
  20.             if (!$subqa->get_state()->is_finished()) {
  21.                 $subqa->finish();
  22.             }
  23.  
  24.             $fractionsum += $subqa->get_mark();
  25.         }
  26.         return $fractionsum / $fractionmax;
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement