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 @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: saml.php:7

References $DIC, and read().

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

165 {
166 $this->questions = array();
167 }

◆ create()

ilLOTestRun::create ( )

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

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

References $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 217 of file class.ilLOTestRun.php.

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 }

References $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 80 of file class.ilLOTestRun.php.

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 }

References $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 70 of file class.ilLOTestRun.php.

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 }

References $ilDB, and $query.

Referenced by ilObjCourseGUI\resetObject().

+ Here is the caller graph for this function:

◆ getContainerId()

ilLOTestRun::getContainerId ( )

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

130 {
131 return $this->container_id;
132 }

References $container_id.

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

+ Here is the caller graph for this function:

◆ getMaxPoints()

ilLOTestRun::getMaxPoints ( )

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

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

References $max_points.

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

+ Here is the caller graph for this function:

◆ getObjectiveId()

ilLOTestRun::getObjectiveId ( )

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

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

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 159 of file class.ilLOTestRun.php.

160 {
161 return (array) $this->questions;
162 }

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 193 of file class.ilLOTestRun.php.

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 }

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 112 of file class.ilLOTestRun.php.

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

References $ilDB, $query, $res, $row, 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 139 of file class.ilLOTestRun.php.

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

References $test_id.

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

+ Here is the caller graph for this function:

◆ getUserId()

ilLOTestRun::getUserId ( )

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

135 {
136 return $this->user_id;
137 }

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 91 of file class.ilLOTestRun.php.

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.

References $GLOBALS, $ilDB, $query, $res, $row, 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 $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 }

References $ilDB, $query, $res, $row, 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 174 of file class.ilLOTestRun.php.

175 {
176 return array_key_exists($a_question_id, (array) $this->questions);
177 }

◆ read()

ilLOTestRun::read ( )

@global type $ilDB

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

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 }

References $ilDB, $query, $res, $row, 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 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.

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 }

References ilLogLevel\DEBUG.

◆ update()

ilLOTestRun::update ( )

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

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 }

References $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: