51 $this->sourcePoolDefinitions[ $sourcePoolDefinition->
getId() ] = $sourcePoolDefinition;
56 $query =
"SELECT * FROM tst_rnd_quest_set_qpls WHERE test_fi = %s ORDER BY sequence_pos ASC";
57 $res = $this->db->queryF(
$query, array(
'integer'), array($this->testOBJ->getTestId()));
59 while(
$row = $this->db->fetchAssoc(
$res) )
61 $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getEmptySourcePoolDefinition();
63 $sourcePoolDefinition->initFromArray(
$row);
69 public function saveDefinitions()
71 foreach($this as $sourcePoolDefinition)
74 $sourcePoolDefinition->saveToDb();
78 public function cloneDefinitionsForTestId($testId)
80 foreach($this as $definition)
83 $definition->cloneToDbForTestId($testId);
90 $query =
"DELETE FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
91 $this->db->manipulateF(
$query, array(
'integer'), array($this->testOBJ->getTestId()));
94 public function reindexPositions()
96 $positionIndex = array();
98 foreach($this as $definition)
101 $positionIndex[ $definition->getId() ] = $definition->getSequencePosition();
104 asort($positionIndex);
108 foreach($positionIndex as $definitionId => $definitionPosition)
110 $positionIndex[$definitionId] = $i++;
113 foreach($this as $definition)
115 $definition->setSequencePosition( $positionIndex[$definition->getId()] );
121 return ( count($this->sourcePoolDefinitions) + 1 );
124 public function getInvolvedSourcePoolIds()
126 $involvedSourcePoolIds = array();
128 foreach($this as $definition)
131 $involvedSourcePoolIds[ $definition->getPoolId() ] = $definition->getPoolId();
134 return array_values($involvedSourcePoolIds);
137 public function getQuestionAmount()
141 foreach($this as $definition)
144 $questionAmount += $definition->getQuestionAmount();
147 return $questionAmount;
155 $query =
"SELECT COUNT(*) cnt FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
156 $res = $this->db->queryF(
$query, array(
'integer'), array($this->testOBJ->getTestId()));
160 return $row[
'cnt'] > 0;
163 public function hasTaxonomyFilters()
165 foreach($this as $definition)
168 if( $definition->getMappedFilterTaxId() && $definition->getMappedFilterTaxNodeId() )
182 return reset($this->sourcePoolDefinitions);
190 return current($this->sourcePoolDefinitions);
198 return key($this->sourcePoolDefinitions);
206 return next($this->sourcePoolDefinitions);
214 return key($this->sourcePoolDefinitions) !== null;
__construct(ilDB $db, ilObjTest $testOBJ, ilTestRandomQuestionSetSourcePoolDefinitionFactory $sourcePoolDefinitionFactory)
Constructor.
addDefinition(ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition)
$sourcePoolDefinitionFactory