ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilLOTestRun Class Reference

Stores current objective, questions and max points. More...

+ Collaboration diagram for ilLOTestRun:

Public Member Functions

 __construct ($a_crs_id, $a_user_id, $a_test_id, $a_objective_id)
 
 getContainerId ()
 
 getUserId ()
 
 getTestId ()
 
 getObjectiveId ()
 
 getMaxPoints ()
 
 setMaxPoints ($a_points)
 
 getQuestions ()
 
 clearQuestions ()
 
 addQuestion ($a_id)
 
 questionExists ($a_question_id)
 
 setQuestionResult ($a_qst_id, $a_points)
 
 getResult ()
 Get result for objective run. More...
 
 delete ()
 Delete all entries type $ilDB. More...
 
 create ()
 
 update ()
 
 read ()
 type $ilDB More...
 

Static Public Member Functions

static lookupRunExistsForObjective ($a_test_id, $a_objective_id, $a_user_id)
 type $ilDB More...
 
static deleteRuns ($a_container_id, $a_user_id)
 Delete runs type $ilDB. More...
 
static deleteRun ($a_container_id, $a_user_id, $a_test_id)
 
static lookupObjectives ($a_container_id, $a_user_id, $a_test_id)
 
static getRun ($a_container_id, $a_user_id, $a_test_id)
 

Protected Attributes

 $container_id = 0
 
 $user_id = 0
 
 $test_id = 0
 
 $objective_id = 0
 
 $max_points = 0
 
 $questions = array()
 

Private Attributes

 $logger = null
 

Detailed Description

Stores current objective, questions and max points.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 10 of file class.ilLOTestRun.php.

Constructor & Destructor Documentation

◆ __construct()

ilLOTestRun::__construct (   $a_crs_id,
  $a_user_id,
  $a_test_id,
  $a_objective_id 
)

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

References $DIC, and read().

27  {
28  global $DIC;
29 
30  $this->logger = $DIC->logger()->crs();
31 
32  $this->container_id = $a_crs_id;
33  $this->user_id = $a_user_id;
34  $this->test_id = $a_test_id;
35  $this->objective_id = $a_objective_id;
36 
37  $this->read();
38  }
global $DIC
Definition: saml.php:7
read()
type $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ addQuestion()

ilLOTestRun::addQuestion (   $a_id)

Definition at line 169 of file class.ilLOTestRun.php.

170  {
171  $this->questions[$a_id] = 0;
172  }

◆ clearQuestions()

ilLOTestRun::clearQuestions ( )

Definition at line 164 of file class.ilLOTestRun.php.

References array.

165  {
166  $this->questions = array();
167  }
Create styles array
The data for the language used.

◆ create()

ilLOTestRun::create ( )

Definition at line 229 of file class.ilLOTestRun.php.

References $ilDB, $query, getContainerId(), getMaxPoints(), getObjectiveId(), getQuestions(), getTestId(), and getUserId().

Referenced by ilLOTestQuestionAdapter\notifyTestStart().

230  {
231  global $ilDB;
232 
233  $query = 'INSERT INTO loc_tst_run ' .
234  '(container_id, user_id, test_id, objective_id,max_points,questions) ' .
235  'VALUES( ' .
236  $ilDB->quote($this->getContainerId(), 'integer') . ', ' .
237  $ilDB->quote($this->getUserId(), 'integer') . ', ' .
238  $ilDB->quote($this->getTestId(), 'integer') . ', ' .
239  $ilDB->quote($this->getObjectiveId(), 'integer') . ', ' .
240  $ilDB->quote($this->getMaxPoints(), 'integer') . ', ' .
241  $ilDB->quote(serialize($this->getQuestions()), 'text') . ' ' .
242  ')';
243  $ilDB->manipulate($query);
244  }
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilLOTestRun::delete ( )

Delete all entries type $ilDB.

Definition at line 217 of file class.ilLOTestRun.php.

References $ilDB, $query, getContainerId(), getObjectiveId(), getTestId(), and getUserId().

218  {
219  global $ilDB;
220 
221  $query = 'DELETE FROM loc_tst_run ' .
222  'WHERE container_id = ' . $ilDB->quote($this->getContainerId(), 'integer') . ' ' .
223  'AND user_id = ' . $ilDB->quote($this->getUserId(), 'integer') . ' ' .
224  'AND test_id = ' . $ilDB->quote($this->getTestId(), 'integer') . ' ' .
225  'AND objective_id = ' . $ilDB->quote($this->getObjectiveId(), 'integer');
226  $ilDB->manipulate($query);
227  }
$query
global $ilDB
+ Here is the call graph for this function:

◆ deleteRun()

static ilLOTestRun::deleteRun (   $a_container_id,
  $a_user_id,
  $a_test_id 
)
static

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

References $ilDB, and $query.

Referenced by ilLOTestQuestionAdapter\notifyTestStart().

