ILIAS  trunk Revision v12.0_alpha-1329-g1094ddb0c33
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 (float $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
 
float $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 24 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 35 of file class.ilLOTestRun.php.

36 {
37 global $DIC;
38
39 $this->db = $DIC->database();
40
41 $this->container_id = $a_crs_id;
42 $this->user_id = $a_user_id;
43 $this->test_id = $a_test_id;
44 $this->objective_id = $a_objective_id;
45
46 $this->read();
47 }
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 166 of file class.ilLOTestRun.php.

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

◆ clearQuestions()

ilLOTestRun::clearQuestions ( )

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

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

◆ create()

ilLOTestRun::create ( )

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

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

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

+ Here is the call graph for this function:

◆ delete()

ilLOTestRun::delete ( )

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

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

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

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

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

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

References $DIC, and $ilDB.

Referenced by ilObjCourseGUI\resetObject().

+ Here is the caller graph for this function:

◆ getContainerId()

ilLOTestRun::getContainerId ( )

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

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

References $container_id.

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

+ Here is the caller graph for this function:

◆ getMaxPoints()

ilLOTestRun::getMaxPoints ( )

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

146 : float
147 {
148 return $this->max_points;
149 }

References $max_points.

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

+ Here is the caller graph for this function:

◆ getObjectiveId()

ilLOTestRun::getObjectiveId ( )

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

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

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

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

References $questions.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getResult()

ilLOTestRun::getResult ( )

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

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

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

108 : array
109 {
110 global $DIC;
111
112 $ilDB = $DIC->database();
113 $query = 'SELECT objective_id FROM loc_tst_run ' .
114 'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
115 'AND user_id = ' . $ilDB->quote($a_user_id, 'integer') . ' ' .
116 'AND test_id = ' . $ilDB->quote($a_test_id, 'integer') . ' ';
117 $res = $ilDB->query($query);
118
119 $run = array();
120 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
121 $run[] = new ilLOTestRun($a_container_id, $a_user_id, $a_test_id, $row->objective_id);
122 }
123 return $run;
124 }
const FETCHMODE_OBJECT
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 136 of file class.ilLOTestRun.php.

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

References $test_id.

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

+ Here is the caller graph for this function:

◆ getUserId()

ilLOTestRun::getUserId ( )

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

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

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

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

49 : bool
50 {
51 global $DIC;
52
53 $ilDB = $DIC->database();
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 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
60 return true;
61 }
62 return false;
63 }

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

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

◆ read()

ilLOTestRun::read ( )

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

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

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

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

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

◆ setQuestionResult()

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

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

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

◆ update()

ilLOTestRun::update ( )

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

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

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

Referenced by getContainerId().

◆ $db

ilDBInterface ilLOTestRun::$db
protected

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

◆ $max_points

float ilLOTestRun::$max_points = 0
protected

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

Referenced by getMaxPoints().

◆ $objective_id

int ilLOTestRun::$objective_id = 0
protected

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

Referenced by getObjectiveId().

◆ $questions

array ilLOTestRun::$questions = array()
protected

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

Referenced by getQuestions().

◆ $test_id

int ilLOTestRun::$test_id = 0
protected

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

Referenced by getTestId().

◆ $user_id

int ilLOTestRun::$user_id = 0
protected

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

Referenced by getUserId().


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