ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilLOTestRun Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilLOTestRun:

Public Member Functions

 __construct (int $a_crs_id, int $a_user_id, int $a_test_id, int $a_objective_id)
 
 getContainerId ()
 
 getUserId ()
 
 getTestId ()
 
 getObjectiveId ()
 
 getMaxPoints ()
 
 setMaxPoints (int $a_points)
 
 getQuestions ()
 
 clearQuestions ()
 
 addQuestion (int $a_id)
 
 questionExists (int $a_question_id)
 
 setQuestionResult (int $a_qst_id, float $a_points)
 
 getResult ()
 
 delete ()
 
 create ()
 
 update ()
 
 read ()
 

Static Public Member Functions

static lookupRunExistsForObjective (int $a_test_id, int $a_objective_id, int $a_user_id)
 
static deleteRuns (int $a_container_id, int $a_user_id)
 
static deleteRun (int $a_container_id, int $a_user_id, int $a_test_id)
 
static lookupObjectives (int $a_container_id, int $a_user_id, int $a_test_id)
 
static getRun (int $a_container_id, int $a_user_id, int $a_test_id)
 

Protected Attributes

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

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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 23 of file class.ilLOTestRun.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

35 {
36 global $DIC;
37
38 $this->db = $DIC->database();
39
40 $this->container_id = $a_crs_id;
41 $this->user_id = $a_user_id;
42 $this->test_id = $a_test_id;
43 $this->objective_id = $a_objective_id;
44
45 $this->read();
46 }
global $DIC
Definition: shib_login.php:26

References $DIC, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ addQuestion()

ilLOTestRun::addQuestion ( int  $a_id)

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

165 : void
166 {
167 $this->questions[$a_id] = 0;
168 }

◆ clearQuestions()

ilLOTestRun::clearQuestions ( )

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

160 : void
161 {
162 $this->questions = array();
163 }

◆ create()

ilLOTestRun::create ( )

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

209 : void
210 {
211 $query = 'INSERT INTO loc_tst_run ' .
212 '(container_id, user_id, test_id, objective_id,max_points,questions) ' .
213 'VALUES( ' .
214 $this->db->quote($this->getContainerId(), 'integer') . ', ' .
215 $this->db->quote($this->getUserId(), 'integer') . ', ' .
216 $this->db->quote($this->getTestId(), 'integer') . ', ' .
217 $this->db->quote($this->getObjectiveId(), 'integer') . ', ' .
218 $this->db->quote($this->getMaxPoints(), 'integer') . ', ' .
219 $this->db->quote(serialize($this->getQuestions()), 'text') . ' ' .
220 ')';
221 $this->db->manipulate($query);
222 }

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

+ Here is the call graph for this function:

◆ delete()

ilLOTestRun::delete ( )

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

199 : void
200 {
201 $query = 'DELETE FROM loc_tst_run ' .
202 'WHERE container_id = ' . $this->db->quote($this->getContainerId(), 'integer') . ' ' .
203 'AND user_id = ' . $this->db->quote($this->getUserId(), 'integer') . ' ' .
204 'AND test_id = ' . $this->db->quote($this->getTestId(), 'integer') . ' ' .
205 'AND objective_id = ' . $this->db->quote($this->getObjectiveId(), 'integer');
206 $this->db->manipulate($query);
207 }

References getContainerId().

+ Here is the call graph for this function:

◆ deleteRun()

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

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

75 : void
76 {
77 global $DIC;
78
79 $ilDB = $DIC->database();
80 $query = 'DELETE FROM loc_tst_run ' .
81 'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
82 'AND user_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ' .
83 'AND test_id = ' . $ilDB->quote($a_test_id, 'integer') . ' ';
84 $ilDB->manipulate($query);
85 }

References $DIC, and $ilDB.

Referenced by ilLOTestQuestionAdapter\notifyTestStart().

+ Here is the caller graph for this function:

◆ deleteRuns()

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

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

64 : void
65 {
66 global $DIC;
67
68 $ilDB = $DIC['ilDB'];
69 $query = 'DELETE FROM loc_tst_run ' .
70 'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
71 'AND user_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ';
72 $ilDB->manipulate($query);
73 }

References $DIC, and $ilDB.

Referenced by ilObjCourseGUI\resetObject().

+ Here is the caller graph for this function:

◆ getContainerId()

ilLOTestRun::getContainerId ( )

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

125 : int
126 {
127 return $this->container_id;
128 }

References $container_id.

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

+ Here is the caller graph for this function:

◆ getMaxPoints()

ilLOTestRun::getMaxPoints ( )

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

145 : int
146 {
147 return $this->max_points;
148 }

References $max_points.

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

+ Here is the caller graph for this function:

◆ getObjectiveId()

ilLOTestRun::getObjectiveId ( )

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

140 : int
141 {
142 return $this->objective_id;
143 }

References $objective_id.

Referenced by create(), ILIAS\Test\Results\Presentation\TitlesBuilder\getObjectiveTitle(), read(), and update().

+ Here is the caller graph for this function:

◆ getQuestions()

ilLOTestRun::getQuestions ( )

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

155 : array
156 {
157 return $this->questions;
158 }

References $questions.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getResult()

ilLOTestRun::getResult ( )

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

180 : array
181 {
182 $sum_points = 0;
183 foreach ($this->questions as $points) {
184 $sum_points += $points;
185 }
186
187 $percentage =
188 ($this->getMaxPoints() > 0) ?
189 round(($sum_points / $this->getMaxPoints() * 100), 0) :
190 100;
191
192 return array(
193 'max' => $this->getMaxPoints(),
194 'reached' => $sum_points,
195 'percentage' => $percentage
196 );
197 }

