ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
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 type $ilDB. More...
 
 create ()
 
 update ()
 
 read ()
 type $ilDB More...
 

Static Public Member Functions

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

References read().

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()
type $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ addQuestion()

ilLOTestRun::addQuestion (   $a_id)

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

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

◆ clearQuestions()

ilLOTestRun::clearQuestions ( )

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

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

◆ create()

ilLOTestRun::create ( )

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

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

Referenced by ilLOTestQuestionAdapter\notifyTestStart().

227  {
228  global $ilDB;
229 
230  $query = 'INSERT INTO loc_tst_run '.
231  '(container_id, user_id, test_id, objective_id,max_points,questions) '.
232  'VALUES( '.
233  $ilDB->quote($this->getContainerId(),'integer').', '.
234  $ilDB->quote($this->getUserId(),'integer').', '.
235  $ilDB->quote($this->getTestId(),'integer').', '.
236  $ilDB->quote($this->getObjectiveId(),'integer').', '.
237  $ilDB->quote($this->getMaxPoints(),'integer').', '.
238  $ilDB->quote(serialize($this->getQuestions()),'text').' '.
239  ')';
240  $ilDB->manipulate($query);
241  }
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilLOTestRun::delete ( )

Delete all entries type $ilDB.

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

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

215  {
216  global $ilDB;
217 
218  $query = 'DELETE FROM loc_tst_run '.
219  'WHERE container_id = ' . $ilDB->quote($this->getContainerId(),'integer').' '.
220  'AND user_id = '.$ilDB->quote($this->getUserId(),'integer').' '.
221  'AND test_id = '.$ilDB->quote($this->getTestId(),'integer').' '.
222  'AND objective_id = '.$ilDB->quote($this->getObjectiveId(),'integer');
223  $ilDB->manipulate($query);
224  }
global $ilDB
+ 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 73 of file class.ilLOTestRun.php.

References $ilDB, and $query.

Referenced by ilLOTestQuestionAdapter\notifyTestStart().

74  {
75  global $ilDB;
76 
77  $query = 'DELETE FROM loc_tst_run '.
78  'WHERE container_id = ' . $ilDB->quote($a_container_id,'integer').' '.
79  'AND user_id = '.$ilDB->quote($a_user_id,'integer').' '.
80  'AND test_id = '.$ilDB->quote($a_test_id,'integer').' ';
81  $ilDB->manipulate($query);
82  }
global $ilDB
+ Here is the caller graph for this function:

◆ deleteRuns()

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

Delete runs type $ilDB.

Parameters
type$a_container_id
type$a_user_id

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

References $ilDB, and $query.

Referenced by ilObjCourseGUI\resetObject().

63  {
64  global $ilDB;
65 
66  $query = 'DELETE FROM loc_tst_run '.
67  'WHERE container_id = ' . $ilDB->quote($a_container_id,'integer').' '.
68  'AND user_id = '.$ilDB->quote($a_user_id,'integer').' ';
69  $ilDB->manipulate($query);
70 
71  }
global $ilDB
+ Here is the caller graph for this function:

◆ getContainerId()

ilLOTestRun::getContainerId ( )

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

References $container_id.

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

125  {
126  return $this->container_id;
127  }
+ Here is the caller graph for this function:

◆ getMaxPoints()

ilLOTestRun::getMaxPoints ( )

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

References $max_points.

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

145  {
146  return $this->max_points;
147  }
+ Here is the caller graph for this function:

◆ getObjectiveId()

ilLOTestRun::getObjectiveId ( )

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

References $objective_id.

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

140  {
141  return $this->objective_id;
142  }
+ Here is the caller graph for this function:

◆ getQuestions()

ilLOTestRun::getQuestions ( )

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

References $questions.

Referenced by create(), and update().

155  {
156  return (array) $this->questions;
157  }
+ Here is the caller graph for this function:

◆ getResult()

ilLOTestRun::getResult ( )

Get result for objective run.

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

References getMaxPoints().

190  {
191  $sum_points = 0;
192  foreach($this->questions as $qid => $points)
193  {
194  $sum_points += $points;
195  }
196 
197  $percentage =
198  ($this->getMaxPoints() > 0) ?
199  ($sum_points / $this->getMaxPoints() * 100) :
200  100;
201 
202  return array(
203  'max' => $this->getMaxPoints(),
204  'reached' => $sum_points,
205  'percentage' => $percentage
206  );
207  }
+ 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 106 of file class.ilLOTestRun.php.

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

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

107  {
108  global $ilDB;
109 
110  $query = 'SELECT objective_id FROM loc_tst_run '.
111  'WHERE container_id = ' . $ilDB->quote($a_container_id,'integer').' '.
112  'AND user_id = '.$ilDB->quote($a_user_id,'integer').' '.
113  'AND test_id = '.$ilDB->quote($a_test_id,'integer').' ';
114  $res = $ilDB->query($query);
115 
116  $run = array();
117  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
118  {
119  $run[] = new ilLOTestRun($a_container_id, $a_user_id, $a_test_id, $row->objective_id);
120  }
121  return $run;
122  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
Stores current objective, questions and max points.
+ Here is the caller graph for this function:

◆ getTestId()

ilLOTestRun::getTestId ( )

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

References $test_id.

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

135  {
136  return $this->test_id;
137  }
+ Here is the caller graph for this function:

◆ getUserId()

ilLOTestRun::getUserId ( )

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

References $user_id.

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

130  {
131  return $this->user_id;
132  }
+ 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 84 of file class.ilLOTestRun.php.

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

Referenced by ilLOUtils\hasActiveRun().

85  {
86  global $ilDB;
87 
88  $query = 'SELECT objective_id FROM loc_tst_run '.
89  'WHERE container_id = '.$ilDB->quote($a_container_id,'integer').' '.
90  'AND user_id = '.$ilDB->quote($a_user_id,'integer').' '.
91  'AND test_id = '.$ilDB->quote($a_test_id,'integer');
92  $GLOBALS['ilLog']->write(__METHOD__.': '.$query);
93  $res = $ilDB->query($query);
94  $objectives = array();
95  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
96  {
97  $objectives[] = $row->objective_id;
98  }
99  return $objectives;
100  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
+ Here is the caller graph for this function:

◆ lookupRunExistsForObjective()

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

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.

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

Referenced by ilContainerObjectiveGUI\updateResult().

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  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ Here is the caller graph for this function:

◆ questionExists()

ilLOTestRun::questionExists (   $a_question_id)

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

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

◆ read()

ilLOTestRun::read ( )

type $ilDB

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

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, getContainerId(), getObjectiveId(), getTestId(), and getUserId().

Referenced by __construct().

262  {
263  global $ilDB;
264 
265  $query = 'SELECT * FROM loc_tst_run '.
266  'WHERE container_id = ' . $ilDB->quote($this->getContainerId(),'integer').' '.
267  'AND user_id = '.$ilDB->quote($this->getUserId(),'integer').' '.
268  'AND test_id = '.$ilDB->quote($this->getTestId(),'integer').' '.
269  'AND objective_id = '.$ilDB->quote($this->getObjectiveId(),'integer');
270  $res = $ilDB->query($query);
271  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
272  {
273  $this->max_points = $row->max_points;
274  if($row->questions)
275  {
276  $this->questions = unserialize($row->questions);
277  }
278  }
279 
280  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMaxPoints()

ilLOTestRun::setMaxPoints (   $a_points)

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

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

◆ setQuestionResult()

ilLOTestRun::setQuestionResult (   $a_qst_id,
  $a_points 
)

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

References $GLOBALS.

175  {
176  $GLOBALS['ilLog']->write(__METHOD__.': '.$a_qst_id.' '.$a_points);
177 
178 
179  if($this->questions[$a_qst_id] < $a_points)
180  {
181  $this->questions[$a_qst_id] = $a_points;
182  }
183  $GLOBALS['ilLog']->write(__METHOD__.': '.print_r($this->questions,true));
184  }
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276

◆ update()

ilLOTestRun::update ( )

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

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

244  {
245  global $ilDB;
246 
247  $query = 'UPDATE loc_tst_run SET '.
248  'max_points = '.$ilDB->quote($this->getMaxPoints(),'integer').', '.
249  'questions = '.$ilDB->quote(serialize($this->getQuestions()),'text').' '.
250  'WHERE container_id = '.$ilDB->quote($this->container_id,'integer').' '.
251  'AND user_id = '.$ilDB->quote($this->getUserId(),'integer').' '.
252  'AND test_id = '.$ilDB->quote($this->getTestId(),'integer').' '.
253  'AND objective_id = '.$ilDB->quote($this->getObjectiveId(),'integer').' ';
254  $ilDB->manipulate($query);
255  }
global $ilDB
+ 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: