ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 ()
 
 deleteForObjectiveAndTestType ($a_course_id, $a_objective_id, $a_tst_type)
 Delete assignment for objective id and test type. More...
 
 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 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 204 of file class.ilLORandomTestQuestionPools.php.

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

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

◆ create()

ilLORandomTestQuestionPools::create ( )

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

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

305  {
306  global $ilDB;
307 
308  $query = 'INSERT INTO loc_rnd_qpl ' .
309  '(container_id, objective_id, tst_type, tst_id, qp_seq, percentage) ' .
310  'VALUES ( ' .
311  $ilDB->quote($this->getContainerId(), 'integer') . ', ' .
312  $ilDB->quote($this->getObjectiveId(), 'integer') . ', ' .
313  $ilDB->quote($this->getTestType(), 'integer') . ', ' .
314  $ilDB->quote($this->getTestId(), 'integer') . ', ' .
315  $ilDB->quote($this->getQplSequence(), 'integer') . ', ' .
316  $ilDB->quote($this->getLimit()) . ' ' .
317  ')';
318  $ilDB->manipulate($query);
319  }
$query
global $ilDB
+ Here is the call graph for this function:

◆ delete()

ilLORandomTestQuestionPools::delete ( )

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

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

276  {
277  global $ilDB;
278 
279  $query = 'DELETE FROM loc_rnd_qpl ' .
280  'WHERE container_id = ' . $ilDB->quote($this->getContainerId(), 'integer') . ' ' .
281  'AND objective_id = ' . $ilDB->quote($this->getObjectiveId(), 'integer') . ' ' .
282  'AND tst_type = ' . $ilDB->quote($this->getTestType(), 'integer') . ' ' .
283  'AND qp_seq = ' . $ilDB->quote($this->getQplSequence(), 'integer');
284  $ilDB->manipulate($query);
285  }
$query
global $ilDB
+ Here is the call graph for this function:

◆ deleteForObjectiveAndTestType()

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

Delete assignment for objective id and test type.

Parameters
int$a_course_id
int$a_objective_id
int$a_tst_type

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

References $GLOBALS, and $query.

Referenced by ilCourseObjectivesGUI\saveRandom().

294  {
295  $db = $GLOBALS['DIC']->database();
296 
297  $query = 'DELETE FROM loc_rnd_qpl ' .
298  'WHERE container_id = ' . $db->quote($a_course_id, 'integer') . ' ' .
299  'AND objective_id = ' . $db->quote($a_objective_id, 'integer') . ' ' .
300  'AND tst_type = ' . $db->quote($a_tst_type, 'integer');
301  $db->manipulate($query);
302  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$query
+ Here is the caller graph for this function:

◆ getContainerId()

ilLORandomTestQuestionPools::getContainerId ( )

Definition at line 144 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 194 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 154 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 184 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 174 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 164 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 $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

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

49  {
50  global $ilDB;
51 
52  $query = 'SELECT * FROM loc_rnd_qpl ' .
53  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
54  'AND objective_id = ' . $ilDB->quote($a_objective_id, 'integer') . ' ' .
55  'AND tst_type = ' . $ilDB->quote($a_test_type, 'integer');
56  $res = $ilDB->query($query);
57  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
58  return $row->percentage;
59  }
60  return 0;
61  }
foreach($_POST as $key=> $value) $res
$query
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 123 of file class.ilLORandomTestQuestionPools.php.

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

Referenced by ilLOTestQuestionAdapter\lookupObjectiveIdByRandomQuestionSelectionDefinitionId().

124  {
125  global $ilDB;
126 
127  $query = 'SELECT objective_id FROM loc_rnd_qpl ' .
128  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
129  'AND qp_seq = ' . $ilDB->quote($a_seq_id, 'integer');
130  $res = $ilDB->query($query);
131  $objectiveIds = array();
132  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
133  $objectiveIds[] = $row->objective_id;
134  }
135  return $objectiveIds;
136  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
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 71 of file class.ilLORandomTestQuestionPools.php.

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

Referenced by ilLOEditorStatus\lookupQuestionsAssigned().

