ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
28{
29 protected int $test_id;
30 protected SettingsScoring $settings_scoring;
34
35 public function __construct(
36 int $test_id,
37 SettingsScoring $settings_scoring,
41 ) {
42 $this->test_id = $test_id;
43
44 foreach ([
49 ] as $setting) {
50 $this->throwOnDifferentTestId($setting);
51 }
52
55
56 $this->settings_scoring = $settings_scoring;
57 $this->settings_result_summary = $settings_result_summary;
58 $this->settings_result_details = $settings_result_details;
59 $this->settings_gamification = $settings_gamification;
60 }
61
63 {
64 if ($setting->getTestId() !== $this->getTestId()) {
65 throw new \LogicException('TestId mismatch in ' . get_class($setting));
66 }
67 }
68
69 public function getTestId(): int
70 {
71 return $this->test_id;
72 }
73 public function withTestId(int $test_id): self
74 {
75 $clone = clone $this;
76 $clone->test_id = $test_id;
77 $clone->settings_scoring = $clone->settings_scoring->withTestId($test_id);
78 $clone->settings_result_summary = $clone->settings_result_summary->withTestId($test_id);
79 $clone->settings_result_details = $clone->settings_result_details->withTestId($test_id);
80 $clone->settings_gamification = $clone->settings_gamification->withTestId($test_id);
81 return $clone;
82 }
83
84
85 public function getScoringSettings(): SettingsScoring
86 {
88 }
89 public function withScoringSettings(SettingsScoring $settings): self
90 {
91 $this->throwOnDifferentTestId($settings);
92 $clone = clone $this;
93 $clone->settings_scoring = $settings;
94 return $clone;
95 }
96
98 {
100 }
101 public function withResultSummarySettings(SettingsResultSummary $settings): self
102 {
103 $this->throwOnDifferentTestId($settings);
104 $clone = clone $this;
105 $clone->settings_result_summary = $settings;
106 return $clone;
107 }
108
110 {
112 }
113 public function withResultDetailsSettings(SettingsResultDetails $settings): self
114 {
115 $this->throwOnDifferentTestId($settings);
116 $clone = clone $this;
117 $clone->settings_result_details = $settings;
118 return $clone;
119 }
120
122 {
124 }
125
126 public function withGamificationSettings(SettingsGamification $settings): self
127 {
128 $this->throwOnDifferentTestId($settings);
129 $clone = clone $this;
130 $clone->settings_gamification = $settings;
131 return $clone;
132 }
133
134 public function getArrayForLog(
135 AdditionalInformationGenerator $additional_info
136 ): array {
137 return $this->settings_scoring->toLog($additional_info)
138 + $this->settings_result_summary->toLog($additional_info)
139 + $this->settings_result_details->toLog($additional_info)
140 + $this->settings_gamification->toLog($additional_info);
141 }
142}
getArrayForLog(AdditionalInformationGenerator $additional_info)
withResultDetailsSettings(SettingsResultDetails $settings)
withGamificationSettings(SettingsGamification $settings)
__construct(int $test_id, SettingsScoring $settings_scoring, SettingsResultSummary $settings_result_summary, SettingsResultDetails $settings_result_details, SettingsGamification $settings_gamification)
withResultSummarySettings(SettingsResultSummary $settings)
ilSetting $setting
Definition: class.ilias.php:68
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...