ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ScoreSettings.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\Test\Scoring\Settings\Settings as SettingsScoring;
26
27class ScoreSettings implements Exportable
28{
29 public function __construct(
30 protected int $id,
31 protected SettingsScoring $settings_scoring,
32 protected SettingsResultSummary $settings_result_summary,
33 protected SettingsResultDetails $settings_result_details,
34 protected SettingsGamification $settings_gamification
35 ) {
36 $this->settings_result_summary = $settings_result_summary
37 ->withShowPassDetails($settings_result_details->getShowPassDetails());
38 }
39
40 public function getId(): int
41 {
42 return $this->id;
43 }
44
45 public function withId(int $id): self
46 {
47 $clone = clone $this;
48 $clone->id = $id;
49 return $clone;
50 }
51
52 public function getScoringSettings(): SettingsScoring
53 {
54 return $this->settings_scoring;
55 }
56
57 public function withScoringSettings(SettingsScoring $settings): self
58 {
59 $clone = clone $this;
60 $clone->settings_scoring = $settings;
61 return $clone;
62 }
63
65 {
66 return $this->settings_result_summary;
67 }
68
69 public function withResultSummarySettings(SettingsResultSummary $settings): self
70 {
71 $clone = clone $this;
72 $clone->settings_result_summary = $settings;
73 return $clone;
74 }
75
77 {
78 return $this->settings_result_details;
79 }
80
81 public function withResultDetailsSettings(SettingsResultDetails $settings): self
82 {
83 $clone = clone $this;
84 $clone->settings_result_details = $settings;
85 return $clone;
86 }
87
89 {
90 return $this->settings_gamification;
91 }
92
93 public function withGamificationSettings(SettingsGamification $settings): self
94 {
95 $clone = clone $this;
96 $clone->settings_gamification = $settings;
97 return $clone;
98 }
99
100 public function getArrayForLog(AdditionalInformationGenerator $additional_info): array
101 {
102 return $this->settings_scoring->toLog($additional_info)
103 + $this->settings_result_summary->toLog($additional_info)
104 + $this->settings_result_details->toLog($additional_info)
105 + $this->settings_gamification->toLog($additional_info);
106 }
107
108 public function toExport(): array
109 {
110 return [
111 'settings_scoring' => $this->settings_scoring->toExport(),
112 'settings_result_summary' => $this->settings_result_summary->toExport(),
113 'settings_result_details' => $this->settings_result_details->toExport(),
114 'settings_gamification' => $this->settings_gamification->toExport()
115 ];
116 }
117
118 public static function fromExport(array $data): static
119 {
120 return new self(
121 $data['id'] ?? -1,
122 SettingsScoring::fromExport($data['settings_scoring']),
123 SettingsResultSummary::fromExport($data['settings_result_summary']),
124 SettingsResultDetails::fromExport($data['settings_result_details']),
125 SettingsGamification::fromExport($data['settings_gamification'])
126 );
127 }
128}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getArrayForLog(AdditionalInformationGenerator $additional_info)
static fromExport(array $data)
Creates an instance of the object from an array.
toExport()
Transform the object into a simple, associative array.
withResultDetailsSettings(SettingsResultDetails $settings)
withGamificationSettings(SettingsGamification $settings)
withResultSummarySettings(SettingsResultSummary $settings)
__construct(protected int $id, protected SettingsScoring $settings_scoring, protected SettingsResultSummary $settings_result_summary, protected SettingsResultDetails $settings_result_details, protected SettingsGamification $settings_gamification)
static fromExport(array $data)
Creates an instance of the object from an array.
static fromExport(array $data)
Creates an instance of the object from an array.
static fromExport(array $data)
Creates an instance of the object from an array.
This interface allows an object to define its own transformation into a language-neutral,...
Definition: Exportable.php:40