ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTestScoring Class Reference

Class ilTestScoring. More...

+ Collaboration diagram for ilTestScoring:

Public Member Functions

 __construct (ilObjTest $test)
 
 setPreserveManualScores ($preserve_manual_scores)
 
 getPreserveManualScores ()
 
 getQuestionId ()
 
 setQuestionId (int $questionId)
 
 recalculateSolutions ()
 
 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

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 23 of file class.ilTestScoring.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestScoring::__construct ( ilObjTest  $test)

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

39 {
40 $this->test = $test;
41 $this->preserve_manual_scores = false;
42
43 $this->recalculatedPasses = array();
44 }
test()
Definition: build.php:107

References $test, and test().

+ Here is the call graph for this function:

Member Function Documentation

◆ addRecalculatedPassByActive()

ilTestScoring::addRecalculatedPassByActive (   $activeId,
  $pass 
)

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

186 {
187 if (!is_array($this->recalculatedPasses[$activeId])) {
188 $this->recalculatedPasses[$activeId] = array();
189 }
190
191 $this->recalculatedPasses[$activeId][] = $pass;
192 }

References $pass.

Referenced by recalculatePasses().

+ Here is the caller graph for this function:

◆ getNumManualScorings()

ilTestScoring::getNumManualScorings ( )
Returns
int

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

222 {
223 global $DIC; /* @var ILIAS\DI\Container $DIC */
224
225 $query = "
226 SELECT COUNT(*) num_manual_scorings
227 FROM tst_test_result tres
228
229 INNER JOIN tst_active tact
230 ON tact.active_id = tres.active_fi
231 AND tact.test_fi = %s
232
233 WHERE tres.manual = 1
234 ";
235
236 $types = array('integer');
237 $values = array($this->test->getTestId());
238
239 if ($this->getQuestionId()) {
240 $query .= "
241 AND tres.question_fi = %s
242 ";
243
244 $types[] = 'integer';
245 $values[] = $this->getQuestionId();
246 }
247
248 $res = $DIC->database()->queryF($query, $types, $values);
249
250 while ($row = $DIC->database()->fetchAssoc($res)) {
251 return (int) $row['num_manual_scorings'];
252 }
253
254 return 0;
255 }
$row
$query
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$values

References $DIC, $query, $res, $row, $values, getQuestionId(), and test().

+ Here is the call graph for this function:

◆ getPreserveManualScores()

ilTestScoring::getPreserveManualScores ( )
Returns
boolean

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

References $preserve_manual_scores.

◆ getQuestionId()

ilTestScoring::getQuestionId ( )
Returns
int

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

66 {
67 return $this->questionId;
68 }

References $questionId.

Referenced by getNumManualScorings(), and recalculatePass().

+ Here is the caller graph for this function:

◆ getRecalculatedPassesByActives()

ilTestScoring::getRecalculatedPassesByActives ( )

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

181 {
183 }

References $recalculatedPasses.

◆ recalculatePass()

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

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

113 {
114 $questions = $passdata->getAnsweredQuestions();
115 if (is_array($questions)) {
116 foreach ($questions as $questiondata) {
117 if ($this->getQuestionId() && $this->getQuestionId() != $questiondata['id']) {
118 continue;
119 }
120
121 $question_gui = $this->test->createQuestionGUI("", $questiondata['id']);
122 $this->recalculateQuestionScore($question_gui, $active_id, $pass, $questiondata);
123 }
124 }
125 }

References $pass, getQuestionId(), and test().

Referenced by recalculatePasses().

+ 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 96 of file class.ilTestScoring.php.

97 {
98 $passes = $userdata->getPasses();
99 foreach ($passes as $pass => $passdata) {
100 if (is_object($passdata)) {
101 $this->recalculatePass($passdata, $active_id, $pass);
102 $this->addRecalculatedPassByActive($active_id, $pass);
103 }
104 }
105 }
addRecalculatedPassByActive($activeId, $pass)
recalculatePass($passdata, $active_id, $pass)

References $pass, addRecalculatedPassByActive(), and recalculatePass().

Referenced by recalculateSolutions().

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

◆ recalculateSolutions()

ilTestScoring::recalculateSolutions ( )

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

79 {
80 $participants = $this->test->getCompleteEvaluationData(false)->getParticipants();
81 if (is_array($participants)) {
82 require_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
83 foreach ($participants as $active_id => $userdata) {
84 if (is_object($userdata) && is_array($userdata->getPasses())) {
85 $this->recalculatePasses($userdata, $active_id);
86 }
88 }
89 }
90 }
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
@TODO Move this to a proper place.
recalculatePasses($userdata, $active_id)

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

+ Here is the call graph for this function:

◆ removeAllQuestionResults()

ilTestScoring::removeAllQuestionResults (   $questionId)

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

195 {
196 global $DIC; /* @var ILIAS\DI\Container $DIC */
197
198 $query = "DELETE FROM tst_test_result WHERE question_fi = %s";
199 $DIC->database()->manipulateF($query, array('integer'), array($questionId));
200 }

References $DIC, $query, and $questionId.

◆ resetRecalculatedPassesByActives()

ilTestScoring::resetRecalculatedPassesByActives ( )

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

176 {
177 $this->recalculatedPasses = array();
178 }

◆ setPreserveManualScores()

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

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

50 {
51 $this->preserve_manual_scores = $preserve_manual_scores;
52 }

References $preserve_manual_scores.

◆ setQuestionId()

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

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

74 {
75 $this->questionId = $questionId;
76 }

References $questionId.

◆ updatePassAndTestResults()

ilTestScoring::updatePassAndTestResults (   $activeIds)

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

203 {
204 global $DIC; /* @var ILIAS\DI\Container $DIC */
205
206 foreach ($activeIds as $activeId) {
207 $passSelector = new ilTestPassesSelector($DIC->database(), $this->test);
208 $passSelector->setActiveId($activeId);
209
210 foreach ($passSelector->getExistingPasses() as $pass) {
211 assQuestion::_updateTestPassResults($activeId, $pass, $this->test->areObligationsEnabled());
212 }
213
215 }
216 }

References $DIC, $pass, assQuestion\_updateTestResultCache(), and test().

+ Here is the call graph for this function:

Field Documentation

◆ $preserve_manual_scores

bool ilTestScoring::$preserve_manual_scores
protected

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

Referenced by getPreserveManualScores(), and setPreserveManualScores().

◆ $questionId

ilTestScoring::$questionId = 0
protected

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

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

◆ $recalculatedPasses

ilTestScoring::$recalculatedPasses
private

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

Referenced by getRecalculatedPassesByActives().

◆ $test

ilObjTest ilTestScoring::$test
protected

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

Referenced by __construct().


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