19 declare(strict_types=1);
35 private const ENV =
'e';
36 private const LNG =
'l';
60 $target =
new URLBuilder($data_factory->uri($http->request()->getUri()->__toString()));
62 $this->table = $ui_factory->table()->presentation(
76 return $this->ui_renderer->render($this->table);
85 array $question_results
88 case self::MODE_OPT_CORRECT:
91 case self::MODE_OPT_INCORRECT:
94 case self::MODE_OPT_ALL:
96 $filter =
static fn($qr) =>
true;
98 $question_results = array_filter($question_results, $filter);
100 if ($sortation === self::SORT_OPT_POSSIBLESCORE) {
105 $question_results = array_reverse($question_results);
107 return $question_results;
113 $namespace[] = (string) $this->test_results->getActiveId();
114 $namespace[] = (string) $this->test_results->getPass();
120 $request = $this->
http->wrapper()->query();
123 $mode = $request->has($pre . self::PARAM_MODE) ?
124 $request->retrieve($pre . self::PARAM_MODE, $this->
refinery->kindlyTo()->string()) : self::MODE_OPT_ALL;
126 $sortation = $request->has($pre . self::PARAM_SORT) ?
127 $request->retrieve($pre . self::PARAM_SORT, $this->
refinery->kindlyTo()->string()) : self::SORT_OPT_ORDEROFAPPEARANCE;
129 return [$mode, $sortation];
143 [$target,
$token] = $builder;
146 $lng->
txt(
'resulttable_all') => $target->
withParameter(
$token, self::MODE_OPT_ALL)->buildURI()->__toString(),
147 $lng->
txt(
'resulttable_correct') => $target->
withParameter(
$token, self::MODE_OPT_CORRECT)->buildURI()->__toString(),
148 $lng->
txt(
'resulttable_incorrect') => $target->
withParameter(
$token, self::MODE_OPT_INCORRECT)->buildURI()->__toString(),
150 $check = [self::MODE_OPT_ALL, self::MODE_OPT_CORRECT, self::MODE_OPT_INCORRECT];
151 $active = array_search($mode,
$check);
153 $vc_mode = $ui_factory->viewControl()->mode($modes, $lng->
txt(
'ta_resulttable_vc_mode_aria'))
154 ->withActive(array_keys($modes)[$active]);
157 self::SORT_OPT_ORDEROFAPPEARANCE => $lng->
txt(
'resulttable_vc_sort_iooa'),
158 self::SORT_OPT_POSSIBLESCORE => $lng->
txt(
'resulttable_vc_sort_posscore')
162 $vc_sort = $ui_factory->viewControl()->sortation($options)->withTargetURL(
164 $pre . self::PARAM_SORT
166 ->withLabel($options[$sortation]);
176 return function ($row, $question_result, $ui_factory, $environment) {
177 $env = $environment[self::ENV];
178 $lng = $environment[self::LNG];
180 $title = htmlspecialchars($question_result->getTitle());
182 $important_fields = [
183 $lng->txt(
'position') => (string) ($question_result->getPosition() + 1),
184 $lng->txt(
'question_id') => (string) $question_result->getId(),
185 $lng->txt(
'question_type') =>
$lng->txt($question_result->getType()),
186 $lng->txt(
'points') => sprintf(
188 (
string) $question_result->getUserScore(),
189 (string) $question_result->getQuestionScore(),
190 (string) $question_result->getUserScorePercent()
194 $stats_fields = $important_fields;
195 $stats_fields[
$lng->txt(
'tst_question_hints_requested_hint_count_header')] = (string) $question_result->getNumberOfRequestedHints();
196 $stats = $ui_factory->listing()->characteristicValue()->text($stats_fields);
199 $feedback = $ui_factory->listing()->descriptive([
200 $lng->txt(
'tst_feedback') => $question_result->getFeedback()
205 $contents[] = $stats;
206 if ($env->getShowFeedback()) {
207 $contents[] = $feedback;
210 if ($recap = $question_result->getContentForRecapitulation()) {
211 $contents[] = $ui_factory->listing()->descriptive([
212 $lng->txt(
'suggested_solution') => $recap
217 $lng->txt(
'tst_header_participant') => $question_result->getUserAnswer()
219 if ($autosave_content = $question_result->getAutosavedAnswer()) {
220 $listing[
$lng->txt(
'autosavecontent')] = $autosave_content;
224 $ui_factory->listing()->descriptive($listing)
226 if ($env->getShowBestSolution()) {
227 $answer_contents[] = $ui_factory->listing()->descriptive([
228 $lng->txt(
'tst_header_solution') => $question_result->getBestSolution()
232 $answers = $ui_factory->layout()->alignment()->horizontal()->evenlyDistributed(...$answer_contents);
233 $contents[] = $answers;
235 $content = $ui_factory->layout()->alignment()->vertical(...$contents);
237 switch ($question_result->getCorrect()) {
239 $icon_name =
'icon_ok.svg';
240 $label =
$lng->txt(
"answer_is_right");
243 $icon_name =
'icon_mostly_ok.svg';
244 $label =
$lng->txt(
"answer_is_not_correct_but_positive");
247 $icon_name =
'icon_not_ok.svg';
248 $label =
$lng->txt(
"answer_is_wrong");
252 $correct_icon = $ui_factory->symbol()->icon()->custom(
258 ->withHeadline($title)
259 ->withLeadingSymbol($correct_icon)
260 ->withImportantFields($important_fields)
261 ->withContent($content);
if($err=$client->getError()) $namespace
getViewControlsParameter()
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
buildURI()
Get a URI representation of the full URL including query string and fragment/hash.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
const SORT_OPT_ORDEROFAPPEARANCE
__construct(UIFactory $ui_factory, protected UIRenderer $ui_renderer, protected Refinery $refinery, protected HTTPService $http, DataFactory $data_factory, ilLanguage $lng, protected ilTestPassResult $test_results, string $title)
getViewControlNamespace()
static http()
Fetches the global http state from ILIAS.
applyControls(string $mode, string $sortation, array $question_results)
getViewControls(UIFactory $ui_factory, ilLanguage $lng, URLBuilder $target, string $mode, string $sortation)
return []
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.
const SORT_OPT_POSSIBLESCORE
Refinery Factory $refinery