81  {
82  global $ilDB;
83 
84  $query = 'DELETE FROM loc_tst_run ' .
85  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
86  'AND user_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ' .
87  'AND test_id = ' . $ilDB->quote($a_test_id, 'integer') . ' ';
88  $ilDB->manipulate($query);
89  }
$query
global $ilDB
+ Here is the caller graph for this function:

◆ deleteRuns()

static ilLOTestRun::deleteRuns (   $a_container_id,
  $a_user_id 
)
static

Delete runs type $ilDB.

Parameters
type$a_container_id
type$a_user_id

Definition at line 70 of file class.ilLOTestRun.php.

References $ilDB, and $query.

Referenced by ilObjCourseGUI\resetObject().

71  {
72  global $ilDB;
73 
74  $query = 'DELETE FROM loc_tst_run ' .
75  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
76  'AND user_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ';
77  $ilDB->manipulate($query);
78  }
$query
global $ilDB
+ Here is the caller graph for this function:

◆ getContainerId()

ilLOTestRun::getContainerId ( )

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

References $container_id.

Referenced by create(), delete(), and read().

130  {
131  return $this->container_id;
132  }
+ Here is the caller graph for this function:

◆ getMaxPoints()

ilLOTestRun::getMaxPoints ( )

Definition at line 149 of file class.ilLOTestRun.php.

References $max_points.

Referenced by create(), getResult(), and update().

150  {
151  return $this->max_points;
152  }
+ Here is the caller graph for this function:

◆ getObjectiveId()

ilLOTestRun::getObjectiveId ( )

Definition at line 144 of file class.ilLOTestRun.php.

References $objective_id.

Referenced by create(), delete(), ilTestResultHeaderLabelBuilder\getObjectiveTitle(), read(), and update().

145  {
146  return $this->objective_id;
147  }
+ Here is the caller graph for this function:

◆ getQuestions()

ilLOTestRun::getQuestions ( )

Definition at line 159 of file class.ilLOTestRun.php.

References $questions, and array.

Referenced by create(), and update().

