19 declare(strict_types=1);
70 $this->
setId(
'qpl_brows_tabl_' . $this->test_obj->getId());
77 $this->
setStyle(
'table',
'fullwidth');
79 $this->
addColumn($this->
lng->txt(
"tst_question_title"),
'title',
'');
80 $this->
addColumn($this->
lng->txt(
"description"),
'description',
'');
81 $this->
addColumn($this->
lng->txt(
"tst_question_type"),
'ttype',
'');
82 $this->
addColumn($this->
lng->txt(
"author"),
'author',
'');
83 $this->
addColumn($this->
lng->txt(
'qst_lifecycle'),
'lifecycle',
'');
84 $this->
addColumn($this->
lng->txt(
"create_date"),
'created',
'');
86 $this->
lng->txt(
"last_update"),
92 $this->
setRowTemplate(
"tpl.il_as_tst_question_browser_row.html",
"Modules/Test");
99 $this->
enable(
'select_all');
106 $this->writeAccess = $value;
126 switch (strtolower((
string) $this->
ctrl->getNextClass($this))) {
127 case strtolower(__CLASS__):
130 $cmd = $this->
ctrl->getCmd() .
'Cmd';
131 return $this->$cmd();
135 $this->
ctrl->setReturn($this, self::CMD_BROWSE_QUESTIONS);
136 return parent::executeCommand();
144 $this->main_tpl->setContent($this->
ctrl->getHTML($this));
151 $this->
ctrl->redirect($this, self::CMD_BROWSE_QUESTIONS);
157 $this->
ctrl->redirect($this, self::CMD_BROWSE_QUESTIONS);
162 $selected_array = [];
163 if ($this->http_state->wrapper()->post()->has(
'q_id')) {
164 $selected_array = $this->http_state->wrapper()->post()->retrieve(
170 if ($selected_array === []) {
171 $this->main_tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"tst_insert_missing_question"),
true);
172 $this->
ctrl->redirect($this, self::CMD_BROWSE_QUESTIONS);
179 foreach ($selected_array as
$key => $value) {
180 $last_question_id = $this->test_obj->insertQuestion($testQuestionSetConfig, $value);
187 $this->test_obj->saveCompleteStatus($testQuestionSetConfig);
190 $this->main_tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"manscoring_hint"),
true);
192 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"tst_questions_inserted"),
true);
200 if ($this->testrequest->isset(self::CONTEXT_PARAMETER)) {
201 $this->
ctrl->setParameterByClass(
203 self::CONTEXT_PARAMETER,
204 $this->testrequest->raw(self::CONTEXT_PARAMETER)
206 $this->
addHiddenInput(self::CONTEXT_PARAMETER, $this->testrequest->raw(self::CONTEXT_PARAMETER));
209 if ($this->testrequest->isset(self::MODE_PARAMETER)) {
210 $this->
ctrl->setParameterByClass(
212 self::MODE_PARAMETER,
213 $this->testrequest->raw(self::MODE_PARAMETER)
215 $this->
addHiddenInput(self::MODE_PARAMETER, $this->testrequest->raw(self::MODE_PARAMETER));
224 if ($this->testrequest->isset(self::CONTEXT_PARAMETER)) {
225 return $this->testrequest->raw(self::CONTEXT_PARAMETER);
236 if ($this->testrequest->isset(self::MODE_PARAMETER)) {
237 return $this->testrequest->raw(self::MODE_PARAMETER);
245 $this->
tabs->clearTargets();
246 $this->
tabs->clearSubTabs();
248 $this->
tabs->setBackTarget(
258 $this->
tabs->activateTab(
'browseQuestions');
263 return $this->
lng->txt(
'backtocallingtest');
268 return $this->
ctrl->getLinkTargetByClass(
277 case self::CONTEXT_PAGE_VIEW:
279 return 'ilTestExpressPageObjectGUI';
280 case self::CONTEXT_LIST_VIEW:
282 return 'ilObjTestGUI';
289 case self::CONTEXT_LIST_VIEW:
293 case self::CONTEXT_PAGE_VIEW:
304 case self::MODE_BROWSE_POOLS:
306 return $this->
lng->txt(
'tst_browse_for_qpl_questions');
308 case self::MODE_BROWSE_TESTS:
310 return $this->
lng->txt(
'tst_browse_for_tst_questions');
318 return $this->
ctrl->getLinkTarget($this, self::CMD_BROWSE_QUESTIONS);
323 $ti =
new ilTextInputGUI($this->
lng->txt(
"tst_qbt_filter_question_title"),
"title");
324 $ti->setMaxLength(64);
326 $ti->setValidationRegexp(
'/(^[^%]+$)|(^$)/is');
328 $ti->readFromSession();
329 $this->
filter[
"title"] = $ti->getValue();
332 $ti->setMaxLength(64);
334 $ti->setValidationRegexp(
'/(^[^%]+$)|(^$)/is');
336 $ti->readFromSession();
337 $this->
filter[
"description"] = $ti->getValue();
340 $ti->setMaxLength(64);
343 $ti->setValidationRegexp(
'/(^[^%]+$)|(^$)/is');
344 $ti->readFromSession();
345 $this->
filter[
"author"] = $ti->getValue();
347 $lifecycleOptions = array_merge(
348 [
'' => $this->
lng->txt(
'qst_lifecycle_filter_all')],
354 $lifecycleInp->readFromSession();
355 $this->
filter[
'lifecycle'] = $lifecycleInp->getValue();
359 $options[
""] = $this->
lng->txt(
'filter_all_question_types');
360 foreach ($types as $translation => $row) {
361 $options[$row[
'type_tag']] = $translation;
367 $si->readFromSession();
368 $this->
filter[
"type"] = $si->getValue();
371 $ti->setMaxLength(64);
373 $ti->setValidationRegexp(
'/(^[^%]+$)|(^$)/is');
375 $ti->readFromSession();
376 $this->
filter[
'parent_title'] = $ti->getValue();
381 $ri->setClickableTypes([
'tst']);
383 $ri->setClickableTypes([
'qpl']);
386 $ri->readFromSession();
388 if (!$this->tree->isDeleted($ri->getValue())
389 && $this->tree->isInTree($ri->getValue())) {
390 $this->
filter[
'repository_root_node'] = $ri->getValue();
392 $ri->setValue(self::REPOSITORY_ROOT_NODE_ID);
399 case self::MODE_BROWSE_POOLS:
401 return $this->
lng->txt(
'qpl');
403 case self::MODE_BROWSE_TESTS:
405 return $this->
lng->txt(
'tst');
422 $this->tpl->setVariable(
"QUESTION_ID", $a_set[
"question_id"]);
423 $this->tpl->setVariable(
"QUESTION_TITLE", $a_set[
"title"]);
424 $this->tpl->setVariable(
"QUESTION_COMMENT", $a_set[
"description"]);
425 $this->tpl->setVariable(
"QUESTION_TYPE", $this->questioninfo->getQuestionTypeName($a_set[
"question_id"]));
426 $this->tpl->setVariable(
"QUESTION_AUTHOR", $a_set[
"author"]);
428 $this->tpl->setVariable(
432 $this->tpl->setVariable(
436 $this->tpl->setVariable(
437 "QUESTION_POOL_OR_TEST_TITLE",
439 (
int) $a_set[
"obj_fi"],
440 $a_set[
"parent_title"]
448 case self::MODE_BROWSE_POOLS:
449 return $this->buildPossiblyLinkedQuestonPoolTitle(
459 case self::MODE_BROWSE_TESTS:
460 return $this->buildPossiblyLinkedTestTitle(
481 $this->component_repository,
486 return $testQuestionSetConfigFactory->getQuestionSetConfig();
494 $questionList->setExcludeQuestionIdsFilter($this->test_obj->getExistingQuestions());
496 $repositoryRootNode = self::REPOSITORY_ROOT_NODE_ID;
499 if (!in_array($item->getValue(), [
false, null,
''],
true)) {
500 switch ($item->getPostVar()) {
507 $questionList->addFieldFilter($item->getPostVar(), $item->getValue());
510 case 'repository_root_node':
511 $repositoryRootNode = (
int) $item->getValue();
515 if ($repositoryRootNode < 1) {
516 $repositoryRootNode = self::REPOSITORY_ROOT_NODE_ID;
521 if (!count($parentObjectIds)) {
525 $questionList->setParentObjIdsFilter($parentObjectIds);
528 $questionList->load();
530 return $questionList->getQuestionDataArray();
548 $parents = $this->tree->getSubTree(
549 $this->tree->getNodeData($repositoryRootNode),
556 foreach ($parents as $nodeData) {
557 if ((
int) $nodeData[
'obj_id'] === $this->test_obj->getId()) {
561 $parentIds[$nodeData[
'obj_id']] = $nodeData[
'obj_id'];
564 $parentIds = array_map(
'intval', array_values($parentIds));
568 return array_intersect($parentIds, $available_pools);
570 return array_filter($parentIds,
function ($obj_id):
bool {
572 $refId = current($refIds);
getBrowseQuestionsTabUrl()
Interface GlobalHttpState.
static getInstance($identifier)
Readable part of repository interface to ilComponentDataDB.
enable(string $a_module_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFormAction(string $a_form_action, bool $a_multipart=false)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
static _getAvailableQuestionpools( $use_object_id=false, $equal_points=false, $could_be_offline=false, $showPath=false, $with_questioncount=false, $permission='read', $usr_id='')
Returns the available question pools for the active user.
getBrowseQuestionsTabLabel()
setResetCommand(string $a_val, string $a_caption="")
Class ChatMainBarProvider .
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
static _getAllReferences(int $id)
get all reference ids for object ID
const REPOSITORY_ROOT_NODE_ID
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
setDisableFilterHiding(bool $a_val=true)
getQuestionInstanceTypeFilter()
getQuestionParentObjectType()
const CMD_BROWSE_QUESTIONS
setFormName(string $a_name="")
setWriteAccess(bool $value)
buildPossiblyLinkedQuestonPoolOrTestTitle(int $obj_id, string $parent_title)
setStyle(string $a_element, string $a_style)
static _needsManualScoring(int $question_id)
addHiddenInput(string $a_name, string $a_value)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setFilterCommand(string $a_val, string $a_caption="")
setDefaultOrderDirection(string $a_defaultorderdirection)
getQuestionParentObjIds(int $repositoryRootNode)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
getFilterItems(bool $a_optionals=false)
__construct(private ilTabsGUI $tabs, private ilTree $tree, private ilDBInterface $db, private ilLogger $log, private ilComponentRepository $component_repository, private ilObjTest $test_obj, private ilAccessHandler $access, private GlobalHttpState $http_state, private Refinery $refinery, private UIFactory $ui_factory, private UIRenderer $ui_renderer, private InternalRequestService $testrequest, private ILIAS\TestQuestionPool\QuestionInfoService $questioninfo)
const QUESTION_INSTANCE_TYPE_ALL
addMultiCommand(string $a_cmd, string $a_text)
static getDraftInstance()
const QUESTION_INSTANCE_TYPE_ORIGINALS
const CMD_INSERT_QUESTIONS
getTranslatedLifecycle(?string $lifecycle)
buildTestQuestionSetConfig()
static _getQuestionTypes($all_tags=false, $fixOrder=false, $withDeprecatedTypes=true)
Refinery Factory $refinery