ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
QuestionsBrowserFilter.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 use ilLanguage;
29 use ilUIService;
31 
33 {
34  public function __construct(
35  private readonly ilUIService $ui_service,
36  private readonly ilLanguage $lng,
37  private readonly UIFactory $ui_factory,
38  private readonly string $filter_id,
39  private readonly string $parent_title
40  ) {
41  }
42 
43  public function getComponent(string $action, ServerRequestInterface $request): Filter
44  {
45  $filter_inputs = [];
46  $is_input_initially_rendered = [];
47  $field_factory = $this->ui_factory->input()->field();
48 
49  foreach ($this->getFields($field_factory) as $filter_id => $filter) {
50  [$filter_inputs[$filter_id], $is_input_initially_rendered[$filter_id]] = $filter;
51  }
52 
53  $component = $this->ui_service->filter()->standard(
54  $this->filter_id,
55  $action,
56  $filter_inputs,
57  $is_input_initially_rendered,
58  true,
59  true
60  );
61 
62  return $request->getMethod() === 'POST' ? $component->withRequest($request) : $component;
63  }
64 
70  private function getFields(FieldFactory $input): array
71  {
72  $lifecycle_options = array_merge(
73  ['' => $this->lng->txt('qst_lifecycle_filter_all')],
74  ilAssQuestionLifecycle::getDraftInstance()->getSelectOptions($this->lng)
75  );
76  $yes_no_all_options = [
77  '' => $this->lng->txt('resulttable_all'),
78  'true' => $this->lng->txt('yes'),
79  'false' => $this->lng->txt('no')
80  ];
81 
82  return [
83  'title' => [$input->text($this->lng->txt('tst_question_title')), true],
84  'description' => [$input->text($this->lng->txt('description')), false],
85  'type' => [$input->select($this->lng->txt('tst_question_type'), $this->resolveQuestionTypeFilterOptions()), true],
86  'author' => [$input->text($this->lng->txt('author')), false],
87  'lifecycle' => [$input->select($this->lng->txt('qst_lifecycle'), $lifecycle_options), false],
88  'parent_title' => [$input->text($this->lng->txt($this->parent_title)), true],
89  'taxonomy_title' => [$input->text($this->lng->txt('taxonomy_title')), true],
90  'taxonomy_node_title' => [$input->text($this->lng->txt('taxonomy_node_title')), true],
91  'feedback' => [$input->select($this->lng->txt('feedback'), $yes_no_all_options), false],
92  'hints' => [$input->select($this->lng->txt('hints'), $yes_no_all_options), false]
93  ];
94  }
95 
96  private function resolveQuestionTypeFilterOptions(): array
97  {
98  $question_type_options = ['' => $this->lng->txt('filter_all_question_types')];
99 
100  foreach (ilObjQuestionPool::_getQuestionTypes() as $translation => $row) {
101  $question_type_options[$row['type_tag']] = $translation;
102  }
103  return $question_type_options;
104  }
105 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getComponent(string $action, ServerRequestInterface $request)
global $lng
Definition: privfeed.php:31
__construct(private readonly ilUIService $ui_service, private readonly ilLanguage $lng, private readonly UIFactory $ui_factory, private readonly string $filter_id, private readonly string $parent_title)
static _getQuestionTypes($all_tags=false, $fixOrder=false, $withDeprecatedTypes=true)