ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 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 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.

68 {
69 }

Member Function Documentation

◆ addModeParametersToQuestionList()

ilTestQuestionBrowserTableGUI::addModeParametersToQuestionList ( ilAssQuestionList  $question_list)
private

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

220 {
221 if ($this->testrequest->raw(self::MODE_PARAMETER) === self::MODE_BROWSE_TESTS) {
222 $question_list->setParentObjectType('tst');
224 $question_list->setExcludeQuestionIdsFilter($this->test_obj->getQuestions());
225 return $question_list;
226 }
227
228 $question_list->setParentObjIdsFilter($this->getQuestionParentObjIds(self::REPOSITORY_ROOT_NODE_ID));
230 $question_list->setExcludeQuestionIdsFilter($this->test_obj->getExistingQuestions());
231 return $question_list;
232 }
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 95 of file class.ilTestQuestionBrowserTableGUI.php.

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

207 {
209 $this->tree,
210 $this->db,
211 $this->lng,
212 $this->logger,
213 $this->component_repository,
214 $this->test_obj,
215 $this->questionrepository
216 ))->getQuestionSetConfig();
217 }

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 71 of file class.ilTestQuestionBrowserTableGUI.php.

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

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 234 of file class.ilTestQuestionBrowserTableGUI.php.

234 : array
235 {
236 $parents = $this->tree->getSubTree(
237 $this->tree->getNodeData($repositoryRootNode),
238 true,
239 ['qpl']
240 );
241
242 $parentIds = [];
243
244 foreach ($parents as $nodeData) {
245 if ((int) $nodeData['obj_id'] === $this->test_obj->getId()) {
246 continue;
247 }
248
249 $parentIds[$nodeData['obj_id']] = $nodeData['obj_id'];
250 }
251
252 $parentIds = array_map('intval', array_values($parentIds));
253 $available_pools = array_map('intval', array_keys(\ilObjQuestionPool::_getAvailableQuestionpools(true)));
254 return array_intersect($parentIds, $available_pools);
255 }
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 116 of file class.ilTestQuestionBrowserTableGUI.php.

116 : Filter
117 {
118 return (new QuestionsBrowserFilter(
119 $this->ui_service,
120 $this->lng,
121 $this->ui_factory,
122 'question_browser_filter',
123 $parent_title
124 ))->getComponent($action, $this->http_state->request());
125 }
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 127 of file class.ilTestQuestionBrowserTableGUI.php.

128 {
129 $question_list = new ilAssQuestionList($this->db, $this->lng, $this->refinery, $this->component_repository);
130 $question_list = $this->addModeParametersToQuestionList($question_list);
131
132 return new QuestionsBrowserTable(
133 (string) $this->test_obj->getId(),
134 $this->current_user,
135 $this->ui_factory,
136 $this->ui_renderer,
137 $this->lng,
138 $this->ctrl,
139 $this->data_factory,
140 $question_list,
141 $this->taxonomy,
142 $parent_title
143 );
144 }
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 182 of file class.ilTestQuestionBrowserTableGUI.php.

182 : void
183 {
184 $this->tabs->clearTargets();
185 $this->tabs->clearSubTabs();
186
187 $this->tabs->setBackTarget(
188 $this->lng->txt('backtocallingtest'),
189 $this->ctrl->getLinkTargetByClass(ilObjTestGUI::class, ilObjTestGUI::SHOW_QUESTIONS_CMD)
190 );
191
192 $browseQuestionsTabLabel = match ($this->testrequest->raw(self::MODE_PARAMETER)) {
193 self::MODE_BROWSE_POOLS => $this->lng->txt('tst_browse_for_qpl_questions'),
194 self::MODE_BROWSE_TESTS => $this->lng->txt('tst_browse_for_tst_questions'),
195 default => ''
196 };
197
198 $this->tabs->addTab(
199 self::CMD_BROWSE_QUESTIONS,
200 $browseQuestionsTabLabel,
201 $this->ctrl->getLinkTarget($this, self::CMD_BROWSE_QUESTIONS)
202 );
203 $this->tabs->activateTab('browseQuestions');
204 }

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 88 of file class.ilTestQuestionBrowserTableGUI.php.

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

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 146 of file class.ilTestQuestionBrowserTableGUI.php.

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

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'

◆ 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: