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);
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)