ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilTestQuestionBrowserTableGUI Class Reference

@ilCtrl_Calls ilTestQuestionBrowserTableGUI: ilFormPropertyDispatchGUI More...

+ Collaboration diagram for ilTestQuestionBrowserTableGUI:

Public Member Functions

 __construct (private readonly ilTabsGUI $tabs, private readonly ilTree $tree, private readonly ilDBInterface $db, private readonly TestLogger $logger, private readonly ilComponentRepository $component_repository, private readonly ilComponentFactory $component_factory, private readonly ilObjTest $test_obj, private readonly ilObjUser $current_user, private readonly ilAccessHandler $access, private readonly GlobalHttpState $http_state, private readonly Refinery $refinery, private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly RequestDataCollector $testrequest, private readonly GeneralQuestionPropertiesRepository $questionrepository, private readonly ilLanguage $lng, private readonly ilCtrl $ctrl, private readonly ilGlobalTemplateInterface $main_tpl, private readonly ilUIService $ui_service, private readonly DataFactory $data_factory, private readonly TaxonomyService $taxonomy,)
 
 executeCommand ()
 

Data Fields

const REPOSITORY_ROOT_NODE_ID = 1
 
const MODE_PARAMETER = 'question_browse_mode'
 
const MODE_BROWSE_POOLS = 'modeBrowsePools'
 
const MODE_BROWSE_TESTS = 'modeBrowseTests'
 
const CMD_BROWSE_QUESTIONS = 'browseQuestions'
 
const CMD_INSERT_QUESTIONS = 'insertQuestions'
 

Private Member Functions

 handleWriteAccess ()
 
 browseQuestionsCmd ()
 
 getQuestionsBrowserFilterComponent (string $parent_title='', string $action='')
 
 getQuestionsBrowserTable (string $parent_title='')
 
 insertQuestionsCmd ()
 
 handleTabs ()
 
 buildTestQuestionSetConfig ()
 
 addModeParametersToQuestionList (ilAssQuestionList $question_list)
 
 getQuestionParentObjIds (int $repositoryRootNode)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTestQuestionBrowserTableGUI::__construct ( private readonly ilTabsGUI  $tabs,
private readonly ilTree  $tree,
private readonly ilDBInterface  $db,
private readonly TestLogger  $logger,
private readonly ilComponentRepository  $component_repository,
private readonly ilComponentFactory  $component_factory,
private readonly ilObjTest  $test_obj,
private readonly ilObjUser  $current_user,
private readonly ilAccessHandler  $access,
private readonly GlobalHttpState  $http_state,
private readonly Refinery  $refinery,
private readonly UIFactory  $ui_factory,
private readonly UIRenderer  $ui_renderer,
private readonly RequestDataCollector  $testrequest,
private readonly GeneralQuestionPropertiesRepository  $questionrepository,
private readonly ilLanguage  $lng,
private readonly ilCtrl  $ctrl,
private readonly ilGlobalTemplateInterface  $main_tpl,
private readonly ilUIService  $ui_service,
private readonly DataFactory  $data_factory,
private readonly TaxonomyService  $taxonomy 
)

Definition at line 47 of file class.ilTestQuestionBrowserTableGUI.php.

69 {
70 }

Member Function Documentation

◆ addModeParametersToQuestionList()

ilTestQuestionBrowserTableGUI::addModeParametersToQuestionList ( ilAssQuestionList  $question_list)
private

Definition at line 227 of file class.ilTestQuestionBrowserTableGUI.php.

228 {
229 if ($this->testrequest->raw(self::MODE_PARAMETER) === self::MODE_BROWSE_TESTS) {
230 $question_list->setParentObjectType('tst');
232 $question_list->setExcludeQuestionIdsFilter($this->test_obj->getQuestions());
233 return $question_list;
234 }
235
236 $question_list->setParentObjIdsFilter($this->getQuestionParentObjIds(self::REPOSITORY_ROOT_NODE_ID));
238 $question_list->setExcludeQuestionIdsFilter($this->test_obj->getExistingQuestions());
239 return $question_list;
240 }
setQuestionInstanceTypeFilter(?string $questionInstanceTypeFilter)
setParentObjIdsFilter(array $parentObjIdsFilter)
setExcludeQuestionIdsFilter(array $excludeQuestionIdsFilter)
setParentObjectType(string $parentObjType)

References getQuestionParentObjIds(), ilAssQuestionList\QUESTION_INSTANCE_TYPE_ALL, ilAssQuestionList\QUESTION_INSTANCE_TYPE_ORIGINALS, ilAssQuestionList\setExcludeQuestionIdsFilter(), ilAssQuestionList\setParentObjectType(), ilAssQuestionList\setParentObjIdsFilter(), and ilAssQuestionList\setQuestionInstanceTypeFilter().

Referenced by getQuestionsBrowserTable().

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

◆ browseQuestionsCmd()

ilTestQuestionBrowserTableGUI::browseQuestionsCmd ( )
private

Definition at line 96 of file class.ilTestQuestionBrowserTableGUI.php.

96 : bool
97 {
98 $this->ctrl->setParameter($this, self::MODE_PARAMETER, $this->testrequest->raw(self::MODE_PARAMETER));
99 $action = $this->ctrl->getLinkTarget($this, self::CMD_BROWSE_QUESTIONS);
100
101 $mode = $this->ctrl->getParameterArrayByClass(self::class)[self::MODE_PARAMETER];
102 $parent_title = ($mode === self::MODE_BROWSE_TESTS ? 'test_title' : 'tst_source_question_pool');
103
104 $filter = $this->getQuestionsBrowserFilterComponent($parent_title, $action);
105 $question_browser_table = $this->getQuestionsBrowserTable($parent_title);
106
107 $this->main_tpl->setContent(
108 $this->ui_renderer->render([
109 $filter,
110 $question_browser_table->getComponent($this->http_state->request(), $this->ui_service->filter()->getData($filter))
111 ])
112 );
113
114 return true;
115 }
getQuestionsBrowserFilterComponent(string $parent_title='', string $action='')

References ILIAS\Repository\ctrl(), getQuestionsBrowserFilterComponent(), getQuestionsBrowserTable(), and MODE_PARAMETER.

Referenced by executeCommand().

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

◆ buildTestQuestionSetConfig()

ilTestQuestionBrowserTableGUI::buildTestQuestionSetConfig ( )
private

Definition at line 214 of file class.ilTestQuestionBrowserTableGUI.php.

215 {
217 $this->tree,
218 $this->db,
219 $this->lng,
220 $this->logger,
221 $this->component_repository,
222 $this->test_obj,
223 $this->questionrepository
224 ))->getQuestionSetConfig();
225 }

References ILIAS\Repository\lng(), and ILIAS\Repository\logger().

Referenced by insertQuestionsCmd().

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

◆ executeCommand()

ilTestQuestionBrowserTableGUI::executeCommand ( )

Definition at line 72 of file class.ilTestQuestionBrowserTableGUI.php.

72 : bool
73 {
74 $this->handleWriteAccess();
75 $this->handleTabs();
76
77 switch (strtolower((string) $this->ctrl->getNextClass($this))) {
78 case strtolower(self::class):
79 case '':
80 $cmd = $this->ctrl->getCmd() . 'Cmd';
81 return $this->$cmd();
82
83 default:
84 $this->ctrl->setReturn($this, self::CMD_BROWSE_QUESTIONS);
85 return $this->browseQuestionsCmd();
86 }
87 }

References browseQuestionsCmd(), ILIAS\Repository\ctrl(), handleTabs(), and handleWriteAccess().

+ Here is the call graph for this function:

◆ getQuestionParentObjIds()

ilTestQuestionBrowserTableGUI::getQuestionParentObjIds ( int  $repositoryRootNode)
private

Definition at line 242 of file class.ilTestQuestionBrowserTableGUI.php.

242 : array
243 {
244 $parents = $this->tree->getSubTree(
245 $this->tree->getNodeData($repositoryRootNode),
246 true,
247 ['qpl']
248 );
249
250 $parentIds = [];
251
252 foreach ($parents as $nodeData) {
253 if ((int) $nodeData['obj_id'] === $this->test_obj->getId()) {
254 continue;
255 }
256
257 $parentIds[$nodeData['obj_id']] = $nodeData['obj_id'];
258 }
259
260 $parentIds = array_map('intval', array_values($parentIds));
261 $available_pools = array_map('intval', array_keys(\ilObjQuestionPool::_getAvailableQuestionpools(true)));
262 return array_intersect($parentIds, $available_pools);
263 }
static _getAvailableQuestionpools(bool $use_object_id=false, bool $equal_points=false, bool $could_be_offline=false, bool $showPath=false, bool $with_questioncount=false, string $permission='read', int $usr_id=0)
Returns the available question pools for the active user.

References ilObjQuestionPool\_getAvailableQuestionpools().

Referenced by addModeParametersToQuestionList().

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

◆ getQuestionsBrowserFilterComponent()

ilTestQuestionBrowserTableGUI::getQuestionsBrowserFilterComponent ( string  $parent_title = '',
string  $action = '' 
)
private

Definition at line 117 of file class.ilTestQuestionBrowserTableGUI.php.

117 : Filter
118 {
119 return (new QuestionsBrowserFilter(
120 $this->ui_service,
121 $this->lng,
122 $this->ui_factory,
123 "question_browser_filter_{$this->testrequest->getRefId()}",
124 $parent_title
125 ))->getComponent($action, $this->http_state->request());
126 }
This describes commonalities between all filters.
Definition: Filter.php:34

References ILIAS\Repository\lng().

Referenced by browseQuestionsCmd().

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

◆ getQuestionsBrowserTable()

ilTestQuestionBrowserTableGUI::getQuestionsBrowserTable ( string  $parent_title = '')
private

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

129 {
130 $question_list = $this->addModeParametersToQuestionList(
132 $this->db,
133 $this->lng,
134 $this->refinery,
135 $this->component_repository,
136 $this->component_factory
137 )
138 );
139
140 return new QuestionsBrowserTable(
141 (string) $this->test_obj->getId(),
142 $this->current_user,
143 $this->ui_factory,
144 $this->ui_renderer,
145 $this->lng,
146 $this->ctrl,
147 $this->data_factory,
148 $question_list,
149 $this->taxonomy,
150 $parent_title
151 );
152 }
addModeParametersToQuestionList(ilAssQuestionList $question_list)

References addModeParametersToQuestionList(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

Referenced by browseQuestionsCmd(), and insertQuestionsCmd().

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

◆ handleTabs()

ilTestQuestionBrowserTableGUI::handleTabs ( )
private

Definition at line 190 of file class.ilTestQuestionBrowserTableGUI.php.

190 : void
191 {
192 $this->tabs->clearTargets();
193 $this->tabs->clearSubTabs();
194
195 $this->tabs->setBackTarget(
196 $this->lng->txt('backtocallingtest'),
197 $this->ctrl->getLinkTargetByClass(ilObjTestGUI::class, ilObjTestGUI::SHOW_QUESTIONS_CMD)
198 );
199
200 $browseQuestionsTabLabel = match ($this->testrequest->raw(self::MODE_PARAMETER)) {
201 self::MODE_BROWSE_POOLS => $this->lng->txt('tst_browse_for_qpl_questions'),
202 self::MODE_BROWSE_TESTS => $this->lng->txt('tst_browse_for_tst_questions'),
203 default => ''
204 };
205
206 $this->tabs->addTab(
207 self::CMD_BROWSE_QUESTIONS,
208 $browseQuestionsTabLabel,
209 $this->ctrl->getLinkTarget($this, self::CMD_BROWSE_QUESTIONS)
210 );
211 $this->tabs->activateTab('browseQuestions');
212 }

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ilObjTestGUI\SHOW_QUESTIONS_CMD, and ILIAS\Repository\tabs().

Referenced by executeCommand().

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

◆ handleWriteAccess()

ilTestQuestionBrowserTableGUI::handleWriteAccess ( )
private

Definition at line 89 of file class.ilTestQuestionBrowserTableGUI.php.

89 : void
90 {
91 if (!$this->access->checkAccess('write', '', $this->test_obj->getRefId())) {
92 $this->ctrl->redirectByClass(ilObjTestGUI::class, ilObjTestGUI::SHOW_QUESTIONS_CMD);
93 }
94 }

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), and ilObjTestGUI\SHOW_QUESTIONS_CMD.

Referenced by executeCommand().

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

◆ insertQuestionsCmd()

ilTestQuestionBrowserTableGUI::insertQuestionsCmd ( )
private

Definition at line 154 of file class.ilTestQuestionBrowserTableGUI.php.

154 : void
155 {
156 $selected_array = $this->http_state->wrapper()->query()->retrieve(
157 'qlist_q_id',
158 $this->refinery->byTrying([
159 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
160 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string()),
161 $this->refinery->always([])
162 ])
163 );
164
165 if ($selected_array === []) {
166 $this->main_tpl->setOnScreenMessage('info', $this->lng->txt('tst_insert_missing_question'), true);
167 $this->ctrl->redirect($this, self::CMD_BROWSE_QUESTIONS);
168 }
169
170 if (in_array('ALL_OBJECTS', $selected_array, true)) {
171 $selected_array = array_keys(
172 $this->getQuestionsBrowserTable()->loadRecords(
173 $this->ui_service->filter()->getData($this->getQuestionsBrowserFilterComponent()) ?? []
174 )
175 );
176 }
177
178 array_map(
179 fn(int $v): int => $this->test_obj->insertQuestion($v),
180 $selected_array
181 );
182
183 $this->test_obj->saveCompleteStatus($this->buildTestQuestionSetConfig());
184
185 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt('tst_questions_inserted'), true);
186
187 $this->ctrl->redirectByClass(ilObjTestGUI::class, ilObjTestGUI::SHOW_QUESTIONS_CMD);
188 }

References buildTestQuestionSetConfig(), ILIAS\Repository\ctrl(), getQuestionsBrowserTable(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ilObjTestGUI\SHOW_QUESTIONS_CMD.

+ Here is the call graph for this function:

Field Documentation

◆ CMD_BROWSE_QUESTIONS

const ilTestQuestionBrowserTableGUI::CMD_BROWSE_QUESTIONS = 'browseQuestions'

◆ CMD_INSERT_QUESTIONS

const ilTestQuestionBrowserTableGUI::CMD_INSERT_QUESTIONS = 'insertQuestions'

Definition at line 45 of file class.ilTestQuestionBrowserTableGUI.php.

◆ MODE_BROWSE_POOLS

const ilTestQuestionBrowserTableGUI::MODE_BROWSE_POOLS = 'modeBrowsePools'

◆ MODE_BROWSE_TESTS

const ilTestQuestionBrowserTableGUI::MODE_BROWSE_TESTS = 'modeBrowseTests'

◆ MODE_PARAMETER

const ilTestQuestionBrowserTableGUI::MODE_PARAMETER = 'question_browse_mode'

◆ REPOSITORY_ROOT_NODE_ID

const ilTestQuestionBrowserTableGUI::REPOSITORY_ROOT_NODE_ID = 1

Definition at line 39 of file class.ilTestQuestionBrowserTableGUI.php.


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