ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
ilLORandomTestQuestionPools Class Reference

Class ilLOEditorGUI. More...

+ Collaboration diagram for ilLORandomTestQuestionPools:

Public Member Functions

 __construct ($a_container_id, $a_objective_id, $a_test_type)
 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 ()
 
 delete ()
 
 create ()
 

Static Public Member Functions

static lookupLimit ($a_container_id, $a_objective_id, $a_test_type)
 
static lookupSequence ($a_container_id, $a_objective_id, $a_test_id)
 
static lookupObjectiveIdsBySequence ($a_container_id, $a_seq_id)
 Lookup objective id by sequence. 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 
)

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 
36  $this->read();
37  }
+ 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 157 of file class.ilLORandomTestQuestionPools.php.

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

158  {
159  include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php';
161  $mappings = $options->getMappings();
162 
163  $new_ass = new self(
164  $a_new_course_id,
165  $a_new_objective_id,
166  $this->getTestType()
167  );
168  $new_ass->setLimit($this->getLimit());
169 
170  $mapped_id = 0;
171  $test_ref_id = 0;
172  foreach((array) ilObject::_getAllReferences($this->getTestId()) as $tmp => $ref_id)
173  {
174  ilLoggerFactory::getLogger('crs')->debug($tmp .' ' . $ref_id);
175  $test_ref_id = $ref_id;
176  $mapped_id = $mappings[$ref_id];
177  if($mapped_id)
178  {
179  continue;
180  }
181  }
182 
183  if(!$mapped_id)
184  {
185  ilLoggerFactory::getLogger('crs')->debug('No test mapping found for random question pool assignment: ' . $this->getTestId());
186  return FALSE;
187  }
188  $new_ass->setTestId($mapped_id);
189 
190  // Mapping for sequence
191  $new_question_info = $mappings[$test_ref_id.'_rndSelDef_'.$this->getQplSequence()];
192  $new_question_arr = explode('_',$new_question_info);
193  if(!isset($new_question_arr[2]) or !$new_question_arr[2])
194  {
195  ilLoggerFactory::getLogger('crs')->debug(print_r($mappings,TRUE));
196  ilLoggerFactory::getLogger('crs')->debug('Found invalid or no mapping format of random question id mapping: ' . print_r($new_question_arr,TRUE));
197  return FALSE;
198  }
199 
200  $new_ass->setQplSequence($new_question_arr[2]);
201  $new_ass->create();
202  }
static _getAllReferences($a_id)
get all reference ids of object
static _getInstance($a_copy_id)
Get instance of copy wizard options.
if(!is_array($argv)) $options
$ref_id
Definition: sahs_server.php:39
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

◆ create()

ilLORandomTestQuestionPools::create ( )

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

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

236  {
237  global $ilDB;
238 
239  $query = 'INSERT INTO loc_rnd_qpl ' .
240  '(container_id, objective_id, tst_type, tst_id, qp_seq, percentage) '.
241  'VALUES ( '.
242  $ilDB->quote($this->getContainerId(),'integer').', '.
243  $ilDB->quote($this->getObjectiveId(),'integer').', '.
244  $ilDB->quote($this->getTestType(),'integer').', '.
245  $ilDB->quote($this->getTestId(),'integer').', '.
246  $ilDB->quote($this->getQplSequence(),'integer').', '.
247  $ilDB->quote($this->getLimit()).' '.
248  ')';
249  $ilDB->manipulate($query);
250  }
global $ilDB
+ Here is the call graph for this function:

◆ delete()

ilLORandomTestQuestionPools::delete ( )

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

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

225  {
226  global $ilDB;
227 
228  $query = 'DELETE FROM loc_rnd_qpl '.
229  'WHERE container_id = '.$ilDB->quote($this->getContainerId(),'integer').' '.
230  'AND objective_id = '.$ilDB->quote($this->getObjectiveId(),'integer').' '.
231  'AND tst_type = '.$ilDB->quote($this->getTestType(),'integer');
232  $ilDB->manipulate($query);
233  }
global $ilDB
+ Here is the call graph for this function:

◆ getContainerId()

ilLORandomTestQuestionPools::getContainerId ( )

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

References $container_id.

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

+ Here is the caller graph for this function:

◆ getLimit()

ilLORandomTestQuestionPools::getLimit ( )

Definition at line 147 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 107 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 137 of file class.ilLORandomTestQuestionPools.php.

References $qpl_seq.

Referenced by copy(), and create().

+ Here is the caller graph for this function:

◆ getTestId()

ilLORandomTestQuestionPools::getTestId ( )

Definition at line 127 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 117 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

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

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

Referenced by ilLOUtils\lookupObjectiveRequiredPercentage().

40  {
41  global $ilDB;
42 
43  $query = 'SELECT * FROM loc_rnd_qpl '.
44  'WHERE container_id = '.$ilDB->quote($a_container_id,'integer').' '.
45  'AND objective_id = '.$ilDB->quote($a_objective_id,'integer').' '.
46  'AND tst_type = '.$ilDB->quote($a_test_type,'integer');
47  $res = $ilDB->query($query);
48  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
49  {
50  return $row->percentage;
51  }
52  return 0;
53  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ Here is the caller graph for this function:

◆ lookupObjectiveIdsBySequence()

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

Lookup objective id by sequence.

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

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

Referenced by ilLOTestQuestionAdapter\lookupObjectiveIdByRandomQuestionSelectionDefinitionId().

76  {
77  global $ilDB;
78 
79  $query = 'SELECT objective_id FROM loc_rnd_qpl '.
80  'WHERE container_id = '.$ilDB->quote($a_container_id,'integer').' '.
81  'AND qp_seq = '.$ilDB->quote($a_seq_id,'integer');
82  $res = $ilDB->query($query);
83  $objectiveIds = array();
84  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
85  {
86  $objectiveIds[] = $row->objective_id;
87  }
88  return $objectiveIds;
89  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ Here is the caller graph for this function:

◆ lookupSequence()

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

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

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

Referenced by ilLOEditorStatus\lookupQuestionsAssigned().

56  {
57  global $ilDB;
58 
59  $query = 'SELECT * FROM loc_rnd_qpl '.
60  'WHERE container_id = '.$ilDB->quote($a_container_id,'integer').' '.
61  'AND objective_id = '.$ilDB->quote($a_objective_id,'integer').' '.
62  'AND tst_id = '.$ilDB->quote($a_test_id,'integer');
63  $res = $ilDB->query($query);
64  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
65  {
66  return $row->qp_seq;
67  }
68  return 0;
69 
70  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
global $ilDB
+ Here is the caller graph for this function:

◆ read()

ilLORandomTestQuestionPools::read ( )

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

References $ilDB, $query, $res, $row, DB_FETCHMODE_OBJECT, getContainerId(), getObjectiveId(), getTestType(), setLimit(), setQplSequence(), and setTestId().

Referenced by __construct().

206  {
207  global $ilDB;
208 
209  $query = 'SELECT * FROM loc_rnd_qpl '.
210  'WHERE container_id = '.$ilDB->quote($this->getContainerId(),'integer').' '.
211  'AND objective_id = '.$ilDB->quote($this->getObjectiveId(),'integer').' '.
212  'AND tst_type = '.$ilDB->quote($this->getTestType(),'integer');
213 
214  $res = $ilDB->query($query);
215  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
216  {
217  $this->setLimit($row->percentage);
218  $this->setTestId($row->tst_id);
219  $this->setQplSequence($row->qp_seq);
220  }
221  return true;
222  }
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:

◆ setContainerId()

ilLORandomTestQuestionPools::setContainerId (   $a_id)

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

93  {
94  $this->container_id = $a_id;
95  }

◆ setLimit()

ilLORandomTestQuestionPools::setLimit (   $a_id)

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

Referenced by read().

143  {
144  $this->limit = $a_id;
145  }
+ Here is the caller graph for this function:

◆ setObjectiveId()

ilLORandomTestQuestionPools::setObjectiveId (   $a_id)

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

103  {
104  $this->objective_id = $a_id;
105  }

◆ setQplSequence()

ilLORandomTestQuestionPools::setQplSequence (   $a_id)

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

Referenced by read().

133  {
134  $this->qpl_seq = $a_id;
135  }
+ Here is the caller graph for this function:

◆ setTestId()

ilLORandomTestQuestionPools::setTestId (   $a_id)

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

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

123  {
124  $this->test_id = $a_id;
125  }
+ Here is the caller graph for this function:

◆ setTestType()

ilLORandomTestQuestionPools::setTestType (   $a_type)

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

113  {
114  $this->test_type = $a_type;
115  }

◆ toXml()

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

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

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

Referenced by ilCourseObjective\toXml().

254  {
255  global $ilDB;
256 
257  $query = 'SELECT * FROM loc_rnd_qpl '.
258  'WHERE objective_id = '.$ilDB->quote($a_objective_id,'integer');
259  $res = $ilDB->query($query);
260  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
261  {
262  include_once './Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
263  $writer->xmlElement(
264  'Test',
265  array(
266  'type' => ilLOXmlWriter::TYPE_TST_RND,
267  'objId' => $row->tst_id,
268  'testType' => $row->tst_type,
269  'limit' => $row->percentage,
270  'poolId' => $row->qp_seq
271  )
272  );
273  }
274  }
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
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:

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: