-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f8f473
commit 512b76d
Showing
10 changed files
with
682 additions
and
469 deletions.
There are no files selected for viewing
542 changes: 99 additions & 443 deletions
542
components/ILIAS/Test/classes/Tables/class.ilTestQuestionBrowserTableGUI.php
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
components/ILIAS/Test/src/Questions/QuestionsBrowserFilter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
* | ||
* ILIAS is licensed with the GPL-3.0, | ||
* see https://www.gnu.org/licenses/gpl-3.0.en.html | ||
* You should have received a copy of said license along with the | ||
* source code, too. | ||
* | ||
* If this is not the case or you just want to try ILIAS, you'll find | ||
* us at: | ||
* https://www.ilias.de | ||
* https://github.com/ILIAS-eLearning | ||
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ILIAS\Test\Questions; | ||
|
||
use ilAssQuestionLifecycle; | ||
use ILIAS\UI\Component\Input\Field\Factory as FieldFactory; | ||
use ILIAS\UI\Component\Input\Input; | ||
use ILIAS\UI\Factory as UIFactory; | ||
use ILIAS\UI\Component\Input\Container\Filter\Filter; | ||
use ilLanguage; | ||
use ilObjQuestionPool; | ||
use ilUIService; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
|
||
class QuestionsBrowserFilter | ||
{ | ||
public function __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 | ||
) { | ||
} | ||
|
||
public function getComponent(string $action, ServerRequestInterface $request): Filter | ||
{ | ||
$filter_inputs = []; | ||
$is_input_initially_rendered = []; | ||
$field_factory = $this->ui_factory->input()->field(); | ||
|
||
foreach ($this->getFields($field_factory) as $filter_id => $filter) { | ||
[$filter_inputs[$filter_id], $is_input_initially_rendered[$filter_id]] = $filter; | ||
} | ||
|
||
$component = $this->ui_service->filter()->standard( | ||
$this->filter_id, | ||
$action, | ||
$filter_inputs, | ||
$is_input_initially_rendered, | ||
true, | ||
true | ||
); | ||
|
||
return $request->getMethod() === 'POST' ? $component->withRequest($request) : $component; | ||
} | ||
|
||
/** | ||
* @param FieldFactory $input | ||
* | ||
* @return array<string, array<Input, bool>> | ||
*/ | ||
private function getFields(FieldFactory $input): array | ||
{ | ||
$lifecycle_options = array_merge( | ||
['' => $this->lng->txt('qst_lifecycle_filter_all')], | ||
ilAssQuestionLifecycle::getDraftInstance()->getSelectOptions($this->lng) | ||
); | ||
$yes_no_all_options = [ | ||
'' => $this->lng->txt('resulttable_all'), | ||
'true' => $this->lng->txt('yes'), | ||
'false' => $this->lng->txt('no') | ||
]; | ||
|
||
return [ | ||
'title' => [$input->text($this->lng->txt('tst_question_title')), true], | ||
'description' => [$input->text($this->lng->txt('description')), false], | ||
'type' => [$input->select($this->lng->txt('tst_question_type'), $this->resolveQuestionTypeFilterOptions()), true], | ||
'author' => [$input->text($this->lng->txt('author')), false], | ||
'lifecycle' => [$input->select($this->lng->txt('qst_lifecycle'), $lifecycle_options), false], | ||
'parent_title' => [$input->text($this->lng->txt($this->parent_title)), true], | ||
'taxonomy_title' => [$input->text($this->lng->txt('taxonomy_title')), true], | ||
'taxonomy_node_title' => [$input->text($this->lng->txt('taxonomy_node_title')), true], | ||
'feedback' => [$input->select($this->lng->txt('feedback'), $yes_no_all_options), false], | ||
'hints' => [$input->select($this->lng->txt('hints'), $yes_no_all_options), false] | ||
]; | ||
} | ||
|
||
private function resolveQuestionTypeFilterOptions(): array | ||
{ | ||
$question_type_options = ['' => $this->lng->txt('filter_all_question_types')]; | ||
|
||
foreach (ilObjQuestionPool::_getQuestionTypes() as $translation => $row) { | ||
$question_type_options[$row['type_tag']] = $translation; | ||
} | ||
return $question_type_options; | ||
} | ||
} |
Oops, something went wrong.