19 declare(strict_types=1);
38 private string $short_name =
"",
39 private string $official_name =
"",
40 private float $minimum_level = 0.0,
41 private bool $passed =
false 47 return $this->short_name;
53 $clone->short_name = $short_name;
59 return $this->official_name;
65 $clone->official_name = $official_name;
71 return $this->minimum_level;
76 if (($minimum_level >= 0.0) && ($minimum_level <= 100.0)) {
78 $clone->minimum_level = $minimum_level;
81 throw new \Exception(
'Markstep: minimum level must be between 0 and 100');
93 $clone->passed = $passed;
106 $percent_trafo = $refinery->kindlyTo()->float();
107 $percent_constraint = $refinery->custom()->constraint(
108 static function (
float $v):
bool {
109 if ($v > 100.0 || $v < 0.0) {
114 $lng->
txt(
'tst_mark_minimum_level_invalid')
116 $mark_trafo = $refinery->custom()->transformation(
117 static function (array $vs):
Mark {
120 $vs[
'official_name'],
121 $vs[
'minimum_level'],
126 $missing_passed_check = $refinery->custom()->constraint(
127 static function (
Mark $v) use ($mark_schema) {
134 if ($local_schema->checkForMissingPassed()) {
139 $lng->
txt(
'no_passed_mark')
141 $missing_zero_check = $refinery->custom()->constraint(
142 static function (
Mark $v) use ($mark_schema) {
149 if ($local_schema->checkForMissingZeroPercentage()) {
154 $lng->
txt(
'no_passed_mark')
157 'name' => $f->text($lng->
txt(
'tst_mark_short_form'))
159 ->withRequired(
true),
160 'official_name' => $f->text($lng->
txt(
'tst_mark_official_form'))
162 ->withRequired(
true),
163 'minimum_level' => $f->text($lng->
txt(
'tst_mark_minimum_level'))
165 ->withAdditionalTransformation($percent_constraint)
167 ->withRequired(
true),
168 'passed' => $f->checkbox($lng->
txt(
'tst_mark_passed'))
170 ])->withAdditionalTransformation($mark_trafo)
171 ->withAdditionalTransformation($missing_passed_check)
172 ->withAdditionalTransformation($missing_zero_check);
178 'short_name' => [
'text', mb_substr($this->
getShortName(), 0, 15)],
179 'official_name' => [
'text', mb_substr($this->
getOfficialName(), 0, 50)],
182 'tstamp' => [
'integer', time()]
A class defining mark schemas for assessment test objects.
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...
withMarkSteps(array $mark_steps)
A class defining marks for assessment test objects.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
withMinimumLevel(float $minimum_level)
toForm(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, MarkSchema $mark_schema)
__construct(private string $short_name="", private string $official_name="", private float $minimum_level=0.0, private bool $passed=false)
withShortName(string $short_name)
withOfficialName(string $official_name)