ILIAS  release_8 Revision v8.24
ilTestScoring Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilTestScoring:

Public Member Functions

 __construct (ilObjTest $test)
 
 setPreserveManualScores ($preserve_manual_scores)
 
 getPreserveManualScores ()
 
 getQuestionId ()
 
 setQuestionId (int $questionId)
 
 recalculateSolutions ()
 
 recalculateSolution ($active_id, $pass)
 Updates passed status of the Test. More...
 
 recalculatePasses ($userdata, $active_id)
 
 recalculatePass ($passdata, $active_id, $pass)
 
 resetRecalculatedPassesByActives ()
 
 getRecalculatedPassesByActives ()
 
 addRecalculatedPassByActive ($activeId, $pass)
 
 removeAllQuestionResults ($questionId)
 
 updatePassAndTestResults ($activeIds)
 
 getNumManualScorings ()
 

Protected Attributes

 $test
 
 $preserve_manual_scores
 
 $questionId = 0
 

Private Attributes

 $recalculatedPasses
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilTestScoring

This class holds a mechanism to get the scoring for

  • a test,
  • a user in a test,
  • a pass in a users passes in a test, or
  • a question in a pass in a users passes in a test.

Warning: Please use carefully, this is one of the classes that may cause funny spikes on your servers load graph on large datasets in the test.

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 38 of file class.ilTestScoring.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestScoring::__construct ( ilObjTest  $test)

Definition at line 53 of file class.ilTestScoring.php.

54 {
55 $this->test = $test;
56 $this->preserve_manual_scores = false;
57
58 $this->recalculatedPasses = array();
59 }

References $test.

Member Function Documentation

◆ addRecalculatedPassByActive()

ilTestScoring::addRecalculatedPassByActive (   $activeId,
  $pass 
)

Definition at line 219 of file class.ilTestScoring.php.

220 {
221 if (!array_key_exists($activeId, $this->recalculatedPasses)
222 || !is_array($this->recalculatedPasses[$activeId])
223 ) {
224 $this->recalculatedPasses[$activeId] = array();
225 }
226
227 $this->recalculatedPasses[$activeId][] = $pass;
228 }

Referenced by recalculatePasses().

+ Here is the caller graph for this function:

◆ getNumManualScorings()

ilTestScoring::getNumManualScorings ( )
Returns
int

Definition at line 257 of file class.ilTestScoring.php.

257 : int
258 {
259 global $DIC; /* @var ILIAS\DI\Container $DIC */
260
261 $query = "
262 SELECT COUNT(*) num_manual_scorings
263 FROM tst_test_result tres
264
265 INNER JOIN tst_active tact
266 ON tact.active_id = tres.active_fi
267 AND tact.test_fi = %s
268
269 WHERE tres.manual = 1
270 ";
271
272 $types = array('integer');
273 $values = array($this->test->getTestId());
274
275 if ($this->getQuestionId()) {
276 $query .= "
277 AND tres.question_fi = %s
278 ";
279
280 $types[] = 'integer';
281 $values[] = $this->getQuestionId();
282 }
283
284 $res = $DIC->database()->queryF($query, $types, $values);
285
286 while ($row = $DIC->database()->fetchAssoc($res)) {
287 return (int) $row['num_manual_scorings'];
288 }
289
290 return 0;
291 }
global $DIC
Definition: feed.php:28
$res
Definition: ltiservices.php:69
$query

References $DIC, $query, $res, and getQuestionId().

+ Here is the call graph for this function:

◆ getPreserveManualScores()

ilTestScoring::getPreserveManualScores ( )
Returns
boolean

Definition at line 72 of file class.ilTestScoring.php.

72 : bool
73 {
75 }

References $preserve_manual_scores.

◆ getQuestionId()

ilTestScoring::getQuestionId ( )
Returns
int

Definition at line 80 of file class.ilTestScoring.php.

80 : int
81 {
82 return $this->questionId;
83 }

References $questionId.

Referenced by getNumManualScorings(), and recalculatePass().

+ Here is the caller graph for this function:

◆ getRecalculatedPassesByActives()

ilTestScoring::getRecalculatedPassesByActives ( )

Definition at line 214 of file class.ilTestScoring.php.

214 : array
215 {
217 }

References $recalculatedPasses.

◆ recalculatePass()

ilTestScoring::recalculatePass (   $passdata,
  $active_id,
  $pass 
)
Parameters
$passdata
$active_id
$pass

Definition at line 145 of file class.ilTestScoring.php.

146 {
147 $questions = $passdata->getAnsweredQuestions();
148 if (is_array($questions)) {
149 foreach ($questions as $questiondata) {
150 if ($this->getQuestionId() && $this->getQuestionId() != $questiondata['id']) {
151 continue;
152 }
153
154 $question_gui = $this->test->createQuestionGUI("", $questiondata['id']);
155 $this->recalculateQuestionScore($question_gui, $active_id, $pass, $questiondata);
156 }
157 }
158 }

References getQuestionId().

Referenced by recalculatePasses(), and recalculateSolution().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ recalculatePasses()

ilTestScoring::recalculatePasses (   $userdata,
  $active_id 
)
Parameters
$userdata
$active_id

Definition at line 129 of file class.ilTestScoring.php.

130 {
131 $passes = $userdata->getPasses();
132 foreach ($passes as $pass => $passdata) {
133 if (is_object($passdata)) {
134 $this->recalculatePass($passdata, $active_id, $pass);
135 $this->addRecalculatedPassByActive($active_id, $pass);
136 }
137 }
138 }
addRecalculatedPassByActive($activeId, $pass)
recalculatePass($passdata, $active_id, $pass)

References addRecalculatedPassByActive(), and recalculatePass().

Referenced by recalculateSolutions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ recalculateSolution()

ilTestScoring::recalculateSolution (   $active_id,
  $pass 
)

Updates passed status of the Test.

Parameters
$active_id
$pass

Definition at line 113 of file class.ilTestScoring.php.

114 {
115 $user_data = $this
116 ->test
117 ->getCompleteEvaluationData(false)
118 ->getParticipant($active_id)
119 ->getPass($pass);
120
121 $this->recalculatePass($user_data, $active_id, $pass);
123 }
static _updateTestResultCache(int $active_id, ilAssQuestionProcessLocker $processLocker=null)
@TODO Move this to a proper place.

References assQuestion\_updateTestResultCache(), and recalculatePass().

+ Here is the call graph for this function:

◆ recalculateSolutions()

ilTestScoring::recalculateSolutions ( )

Definition at line 93 of file class.ilTestScoring.php.

94 {
95 $participants = $this->test->getCompleteEvaluationData(false)->getParticipants();
96 if (is_array($participants)) {
97 require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
98 foreach ($participants as $active_id => $userdata) {
99 if (is_object($userdata) && is_array($userdata->getPasses())) {
100 $this->recalculatePasses($userdata, $active_id);
101 }
103 }
104 }
105 }
recalculatePasses($userdata, $active_id)

References assQuestion\_updateTestResultCache(), and recalculatePasses().

+ Here is the call graph for this function:

◆ removeAllQuestionResults()

ilTestScoring::removeAllQuestionResults (   $questionId)

Definition at line 230 of file class.ilTestScoring.php.

231 {
232 global $DIC; /* @var ILIAS\DI\Container $DIC */
233
234 $query = "DELETE FROM tst_test_result WHERE question_fi = %s";
235 $DIC->database()->manipulateF($query, array('integer'), array($questionId));
236 }

References $DIC, $query, and $questionId.

◆ resetRecalculatedPassesByActives()

ilTestScoring::resetRecalculatedPassesByActives ( )

Definition at line 209 of file class.ilTestScoring.php.

210 {
211 $this->recalculatedPasses = array();
212 }

◆ setPreserveManualScores()

ilTestScoring::setPreserveManualScores (   $preserve_manual_scores)
Parameters
boolean$preserve_manual_scores

Definition at line 64 of file class.ilTestScoring.php.

65 {
66 $this->preserve_manual_scores = $preserve_manual_scores;
67 }

References $preserve_manual_scores.

◆ setQuestionId()

ilTestScoring::setQuestionId ( int  $questionId)
Parameters
int$questionId

Definition at line 88 of file class.ilTestScoring.php.

89 {
90 $this->questionId = $questionId;
91 }

References $questionId.

◆ updatePassAndTestResults()

ilTestScoring::updatePassAndTestResults (   $activeIds)

Definition at line 238 of file class.ilTestScoring.php.

239 {
240 global $DIC; /* @var ILIAS\DI\Container $DIC */
241
242 foreach ($activeIds as $activeId) {
243 $passSelector = new ilTestPassesSelector($DIC->database(), $this->test);
244 $passSelector->setActiveId($activeId);
245
246 foreach ($passSelector->getExistingPasses() as $pass) {
247 assQuestion::_updateTestPassResults($activeId, $pass, $this->test->areObligationsEnabled());
248 }
249
251 }
252 }

References $DIC, and assQuestion\_updateTestResultCache().

+ Here is the call graph for this function:

Field Documentation

◆ $preserve_manual_scores

bool ilTestScoring::$preserve_manual_scores
protected

Definition at line 44 of file class.ilTestScoring.php.

Referenced by getPreserveManualScores(), and setPreserveManualScores().

◆ $questionId

ilTestScoring::$questionId = 0
protected

Definition at line 51 of file class.ilTestScoring.php.

Referenced by getQuestionId(), removeAllQuestionResults(), and setQuestionId().

◆ $recalculatedPasses

ilTestScoring::$recalculatedPasses
private

Definition at line 46 of file class.ilTestScoring.php.

Referenced by getRecalculatedPassesByActives().

◆ $test

ilObjTest ilTestScoring::$test
protected

Definition at line 41 of file class.ilTestScoring.php.

Referenced by __construct().


The documentation for this class was generated from the following file: