19 declare(strict_types=1);
37 private const ENV =
'e';
38 private const LNG =
'l';
64 $target =
new URLBuilder($data_factory->uri($http->request()->getUri()->__toString()));
66 $this->table = $ui_factory->table()->presentation(
68 $for_print ? [] : $this->
getViewControls($ui_factory, $lng, $target, $mode, $sortation),
72 self::ENV => $settings,
80 return $this->ui_renderer->render($this->table);
94 array $question_results
97 case self::MODE_OPT_CORRECT:
100 case self::MODE_OPT_INCORRECT:
103 case self::MODE_OPT_ALL:
105 $filter =
static fn($qr) =>
true;
107 $question_results = array_filter($question_results, $filter);
109 if ($sortation === self::SORT_OPT_POSSIBLESCORE) {
114 $question_results = array_reverse($question_results);
116 return $question_results;
122 $namespace[] = (string) $this->test_results->getActiveId();
123 $namespace[] = (string) $this->test_results->getAttempt();
129 $request = $this->
http->wrapper()->query();
132 $mode = $request->has($pre . self::PARAM_MODE) ?
133 $request->retrieve($pre . self::PARAM_MODE, $this->
refinery->kindlyTo()->string()) : self::MODE_OPT_ALL;
135 $sortation = $request->has($pre . self::PARAM_SORT) ?
136 $request->retrieve($pre . self::PARAM_SORT, $this->
refinery->kindlyTo()->string()) : self::SORT_OPT_ORDEROFAPPEARANCE;
138 return [$mode, $sortation];
152 [$target,
$token] = $builder;
155 $lng->
txt(
'resulttable_all') => $target->
withParameter(
$token, self::MODE_OPT_ALL)->buildURI()->__toString(),
156 $lng->
txt(
'resulttable_correct') => $target->
withParameter(
$token, self::MODE_OPT_CORRECT)->buildURI()->__toString(),
157 $lng->
txt(
'resulttable_incorrect') => $target->
withParameter(
$token, self::MODE_OPT_INCORRECT)->buildURI()->__toString(),
159 $check = [self::MODE_OPT_ALL, self::MODE_OPT_CORRECT, self::MODE_OPT_INCORRECT];
160 $active = array_search($mode,
$check);
162 $vc_mode = $ui_factory->viewControl()->mode($modes, $lng->
txt(
'ta_resulttable_vc_mode_aria'))
163 ->withActive(array_keys($modes)[$active]);
166 self::SORT_OPT_ORDEROFAPPEARANCE => $lng->
txt(
'resulttable_vc_sort_iooa'),
167 self::SORT_OPT_POSSIBLESCORE => $lng->
txt(
'resulttable_vc_sort_posscore')
171 $vc_sort = $ui_factory->viewControl()->sortation($options, $sortation)->withTargetURL(
173 $pre . self::PARAM_SORT
185 $env = $environment[self::ENV];
186 $lng = $environment[self::LNG];
188 $title = $this->
refinery->encode()->htmlSpecialCharsAsEntities()->transform(
189 $question->getTitle()
192 $important_fields = [
193 $lng->txt(
'position') => (string) ($question->getPosition() + 1),
194 $lng->txt(
'question_id') => (string) $question->getId(),
195 $lng->txt(
'question_type') =>
$lng->txt($question->getType()),
196 $lng->txt(
'points') => sprintf(
198 (
string) $question->getUserScore(),
199 (string) $question->getQuestionScore(),
200 (string) $question->getUserScorePercent()
204 $stats_fields = $important_fields;
205 $stats = $ui_factory->listing()->characteristicValue()->text($stats_fields);
208 $feedback = $ui_factory->listing()->descriptive([
209 $lng->txt(
'tst_feedback') => $question->getFeedback()
214 $contents[] = $stats;
215 if ($env->getShowFeedback()) {
216 $contents[] = $feedback;
219 if ($recap = $question->getContentForRecapitulation()) {
220 $contents[] = $ui_factory->listing()->descriptive([
221 $lng->txt(
'suggested_solution') => $recap
225 $user_answer = $question->getUserAnswer();
227 $ui_factory->listing()->descriptive([
$lng->txt(
'tst_header_participant') => $user_answer])
229 if ($env->getShowBestSolution()) {
230 $answer_contents[] = $ui_factory->listing()->descriptive([
231 $lng->txt(
'tst_header_solution') => $question->getBestSolution()
235 $answers = $ui_factory->layout()->alignment()->horizontal()->evenlyDistributed(...$answer_contents);
236 $contents[] = $answers;
238 $content = $ui_factory->layout()->alignment()->vertical(...$contents);
240 switch ($question->getCorrect()) {
242 $icon_name =
'icon_ok.svg';
243 $label =
$lng->txt(
"answer_is_right");
246 $icon_name =
'icon_mostly_ok.svg';
247 $label =
$lng->txt(
"answer_is_not_correct_but_positive");
250 $icon_name =
'icon_not_ok.svg';
251 $label =
$lng->txt(
"answer_is_wrong");
255 $correct_icon = $ui_factory->symbol()->icon()->custom(
262 ->withLeadingSymbol($correct_icon)
263 ->withImportantFields($important_fields)
264 ->withContent($content);
if($err=$client->getError()) $namespace
buildURI()
Get a URI representation of the full URL including query string and fragment/hash.
getViewControlsParameter()
const SEPARATOR
Separator for parts of a parameter's namespace.
const SORT_OPT_ORDEROFAPPEARANCE
txt(string $a_topic, string $a_default_lang_fallback_mod="")
applyControls(string $mode, string $sortation, array $question_results)
static http()
Fetches the global http state from ILIAS.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
withHeadline(string $headline)
Get a row like this with the given headline.
This describes a Row used in Presentation Table.
getViewControls(UIFactory $ui_factory, Language $lng, URLBuilder $target, string $mode, string $sortation)
return array<>
const SORT_OPT_POSSIBLESCORE
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
acquireParameter(array $namespace, string $name, ?string $initial_value=null)
Add a new parameter with a namespace and get its token for subsequent changes.
__construct(UIFactory $ui_factory, private UIRenderer $ui_renderer, private Refinery $refinery, private HTTPService $http, DataFactory $data_factory, Language $lng, private AttemptSolutions $test_results, Settings $settings, string $title, bool $for_print)
getViewControlNamespace()