4 require_once
'Modules/Test/classes/class.ilTestRandomQuestionSetNonAvailablePool.php';
62 $this->sourcePoolDefinitions[ $sourcePoolDefinition->
getId() ] = $sourcePoolDefinition;
67 $this->lostPools[$lostPool->
getId()] = $lostPool;
72 return isset($this->lostPools[$poolId]);
77 return (
bool) count($this->lostPools);
88 return $this->lostPools[$poolId];
96 return isset($this->trashedPools[$poolId]);
101 return (
bool) count($this->trashedPools);
124 return $this->
getDefinition($sourcePoolDefinitionId) !== null;
129 if (isset($this->sourcePoolDefinitions[$sourcePoolDefinitionId])) {
130 return $this->sourcePoolDefinitions[$sourcePoolDefinitionId];
138 foreach ($this as $definition) {
139 if ($definition->getPoolId() != $sourcePoolId) {
151 return array_keys($this->sourcePoolDefinitions);
156 return count($this->sourcePoolDefinitions);
163 SELECT tst_rnd_quest_set_qpls.*, odat.obj_id pool_id, tree.child 164 FROM tst_rnd_quest_set_qpls 165 LEFT JOIN object_data odat 166 ON odat.obj_id = pool_fi 167 LEFT JOIN object_reference oref 168 ON oref.obj_id = pool_fi 171 AND child = oref.ref_id 173 ORDER BY sequence_pos ASC 176 $res = $this->db->queryF(
$query, array(
'integer',
'integer'), array(1, $this->testOBJ->getTestId()));
178 $handledDefinitions = array();
181 while (
$row = $this->db->fetchAssoc(
$res)) {
182 $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getEmptySourcePoolDefinition();
183 $sourcePoolDefinition->initFromArray(
$row);
185 if (!isset($handledDefinitions[$sourcePoolDefinition->getId()])) {
187 $handledDefinitions[$sourcePoolDefinition->getId()] = $sourcePoolDefinition->getId();
190 $trashedPool->assignDbRow(
$row);
192 $trashedPool->setUnavailabilityStatus(
200 if (!
$row[
'pool_id']) {
202 $lostPool->assignDbRow(
$row);
204 $lostPool->setUnavailabilityStatus(
224 public function saveDefinitions()
226 foreach ($this as $sourcePoolDefinition) {
228 $sourcePoolDefinition->saveToDb();
232 public function cloneDefinitionsForTestId($testId)
234 $definitionIdMap = array();
236 foreach ($this as $definition) {
239 $originalId = $definition->getId();
240 $definition->cloneToDbForTestId($testId);
241 $cloneId = $definition->getId();
243 $definitionIdMap[$originalId] = $cloneId;
246 return $definitionIdMap;
251 $query =
"DELETE FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
252 $this->db->manipulateF(
$query, array(
'integer'), array($this->testOBJ->getTestId()));
255 public function reindexPositions()
257 $positionIndex = array();
259 foreach ($this as $definition) {
261 $positionIndex[ $definition->getId() ] = $definition->getSequencePosition();
264 asort($positionIndex);
268 foreach ($positionIndex as $definitionId => $definitionPosition) {
269 $positionIndex[$definitionId] =
$i++;
272 foreach ($this as $definition) {
273 $definition->setSequencePosition($positionIndex[$definition->getId()]);
279 return (count($this->sourcePoolDefinitions) + 1);
282 public function getInvolvedSourcePoolIds()
284 $involvedSourcePoolIds = array();
286 foreach ($this as $definition) {
288 $involvedSourcePoolIds[ $definition->getPoolId() ] = $definition->getPoolId();
291 return array_values($involvedSourcePoolIds);
294 public function getQuestionAmount()
298 foreach ($this as $definition) {
300 $questionAmount += $definition->getQuestionAmount();
303 return $questionAmount;
311 $query =
"SELECT COUNT(*) cnt FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
312 $res = $this->db->queryF(
$query, array(
'integer'), array($this->testOBJ->getTestId()));
316 return $row[
'cnt'] > 0;
319 public function hasTaxonomyFilters()
321 foreach ($this as $definition) {
324 if (count($definition->getMappedTaxonomyFilter())) {
327 #if( $definition->getMappedFilterTaxId() && $definition->getMappedFilterTaxNodeId() ) 340 foreach ($this as $definition) {
341 if (count($definition->getTypeFilter())) {
367 return reset($this->sourcePoolDefinitions);
375 return current($this->sourcePoolDefinitions);
383 return key($this->sourcePoolDefinitions);
391 return next($this->sourcePoolDefinitions);
399 return key($this->sourcePoolDefinitions) !== null;
setTrashedPools($trashedPools)
__construct(ilDBInterface $db, ilObjTest $testOBJ, ilTestRandomQuestionSetSourcePoolDefinitionFactory $sourcePoolDefinitionFactory)
Constructor.
hasDefinition($sourcePoolDefinitionId)
const UNAVAILABILITY_STATUS_LOST
areAllUsedPoolsAvailable()
const UNAVAILABILITY_STATUS_TRASHED
addDefinition(ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition)
$sourcePoolDefinitionFactory
foreach($_POST as $key=> $value) $res
getDefinition($sourcePoolDefinitionId)
getDefinitionBySourcePoolId($sourcePoolId)
addLostPool(ilTestRandomQuestionSetNonAvailablePool $lostPool)