19 declare(strict_types=1);
    45         $this->source_pool_definitions[ $source_pool_definition->
getId() ] = $source_pool_definition;
    50         $this->lost_pools[$lost_pool->
getId()] = $lost_pool;
    55         return isset($this->lost_pools[$pool_id]);
    60         return (
bool) count($this->lost_pools);
    71             return $this->lost_pools[$pool_id];
    79         return isset($this->trashed_pools[$pool_id]);
    84         return (
bool) count($this->trashed_pools);
   101         return $this->
getDefinition($source_pool_definition_id) !== null;
   106         if (isset($this->source_pool_definitions[$source_pool_definition_id])) {
   107             return $this->source_pool_definitions[$source_pool_definition_id];
   115         foreach ($this as $definition) {
   116             if ($definition->getPoolId() != $source_pool_id) {
   128         return array_keys($this->source_pool_definitions);
   133         return count($this->source_pool_definitions);
   140                         SELECT tst_rnd_quest_set_qpls.*, odat.obj_id pool_id, odat.title actual_pool_title, tree.child   141                         FROM tst_rnd_quest_set_qpls   142                         LEFT JOIN object_data odat   143                         ON odat.obj_id = pool_fi   144                         LEFT JOIN object_reference oref   145                         ON oref.obj_id = pool_fi   148                         AND child = oref.ref_id   150                         ORDER BY sequence_pos ASC   153         $res = $this->db->queryF($query, [
'integer', 
'integer'], [1, $this->test_obj->getTestId()]);
   155         $handled_definitions = [];
   158         while ($row = $this->db->fetchAssoc(
$res)) {
   159             $source_pool_definition = $this->source_pool_definition_factory->getEmptySourcePoolDefinition();
   160             $source_pool_definition->initFromArray($row);
   162             if (!isset($handled_definitions[$source_pool_definition->getId()])) {
   164                 $handled_definitions[$source_pool_definition->getId()] = $source_pool_definition->getId();
   167                 $trashedPool->assignDbRow($row);
   169                 $trashedPool->setUnavailabilityStatus(
   173                 $trashed_pools[$trashedPool->getId()] = $trashedPool;
   177                 && !$row[
'pool_id']) {
   179                 $lost_pool->assignDbRow($row);
   181                 $lost_pool->setUnavailabilityStatus(
   187                 if (isset($trashed_pools[$lost_pool->getId()])) {
   188                     unset($trashed_pools[$lost_pool->getId()]);
   192             if (isset($row[
'actual_pool_title'])
   193                 && $source_pool_definition->getPoolTitle() !== $row[
'actual_pool_title']) {
   194                 $source_pool_definition->setPoolTitle($row[
'actual_pool_title']);
   195                 $source_pool_definition->saveToDb();
   199                 unset($trashed_pools[$row[
'pool_id']]);
   208         foreach ($this as $source_pool_definition) {
   209             $source_pool_definition->saveToDb();
   213     public function cloneDefinitionsForTestId(
int $test_id): array
   215         $definition_id_map = [];
   217         foreach ($this as $definition) {
   220             $original_id = $definition->getId();
   221             $definition->cloneToDbForTestId($test_id);
   222             $clone_id = $definition->getId();
   224             $definition_id_map[$original_id] = $clone_id;
   227         return $definition_id_map;
   232         $query = 
"DELETE FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
   233         $this->db->manipulateF($query, [
'integer'], [$this->test_obj->getTestId()]);
   236     public function reindexPositions(): 
void   238         $position_index = [];
   240         foreach ($this as $definition) {
   242             $position_index[ $definition->getId() ] = $definition->getSequencePosition();
   245         asort($position_index);
   249         foreach (array_keys($position_index) as $definition_id) {
   250             $position_index[$definition_id] = $i++;
   253         foreach ($this as $definition) {
   254             $definition->setSequencePosition($position_index[$definition->getId()]);
   260         return (count($this->source_pool_definitions) + 1);
   265         $involved_source_pool_ids = [];
   267         foreach ($this as $definition) {
   268             $involved_source_pool_ids[ $definition->getPoolId() ] = $definition->getPoolId();
   271         return array_values($involved_source_pool_ids);
   276         $question_amount = 0;
   278         foreach ($this as $definition) {
   279             $question_amount += $definition->getQuestionAmount();
   282         return $question_amount;
   290         $query = 
"SELECT COUNT(*) cnt FROM tst_rnd_quest_set_qpls WHERE test_fi = %s";
   291         $res = $this->db->queryF($query, [
'integer'], [$this->test_obj->getTestId()]);
   293         $row = $this->db->fetchAssoc(
$res);
   295         return $row[
'cnt'] > 0;
   300         foreach ($this as $definition) {
   301             if (count($definition->getMappedTaxonomyFilter())) {
   311         foreach ($this as $definition) {
   312             if (count($definition->getTypeFilter())) {
   334         reset($this->source_pool_definitions);
   339         $current = 
current($this->source_pool_definitions);
   340         return $current !== 
false ? $current : null;
   345         return key($this->source_pool_definitions);
   350         next($this->source_pool_definitions);
   355         return key($this->source_pool_definitions) !== null;
 array $source_pool_definitions
 
getDefinitionBySourcePoolId(int $source_pool_id)
 
const UNAVAILABILITY_STATUS_LOST
 
setTrashedPools(array $trashed_pools)
 
areAllUsedPoolsAvailable()
 
const UNAVAILABILITY_STATUS_TRASHED
 
getDefinition(int $source_pool_definition_id)
 
isTrashedPool(int $pool_id)
 
getInvolvedSourcePoolIds()
 
isLostPool(?int $pool_id)
 
addDefinition(ilTestRandomQuestionSetSourcePoolDefinition $source_pool_definition)
 
getLostPool(int $pool_id)
 
hasDefinition(int $source_pool_definition_id)
 
addLostPool(ilTestRandomQuestionSetNonAvailablePool $lost_pool)
 
ilTestRandomQuestionSetSourcePoolDefinitionFactory $source_pool_definition_factory
 
__construct(ilDBInterface $db, ilObjTest $test_obj, ilTestRandomQuestionSetSourcePoolDefinitionFactory $source_pool_definition_factory)