ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilLORandomTestQuestionPools Class Reference

Class ilLOEditorGUI. More...

+ Collaboration diagram for ilLORandomTestQuestionPools:

Public Member Functions

 __construct ($a_container_id, $a_objective_id, $a_test_type, $a_qpl_sequence)
 Constructor. More...
 
 setContainerId ($a_id)
 
 getContainerId ()
 
 setObjectiveId ($a_id)
 
 getObjectiveId ()
 
 setTestType ($a_type)
 
 getTestType ()
 
 setTestId ($a_id)
 
 getTestId ()
 
 setQplSequence ($a_id)
 
 getQplSequence ()
 
 setLimit ($a_id)
 
 getLimit ()
 
 copy ($a_copy_id, $a_new_course_id, $a_new_objective_id)
 Copy assignment. More...
 
 read ()
 read settings type $ilDB More...
 
 delete ()
 
 create ()
 

Static Public Member Functions

static lookupLimit ($a_container_id, $a_objective_id, $a_test_type)
 lookup limit type $ilDB More...
 
static lookupSequences ($a_container_id, $a_objective_id, $a_test_id)
 Lookup sequence ids type $ilDB. More...
 
static lookupSequencesByType ($a_container_id, $a_objective_id, $a_test_id, $a_test_type)
 Lookup sequence ids type $ilDB. More...
 
static lookupObjectiveIdsBySequence ($a_container_id, $a_seq_id)
 Lookup objective ids by sequence_id type $ilDB. More...
 
static deleteForObjectiveAndTestType ($a_course_id, $a_objective_id, $a_tst_type)
 Delete assignment for objective id and test type. More...
 
static toXml (ilXmlWriter $writer, $a_objective_id)
 

Protected Attributes

 $container_id = 0
 
 $objective_id = 0
 
 $test_type = 0
 
 $test_id = 0
 
 $qpl_seq = 0
 
 $limit = 50
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
type$a_container_id
type$a_objective_id

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

References read().

31  {
32  $this->container_id = $a_container_id;
33  $this->objective_id = $a_objective_id;
34  $this->test_type = $a_test_type;
35  $this->qpl_seq = $a_qpl_sequence;
36 
37  $this->read();
38  }
+ Here is the call graph for this function:

Member Function Documentation

◆ copy()

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

Copy assignment.

Parameters
type$a_copy_id
type$a_new_objective_id

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

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

213  {
214  include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
216  $mappings = $options->getMappings();
217 
218  foreach (self::lookupSequences($this->getContainerId(), $this->getContainerId(), $this->getTestId()) as $sequence) {
219  // not nice
220  $this->setQplSequence($sequence);
221  $this->read();
222 
223 
224  $mapped_id = 0;
225  $test_ref_id = 0;
226  foreach ((array) ilObject::_getAllReferences($this->getTestId()) as $tmp => $ref_id) {
227  $test_ref_id = $ref_id;
228  $mapped_id = $mappings[$ref_id];
229  if ($mapped_id) {
230  continue;
231  }
232  }
233  if (!$mapped_id) {
234  ilLoggerFactory::getLogger('crs')->debug('No test mapping found for random question pool assignment: ' . $this->getTestId() . ' ' . $sequence);
235  continue;
236  }
237 
238  // Mapping for sequence
239  $new_question_info = $mappings[$test_ref_id . '_rndSelDef_' . $this->getQplSequence()];
240  $new_question_arr = explode('_', $new_question_info);
241  if (!isset($new_question_arr[2]) or !$new_question_arr[2]) {
242  //ilLoggerFactory::getLogger('crs')->debug(print_r($mappings,TRUE));
243  ilLoggerFactory::getLogger('crs')->debug('Found invalid or no mapping format of random question id mapping: ' . print_r($new_question_arr, true));
244  continue;
245  }
246 
247  $new_ass = new self(
248  $a_new_course_id,
249  $a_new_objective_id,
250  $this->getTestType(),
251  $new_question_arr[2]
252  );
253  $new_ass->setTestId($mapped_id);
254  $new_ass->setLimit($this->getLimit());
255  $new_ass->create();
256  }
257  }
static _getAllReferences($a_id)
get all reference ids of object
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

◆ create()

ilLORandomTestQuestionPools::create ( )

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

References $DIC, $ilDB, $query, getContainerId(), getLimit(), getObjectiveId(), getQplSequence(), getTestId(), and getTestType().

318  {
319  global $DIC;
320 
321  $ilDB = $DIC['ilDB'];
322 
323  $query = 'INSERT INTO loc_rnd_qpl ' .
324  '(container_id, objective_id, tst_type, tst_id, qp_seq, percentage) ' .
325  'VALUES ( ' .
326  $ilDB->quote($this->getContainerId(), 'integer') . ', ' .
327  $ilDB->quote($this->getObjectiveId(), 'integer') . ', ' .
328  $ilDB->quote($this->getTestType(), 'integer') . ', ' .
329  $ilDB->quote($this->getTestId(), 'integer') . ', ' .
330  $ilDB->quote($this->getQplSequence(), 'integer') . ', ' .
331  $ilDB->quote($this->getLimit()) . ' ' .
332  ')';
333  $ilDB->manipulate($query);
334  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the call graph for this function:

◆ delete()

ilLORandomTestQuestionPools::delete ( )

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

References $DIC, $ilDB, $query, getContainerId(), getObjectiveId(), getQplSequence(), and getTestType().

286  {
287  global $DIC;
288 
289  $ilDB = $DIC['ilDB'];
290 
291  $query = 'DELETE FROM loc_rnd_qpl ' .
292  'WHERE container_id = ' . $ilDB->quote($this->getContainerId(), 'integer') . ' ' .
293  'AND objective_id = ' . $ilDB->quote($this->getObjectiveId(), 'integer') . ' ' .
294  'AND tst_type = ' . $ilDB->quote($this->getTestType(), 'integer') . ' ' .
295  'AND qp_seq = ' . $ilDB->quote($this->getQplSequence(), 'integer');
296  $ilDB->manipulate($query);
297  }
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the call graph for this function:

◆ deleteForObjectiveAndTestType()

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

Delete assignment for objective id and test type.

Parameters
int$a_course_id
int$a_objective_id
int$a_tst_type

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

References $GLOBALS, and $query.

Referenced by ilCourseObjectivesGUI\saveRandom().

307  {
308  $db = $GLOBALS['DIC']->database();
309 
310  $query = 'DELETE FROM loc_rnd_qpl ' .
311  'WHERE container_id = ' . $db->quote($a_course_id, 'integer') . ' ' .
312  'AND objective_id = ' . $db->quote($a_objective_id, 'integer') . ' ' .
313  'AND tst_type = ' . $db->quote($a_tst_type, 'integer');
314  $db->manipulate($query);
315  }
$query
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the caller graph for this function:

◆ getContainerId()

ilLORandomTestQuestionPools::getContainerId ( )

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

References $container_id.

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

+ Here is the caller graph for this function:

◆ getLimit()

ilLORandomTestQuestionPools::getLimit ( )

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

References $limit.

Referenced by copy(), and create().

+ Here is the caller graph for this function:

◆ getObjectiveId()

ilLORandomTestQuestionPools::getObjectiveId ( )

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

References $objective_id.

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

+ Here is the caller graph for this function:

◆ getQplSequence()

ilLORandomTestQuestionPools::getQplSequence ( )

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

References $qpl_seq.

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

+ Here is the caller graph for this function:

◆ getTestId()

ilLORandomTestQuestionPools::getTestId ( )

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

References $test_id.

Referenced by copy(), and create().

+ Here is the caller graph for this function:

◆ getTestType()

ilLORandomTestQuestionPools::getTestType ( )

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

References $test_type.

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

+ Here is the caller graph for this function:

◆ lookupLimit()

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

lookup limit type $ilDB

Parameters
int$a_container_id
int$a_objective_id
int$a_test_type
Returns
int

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

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

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

49  {
50  global $DIC;
51 
52  $ilDB = $DIC['ilDB'];
53 
54  $query = 'SELECT * FROM loc_rnd_qpl ' .
55  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
56  'AND objective_id = ' . $ilDB->quote($a_objective_id, 'integer') . ' ' .
57  'AND tst_type = ' . $ilDB->quote($a_test_type, 'integer');
58  $res = $ilDB->query($query);
59  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
60  return $row->percentage;
61  }
62  return 0;
63  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ lookupObjectiveIdsBySequence()

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

Lookup objective ids by sequence_id type $ilDB.

Parameters
int$a_container_id
int$a_seq_id
Returns
int[]

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

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

Referenced by ilLOTestQuestionAdapter\lookupObjectiveIdByRandomQuestionSelectionDefinitionId().

130  {
131  global $DIC;
132 
133  $ilDB = $DIC['ilDB'];
134 
135  $query = 'SELECT objective_id FROM loc_rnd_qpl ' .
136  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
137  'AND qp_seq = ' . $ilDB->quote($a_seq_id, 'integer');
138  $res = $ilDB->query($query);
139  $objectiveIds = array();
140  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
141  $objectiveIds[] = $row->objective_id;
142  }
143  return $objectiveIds;
144  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ lookupSequences()

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

Lookup sequence ids type $ilDB.

Parameters
int$a_container_id
int$a_objective_id
int$a_test_id
Returns
int[]

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

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

Referenced by ilLOEditorStatus\lookupQuestionsAssigned().

74  {
75  global $DIC;
76 
77  $ilDB = $DIC['ilDB'];
78 
79  $query = 'SELECT * FROM loc_rnd_qpl ' .
80  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
81  'AND objective_id = ' . $ilDB->quote($a_objective_id, 'integer') . ' ' .
82  'AND tst_id = ' . $ilDB->quote($a_test_id, 'integer');
83 
84  $res = $ilDB->query($query);
85  $sequences = [];
86  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
87  $sequences[] = $row->qp_seq;
88  }
89  return (array) $sequences;
90  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ lookupSequencesByType()

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

Lookup sequence ids type $ilDB.

Parameters
int$a_container_id
int$a_objective_id
int$a_test_id
int$a_test_type
Returns
int[]

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

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

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

102  {
103  global $DIC;
104 
105  $ilDB = $DIC['ilDB'];
106 
107  $query = 'SELECT * FROM loc_rnd_qpl ' .
108  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
109  'AND objective_id = ' . $ilDB->quote($a_objective_id, 'integer') . ' ' .
110  'AND tst_id = ' . $ilDB->quote($a_test_id, 'integer') . ' ' .
111  'AND tst_type = ' . $ilDB->quote($a_test_type, 'integer');
112 
113  $res = $ilDB->query($query);
114  $sequences = [];
115  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
116  $sequences[] = $row->qp_seq;
117  }
118  return (array) $sequences;
119  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ read()

ilLORandomTestQuestionPools::read ( )

read settings type $ilDB

Returns
boolean

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

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

Referenced by __construct(), and copy().

266  {
267  global $DIC;
268 
269  $ilDB = $DIC['ilDB'];
270 
271  $query = 'SELECT * FROM loc_rnd_qpl ' .
272  'WHERE container_id = ' . $ilDB->quote($this->getContainerId(), 'integer') . ' ' .
273  'AND objective_id = ' . $ilDB->quote($this->getObjectiveId(), 'integer') . ' ' .
274  'AND tst_type = ' . $ilDB->quote($this->getTestType(), 'integer') . ' ' .
275  'AND qp_seq = ' . $ilDB->quote($this->getQplSequence(), 'integer');
276 
277  $res = $ilDB->query($query);
278  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
279  $this->setLimit($row->percentage);
280  $this->setTestId($row->tst_id);
281  }
282  return true;
283  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setContainerId()

ilLORandomTestQuestionPools::setContainerId (   $a_id)

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

148  {
149  $this->container_id = $a_id;
150  }

◆ setLimit()

ilLORandomTestQuestionPools::setLimit (   $a_id)

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

Referenced by read().

198  {
199  $this->limit = $a_id;
200  }
+ Here is the caller graph for this function:

◆ setObjectiveId()

ilLORandomTestQuestionPools::setObjectiveId (   $a_id)

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

158  {
159  $this->objective_id = $a_id;
160  }

◆ setQplSequence()

ilLORandomTestQuestionPools::setQplSequence (   $a_id)

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

Referenced by copy().

188  {
189  $this->qpl_seq = $a_id;
190  }
+ Here is the caller graph for this function:

◆ setTestId()

ilLORandomTestQuestionPools::setTestId (   $a_id)

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

Referenced by read().

178  {
179  $this->test_id = $a_id;
180  }
+ Here is the caller graph for this function:

◆ setTestType()

ilLORandomTestQuestionPools::setTestType (   $a_type)

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

References $a_type.

168  {
169  $this->test_type = $a_type;
170  }
$a_type
Definition: workflow.php:92

◆ toXml()

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

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

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

Referenced by ilCourseObjective\toXml().

338  {
339  global $DIC;
340 
341  $ilDB = $DIC['ilDB'];
342 
343  $query = 'SELECT * FROM loc_rnd_qpl ' .
344  'WHERE objective_id = ' . $ilDB->quote($a_objective_id, 'integer');
345  $res = $ilDB->query($query);
346  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
347  include_once './Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
348  $writer->xmlElement(
349  'Test',
350  array(
351  'type' => ilLOXmlWriter::TYPE_TST_RND,
352  'objId' => $row->tst_id,
353  'testType' => $row->tst_type,
354  'limit' => $row->percentage,
355  'poolId' => $row->qp_seq
356  )
357  );
358  }
359  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $container_id

ilLORandomTestQuestionPools::$container_id = 0
protected

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

Referenced by getContainerId().

◆ $limit

ilLORandomTestQuestionPools::$limit = 50
protected

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

Referenced by getLimit().

◆ $objective_id

ilLORandomTestQuestionPools::$objective_id = 0
protected

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

Referenced by getObjectiveId().

◆ $qpl_seq

ilLORandomTestQuestionPools::$qpl_seq = 0
protected

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

Referenced by getQplSequence().

◆ $test_id

ilLORandomTestQuestionPools::$test_id = 0
protected

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

Referenced by getTestId().

◆ $test_type

ilLORandomTestQuestionPools::$test_type = 0
protected

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

Referenced by getTestType().


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