ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
68  foreach ($participants as $active_id => $userdata) {
69  if (is_object($userdata) && is_array($userdata->getPasses())) {
70  $this->recalculatePasses($userdata, $active_id);
71  }
73  }
74  }
75  }
76 
81  public function recalculatePasses($userdata, $active_id)
82  {
83  $passes = $userdata->getPasses();
84  foreach ($passes as $pass => $passdata) {
85  if (is_object($passdata)) {
86  $this->recalculatePass($passdata, $active_id, $pass);
87  $this->addRecalculatedPassByActive($active_id, $pass);
88  }
89  }
90  }
91 
97  public function recalculatePass($passdata, $active_id, $pass)
98  {
99  $questions = $passdata->getAnsweredQuestions();
100  if (is_array($questions)) {
101  foreach ($questions as $questiondata) {
102  $question_gui = $this->test->createQuestionGUI("", $questiondata['id']);
103  $this->recalculateQuestionScore($question_gui, $active_id, $pass, $questiondata);
104  }
105  }
106  }
107 
114  public function recalculateQuestionScore($question_gui, $active_id, $pass, $questiondata)
115  {
117  if (is_object($question_gui)) {
118  $reached = $question_gui->object->calculateReachedPoints($active_id, $pass);
119  $actual_reached = $question_gui->object->adjustReachedPointsByScoringOptions($reached, $active_id, $pass);
120 
121  if ($this->preserve_manual_scores == true && $questiondata['manual'] == '1') {
122  // Do we need processing here?
123  } else {
125 
127  $active_id,
128  $questiondata['id'],
129  $actual_reached,
130  $question_gui->object->getMaximumPoints(),
131  $pass,
132  false,
133  true
134  );
135 
137  }
138  }
139  }
140 
144  public function calculateBestSolutionForTest()
145  {
146  $solution = '';
147  foreach ($this->test->getAllQuestions() as $question) {
149  $question_gui = $this->test->createQuestionGUI("", $question['question_id']);
150  $solution .= $question_gui->getSolutionOutput(0, null, true, true, false, false, true, false);
151  }
152 
153  return $solution;
154  }
155 
157  {
158  $this->recalculatedPasses = array();
159  }
160 
162  {
164  }
165 
166  public function addRecalculatedPassByActive($activeId, $pass)
167  {
168  if (!is_array($this->recalculatedPasses[$activeId])) {
169  $this->recalculatedPasses[$activeId] = array();
170  }
171 
172  $this->recalculatedPasses[$activeId][] = $pass;
173  }
174 }
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
Move this to a proper place.
Class ilObjTestGUI.
recalculatePass($passdata, $active_id, $pass)
$userdata
Definition: demo.php:48
static setForcePassResultUpdateEnabled($forcePassResultsUpdateEnabled)
addRecalculatedPassByActive($activeId, $pass)
__construct(ilObjTest $test)
setPreserveManualScores($preserve_manual_scores)
Class ilTestScoring.
Create styles array
The data for the language used.
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)