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

Public Member Functions

 __construct (ilDBInterface $db, ilObjTest $testOBJ, ilTestRandomQuestionSetSourcePoolDefinitionFactory $sourcePoolDefinitionFactory)
 Constructor. More...
 
 addDefinition (ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition)
 
 isLostPool ($poolId)
 
 hasLostPool ()
 
 getLostPools ()
 
 getLostPool ($poolId)
 
 isTrashedPool ($poolId)
 
 hasTrashedPool ()
 
 getTrashedPools ()
 
 setTrashedPools ($trashedPools)
 
 hasDefinition ($sourcePoolDefinitionId)
 
 getDefinition ($sourcePoolDefinitionId)
 
 getDefinitionBySourcePoolId ($sourcePoolId)
 
 getDefinitionIds ()
 
 getDefinitionCount ()
 
 loadDefinitions ()
 
 deleteDefinitions ()
 
 getNextPosition ()
 
 savedDefinitionsExist ()
 
 areAllUsedPoolsAvailable ()
 
 rewind ()
 
 current ()
 
 key ()
 
 next ()
 
 valid ()
 
 getNonAvailablePools ()
 

Protected Member Functions

 addLostPool (ilTestRandomQuestionSetNonAvailablePool $lostPool)
 

Protected Attributes

 $db = null
 
 $testOBJ = null
 
 $lostPools = array()
 
 $trashedPools = array()
 

Private Attributes

 $sourcePoolDefinitions = array()
 
 $sourcePoolDefinitionFactory = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ addDefinition()

ilTestRandomQuestionSetSourcePoolDefinitionList::addDefinition ( ilTestRandomQuestionSetSourcePoolDefinition  $sourcePoolDefinition)

Definition at line 60 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References ilTestRandomQuestionSetSourcePoolDefinition\getId().

Referenced by loadDefinitions().

61  {
62  $this->sourcePoolDefinitions[ $sourcePoolDefinition->getId() ] = $sourcePoolDefinition;
63  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addLostPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::addLostPool ( ilTestRandomQuestionSetNonAvailablePool  $lostPool)
protected

Definition at line 65 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References ilTestRandomQuestionSetNonAvailablePool\getId().

Referenced by loadDefinitions().

66  {
67  $this->lostPools[$lostPool->getId()] = $lostPool;
68  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ areAllUsedPoolsAvailable()

ilTestRandomQuestionSetSourcePoolDefinitionList::areAllUsedPoolsAvailable ( )

Definition at line 350 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References hasLostPool(), and hasTrashedPool().

351  {
352  if( $this->hasLostPool() )
353  {
354  return false;
355  }
356 
357  if( $this->hasTrashedPool() )
358  {
359  return false;
360  }
361 
362  return true;
363  }
+ Here is the call graph for this function:

◆ current()

ilTestRandomQuestionSetSourcePoolDefinitionList::current ( )

◆ deleteDefinitions()

ilTestRandomQuestionSetSourcePoolDefinitionList::deleteDefinitions ( )

Definition at line 261 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References $query, and array.

262  {
263  $query = "DELETE FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
264  $this->db->manipulateF($query, array('integer'), array($this->testOBJ->getTestId()));
265  }
Create styles array
The data for the language used.

◆ getDefinition()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinition (   $sourcePoolDefinitionId)

Definition at line 128 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

Referenced by hasDefinition().

129  {
130  if( isset($this->sourcePoolDefinitions[$sourcePoolDefinitionId]) )
131  {
132  return $this->sourcePoolDefinitions[$sourcePoolDefinitionId];
133  }
134 
135  return null;
136  }
+ Here is the caller graph for this function:

◆ getDefinitionBySourcePoolId()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinitionBySourcePoolId (   $sourcePoolId)

Definition at line 138 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

139  {
140  foreach($this as $definition)
141  {
142  if($definition->getPoolId() != $sourcePoolId)
143  {
144  continue;
145  }
146 
147  return $definition;
148  }
149 
150  throw new InvalidArgumentException('invalid source pool id given');
151  }

◆ getDefinitionCount()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinitionCount ( )

Definition at line 158 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

159  {
160  return count($this->sourcePoolDefinitions);
161  }

◆ getDefinitionIds()

ilTestRandomQuestionSetSourcePoolDefinitionList::getDefinitionIds ( )

Definition at line 153 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

154  {
155  return array_keys($this->sourcePoolDefinitions);
156  }

◆ getLostPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::getLostPool (   $poolId)

Definition at line 85 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References isLostPool().

86  {
87  if( $this->isLostPool($poolId) )
88  {
89  return $this->lostPools[$poolId];
90  }
91 
92  return null;
93  }
+ Here is the call graph for this function:

◆ getLostPools()

ilTestRandomQuestionSetSourcePoolDefinitionList::getLostPools ( )

Definition at line 80 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References $lostPools.

Referenced by getNonAvailablePools().

+ Here is the caller graph for this function:

◆ getNextPosition()

ilTestRandomQuestionSetSourcePoolDefinitionList::getNextPosition ( )

Definition at line 292 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References array.

293  {
294  return ( count($this->sourcePoolDefinitions) + 1 );
295  }

◆ getNonAvailablePools()

ilTestRandomQuestionSetSourcePoolDefinitionList::getNonAvailablePools ( )

Definition at line 405 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References getLostPools(), and getTrashedPools().

Referenced by ilTestRandomQuestionSetNonAvailablePoolsTableGUI\addColumns().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTrashedPools()

ilTestRandomQuestionSetSourcePoolDefinitionList::getTrashedPools ( )
Returns
array

Definition at line 108 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References $trashedPools.

Referenced by getNonAvailablePools().

+ Here is the caller graph for this function:

◆ hasDefinition()

ilTestRandomQuestionSetSourcePoolDefinitionList::hasDefinition (   $sourcePoolDefinitionId)

Definition at line 123 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References getDefinition().

124  {
125  return $this->getDefinition($sourcePoolDefinitionId) !== null;
126  }
+ Here is the call graph for this function:

◆ hasLostPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::hasLostPool ( )

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

Referenced by areAllUsedPoolsAvailable().

76  {
77  return (bool)count($this->lostPools);
78  }
+ Here is the caller graph for this function:

◆ hasTrashedPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::hasTrashedPool ( )

Definition at line 100 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

Referenced by areAllUsedPoolsAvailable().

101  {
102  return (bool)count($this->trashedPools);
103  }
+ Here is the caller graph for this function:

◆ isLostPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::isLostPool (   $poolId)

Definition at line 70 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

Referenced by getLostPool(), and loadDefinitions().

71  {
72  return isset($this->lostPools[$poolId]);
73  }
+ Here is the caller graph for this function:

◆ isTrashedPool()

ilTestRandomQuestionSetSourcePoolDefinitionList::isTrashedPool (   $poolId)

Definition at line 95 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

96  {
97  return isset($this->trashedPools[$poolId]);
98  }

◆ key()

ilTestRandomQuestionSetSourcePoolDefinitionList::key ( )
Returns
integer

Definition at line 384 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

Referenced by valid().

385  {
386  return key($this->sourcePoolDefinitions);
387  }
+ Here is the caller graph for this function:

◆ loadDefinitions()

ilTestRandomQuestionSetSourcePoolDefinitionList::loadDefinitions ( )

Definition at line 164 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References $query, $res, $row, $trashedPools, addDefinition(), addLostPool(), array, isLostPool(), setTrashedPools(), ilTestRandomQuestionSetNonAvailablePool\UNAVAILABILITY_STATUS_LOST, and ilTestRandomQuestionSetNonAvailablePool\UNAVAILABILITY_STATUS_TRASHED.

165  {
166  $query = "
167  SELECT tst_rnd_quest_set_qpls.*, odat.obj_id pool_id, tree.child
168  FROM tst_rnd_quest_set_qpls
169  LEFT JOIN object_data odat
170  ON odat.obj_id = pool_fi
171  LEFT JOIN object_reference oref
172  ON oref.obj_id = pool_fi
173  LEFT JOIN tree
174  ON tree = %s
175  AND child = oref.ref_id
176  WHERE test_fi = %s
177  ORDER BY sequence_pos ASC
178  ";
179 
180  $res = $this->db->queryF($query, array('integer', 'integer'), array(1, $this->testOBJ->getTestId()));
181 
182  $handledDefinitions = array();
183  $trashedPools = array();
184 
185  while( $row = $this->db->fetchAssoc($res) )
186  {
187  $sourcePoolDefinition = $this->sourcePoolDefinitionFactory->getEmptySourcePoolDefinition();
188  $sourcePoolDefinition->initFromArray($row);
189 
190  if( !isset($handledDefinitions[$sourcePoolDefinition->getId()]) )
191  {
192  $this->addDefinition($sourcePoolDefinition);
193  $handledDefinitions[$sourcePoolDefinition->getId()] = $sourcePoolDefinition->getId();
194 
195  $trashedPool = new ilTestRandomQuestionSetNonAvailablePool();
196  $trashedPool->assignDbRow($row);
197 
198  $trashedPool->setUnavailabilityStatus(
200  );
201 
202  $trashedPools[$trashedPool->getId()] = $trashedPool;
203  }
204 
205  if( !$this->isLostPool($row['pool_id']) )
206  {
207  if( !$row['pool_id'] )
208  {
209  $lostPool = new ilTestRandomQuestionSetNonAvailablePool();
210  $lostPool->assignDbRow($row);
211 
212  $lostPool->setUnavailabilityStatus(
214  );
215 
216  $this->addLostPool($lostPool);
217 
218  if( isset($trashedPools[$lostPool->getId()]) )
219  {
220  unset($trashedPools[$lostPool->getId()]);
221  }
222  }
223  }
224 
225  if( $row['child'] )
226  {
227  unset($trashedPools[$row['pool_id']]);
228  }
229  }
230 
232  }
addDefinition(ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition)
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ next()

ilTestRandomQuestionSetSourcePoolDefinitionList::next ( )

◆ rewind()

ilTestRandomQuestionSetSourcePoolDefinitionList::rewind ( )
Returns
ilTestRandomQuestionSetSourcePoolDefinition

Definition at line 368 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

369  {
370  return reset($this->sourcePoolDefinitions);
371  }

◆ savedDefinitionsExist()

ilTestRandomQuestionSetSourcePoolDefinitionList::savedDefinitionsExist ( )
Returns
bool

Definition at line 326 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References $query, $res, $row, and array.

327  {
328  $query = "SELECT COUNT(*) cnt FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
329  $res = $this->db->queryF($query, array('integer'), array($this->testOBJ->getTestId()));
330 
331  $row = $this->db->fetchAssoc($res);
332 
333  return $row['cnt'] > 0;
334  }
Create styles array
The data for the language used.

◆ setTrashedPools()

ilTestRandomQuestionSetSourcePoolDefinitionList::setTrashedPools (   $trashedPools)
Parameters
array$trashedPools

Definition at line 116 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References $trashedPools.

Referenced by loadDefinitions().

+ Here is the caller graph for this function:

◆ valid()

ilTestRandomQuestionSetSourcePoolDefinitionList::valid ( )
Returns
boolean

Definition at line 400 of file class.ilTestRandomQuestionSetSourcePoolDefinitionList.php.

References key().

401  {
402  return key($this->sourcePoolDefinitions) !== null;
403  }
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilTestRandomQuestionSetSourcePoolDefinitionList::$db = null
protected

◆ $lostPools

ilTestRandomQuestionSetSourcePoolDefinitionList::$lostPools = array()
protected

◆ $sourcePoolDefinitionFactory

ilTestRandomQuestionSetSourcePoolDefinitionList::$sourcePoolDefinitionFactory = null
private

◆ $sourcePoolDefinitions

ilTestRandomQuestionSetSourcePoolDefinitionList::$sourcePoolDefinitions = array()
private

◆ $testOBJ

ilTestRandomQuestionSetSourcePoolDefinitionList::$testOBJ = null
protected

◆ $trashedPools

ilTestRandomQuestionSetSourcePoolDefinitionList::$trashedPools = array()
protected

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