1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Repository/classes/class.ilRepositorySelectorExplorerGUI.php';
5/**
6 * @author        Björn Heyser <bheyser@databay.de>
7 * @version        $Id$
8 *
9 * @package        Modules/Test(QuestionPool)
10 */
11class ilTestQuestionPoolSelectorExplorer extends ilRepositorySelectorExplorerGUI
12{
13    protected $availableQuestionPools = array();
14
15    public function __construct($targetGUI, $roundtripCMD, $selectCMD)
16    {
17        parent::__construct($targetGUI, $roundtripCMD, $targetGUI, $selectCMD);
18
19        $this->setTypeWhiteList(array('grp', 'cat', 'crs', 'fold', 'qpl'));
20        $this->setClickableTypes(array('qpl'));
21        $this->setSelectMode('', false);
22        $this->selection_par = 'quest_pool_ref';
23    }
24
25    public function getAvailableQuestionPools()
26    {
27        return $this->availableQuestionPools;
28    }
29
30    public function setAvailableQuestionPools($availableQuestionPools)
31    {
32        $this->availableQuestionPools = $availableQuestionPools;
33    }
34
35    public function isAvailableQuestionPool($qplRefId)
36    {
37        /* @var ilObjectDataCache $objCache */
38        $objCache = isset($GLOBALS['DIC']) ? $GLOBALS['DIC']['ilObjDataCache'] : $GLOBALS['ilObjDataCache'];
39
40        $qplObjId = $objCache->lookupObjId($qplRefId);
41        return in_array($qplObjId, $this->getAvailableQuestionPools());
42    }
43
44    public function isNodeClickable($a_node)
45    {
46        if ($a_node['type'] != 'qpl') {
47            return parent::isNodeClickable($a_node);
48        }
49
50        return $this->isAvailableQuestionPool($a_node['child']);
51    }
52
53    public function isNodeVisible($a_node)
54    {
55        if ($a_node['type'] != 'qpl') {
56            return parent::isNodeVisible($a_node);
57        }
58
59        return $this->isAvailableQuestionPool($a_node['child']);
60    }
61}
62