160  {
161  return (array) $this->questions;
162  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getResult()

ilLOTestRun::getResult ( )

Get result for objective run.

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

References array, and getMaxPoints().

194  {
195  $sum_points = 0;
196  foreach ($this->questions as $qid => $points) {
197  $sum_points += $points;
198  }
199 
200  $percentage =
201  ($this->getMaxPoints() > 0) ?
202  ($sum_points / $this->getMaxPoints() * 100) :
203  100;
204 
205  return array(
206  'max' => $this->getMaxPoints(),
207  'reached' => $sum_points,
208  'percentage' => $percentage
209  );
210  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getRun()

static ilLOTestRun::getRun (   $a_container_id,
  $a_user_id,
  $a_test_id 
)
static
Returns
ilLOTestRun[]

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

References $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilTestResultHeaderLabelBuilder\initObjectives(), and ilLOTestQuestionAdapter\initTestRun().

113  {
114  global $ilDB;
115 
116  $query = 'SELECT objective_id FROM loc_tst_run ' .
117  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
118  'AND user_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ' .
119  'AND test_id = ' . $ilDB->quote($a_test_id, 'integer') . ' ';
120  $res = $ilDB->query($query);
121 
122  $run = array();
123  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
124  $run[] = new ilLOTestRun($a_container_id, $a_user_id, $a_test_id, $row->objective_id);
125  }
126  return $run;
127  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
Stores current objective, questions and max points.
+ Here is the caller graph for this function:

◆ getTestId()

ilLOTestRun::getTestId ( )

Definition at line 139 of file class.ilLOTestRun.php.

References $test_id.

Referenced by create(), delete(), read(), and update().

140  {
141  return $this->test_id;
142  }
+ Here is the caller graph for this function:

◆ getUserId()

ilLOTestRun::getUserId ( )

Definition at line 134 of file class.ilLOTestRun.php.

References $user_id.

Referenced by create(), delete(), read(), and update().

135  {
136  return $this->user_id;
137  }
+ Here is the caller graph for this function:

◆ lookupObjectives()

static ilLOTestRun::lookupObjectives (   $a_container_id,
  $a_user_id,
  $a_test_id 
)
static

Definition at line 91 of file class.ilLOTestRun.php.

References $GLOBALS, $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilLOUtils\hasActiveRun().

92  {
93  global $ilDB;
94 
95  $query = 'SELECT objective_id FROM loc_tst_run ' .
96  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
97  'AND user_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ' .
98  'AND test_id = ' . $ilDB->quote($a_test_id, 'integer');
99  $GLOBALS['ilLog']->write(__METHOD__ . ': ' . $query);
100  $res = $ilDB->query($query);
101  $objectives = array();
102  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
103  $objectives[] = $row->objective_id;
104  }
105  return $objectives;
106  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ lookupRunExistsForObjective()

static ilLOTestRun::lookupRunExistsForObjective (   $a_test_id,
  $a_objective_id,
  $a_user_id 
)
static

type $ilDB

Parameters
type$a_test_obj_id
type$a_objective_id
type$a_user_id
Returns
boolean

Definition at line 48 of file class.ilLOTestRun.php.

References $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilContainerObjectiveGUI\updateResult().

49  {
50  global $ilDB;
51 
52  $query = 'SELECT * FROM loc_tst_run ' .
53  'WHERE test_id = ' . $ilDB->quote($a_test_id, 'integer') . ' ' .
54  'AND objective_id = ' . $ilDB->quote($a_objective_id, 'integer') . ' ' .
55  'AND user_id = ' . $ilDB->quote($a_user_id, 'integer');
56  $res = $ilDB->query($query);
57 
58  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
59  return true;
60  }
61  return false;
62  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ questionExists()

ilLOTestRun::questionExists (   $a_question_id)

Definition at line 174 of file class.ilLOTestRun.php.

References array.

175  {
176  return array_key_exists($a_question_id, (array) $this->questions);
177  }
Create styles array
The data for the language used.

◆ read()

ilLOTestRun::read ( )

type $ilDB

Definition at line 264 of file class.ilLOTestRun.php.

References $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, getContainerId(), getObjectiveId(), getTestId(), and getUserId().

Referenced by __construct().

265  {
266  global $ilDB;
267 
268  $query = 'SELECT * FROM loc_tst_run ' .
269  'WHERE container_id = ' . $ilDB->quote($this->getContainerId(), 'integer') . ' ' .
270  'AND user_id = ' . $ilDB->quote($this->getUserId(), 'integer') . ' ' .
271  'AND test_id = ' . $ilDB->quote($this->getTestId(), 'integer') . ' ' .
272  'AND objective_id = ' . $ilDB->quote($this->getObjectiveId(), 'integer');
273  $res = $ilDB->query($query);
274  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
275  $this->max_points = $row->max_points;
276  if ($row->questions) {
277  $this->questions = unserialize($row->questions);
278  }
279  }
280  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMaxPoints()

ilLOTestRun::setMaxPoints (   $a_points)

Definition at line 154 of file class.ilLOTestRun.php.

155  {
156  $this->max_points = $a_points;
157  }

◆ setQuestionResult()

ilLOTestRun::setQuestionResult (   $a_qst_id,
  $a_points 
)
Parameters
int$a_qst_id
int$a_points

Definition at line 183 of file class.ilLOTestRun.php.

References ilLogLevel\DEBUG.

184  {
185  $this->logger->debug($a_qst_id . ' ' . $a_points);
186  $this->questions[$a_qst_id] = $a_points;
187  $this->logger->dump($this->questions, ilLogLevel::DEBUG);
188  }

◆ update()

ilLOTestRun::update ( )

Definition at line 246 of file class.ilLOTestRun.php.

References $ilDB, $query, getMaxPoints(), getObjectiveId(), getQuestions(), getTestId(), and getUserId().

247  {
248  global $ilDB;
249 
250  $query = 'UPDATE loc_tst_run SET ' .
251  'max_points = ' . $ilDB->quote($this->getMaxPoints(), 'integer') . ', ' .
252  'questions = ' . $ilDB->quote(serialize($this->getQuestions()), 'text') . ' ' .
253  'WHERE container_id = ' . $ilDB->quote($this->container_id, 'integer') . ' ' .
254  'AND user_id = ' . $ilDB->quote($this->getUserId(), 'integer') . ' ' .
255  'AND test_id = ' . $ilDB->quote($this->getTestId(), 'integer') . ' ' .
256  'AND objective_id = ' . $ilDB->quote($this->getObjectiveId(), 'integer') . ' ';
257  $ilDB->manipulate($query);
258  }
$query
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $container_id

ilLOTestRun::$container_id = 0
protected

Definition at line 12 of file class.ilLOTestRun.php.

Referenced by getContainerId().

◆ $logger

ilLOTestRun::$logger = null
private

Definition at line 23 of file class.ilLOTestRun.php.

◆ $max_points

ilLOTestRun::$max_points = 0
protected

Definition at line 17 of file class.ilLOTestRun.php.

Referenced by getMaxPoints().

◆ $objective_id

ilLOTestRun::$objective_id = 0
protected

Definition at line 15 of file class.ilLOTestRun.php.

Referenced by getObjectiveId().

◆ $questions

ilLOTestRun::$questions = array()
protected

Definition at line 18 of file class.ilLOTestRun.php.

Referenced by getQuestions().

◆ $test_id

ilLOTestRun::$test_id = 0
protected

Definition at line 14 of file class.ilLOTestRun.php.

Referenced by getTestId().

◆ $user_id

ilLOTestRun::$user_id = 0
protected

Definition at line 13 of file class.ilLOTestRun.php.

Referenced by getUserId().


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