72  {
73  global $ilDB;
74 
75  $query = 'SELECT * FROM loc_rnd_qpl ' .
76  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
77  'AND objective_id = ' . $ilDB->quote($a_objective_id, 'integer') . ' ' .
78  'AND tst_id = ' . $ilDB->quote($a_test_id, 'integer');
79 
80  $res = $ilDB->query($query);
81  $sequences = [];
82  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
83  $sequences[] = $row->qp_seq;
84  }
85  return (array) $sequences;
86  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
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 97 of file class.ilLORandomTestQuestionPools.php.

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

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

98  {
99  global $ilDB;
100 
101  $query = 'SELECT * FROM loc_rnd_qpl ' .
102  'WHERE container_id = ' . $ilDB->quote($a_container_id, 'integer') . ' ' .
103  'AND objective_id = ' . $ilDB->quote($a_objective_id, 'integer') . ' ' .
104  'AND tst_id = ' . $ilDB->quote($a_test_id, 'integer') . ' ' .
105  'AND tst_type = ' . $ilDB->quote($a_test_type, 'integer');
106 
107  $res = $ilDB->query($query);
108  $sequences = [];
109  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
110  $sequences[] = $row->qp_seq;
111  }
112  return (array) $sequences;
113  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ read()

ilLORandomTestQuestionPools::read ( )

read settings type $ilDB

Returns
boolean

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

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

Referenced by __construct(), and copy().

258  {
259  global $ilDB;
260 
261  $query = 'SELECT * FROM loc_rnd_qpl ' .
262  'WHERE container_id = ' . $ilDB->quote($this->getContainerId(), 'integer') . ' ' .
263  'AND objective_id = ' . $ilDB->quote($this->getObjectiveId(), 'integer') . ' ' .
264  'AND tst_type = ' . $ilDB->quote($this->getTestType(), 'integer') . ' ' .
265  'AND qp_seq = ' . $ilDB->quote($this->getQplSequence(), 'integer');
266 
267  $res = $ilDB->query($query);
268  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
269  $this->setLimit($row->percentage);
270  $this->setTestId($row->tst_id);
271  }
272  return true;
273  }
foreach($_POST as $key=> $value) $res
$query
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 139 of file class.ilLORandomTestQuestionPools.php.

140  {
141  $this->container_id = $a_id;
142  }

◆ setLimit()

ilLORandomTestQuestionPools::setLimit (   $a_id)

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

Referenced by read().

190  {
191  $this->limit = $a_id;
192  }
+ Here is the caller graph for this function:

◆ setObjectiveId()

ilLORandomTestQuestionPools::setObjectiveId (   $a_id)

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

150  {
151  $this->objective_id = $a_id;
152  }

◆ setQplSequence()

ilLORandomTestQuestionPools::setQplSequence (   $a_id)

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

Referenced by copy().

180  {
181  $this->qpl_seq = $a_id;
182  }
+ Here is the caller graph for this function:

◆ setTestId()

ilLORandomTestQuestionPools::setTestId (   $a_id)

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

Referenced by read().

170  {
171  $this->test_id = $a_id;
172  }
+ Here is the caller graph for this function:

◆ setTestType()

ilLORandomTestQuestionPools::setTestType (   $a_type)

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

References $a_type.

160  {
161  $this->test_type = $a_type;
162  }
$a_type
Definition: workflow.php:92

◆ toXml()

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

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

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

Referenced by ilCourseObjective\toXml().

323  {
324  global $ilDB;
325 
326  $query = 'SELECT * FROM loc_rnd_qpl ' .
327  'WHERE objective_id = ' . $ilDB->quote($a_objective_id, 'integer');
328  $res = $ilDB->query($query);
329  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
330  include_once './Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
331  $writer->xmlElement(
332  'Test',
333  array(
334  'type' => ilLOXmlWriter::TYPE_TST_RND,
335  'objId' => $row->tst_id,
336  'testType' => $row->tst_type,
337  'limit' => $row->percentage,
338  'poolId' => $row->qp_seq
339  )
340  );
341  }
342  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
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: