ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 179 of file class.ilLOTestRun.php.

180  {
181  $this->questions[$a_id] = 0;
182  }

◆ clearQuestions()

ilLOTestRun::clearQuestions ( )

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

175  {
176  $this->questions = array();
177  }

◆ create()

ilLOTestRun::create ( )

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

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

Referenced by ilLOTestQuestionAdapter\notifyTestStart().

242  {
243  global $DIC;
244 
245  $ilDB = $DIC['ilDB'];
246 
247  $query = 'INSERT INTO loc_tst_run ' .
248  '(container_id, user_id, test_id, objective_id,max_points,questions) ' .
249  'VALUES( ' .
250  $ilDB->quote($this->getContainerId(), 'integer') . ', ' .
251  $ilDB->quote($this->getUserId(), 'integer') . ', ' .
252  $ilDB->quote($this->getTestId(), 'integer') . ', ' .
253  $ilDB->quote($this->getObjectiveId(), 'integer') . ', ' .
254  $ilDB->quote($this->getMaxPoints(), 'integer') . ', ' .
255  $ilDB->quote(serialize($this->getQuestions()), 'text') . ' ' .
256  ')';
257  $ilDB->manipulate($query);
258  }
global $DIC
Definition: saml.php:7
$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 227 of file class.ilLOTestRun.php.

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

228  {
229  global $DIC;
230 
231  $ilDB = $DIC['ilDB'];
232 
233  $query = 'DELETE FROM loc_tst_run ' .
234  'WHERE container_id = ' . $ilDB->quote($this->getContainerId(), 'integer') . ' ' .
235  'AND user_id = ' . $ilDB->quote($this->getUserId(), 'integer') . ' ' .
236  'AND test_id = ' . $ilDB->quote($this->getTestId(), 'integer') . ' ' .
237  'AND objective_id = ' . $ilDB->quote($this->getObjectiveId(), 'integer');
238  $ilDB->manipulate($query);
239  }
global $DIC
Definition: saml.php:7
$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 84 of file class.ilLOTestRun.php.

References $DIC, $ilDB, and $query.

Referenced by ilLOTestQuestionAdapter\notifyTestStart().

85  {
86  global $DIC;
87 
88  $ilDB = $DIC['ilDB'];
89 
90  $query = 'DELETE FROM loc_tst_run ' .
91  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
92  'AND user_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ' .
93  'AND test_id = ' . $ilDB->quote($a_test_id, 'integer') . ' ';
94  $ilDB->manipulate($query);
95  }
global $DIC
Definition: saml.php:7
$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 72 of file class.ilLOTestRun.php.

References $DIC, $ilDB, and $query.

Referenced by ilObjCourseGUI\resetObject().

73  {
74  global $DIC;
75 
76  $ilDB = $DIC['ilDB'];
77 
78  $query = 'DELETE FROM loc_tst_run ' .
79  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
80  'AND user_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ';
81  $ilDB->manipulate($query);
82  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the caller graph for this function:

◆ getContainerId()

ilLOTestRun::getContainerId ( )

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

References $container_id.

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

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

◆ getMaxPoints()

ilLOTestRun::getMaxPoints ( )

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

References $max_points.

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

160  {
161  return $this->max_points;
162  }
+ Here is the caller graph for this function:

◆ getObjectiveId()

ilLOTestRun::getObjectiveId ( )

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

References $objective_id.

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

155  {
156  return $this->objective_id;
157  }
+ Here is the caller graph for this function:

◆ getQuestions()

ilLOTestRun::getQuestions ( )

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

References $questions.

Referenced by create(), and update().

170  {
171  return (array) $this->questions;
172  }
+ Here is the caller graph for this function:

◆ getResult()

ilLOTestRun::getResult ( )

Get result for objective run.

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

References getMaxPoints().

204  {
205  $sum_points = 0;
206  foreach ($this->questions as $qid => $points) {
207  $sum_points += $points;
208  }
209 
210  $percentage =
211  ($this->getMaxPoints() > 0) ?
212  ($sum_points / $this->getMaxPoints() * 100) :
213  100;
214 
215  return array(
216  'max' => $this->getMaxPoints(),
217  'reached' => $sum_points,
218  'percentage' => $percentage
219  );
220  }
+ 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 120 of file class.ilLOTestRun.php.

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

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

121  {
122  global $DIC;
123 
124  $ilDB = $DIC['ilDB'];
125 
126  $query = 'SELECT objective_id FROM loc_tst_run ' .
127  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
128  'AND user_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ' .
129  'AND test_id = ' . $ilDB->quote($a_test_id, 'integer') . ' ';
130  $res = $ilDB->query($query);
131 
132  $run = array();
133  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
134  $run[] = new ilLOTestRun($a_container_id, $a_user_id, $a_test_id, $row->objective_id);
135  }
136  return $run;
137  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
Stores current objective, questions and max points.
+ Here is the caller graph for this function:

◆ getTestId()

ilLOTestRun::getTestId ( )

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

References $test_id.

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

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

◆ getUserId()

ilLOTestRun::getUserId ( )

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

References $user_id.

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

145  {
146  return $this->user_id;
147  }
+ 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 97 of file class.ilLOTestRun.php.

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

Referenced by ilLOUtils\hasActiveRun().

98  {
99  global $DIC;
100 
101  $ilDB = $DIC['ilDB'];
102 
103  $query = 'SELECT objective_id FROM loc_tst_run ' .
104  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
105  'AND user_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ' .
106  'AND test_id = ' . $ilDB->quote($a_test_id, 'integer');
107  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': ' . $query);
108  $res = $ilDB->query($query);
109  $objectives = array();
110  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
111  $objectives[] = $row->objective_id;
112  }
113  return $objectives;
114  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ 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 $DIC, $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilContainerObjectiveGUI\updateResult().

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

◆ questionExists()

ilLOTestRun::questionExists (   $a_question_id)

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

185  {
186  return array_key_exists($a_question_id, (array) $this->questions);
187  }

◆ read()

ilLOTestRun::read ( )

type $ilDB

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

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

Referenced by __construct().

281  {
282  global $DIC;
283 
284  $ilDB = $DIC['ilDB'];
285 
286  $query = 'SELECT * FROM loc_tst_run ' .
287  'WHERE container_id = ' . $ilDB->quote($this->getContainerId(), 'integer') . ' ' .
288  'AND user_id = ' . $ilDB->quote($this->getUserId(), 'integer') . ' ' .
289  'AND test_id = ' . $ilDB->quote($this->getTestId(), 'integer') . ' ' .
290  'AND objective_id = ' . $ilDB->quote($this->getObjectiveId(), 'integer');
291  $res = $ilDB->query($query);
292  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
293  $this->max_points = $row->max_points;
294  if ($row->questions) {
295  $this->questions = unserialize($row->questions);
296  }
297  }
298  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
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 164 of file class.ilLOTestRun.php.

165  {
166  $this->max_points = $a_points;
167  }

◆ setQuestionResult()

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

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

References ilLogLevel\DEBUG.

194  {
195  $this->logger->debug($a_qst_id . ' ' . $a_points);
196  $this->questions[$a_qst_id] = $a_points;
197  $this->logger->dump($this->questions, ilLogLevel::DEBUG);
198  }

◆ update()

ilLOTestRun::update ( )

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

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

261  {
262  global $DIC;
263 
264  $ilDB = $DIC['ilDB'];
265 
266  $query = 'UPDATE loc_tst_run SET ' .
267  'max_points = ' . $ilDB->quote($this->getMaxPoints(), 'integer') . ', ' .
268  'questions = ' . $ilDB->quote(serialize($this->getQuestions()), 'text') . ' ' .
269  'WHERE container_id = ' . $ilDB->quote($this->container_id, '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  $ilDB->manipulate($query);
274  }
global $DIC
Definition: saml.php:7
$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: