Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function compute_final_grade($responses, $totaltries) {
- $fractionsum = 0;
- $fractionmax = 0;
- foreach ($this->subquestions as $i => $subq) {
- $fractionmax += $subq->defaultmark;
- $subqa = new question_attempt($subq, 0, null, $subq->defaultmark);
- $initdata = array(); // TODO need to get this from somewhere, but I can't think where.
- $initdata['_triesleft'] = count($this->hints) + 1;
- $subqa->start('interactive', 0, $initdata);
- foreach ($responses as $response) {
- $substep = $this->get_substep(null, $i);
- $subresp = $substep->filter_array($response);
- $subresp['-submit'] = 1;
- $subqa->process_action($subresp);
- // This will fail if a student submits 'right', 'wrong', 'right' to one subquestion.
- }
- if (!$subqa->get_state()->is_finished()) {
- $subqa->finish();
- }
- $fractionsum += $subqa->get_mark();
- }
- return $fractionsum / $fractionmax;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement