ILIAS  release_7 Revision v7.30-3-g800a261c036
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 @global type $ilDB. More...
 
 create ()
 
 update ()
 
 read ()
 @global type $ilDB More...
 

Static Public Member Functions

static lookupRunExistsForObjective ($a_test_id, $a_objective_id, $a_user_id)
 @global type $ilDB More...
 
static deleteRuns ($a_container_id, $a_user_id)
 Delete runs @global 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.

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 }
read()
@global type $ilDB
global $DIC
Definition: goto.php:24

References $DIC, and read().

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

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 }
$query
global $ilDB

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

+ Here is the call graph for this function:

◆ delete()

ilLOTestRun::delete ( )

Delete all entries @global type $ilDB.

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

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 }

References $DIC, $ilDB, $query, and getContainerId().

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

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 }

References $DIC, $ilDB, and $query.

Referenced by ilLOTestQuestionAdapter\notifyTestStart().

+ Here is the caller graph for this function:

◆ deleteRuns()

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

Delete runs @global type $ilDB.

Parameters
type$a_container_id
type$a_user_id

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

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 }

References $DIC, $ilDB, and $query.

Referenced by ilObjCourseGUI\resetObject().

+ Here is the caller graph for this function:

◆ getContainerId()

ilLOTestRun::getContainerId ( )

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

140 {
141 return $this->container_id;
142 }

References $container_id.

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

+ Here is the caller graph for this function:

◆ getMaxPoints()

ilLOTestRun::getMaxPoints ( )

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

160 {
161 return $this->max_points;
162 }

References $max_points.

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

+ Here is the caller graph for this function:

◆ getObjectiveId()

ilLOTestRun::getObjectiveId ( )

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

155 {
156 return $this->objective_id;
157 }

References $objective_id.

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

+ Here is the caller graph for this function:

◆ getQuestions()

ilLOTestRun::getQuestions ( )

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

170 {
171 return (array) $this->questions;
172 }

References $questions.

Referenced by create(), and update().

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

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 }

References getMaxPoints().

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

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 }
Stores current objective, questions and max points.
foreach($_POST as $key=> $value) $res

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

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

+ Here is the caller graph for this function:

◆ getTestId()

ilLOTestRun::getTestId ( )

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

150 {
151 return $this->test_id;
152 }

References $test_id.

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

+ Here is the caller graph for this function:

◆ getUserId()

ilLOTestRun::getUserId ( )

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

145 {
146 return $this->user_id;
147 }

References $user_id.

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

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

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 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64

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

Referenced by ilLOUtils\hasActiveRun().

+ Here is the caller graph for this function:

◆ lookupRunExistsForObjective()

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

@global 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.

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 }

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

Referenced by ilContainerObjectiveGUI\updateResult().

+ 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 ( )

@global type $ilDB

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

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 }

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

Referenced by __construct().

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

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 }

References ilLogLevel\DEBUG.

◆ update()

ilLOTestRun::update ( )

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

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 }

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

+ 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: