ILIAS  release_8 Revision v8.23
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.

References $DIC, and read().

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: feed.php:28
+ 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.

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

Referenced by ilLOTestQuestionAdapter\notifyTestStart().

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  }
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilLOTestRun::delete ( )

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

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

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  }
$query
+ 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.

References $DIC, $ilDB, and $query.

Referenced by ilLOTestQuestionAdapter\notifyTestStart().

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  }
global $DIC
Definition: feed.php:28
$query
+ 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.

References $DIC, $ilDB, and $query.

Referenced by ilObjCourseGUI\resetObject().

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  }
global $DIC
Definition: feed.php:28
$query
+ Here is the caller graph for this function:

◆ getContainerId()

ilLOTestRun::getContainerId ( )

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

References $container_id.

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

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

◆ getMaxPoints()

ilLOTestRun::getMaxPoints ( )

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

References $max_points.

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

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

◆ getObjectiveId()

ilLOTestRun::getObjectiveId ( )

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

References $objective_id.

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

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

◆ getQuestions()

ilLOTestRun::getQuestions ( )

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

References $questions.

Referenced by create(), and update().

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

◆ getResult()

ilLOTestRun::getResult ( )

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

References getMaxPoints().

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  }
+ 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
[]

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

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

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

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  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getTestId()

ilLOTestRun::getTestId ( )

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

References $test_id.

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

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

◆ getUserId()

ilLOTestRun::getUserId ( )

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

References $user_id.

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

130  : int
131  {
132  return $this->user_id;
133  }
+ 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.

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

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  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$objectives
$query

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

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

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  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query

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

References $query, $res, ilDBConstants\FETCHMODE_OBJECT, getContainerId(), getObjectiveId(), getTestId(), and getUserId().

Referenced by __construct().

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  }
$res
Definition: ltiservices.php:69
$query
+ 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.

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

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  }
$query
+ 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: