ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 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()
 

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

22 {
23 $this->container_id = $a_crs_id;
24 $this->user_id = $a_user_id;
25 $this->test_id = $a_test_id;
26 $this->objective_id = $a_objective_id;
27
28 $this->read();
29 }
read()
@global type $ilDB

References read().

+ Here is the call graph for this function:

Member Function Documentation

◆ addQuestion()

ilLOTestRun::addQuestion (   $a_id)

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

148 {
149 $this->questions[$a_id] = 0;
150 }

◆ clearQuestions()

ilLOTestRun::clearQuestions ( )

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

143 {
144 $this->questions = array();
145 }

◆ create()

ilLOTestRun::create ( )

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

210 {
211 global $ilDB;
212
213 $query = 'INSERT INTO loc_tst_run '.
214 '(container_id, user_id, test_id, objective_id,max_points,questions) '.
215 'VALUES( '.
216 $ilDB->quote($this->getContainerId(),'integer').', '.
217 $ilDB->quote($this->getUserId(),'integer').', '.
218 $ilDB->quote($this->getTestId(),'integer').', '.
219 $ilDB->quote($this->getObjectiveId(),'integer').', '.
220 $ilDB->quote($this->getMaxPoints(),'integer').', '.
221 $ilDB->quote(serialize($this->getQuestions()),'text').' '.
222 ')';
223 $ilDB->manipulate($query);
224 }
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 197 of file class.ilLOTestRun.php.

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

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

57 {
58 global $ilDB;
59
60 $query = 'DELETE FROM loc_tst_run '.
61 'WHERE container_id = ' . $ilDB->quote($a_container_id,'integer').' '.
62 'AND user_id = '.$ilDB->quote($a_user_id,'integer').' '.
63 'AND test_id = '.$ilDB->quote($a_test_id,'integer').' ';
64 $ilDB->manipulate($query);
65 }

References $ilDB, and $query.

Referenced by ilObjCourseGUI\redirectLocToTestObject(), and ilObjCourseGUI\resetObject().

+ Here is the caller graph for this function:

◆ getContainerId()

ilLOTestRun::getContainerId ( )

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

108 {
109 return $this->container_id;
110 }

References $container_id.

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

+ Here is the caller graph for this function:

◆ getMaxPoints()

ilLOTestRun::getMaxPoints ( )

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

128 {
129 return $this->max_points;
130 }

References $max_points.

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

+ Here is the caller graph for this function:

◆ getObjectiveId()

ilLOTestRun::getObjectiveId ( )

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

123 {
124 return $this->objective_id;
125 }

References $objective_id.

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

+ Here is the caller graph for this function:

◆ getQuestions()

ilLOTestRun::getQuestions ( )

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

138 {
139 return (array) $this->questions;
140 }

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

173 {
174 $sum_points = 0;
175 foreach($this->questions as $qid => $points)
176 {
177 $sum_points += (int) $points;
178 }
179
180 $percentage =
181 ($this->getMaxPoints() > 0) ?
182 ($sum_points / $this->getMaxPoints() * 100) :
183 100;
184
185 return array(
186 'max' => $this->getMaxPoints(),
187 'reached' => $sum_points,
188 'percentage' => $percentage
189 );
190 }

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

90 {
91 global $ilDB;
92
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
99 $run = array();
100 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
101 {
102 $run[] = new ilLOTestRun($a_container_id, $a_user_id, $a_test_id, $row->objective_id);
103 }
104 return $run;
105 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
Stores current objective, questions and max points.

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilLOTestQuestionAdapter\initTestRun().

+ Here is the caller graph for this function:

◆ getTestId()

ilLOTestRun::getTestId ( )

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

118 {
119 return $this->test_id;
120 }

References $test_id.

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

+ Here is the caller graph for this function:

◆ getUserId()

ilLOTestRun::getUserId ( )

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

113 {
114 return $this->user_id;
115 }

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

68 {
69 global $ilDB;
70
71 $query = 'SELECT objective_id FROM loc_tst_run '.
72 'WHERE container_id = '.$ilDB->quote($a_container_id,'integer').' '.
73 'AND user_id = '.$ilDB->quote($a_user_id,'integer').' '.
74 'AND test_id = '.$ilDB->quote($a_test_id,'integer');
75 $GLOBALS['ilLog']->write(__METHOD__.': '.$query);
76 $res = $ilDB->query($query);
77 $objectives = array();
78 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
79 {
80 $objectives[] = $row->objective_id;
81 }
82 return $objectives;
83 }
$GLOBALS['ct_recipient']

References $GLOBALS, $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilObjCourseGUI\handleActivePass(), and 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 39 of file class.ilLOTestRun.php.

40 {
41 global $ilDB;
42
43 $query = 'SELECT * FROM loc_tst_run '.
44 'WHERE test_id = '.$ilDB->quote($a_test_id,'integer').' '.
45 'AND objective_id = '.$ilDB->quote($a_objective_id,'integer').' '.
46 'AND user_id = '.$ilDB->quote($a_user_id,'integer');
47 $res = $ilDB->query($query);
48
49 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
50 {
51 return true;
52 }
53 return false;
54 }

References $ilDB, $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilContainerObjectiveGUI\updateResult().

+ Here is the caller graph for this function:

◆ questionExists()

ilLOTestRun::questionExists (   $a_question_id)

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

153 {
154 return array_key_exists($a_question_id,(array) $this->questions);
155 }

◆ read()

ilLOTestRun::read ( )

@global type $ilDB

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

245 {
246 global $ilDB;
247
248 $query = 'SELECT * FROM loc_tst_run '.
249 'WHERE container_id = ' . $ilDB->quote($this->getContainerId(),'integer').' '.
250 'AND user_id = '.$ilDB->quote($this->getUserId(),'integer').' '.
251 'AND test_id = '.$ilDB->quote($this->getTestId(),'integer').' '.
252 'AND objective_id = '.$ilDB->quote($this->getObjectiveId(),'integer');
253 $res = $ilDB->query($query);
254 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
255 {
256 $this->max_points = $row->max_points;
257 if($row->questions)
258 {
259 $this->questions = unserialize($row->questions);
260 }
261 }
262
263 }

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

133 {
134 $this->max_points = $a_points;
135 }

◆ setQuestionResult()

ilLOTestRun::setQuestionResult (   $a_qst_id,
  $a_points 
)

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

158 {
159 $GLOBALS['ilLog']->write(__METHOD__.': '.$a_qst_id.' '.$a_points);
160
161
162 if($this->questions[$a_qst_id] < $a_points)
163 {
164 $this->questions[$a_qst_id] = $a_points;
165 }
166 $GLOBALS['ilLog']->write(__METHOD__.': '.print_r($this->questions,true));
167 }

References $GLOBALS.

◆ update()

ilLOTestRun::update ( )

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

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

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

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