References getMaxPoints().

+ Here is the call graph for this function:

◆ getRun()

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

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

107 : array
108 {
109 global $DIC;
110
111 $ilDB = $DIC->database();
112 $query = 'SELECT objective_id FROM loc_tst_run ' .
113 'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
114 'AND user_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ' .
115 'AND test_id = ' . $ilDB->quote($a_test_id, 'integer') . ' ';
116 $res = $ilDB->query($query);
117
118 $run = array();
119 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
120 $run[] = new ilLOTestRun($a_container_id, $a_user_id, $a_test_id, $row->objective_id);
121 }
122 return $run;
123 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$res
Definition: ltiservices.php:69

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

Referenced by ILIAS\Test\Results\Presentation\TitlesBuilder\initObjectives(), and ilLOTestQuestionAdapter\initTestRun().

+ Here is the caller graph for this function:

◆ getTestId()

ilLOTestRun::getTestId ( )

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

135 : int
136 {
137 return $this->test_id;
138 }

References $test_id.

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

+ Here is the caller graph for this function:

◆ getUserId()

ilLOTestRun::getUserId ( )

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

130 : int
131 {
132 return $this->user_id;
133 }

References $user_id.

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

+ Here is the caller graph for this function:

◆ lookupObjectives()

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

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

87 : array
88 {
89 global $DIC;
90
91 $ilDB = $DIC->database();
92 $query = 'SELECT objective_id FROM loc_tst_run ' .
93 'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
94 'AND user_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ' .
95 'AND test_id = ' . $ilDB->quote($a_test_id, 'integer');
96 $res = $ilDB->query($query);
97 $objectives = array();
98 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
99 $objectives[] = $row->objective_id;
100 }
101 return $objectives;
102 }
$objectives

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

◆ lookupRunExistsForObjective()

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

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

48 : bool
49 {
50 global $DIC;
51
52 $ilDB = $DIC->database();
53 $query = 'SELECT * FROM loc_tst_run ' .
54 'WHERE test_id = ' . $ilDB->quote($a_test_id, 'integer') . ' ' .
55 'AND objective_id = ' . $ilDB->quote($a_objective_id, 'integer') . ' ' .
56 'AND user_id = ' . $ilDB->quote($a_user_id, 'integer');
57 $res = $ilDB->query($query);
58 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
59 return true;
60 }
61 return false;
62 }

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

Referenced by ilContainerObjectiveGUI\updateResult().

+ Here is the caller graph for this function:

◆ questionExists()

ilLOTestRun::questionExists ( int  $a_question_id)

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

170 : bool
171 {
172 return array_key_exists($a_question_id, $this->questions);
173 }

◆ read()

ilLOTestRun::read ( )

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

236 : void
237 {
238 $query = 'SELECT * FROM loc_tst_run ' .
239 'WHERE container_id = ' . $this->db->quote($this->getContainerId(), 'integer') . ' ' .
240 'AND user_id = ' . $this->db->quote($this->getUserId(), 'integer') . ' ' .
241 'AND test_id = ' . $this->db->quote($this->getTestId(), 'integer') . ' ' .
242 'AND objective_id = ' . $this->db->quote($this->getObjectiveId(), 'integer');
243 $res = $this->db->query($query);
244 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
245 $this->max_points = $row->max_points;
246 if ($row->questions) {
247 $this->questions = unserialize($row->questions);
248 }
249 }
250 }

References $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 ( int  $a_points)

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

150 : void
151 {
152 $this->max_points = $a_points;
153 }

◆ setQuestionResult()

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

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

175 : void
176 {
177 $this->questions[$a_qst_id] = $a_points;
178 }

◆ update()

ilLOTestRun::update ( )

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

224 : void
225 {
226 $query = 'UPDATE loc_tst_run SET ' .
227 'max_points = ' . $this->db->quote($this->getMaxPoints(), 'integer') . ', ' .
228 'questions = ' . $this->db->quote(serialize($this->getQuestions()), 'text') . ' ' .
229 'WHERE container_id = ' . $this->db->quote($this->container_id, 'integer') . ' ' .
230 'AND user_id = ' . $this->db->quote($this->getUserId(), 'integer') . ' ' .
231 'AND test_id = ' . $this->db->quote($this->getTestId(), 'integer') . ' ' .
232 'AND objective_id = ' . $this->db->quote($this->getObjectiveId(), 'integer') . ' ';
233 $this->db->manipulate($query);
234 }

References getMaxPoints(), getObjectiveId(), getQuestions(), getTestId(), and getUserId().

+ Here is the call graph for this function:

Field Documentation

◆ $container_id

int ilLOTestRun::$container_id = 0
protected

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

Referenced by getContainerId().

◆ $db

ilDBInterface ilLOTestRun::$db
protected

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

◆ $max_points

int ilLOTestRun::$max_points = 0
protected

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

Referenced by getMaxPoints().

◆ $objective_id

int ilLOTestRun::$objective_id = 0
protected

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

Referenced by getObjectiveId().

◆ $questions

array ilLOTestRun::$questions = array()
protected

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

Referenced by getQuestions().

◆ $test_id

int ilLOTestRun::$test_id = 0
protected

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

Referenced by getTestId().

◆ $user_id

int ilLOTestRun::$user_id = 0
protected

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

Referenced by getUserId().


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