ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilLORandomTestQuestionPools Class Reference

Class ilLOEditorGUI. More...

+ Collaboration diagram for ilLORandomTestQuestionPools:

Public Member Functions

 __construct (int $a_container_id, int $a_objective_id, int $a_test_type, int $a_qpl_sequence)
 
 setContainerId (int $a_id)
 
 getContainerId ()
 
 setObjectiveId (int $a_id)
 
 getObjectiveId ()
 
 setTestType (int $a_type)
 
 getTestType ()
 
 setTestId (int $a_id)
 
 getTestId ()
 
 setQplSequence (int $a_id)
 
 getQplSequence ()
 
 setLimit (int $a_id)
 
 getLimit ()
 
 copy (int $a_copy_id, int $a_new_course_id, int $a_new_objective_id)
 
 read ()
 
 delete ()
 
 create ()
 

Static Public Member Functions

static lookupLimit (int $a_container_id, int $a_objective_id, int $a_test_type)
 
static lookupSequences (int $a_container_id, int $a_objective_id, int $a_test_id)
 
static lookupSequencesByType (int $a_container_id, int $a_objective_id, int $a_test_id, int $a_test_type)
 
static lookupObjectiveIdsBySequence (int $a_container_id, int $a_seq_id)
 
static deleteForObjectiveAndTestType (int $a_course_id, int $a_objective_id, int $a_tst_type)
 
static toXml (ilXmlWriter $writer, int $a_objective_id)
 

Protected Attributes

int $container_id = 0
 
int $objective_id = 0
 
int $test_type = 0
 
int $test_id = 0
 
int $qpl_seq = 0
 
int $limit = 50
 
ilDBInterface $db
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilLORandomTestQuestionPools::__construct ( int  $a_container_id,
int  $a_objective_id,
int  $a_test_type,
int  $a_qpl_sequence 
)

Definition at line 36 of file class.ilLORandomTestQuestionPools.php.

References $DIC, and read().

37  {
38  global $DIC;
39 
40  $this->db = $DIC->database();
41 
42  $this->container_id = $a_container_id;
43  $this->objective_id = $a_objective_id;
44  $this->test_type = $a_test_type;
45  $this->qpl_seq = $a_qpl_sequence;
46 
47  $this->read();
48  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ copy()

ilLORandomTestQuestionPools::copy ( int  $a_copy_id,
int  $a_new_course_id,
int  $a_new_objective_id 
)

Definition at line 183 of file class.ilLORandomTestQuestionPools.php.

References $ref_id, ilObject\_getAllReferences(), ilCopyWizardOptions\_getInstance(), getContainerId(), getLimit(), ilLoggerFactory\getLogger(), getQplSequence(), getTestId(), getTestType(), read(), and setQplSequence().

183  : void
184  {
185  $options = ilCopyWizardOptions::_getInstance($a_copy_id);
186  $mappings = $options->getMappings();
187 
188  foreach (self::lookupSequences(
189  $this->getContainerId(),
190  $this->getContainerId(),
191  $this->getTestId()
192  ) as $sequence) {
193  // not nice
194  $this->setQplSequence($sequence);
195  $this->read();
196 
197  $mapped_id = 0;
198  $test_ref_id = 0;
199  foreach (ilObject::_getAllReferences($this->getTestId()) as $ref_id) {
200  $test_ref_id = $ref_id;
201  $mapped_id = $mappings[$ref_id];
202  }
203  if (!$mapped_id) {
204  ilLoggerFactory::getLogger('crs')->debug('No test mapping found for random question pool assignment: ' . $this->getTestId() . ' ' . $sequence);
205  continue;
206  }
207 
208  // Mapping for sequence
209  $new_question_info = $mappings[$test_ref_id . '_rndSelDef_' . $this->getQplSequence()];
210  $new_question_arr = explode('_', $new_question_info);
211  if (!isset($new_question_arr[2]) || !$new_question_arr[2]) {
212  //ilLoggerFactory::getLogger('crs')->debug(print_r($mappings,TRUE));
213  ilLoggerFactory::getLogger('crs')->debug('Found invalid or no mapping format of random question id mapping: ' . print_r(
214  $new_question_arr,
215  true
216  ));
217  continue;
218  }
219 
220  $new_ass = new self(
221  $a_new_course_id,
222  $a_new_objective_id,
223  $this->getTestType(),
224  $new_question_arr[2]
225  );
226  $new_ass->setTestId($mapped_id);
227  $new_ass->setLimit($this->getLimit());
228  $new_ass->create();
229  }
230  }
static getLogger(string $a_component_id)
Get component logger.
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:65
static _getInstance(int $a_copy_id)
+ Here is the call graph for this function:

◆ create()

ilLORandomTestQuestionPools::create ( )

Definition at line 268 of file class.ilLORandomTestQuestionPools.php.

References getContainerId(), getLimit(), getObjectiveId(), getQplSequence(), getTestId(), getTestType(), and ilDBConstants\T_INTEGER.

268  : void
269  {
270  $query = 'INSERT INTO loc_rnd_qpl ' .
271  '(container_id, objective_id, tst_type, tst_id, qp_seq, percentage) ' .
272  'VALUES ( ' .
273  $this->db->quote($this->getContainerId(), 'integer') . ', ' .
274  $this->db->quote($this->getObjectiveId(), 'integer') . ', ' .
275  $this->db->quote($this->getTestType(), 'integer') . ', ' .
276  $this->db->quote($this->getTestId(), 'integer') . ', ' .
277  $this->db->quote($this->getQplSequence(), 'integer') . ', ' .
278  $this->db->quote($this->getLimit(), ilDBConstants::T_INTEGER) . ' ' .
279  ')';
280  $this->db->manipulate($query);
281  }
+ Here is the call graph for this function:

◆ delete()

ilLORandomTestQuestionPools::delete ( )

Definition at line 247 of file class.ilLORandomTestQuestionPools.php.

References getContainerId(), getObjectiveId(), getQplSequence(), and getTestType().

247  : void
248  {
249  $query = 'DELETE FROM loc_rnd_qpl ' .
250  'WHERE container_id = ' . $this->db->quote($this->getContainerId(), 'integer') . ' ' .
251  'AND objective_id = ' . $this->db->quote($this->getObjectiveId(), 'integer') . ' ' .
252  'AND tst_type = ' . $this->db->quote($this->getTestType(), 'integer') . ' ' .
253  'AND qp_seq = ' . $this->db->quote($this->getQplSequence(), 'integer');
254  $this->db->manipulate($query);
255  }
+ Here is the call graph for this function:

◆ deleteForObjectiveAndTestType()

static ilLORandomTestQuestionPools::deleteForObjectiveAndTestType ( int  $a_course_id,
int  $a_objective_id,
int  $a_tst_type 
)
static

Definition at line 257 of file class.ilLORandomTestQuestionPools.php.

References $GLOBALS, ilDBInterface\manipulate(), and ilDBInterface\quote().

Referenced by ilCourseObjectivesGUI\saveRandom().

257  : void
258  {
259  $db = $GLOBALS['DIC']->database();
260 
261  $query = 'DELETE FROM loc_rnd_qpl ' .
262  'WHERE container_id = ' . $db->quote($a_course_id, 'integer') . ' ' .
263  'AND objective_id = ' . $db->quote($a_objective_id, 'integer') . ' ' .
264  'AND tst_type = ' . $db->quote($a_tst_type, 'integer');
265  $db->manipulate($query);
266  }
quote($value, string $type)
$GLOBALS["DIC"]
Definition: wac.php:53
manipulate(string $query)
Run a (write) Query on the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContainerId()

ilLORandomTestQuestionPools::getContainerId ( )

Definition at line 128 of file class.ilLORandomTestQuestionPools.php.

References $container_id.

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

128  : int
129  {
130  return $this->container_id;
131  }
+ Here is the caller graph for this function:

◆ getLimit()

ilLORandomTestQuestionPools::getLimit ( )

Definition at line 178 of file class.ilLORandomTestQuestionPools.php.

References $limit.

Referenced by copy(), and create().

178  : int
179  {
180  return $this->limit;
181  }
+ Here is the caller graph for this function:

◆ getObjectiveId()

ilLORandomTestQuestionPools::getObjectiveId ( )

Definition at line 138 of file class.ilLORandomTestQuestionPools.php.

References $objective_id.

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

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

◆ getQplSequence()

ilLORandomTestQuestionPools::getQplSequence ( )

Definition at line 168 of file class.ilLORandomTestQuestionPools.php.

References $qpl_seq.

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

168  : int
169  {
170  return $this->qpl_seq;
171  }
+ Here is the caller graph for this function:

◆ getTestId()

ilLORandomTestQuestionPools::getTestId ( )

Definition at line 158 of file class.ilLORandomTestQuestionPools.php.

References $test_id.

Referenced by copy(), and create().

158  : int
159  {
160  return $this->test_id;
161  }
+ Here is the caller graph for this function:

◆ getTestType()

ilLORandomTestQuestionPools::getTestType ( )

Definition at line 148 of file class.ilLORandomTestQuestionPools.php.

References $test_type.

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

148  : int
149  {
150  return $this->test_type;
151  }
+ Here is the caller graph for this function:

◆ lookupLimit()

static ilLORandomTestQuestionPools::lookupLimit ( int  $a_container_id,
int  $a_objective_id,
int  $a_test_type 
)
static

Definition at line 50 of file class.ilLORandomTestQuestionPools.php.

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

Referenced by ilCourseObjectivesGUI\initFormRandom(), and ilLOUtils\lookupObjectiveRequiredPercentage().

50  : int
51  {
52  global $DIC;
53 
54  $ilDB = $DIC->database();
55  $query = 'SELECT * FROM loc_rnd_qpl ' .
56  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
57  'AND objective_id = ' . $ilDB->quote($a_objective_id, 'integer') . ' ' .
58  'AND tst_type = ' . $ilDB->quote($a_test_type, 'integer');
59  $res = $ilDB->query($query);
60  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
61  return $row->percentage;
62  }
63  return 0;
64  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ lookupObjectiveIdsBySequence()

static ilLORandomTestQuestionPools::lookupObjectiveIdsBySequence ( int  $a_container_id,
int  $a_seq_id 
)
static

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

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

Referenced by ilLOTestQuestionAdapter\lookupObjectiveIdByRandomQuestionSelectionDefinitionId().

107  : array
108  {
109  global $DIC;
110 
111  $ilDB = $DIC->database();
112  $query = 'SELECT objective_id FROM loc_rnd_qpl ' .
113  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
114  'AND qp_seq = ' . $ilDB->quote($a_seq_id, 'integer');
115  $res = $ilDB->query($query);
116  $objectiveIds = array();
117  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
118  $objectiveIds[] = $row->objective_id;
119  }
120  return $objectiveIds;
121  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ lookupSequences()

static ilLORandomTestQuestionPools::lookupSequences ( int  $a_container_id,
int  $a_objective_id,
int  $a_test_id 
)
static

Definition at line 66 of file class.ilLORandomTestQuestionPools.php.

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

Referenced by ilLOEditorStatus\lookupQuestionsAssigned().

66  : array
67  {
68  global $DIC;
69 
70  $ilDB = $DIC->database();
71  $query = 'SELECT * FROM loc_rnd_qpl ' .
72  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
73  'AND objective_id = ' . $ilDB->quote($a_objective_id, 'integer') . ' ' .
74  'AND tst_id = ' . $ilDB->quote($a_test_id, 'integer');
75 
76  $res = $ilDB->query($query);
77  $sequences = [];
78  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
79  $sequences[] = $row->qp_seq;
80  }
81  return $sequences;
82  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ lookupSequencesByType()

static ilLORandomTestQuestionPools::lookupSequencesByType ( int  $a_container_id,
int  $a_objective_id,
int  $a_test_id,
int  $a_test_type 
)
static

Definition at line 84 of file class.ilLORandomTestQuestionPools.php.

References $DIC, $ilDB, $res, ilDBConstants\FETCHMODE_OBJECT, and ILIAS\Repository\int().

Referenced by ilCourseObjectivesGUI\initFormRandom(), ilCourseObjectivesTableGUI\parse(), and ilLOTestQuestionAdapter\updateRandomQuestions().

89  : array {
90  global $DIC;
91 
92  $ilDB = $DIC->database();
93  $query = 'SELECT * FROM loc_rnd_qpl ' .
94  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
95  'AND objective_id = ' . $ilDB->quote($a_objective_id, 'integer') . ' ' .
96  'AND tst_id = ' . $ilDB->quote($a_test_id, 'integer') . ' ' .
97  'AND tst_type = ' . $ilDB->quote($a_test_type, 'integer');
98 
99  $res = $ilDB->query($query);
100  $sequences = [];
101  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
102  $sequences[] = (int) $row->qp_seq;
103  }
104  return $sequences;
105  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilLORandomTestQuestionPools::read ( )

Definition at line 232 of file class.ilLORandomTestQuestionPools.php.

References $res, ilDBConstants\FETCHMODE_OBJECT, getContainerId(), getObjectiveId(), getQplSequence(), getTestType(), setLimit(), and setTestId().

Referenced by __construct(), and copy().

232  : void
233  {
234  $query = 'SELECT * FROM loc_rnd_qpl ' .
235  'WHERE container_id = ' . $this->db->quote($this->getContainerId(), 'integer') . ' ' .
236  'AND objective_id = ' . $this->db->quote($this->getObjectiveId(), 'integer') . ' ' .
237  'AND tst_type = ' . $this->db->quote($this->getTestType(), 'integer') . ' ' .
238  'AND qp_seq = ' . $this->db->quote($this->getQplSequence(), 'integer');
239 
240  $res = $this->db->query($query);
241  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
242  $this->setLimit($row->percentage);
243  $this->setTestId($row->tst_id);
244  }
245  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setContainerId()

ilLORandomTestQuestionPools::setContainerId ( int  $a_id)

Definition at line 123 of file class.ilLORandomTestQuestionPools.php.

123  : void
124  {
125  $this->container_id = $a_id;
126  }

◆ setLimit()

ilLORandomTestQuestionPools::setLimit ( int  $a_id)

Definition at line 173 of file class.ilLORandomTestQuestionPools.php.

Referenced by read(), and ilCourseObjectivesGUI\saveRandom().

173  : void
174  {
175  $this->limit = $a_id;
176  }
+ Here is the caller graph for this function:

◆ setObjectiveId()

ilLORandomTestQuestionPools::setObjectiveId ( int  $a_id)

Definition at line 133 of file class.ilLORandomTestQuestionPools.php.

133  : void
134  {
135  $this->objective_id = $a_id;
136  }

◆ setQplSequence()

ilLORandomTestQuestionPools::setQplSequence ( int  $a_id)

Definition at line 163 of file class.ilLORandomTestQuestionPools.php.

Referenced by copy().

163  : void
164  {
165  $this->qpl_seq = $a_id;
166  }
+ Here is the caller graph for this function:

◆ setTestId()

ilLORandomTestQuestionPools::setTestId ( int  $a_id)

Definition at line 153 of file class.ilLORandomTestQuestionPools.php.

Referenced by ilLOXmlParser\parseTests(), and read().

153  : void
154  {
155  $this->test_id = $a_id;
156  }
+ Here is the caller graph for this function:

◆ setTestType()

ilLORandomTestQuestionPools::setTestType ( int  $a_type)

Definition at line 143 of file class.ilLORandomTestQuestionPools.php.

143  : void
144  {
145  $this->test_type = $a_type;
146  }

◆ toXml()

static ilLORandomTestQuestionPools::toXml ( ilXmlWriter  $writer,
int  $a_objective_id 
)
static

Definition at line 283 of file class.ilLORandomTestQuestionPools.php.

References $DIC, $ilDB, $res, ilDBConstants\FETCHMODE_OBJECT, ilLOXmlWriter\TYPE_TST_RND, and ilXmlWriter\xmlElement().

Referenced by ilCourseObjective\toXml().

283  : void
284  {
285  global $DIC;
286 
287  $ilDB = $DIC->database();
288  $query = 'SELECT * FROM loc_rnd_qpl ' .
289  'WHERE objective_id = ' . $ilDB->quote($a_objective_id, 'integer');
290  $res = $ilDB->query($query);
291  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
292  $writer->xmlElement(
293  'Test',
294  array(
295  'type' => ilLOXmlWriter::TYPE_TST_RND,
296  'objId' => $row->tst_id,
297  'testType' => $row->tst_type,
298  'limit' => $row->percentage,
299  'poolId' => $row->qp_seq
300  )
301  );
302  }
303  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $container_id

int ilLORandomTestQuestionPools::$container_id = 0
protected

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

Referenced by getContainerId().

◆ $db

ilDBInterface ilLORandomTestQuestionPools::$db
protected

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

◆ $limit

int ilLORandomTestQuestionPools::$limit = 50
protected

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

Referenced by getLimit().

◆ $objective_id

int ilLORandomTestQuestionPools::$objective_id = 0
protected

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

Referenced by getObjectiveId().

◆ $qpl_seq

int ilLORandomTestQuestionPools::$qpl_seq = 0
protected

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

Referenced by getQplSequence().

◆ $test_id

int ilLORandomTestQuestionPools::$test_id = 0
protected

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

Referenced by getTestId().

◆ $test_type

int ilLORandomTestQuestionPools::$test_type = 0
protected

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

Referenced by getTestType().


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