ILIAS  release_7 Revision v7.30-3-g800a261c036
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 ()
 
 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

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.

39  {
40  $this->test = $test;
41  $this->preserve_manual_scores = false;
42 
43  $this->recalculatedPasses = array();
44  }

Member Function Documentation

◆ addRecalculatedPassByActive()

ilTestScoring::addRecalculatedPassByActive (   $activeId,
  $pass 
)

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

References $pass.

Referenced by recalculatePasses().

204  {
205  if (!is_array($this->recalculatedPasses[$activeId])) {
206  $this->recalculatedPasses[$activeId] = array();
207  }
208 
209  $this->recalculatedPasses[$activeId][] = $pass;
210  }
+ Here is the caller graph for this function:

◆ getNumManualScorings()

ilTestScoring::getNumManualScorings ( )
Returns
int

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

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

240  {
241  global $DIC; /* @var ILIAS\DI\Container $DIC */
242 
243  $query = "
244  SELECT COUNT(*) num_manual_scorings
245  FROM tst_test_result tres
246 
247  INNER JOIN tst_active tact
248  ON tact.active_id = tres.active_fi
249  AND tact.test_fi = %s
250 
251  WHERE tres.manual = 1
252  ";
253 
254  $types = array('integer');
255  $values = array($this->test->getTestId());
256 
257  if ($this->getQuestionId()) {
258  $query .= "
259  AND tres.question_fi = %s
260  ";
261 
262  $types[] = 'integer';
263  $values[] = $this->getQuestionId();
264  }
265 
266  $res = $DIC->database()->queryF($query, $types, $values);
267 
268  while ($row = $DIC->database()->fetchAssoc($res)) {
269  return (int) $row['num_manual_scorings'];
270  }
271 
272  return 0;
273  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
+ 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 198 of file class.ilTestScoring.php.

References $recalculatedPasses.

199  {
201  }

◆ recalculatePass()

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

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

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

Referenced by recalculatePasses(), and recalculateSolution().

131  {
132  $questions = $passdata->getAnsweredQuestions();
133  if (is_array($questions)) {
134  foreach ($questions as $questiondata) {
135  if ($this->getQuestionId() && $this->getQuestionId() != $questiondata['id']) {
136  continue;
137  }
138 
139  $question_gui = $this->test->createQuestionGUI("", $questiondata['id']);
140  $this->recalculateQuestionScore($question_gui, $active_id, $pass, $questiondata);
141  }
142  }
143  }
+ 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 114 of file class.ilTestScoring.php.

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

Referenced by recalculateSolutions().

115  {
116  $passes = $userdata->getPasses();
117  foreach ($passes as $pass => $passdata) {
118  if (is_object($passdata)) {
119  $this->recalculatePass($passdata, $active_id, $pass);
120  $this->addRecalculatedPassByActive($active_id, $pass);
121  }
122  }
123  }
recalculatePass($passdata, $active_id, $pass)
addRecalculatedPassByActive($activeId, $pass)
+ 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 98 of file class.ilTestScoring.php.

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

99  {
100  $user_data = $this
101  ->test
102  ->getCompleteEvaluationData(false)
103  ->getParticipant($active_id)
104  ->getPass($pass);
105 
106  $this->recalculatePass($user_data, $active_id, $pass);
108  }
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
Move this to a proper place.
recalculatePass($passdata, $active_id, $pass)
+ Here is the call graph for this function:

◆ recalculateSolutions()

ilTestScoring::recalculateSolutions ( )

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

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

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.
recalculatePasses($userdata, $active_id)
+ Here is the call graph for this function:

◆ removeAllQuestionResults()

ilTestScoring::removeAllQuestionResults (   $questionId)

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

References $DIC, $query, and $questionId.

213  {
214  global $DIC; /* @var ILIAS\DI\Container $DIC */
215 
216  $query = "DELETE FROM tst_test_result WHERE question_fi = %s";
217  $DIC->database()->manipulateF($query, array('integer'), array($questionId));
218  }
global $DIC
Definition: goto.php:24
$query

◆ resetRecalculatedPassesByActives()

ilTestScoring::resetRecalculatedPassesByActives ( )

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

194  {
195  $this->recalculatedPasses = array();
196  }

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

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

221  {
222  global $DIC; /* @var ILIAS\DI\Container $DIC */
223 
224  foreach ($activeIds as $activeId) {
225  $passSelector = new ilTestPassesSelector($DIC->database(), $this->test);
226  $passSelector->setActiveId($activeId);
227 
228  foreach ($passSelector->getExistingPasses() as $pass) {
229  assQuestion::_updateTestPassResults($activeId, $pass, $this->test->areObligationsEnabled());
230  }
231 
233  }
234  }
static _updateTestResultCache($active_id, ilAssQuestionProcessLocker $processLocker=null)
Move this to a proper place.
global $DIC
Definition: goto.php:24
+ 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: