19declare(strict_types=1);
50 ?array $environment =
null
52 $optional_group =
$f->optionalGroup(
54 'highscore_mode' =>
$f->radio(
$lng->txt(
'tst_highscore_mode'),
"")
61 'highscore_top_num' =>
$f->numeric(
$lng->txt(
'tst_highscore_top_num'),
$lng->txt(
'tst_highscore_top_num_description'))
64 'highscore_anon' =>
$f->checkbox(
65 $lng->txt(
'tst_highscore_anon'),
66 $lng->txt(
'tst_highscore_anon_description')
68 'highscore_achieved_ts' =>
$f->checkbox(
69 $lng->txt(
'tst_highscore_achieved_ts'),
70 $lng->txt(
'tst_highscore_achieved_ts_description')
72 'highscore_score' =>
$f->checkbox(
73 $lng->txt(
'tst_highscore_score'),
74 $lng->txt(
'tst_highscore_score_description')
76 'highscore_percentage' =>
$f->checkbox(
77 $lng->txt(
'tst_highscore_percentage'),
78 $lng->txt(
'tst_highscore_percentage_description')
80 'highscore_wtime' =>
$f->checkbox(
81 $lng->txt(
'tst_highscore_wtime'),
82 $lng->txt(
'tst_highscore_wtime_description')
86 $lng->txt(
'tst_highscore_enabled'),
87 $lng->txt(
'tst_highscore_description')
91 $optional_group = $optional_group->withValue(
null);
94 $fields = [
'highscore' => $optional_group];
95 return $f->section($fields,
$lng->txt(
'tst_results_gamification'))
96 ->withAdditionalTransformation(
99 $settings = clone $this;
101 if (! $v[
'highscore']) {
102 return $settings->withHighscoreEnabled(
false);
106 ->withHighscoreEnabled(
true)
108 (
int) $v[
'highscore'][
'highscore_mode'] == self::HIGHSCORE_SHOW_OWN_TABLE ||
109 (
int) $v[
'highscore'][
'highscore_mode'] == self::HIGHSCORE_SHOW_ALL_TABLES
112 (
int) $v[
'highscore'][
'highscore_mode'] == self::HIGHSCORE_SHOW_TOP_TABLE ||
113 (
int) $v[
'highscore'][
'highscore_mode'] == self::HIGHSCORE_SHOW_ALL_TABLES
129 'highscore_enabled' => [
'integer', (
int) $this->getHighscoreEnabled()],
130 'highscore_anon' => [
'integer', (
int) $this->getHighscoreAnon()],
131 'highscore_achieved_ts' => [
'integer', (
int) $this->getHighscoreAchievedTS()],
132 'highscore_score' => [
'integer', (
int) $this->getHighscoreScore()],
133 'highscore_percentage' => [
'integer', (
int) $this->getHighscorePercentage()],
134 'highscore_wtime' => [
'integer', (
int) $this->getHighscoreWTime()],
135 'highscore_own_table' => [
'integer', (
int) $this->getHighscoreOwnTable()],
136 'highscore_top_table' => [
'integer', (
int) $this->getHighscoreTopTable()],
137 'highscore_top_num' => [
'integer', $this->getHighscoreTopNum()]
143 if (!$this->getHighscoreEnabled()) {
150 switch ($this->getHighScoreMode()) {
151 case self::HIGHSCORE_SHOW_OWN_TABLE:
152 $highscore_mode = $additional_info->
getTagForLangVar(
'tst_highscore_own_table');
154 case self::HIGHSCORE_SHOW_TOP_TABLE:
155 $highscore_mode = $additional_info->
getTagForLangVar(
'tst_highscore_top_table');
157 case self::HIGHSCORE_SHOW_ALL_TABLES:
158 $highscore_mode = $additional_info->
getTagForLangVar(
'tst_highscore_all_tables');
184 return $this->highscore_enabled;
188 $clone = clone $this;
189 $clone->highscore_enabled = $highscore_enabled;
195 return $this->highscore_own_table;
199 $clone = clone $this;
200 $clone->highscore_own_table = $highscore_own_table;
205 return $this->highscore_top_table;
209 $clone = clone $this;
210 $clone->highscore_top_table = $highscore_top_table;
216 if ($this->getHighscoreTopTable() && $this->getHighscoreOwnTable()) {
217 return self::HIGHSCORE_SHOW_ALL_TABLES;
220 if ($this->getHighscoreTopTable()) {
221 return self::HIGHSCORE_SHOW_TOP_TABLE;
224 if ($this->getHighscoreOwnTable()) {
225 return self::HIGHSCORE_SHOW_OWN_TABLE;
233 return $this->highscore_top_num;
237 $clone = clone $this;
238 $clone->highscore_top_num = $highscore_top_num;
244 return $this->highscore_anon;
248 $clone = clone $this;
249 $clone->highscore_anon = $highscore_anon;
255 return $this->highscore_achieved_ts;
259 $clone = clone $this;
260 $clone->highscore_achieved_ts = $highscore_achieved_ts;
266 return $this->highscore_score;
270 $clone = clone $this;
271 $clone->highscore_score = $highscore_score;
277 return $this->highscore_percentage;
281 $clone = clone $this;
282 $clone->highscore_percentage = $highscore_percentage;
288 return $this->highscore_wtime;
292 $clone = clone $this;
293 $clone->highscore_wtime = $highscore_wtime;
300 'highscore_enabled' => $this->getHighscoreEnabled(),
301 'highscore_anon' => $this->getHighscoreAnon(),
302 'highscore_achieved_ts' => $this->getHighscoreAchievedTS(),
303 'highscore_score' => $this->getHighscoreScore(),
304 'highscore_percentage' => $this->getHighscorePercentage(),
305 'highscore_wtime' => $this->getHighscoreWTime(),
306 'highscore_own_table' => $this->getHighscoreOwnTable(),
307 'highscore_top_table' => $this->getHighscoreTopTable(),
308 'highscore_top_num' => $this->getHighscoreTopNum(),
315 ->withHighscoreEnabled((
bool)
$data[
'highscore_enabled'])
316 ->withHighscoreAnon((
bool)
$data[
'highscore_anon'])
317 ->withHighscoreAchievedTS((
bool)
$data[
'highscore_achieved_ts'])
318 ->withHighscoreScore((
bool)
$data[
'highscore_score'])
319 ->withHighscorePercentage((
bool)
$data[
'highscore_percentage'])
320 ->withHighscoreWTime((
bool)
$data[
'highscore_wtime'])
321 ->withHighscoreOwnTable((
bool)
$data[
'highscore_own_table'])
322 ->withHighscoreTopTable((
bool)
$data[
'highscore_top_table'])
323 ->withHighscoreTopNum((
int)
$data[
'highscore_top_num']);
const HIGHSCORE_SHOW_ALL_TABLES
toExport()
Transform the object into a simple, associative array.
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)
bool $highscore_achieved_ts
static fromExport(array $data)
Creates an instance of the object from an array.
withHighscoreTopNum(int $highscore_top_num)
withHighscoreTopTable(bool $highscore_top_table)
withHighscoreEnabled(bool $highscore_enabled)
This interface allows an object to define its own transformation into a language-neutral,...