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.

References $test, and test().

39  {
40  $this->test = $test;
41  $this->preserve_manual_scores = false;
42 
43  $this->recalculatedPasses = array();
44  }
test()
Definition: build.php:107
+ 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.

References $pass.

Referenced by recalculatePasses().

186  {
187  if (!is_array($this->recalculatedPasses[$activeId])) {
188  $this->recalculatedPasses[$activeId] = array();
189  }
190 
191  $this->recalculatedPasses[$activeId][] = $pass;
192  }
+ Here is the caller graph for this function:

◆ getNumManualScorings()

ilTestScoring::getNumManualScorings ( )
Returns
int

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

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

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$values
$query
test()
Definition: build.php:107
$row
+ 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.

58  {
60  }

◆ getQuestionId()

ilTestScoring::getQuestionId ( )
Returns
int

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

References $questionId.

Referenced by getNumManualScorings(), and recalculatePass().

66  {
67  return $this->questionId;
68  }
+ Here is the caller graph for this function:

◆ getRecalculatedPassesByActives()

ilTestScoring::getRecalculatedPassesByActives ( )

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

References $recalculatedPasses.

181  {
183  }

◆ recalculatePass()

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

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

References $pass, assQuestion\_setReachedPoints(), getQuestionId(), assQuestion\setForcePassResultUpdateEnabled(), and test().

Referenced by recalculatePasses().

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  }
test()
Definition: build.php:107
+ 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.

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

Referenced by recalculateSolutions().

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  }
recalculatePass($passdata, $active_id, $pass)
addRecalculatedPassByActive($activeId, $pass)
+ 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.

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

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)
Move this to a proper place.
test()
Definition: build.php:107
recalculatePasses($userdata, $active_id)
+ Here is the call graph for this function:

◆ removeAllQuestionResults()

ilTestScoring::removeAllQuestionResults (   $questionId)

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

References $DIC, $query, and $questionId.

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  }
global $DIC
Definition: saml.php:7
$query

◆ 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.

References $preserve_manual_scores.

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

◆ setQuestionId()

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

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

References $questionId.

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

◆ updatePassAndTestResults()

ilTestScoring::updatePassAndTestResults (   $activeIds)

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

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

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  }
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
Move this to a proper place.
global $DIC
Definition: saml.php:7
test()
Definition: build.php:107
+ Here is the call graph for this function:

Field Documentation

◆ $preserve_manual_scores

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

ilTestScoring::$test
protected

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

Referenced by __construct(), and updatePassAndTestResults().


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