ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilTestScoring.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
24 {
26  protected $test;
27 
29  protected $testGUI;
30 
33 
35 
36  public function __construct(ilObjTest $test)
37  {
38  $this->test = $test;
39  $this->preserve_manual_scores = false;
40 
41  $this->recalculatedPasses = array();
42 
43  require_once './Modules/Test/classes/class.ilObjTestGUI.php';
44  $this->testGUI = new ilObjTestGUI();
45  }
46 
51  {
52  $this->preserve_manual_scores = $preserve_manual_scores;
53  }
54 
58  public function getPreserveManualScores()
59  {
61  }
62 
63  public function recalculateSolutions()
64  {
65  $participants = $this->test->getCompleteEvaluationData(false)->getParticipants();
66  if (is_array($participants))
67  {
68  require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
69  foreach ($participants as $active_id => $userdata)
70  {
71  if (is_object($userdata) && is_array($userdata->getPasses()))
72  {
73  $this->recalculatePasses( $userdata, $active_id );
74  }
76  }
77  }
78  }
79 
84  public function recalculatePasses($userdata, $active_id)
85  {
86  $passes = $userdata->getPasses();
87  foreach ($passes as $pass => $passdata)
88  {
89  if (is_object( $passdata ))
90  {
91  $this->recalculatePass( $passdata, $active_id, $pass );
92  $this->addRecalculatedPassByActive($active_id, $pass);
93  }
94  }
95  }
96 
102  public function recalculatePass($passdata, $active_id, $pass)
103  {
104  $questions = $passdata->getAnsweredQuestions();
105  if (is_array( $questions ))
106  {
107  foreach ($questions as $questiondata)
108  {
109  $question_gui = $this->test->createQuestionGUI( "", $questiondata['id'] );
110  $this->recalculateQuestionScore( $question_gui, $active_id, $pass, $questiondata );
111  }
112  }
113 
114  }
115 
122  public function recalculateQuestionScore($question_gui, $active_id, $pass, $questiondata)
123  {
125  if (is_object( $question_gui ))
126  {
127  $reached = $question_gui->object->calculateReachedPoints( $active_id, $pass );
128  $actual_reached = $question_gui->object->adjustReachedPointsByScoringOptions($reached, $active_id, $pass);
129 
130  if ($this->preserve_manual_scores == true && $questiondata['manual'] == '1')
131  {
132  // Do we need processing here?
133  }
134  else
135  {
137 
138  assQuestion::_setReachedPoints( $active_id,
139  $questiondata['id'],
140  $actual_reached,
141  $question_gui->object->getMaximumPoints(),
142  $pass,
143  false,
144  true
145  );
146 
148  }
149  }
150  }
151 
155  public function calculateBestSolutionForTest()
156  {
157  $solution = '';
158  foreach ($this->test->getAllQuestions() as $question)
159  {
161  $question_gui = $this->test->createQuestionGUI("", $question['question_id'] );
162  $solution .= $question_gui->getSolutionOutput(0, null, true, true, false, false, true, false);
163  }
164 
165  return $solution;
166  }
167 
169  {
170  $this->recalculatedPasses = array();
171  }
172 
174  {
176  }
177 
178  public function addRecalculatedPassByActive($activeId, $pass)
179  {
180  if( !is_array($this->recalculatedPasses[$activeId]) )
181  {
182  $this->recalculatedPasses[$activeId] = array();
183  }
184 
185  $this->recalculatedPasses[$activeId][] = $pass;
186  }
187 }
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
Move this to a proper place.
Class ilObjTestGUI.
recalculatePass($passdata, $active_id, $pass)
static setForcePassResultUpdateEnabled($forcePassResultsUpdateEnabled)
addRecalculatedPassByActive($activeId, $pass)
__construct(ilObjTest $test)
Class ilTestScoring.
Create styles array
The data for the language used.
setPreserveManualScores( $preserve_manual_scores)
static _setReachedPoints($active_id, $question_id, $points, $maxpoints, $pass, $manualscoring, $obligationsEnabled)
Sets the points, a learner has reached answering the question Additionally objective results are upda...
recalculatePasses($userdata, $active_id)