19declare(strict_types=1);
55 ?array $environment =
null
57 $optional_group =
$f->optionalGroup(
59 'highscore_mode' =>
$f->radio(
$lng->txt(
'tst_highscore_mode'),
"")
66 'highscore_top_num' =>
$f->numeric(
$lng->txt(
'tst_highscore_top_num'),
$lng->txt(
'tst_highscore_top_num_description'))
69 'highscore_anon' =>
$f->checkbox(
70 $lng->txt(
'tst_highscore_anon'),
71 $lng->txt(
'tst_highscore_anon_description')
73 'highscore_achieved_ts' =>
$f->checkbox(
74 $lng->txt(
'tst_highscore_achieved_ts'),
75 $lng->txt(
'tst_highscore_achieved_ts_description')
77 'highscore_score' =>
$f->checkbox(
78 $lng->txt(
'tst_highscore_score'),
79 $lng->txt(
'tst_highscore_score_description')
81 'highscore_percentage' =>
$f->checkbox(
82 $lng->txt(
'tst_highscore_percentage'),
83 $lng->txt(
'tst_highscore_percentage_description')
85 'highscore_wtime' =>
$f->checkbox(
86 $lng->txt(
'tst_highscore_wtime'),
87 $lng->txt(
'tst_highscore_wtime_description')
91 $lng->txt(
'tst_highscore_enabled'),
92 $lng->txt(
'tst_highscore_description')
96 $optional_group = $optional_group->withValue(
null);
99 $fields = [
'highscore' => $optional_group];
100 return $f->section($fields,
$lng->txt(
'tst_results_gamification'))
101 ->withAdditionalTransformation(
104 $settings = clone $this;
106 if (! $v[
'highscore']) {
107 return $settings->withHighscoreEnabled(
false);
111 ->withHighscoreEnabled(
true)
113 (
int) $v[
'highscore'][
'highscore_mode'] == self::HIGHSCORE_SHOW_OWN_TABLE ||
114 (
int) $v[
'highscore'][
'highscore_mode'] == self::HIGHSCORE_SHOW_ALL_TABLES
117 (
int) $v[
'highscore'][
'highscore_mode'] == self::HIGHSCORE_SHOW_TOP_TABLE ||
118 (
int) $v[
'highscore'][
'highscore_mode'] == self::HIGHSCORE_SHOW_ALL_TABLES
134 'highscore_enabled' => [
'integer', (
int) $this->getHighscoreEnabled()],
135 'highscore_anon' => [
'integer', (
int) $this->getHighscoreAnon()],
136 'highscore_achieved_ts' => [
'integer', (
int) $this->getHighscoreAchievedTS()],
137 'highscore_score' => [
'integer', (
int) $this->getHighscoreScore()],
138 'highscore_percentage' => [
'integer', (
int) $this->getHighscorePercentage()],
139 'highscore_wtime' => [
'integer', (
int) $this->getHighscoreWTime()],
140 'highscore_own_table' => [
'integer', (
int) $this->getHighscoreOwnTable()],
141 'highscore_top_table' => [
'integer', (
int) $this->getHighscoreTopTable()],
142 'highscore_top_num' => [
'integer', $this->getHighscoreTopNum()]
148 if (!$this->getHighscoreEnabled()) {
155 switch ($this->getHighScoreMode()) {
156 case self::HIGHSCORE_SHOW_OWN_TABLE:
157 $highscore_mode = $additional_info->
getTagForLangVar(
'tst_highscore_own_table');
159 case self::HIGHSCORE_SHOW_TOP_TABLE:
160 $highscore_mode = $additional_info->
getTagForLangVar(
'tst_highscore_top_table');
162 case self::HIGHSCORE_SHOW_ALL_TABLES:
163 $highscore_mode = $additional_info->
getTagForLangVar(
'tst_highscore_all_tables');
189 return $this->highscore_enabled;
193 $clone = clone $this;
194 $clone->highscore_enabled = $highscore_enabled;
200 return $this->highscore_own_table;
204 $clone = clone $this;
205 $clone->highscore_own_table = $highscore_own_table;
210 return $this->highscore_top_table;
214 $clone = clone $this;
215 $clone->highscore_top_table = $highscore_top_table;
221 if ($this->getHighscoreTopTable() && $this->getHighscoreOwnTable()) {
222 return self::HIGHSCORE_SHOW_ALL_TABLES;
225 if ($this->getHighscoreTopTable()) {
226 return self::HIGHSCORE_SHOW_TOP_TABLE;
229 if ($this->getHighscoreOwnTable()) {
230 return self::HIGHSCORE_SHOW_OWN_TABLE;
238 return $this->highscore_top_num;
242 $clone = clone $this;
243 $clone->highscore_top_num = $highscore_top_num;
249 return $this->highscore_anon;
253 $clone = clone $this;
254 $clone->highscore_anon = $highscore_anon;
260 return $this->highscore_achieved_ts;
264 $clone = clone $this;
265 $clone->highscore_achieved_ts = $highscore_achieved_ts;
271 return $this->highscore_score;
275 $clone = clone $this;
276 $clone->highscore_score = $highscore_score;
282 return $this->highscore_percentage;
286 $clone = clone $this;
287 $clone->highscore_percentage = $highscore_percentage;
293 return $this->highscore_wtime;
297 $clone = clone $this;
298 $clone->highscore_wtime = $highscore_wtime;
const HIGHSCORE_SHOW_ALL_TABLES
bool $highscore_own_table
withHighscorePercentage(bool $highscore_percentage)
const HIGHSCORE_SHOW_OWN_TABLE
withHighscoreScore(bool $highscore_score)
withHighscoreOwnTable(bool $highscore_own_table)
withHighscoreAchievedTS(bool $highscore_achieved_ts)
toForm(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
withHighscoreWTime(bool $highscore_wtime)
bool $highscore_top_table
const HIGHSCORE_SHOW_TOP_TABLE
toLog(AdditionalInformationGenerator $additional_info)
bool $highscore_percentage
withHighscoreAnon(bool $highscore_anon)
__construct(int $test_id)
bool $highscore_achieved_ts
withHighscoreTopNum(int $highscore_top_num)
withHighscoreTopTable(bool $highscore_top_table)
withHighscoreEnabled(bool $highscore_enabled)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc