ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilTestRandomQuestionSetStagingPoolBuilder Class Reference
+ Collaboration diagram for ilTestRandomQuestionSetStagingPoolBuilder:

Public Member Functions

 __construct (ilDBInterface $db, ilObjTest $testOBJ)
 
 rebuild (ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList)
 
 reset ()
 

Data Fields

 $db = null
 
 $testOBJ = null
 

Private Member Functions

 removeMirroredTaxonomies ()
 
 removeStagedQuestions ()
 
 build (ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList)
 
 stageQuestionsFromSourcePool ($sourcePoolId)
 
 mirrorSourcePoolTaxonomies ($sourcePoolId, $questionIdMapping)
 
 cleanupTestSettings ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTestRandomQuestionSetStagingPoolBuilder::__construct ( ilDBInterface  $db,
ilObjTest  $testOBJ 
)

Member Function Documentation

◆ build()

ilTestRandomQuestionSetStagingPoolBuilder::build ( ilTestRandomQuestionSetSourcePoolDefinitionList  $sourcePoolDefinitionList)
private

Definition at line 87 of file class.ilTestRandomQuestionSetStagingPoolBuilder.php.

References mirrorSourcePoolTaxonomies(), and stageQuestionsFromSourcePool().

Referenced by rebuild().

88  {
89  $involvedSourcePoolIds = $sourcePoolDefinitionList->getInvolvedSourcePoolIds();
90 
91  foreach($involvedSourcePoolIds as $sourcePoolId)
92  {
93  $questionIdMapping = $this->stageQuestionsFromSourcePool($sourcePoolId);
94 
95  $taxonomiesKeysMap = $this->mirrorSourcePoolTaxonomies($sourcePoolId, $questionIdMapping);
96 
97  $this->applyMappedTaxonomiesKeys($sourcePoolDefinitionList, $taxonomiesKeysMap, $sourcePoolId);
98  }
99  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cleanupTestSettings()

ilTestRandomQuestionSetStagingPoolBuilder::cleanupTestSettings ( )
private

Definition at line 166 of file class.ilTestRandomQuestionSetStagingPoolBuilder.php.

References array.

Referenced by reset().

167  {
168  $this->testOBJ->setResultFilterTaxIds(array());
169  $this->testOBJ->saveToDb(true);
170  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ mirrorSourcePoolTaxonomies()

ilTestRandomQuestionSetStagingPoolBuilder::mirrorSourcePoolTaxonomies (   $sourcePoolId,
  $questionIdMapping 
)
private

Definition at line 127 of file class.ilTestRandomQuestionSetStagingPoolBuilder.php.

References ilQuestionPoolDuplicatedTaxonomiesKeysMap\getMappedTaxNodeId(), and ilQuestionPoolDuplicatedTaxonomiesKeysMap\getMappedTaxonomyId().

Referenced by build().

128  {
129  $duplicator = new ilQuestionPoolTaxonomiesDuplicator();
130 
131  $duplicator->setSourceObjId($sourcePoolId);
132  $duplicator->setSourceObjType('qpl');
133  $duplicator->setTargetObjId($this->testOBJ->getId());
134  $duplicator->setTargetObjType($this->testOBJ->getType());
135  $duplicator->setQuestionIdMapping($questionIdMapping);
136 
137  $duplicator->duplicate($duplicator->getAllTaxonomiesForSourceObject());
138 
139  return $duplicator->getDuplicatedTaxonomiesKeysMap();
140  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rebuild()

ilTestRandomQuestionSetStagingPoolBuilder::rebuild ( ilTestRandomQuestionSetSourcePoolDefinitionList  $sourcePoolDefinitionList)

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

References build(), and reset().

35  {
36  $this->reset();
37 
38  $this->build($sourcePoolDefinitionList);
39  }
build(ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList)
+ Here is the call graph for this function:

◆ removeMirroredTaxonomies()

ilTestRandomQuestionSetStagingPoolBuilder::removeMirroredTaxonomies ( )
private

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

References ilObjTaxonomy\getUsageOfObject().

Referenced by reset().

51  {
52  $taxonomyIds = ilObjTaxonomy::getUsageOfObject($this->testOBJ->getId());
53 
54  foreach($taxonomyIds as $taxId)
55  {
56  $taxonomy = new ilObjTaxonomy($taxId);
57  $taxonomy->delete();
58  }
59  }
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeStagedQuestions()

ilTestRandomQuestionSetStagingPoolBuilder::removeStagedQuestions ( )
private

Definition at line 61 of file class.ilTestRandomQuestionSetStagingPoolBuilder.php.

References $GLOBALS, $query, $res, $row, assQuestion\_instanciateQuestion(), and array.

Referenced by reset().

62  {
63  $query = 'SELECT * FROM tst_rnd_cpy WHERE tst_fi = %s';
64  $res = $this->db->queryF( $query, array('integer'), array($this->testOBJ->getTestId())
65  );
66 
67  while( $row = $this->db->fetchAssoc($res) )
68  {
69  $question = assQuestion::_instanciateQuestion($row['qst_fi']);
70 
71  if( $question instanceof assQuestion )
72  {
73  $question->delete($row['qst_fi']);
74  }
75  else
76  {
77  $GLOBALS['ilLog']->warning(
78  "could not delete staged random question (ref={$this->testOBJ->getRefId()} / qst={$row['qst_fi']})"
79  );
80  }
81  }
82 
83  $query = "DELETE FROM tst_rnd_cpy WHERE tst_fi = %s";
84  $this->db->manipulateF( $query, array('integer'), array($this->testOBJ->getTestId()) );
85  }
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
Abstract basic class which is to be extended by the concrete assessment question type classes...
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset()

ilTestRandomQuestionSetStagingPoolBuilder::reset ( )

◆ stageQuestionsFromSourcePool()

ilTestRandomQuestionSetStagingPoolBuilder::stageQuestionsFromSourcePool (   $sourcePoolId)
private

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

References $query, $res, $row, assQuestion\_instanciateQuestion(), and array.

Referenced by build().

102  {
103  $questionIdMapping = array();
104 
105  $query = 'SELECT question_id FROM qpl_questions WHERE obj_fi = %s AND complete = %s AND original_id IS NULL';
106  $res = $this->db->queryF( $query, array('integer', 'text'), array($sourcePoolId, 1) );
107 
108  while( $row = $this->db->fetchAssoc($res) )
109  {
110  $question = assQuestion::_instanciateQuestion($row['question_id']);
111  $duplicateId = $question->duplicate(true, null, null, null, $this->testOBJ->getId());
112 
113  $nextId = $this->db->nextId('tst_rnd_cpy');
114  $this->db->insert('tst_rnd_cpy', array(
115  'copy_id' => array('integer', $nextId),
116  'tst_fi' => array('integer', $this->testOBJ->getTestId()),
117  'qst_fi' => array('integer', $duplicateId),
118  'qpl_fi' => array('integer', $sourcePoolId)
119  ));
120 
121  $questionIdMapping[ $row['question_id'] ] = $duplicateId;
122  }
123 
124  return $questionIdMapping;
125  }
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilTestRandomQuestionSetStagingPoolBuilder::$db = null

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

Referenced by __construct().

◆ $testOBJ

ilTestRandomQuestionSetStagingPoolBuilder::$testOBJ = null

Definition at line 24 of file class.ilTestRandomQuestionSetStagingPoolBuilder.php.

Referenced by __construct().


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