ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ScoringIdentical.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27
28enum ScoringIdentical: string
29{
30 case ScoreAll = 'score_all';
31 case OnlyScoreDistinct = 'score_distinct';
32
33 public function getTranslatedOptionName(
35 ): string {
36 return $lng->txt($this->value);
37 }
38
39 public static function buildInput(
41 FieldFactory $ff,
43 self $default_value
44 ): Select {
45 return $ff->select(
46 $lng->txt('scoring_of_identical_responses'),
47 self::buildOptionsList($lng)
48 )->withRequired(true)
49 ->withAdditionalTransformation(
50 $refinery->custom()->transformation(
51 fn(string $v): self => self::tryFrom($v) ?? $default_value
52 )
53 );
54 }
55
56 private static function buildOptionsList(
58 ): array {
59 return array_reduce(
60 self::cases(),
61 function (array $c, self $v) use ($lng): array {
62 $c[$v->value] = $lng->txt($v->value);
63 return $c;
64 },
65 []
66 );
67 }
Builds data types.
Definition: Factory.php:36
withRequired(bool $is_required, ?Constraint $requirement_constraint=null)
Get an input like this, but set the field to be required (or not).
This is what a factory for input fields looks like.
Definition: Factory.php:31
This describes select field.
Definition: Select.php:29
global $lng
Definition: privfeed.php:26