ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjTestScoreSettings.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  protected int $test_id;
28 
29  public function __construct(
30  int $test_id,
31  ilObjTestSettingsScoring $settings_scoring,
32  ilObjTestSettingsResultSummary $settings_result_summary,
33  ilObjTestSettingsResultDetails $settings_result_details,
34  ilObjTestSettingsGamification $settings_gamification
35  ) {
36  $this->test_id = $test_id;
37 
38  foreach ([
39  $settings_scoring,
40  $settings_result_summary,
41  $settings_result_details,
42  $settings_gamification
43  ] as $setting) {
44  $this->throwOnDifferentTestId($setting);
45  }
46 
47  $settings_result_summary = $settings_result_summary
48  ->withShowPassDetails($settings_result_details->getShowPassDetails());
49 
50  $this->settings_scoring = $settings_scoring;
51  $this->settings_result_summary = $settings_result_summary;
52  $this->settings_result_details = $settings_result_details;
53  $this->settings_gamification = $settings_gamification;
54  }
55 
56  protected function throwOnDifferentTestId(TestSettings $setting)
57  {
58  if ($setting->getTestId() !== $this->getTestId()) {
59  throw new \LogicException('TestId mismatch in ' . get_class($setting));
60  }
61  }
62 
63  public function getTestId(): int
64  {
65  return $this->test_id;
66  }
67  public function withTestId(int $test_id): self
68  {
69  $clone = clone $this;
70  $clone->test_id = $test_id;
71  $clone->settings_scoring = $clone->settings_scoring->withTestId($test_id);
72  $clone->settings_result_summary = $clone->settings_result_summary->withTestId($test_id);
73  $clone->settings_result_details = $clone->settings_result_details->withTestId($test_id);
74  $clone->settings_gamification = $clone->settings_gamification->withTestId($test_id);
75  return $clone;
76  }
77 
78 
80  {
82  }
84  {
85  $this->throwOnDifferentTestId($settings);
86  $clone = clone $this;
87  $clone->settings_scoring = $settings;
88  return $clone;
89  }
90 
92  {
94  }
96  {
97  $this->throwOnDifferentTestId($settings);
98  $clone = clone $this;
99  $clone->settings_result_summary = $settings;
100  return $clone;
101  }
102 
104  {
106  }
108  {
109  $this->throwOnDifferentTestId($settings);
110  $clone = clone $this;
111  $clone->settings_result_details = $settings;
112  return $clone;
113  }
114 
116  {
118  }
120  {
121  $this->throwOnDifferentTestId($settings);
122  $clone = clone $this;
123  $clone->settings_gamification = $settings;
124  return $clone;
125  }
126 }
withScoringSettings(ilObjTestSettingsScoring $settings)
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
withGamificationSettings(ilObjTestSettingsGamification $settings)
withResultSummarySettings(ilObjTestSettingsResultSummary $settings)
ilObjTestSettingsResultSummary $settings_result_summary
__construct(int $test_id, ilObjTestSettingsScoring $settings_scoring, ilObjTestSettingsResultSummary $settings_result_summary, ilObjTestSettingsResultDetails $settings_result_details, ilObjTestSettingsGamification $settings_gamification)
ilObjTestSettingsGamification $settings_gamification
ilObjTestSettingsScoring $settings_scoring
withResultDetailsSettings(ilObjTestSettingsResultDetails $settings)
ilObjTestSettingsResultDetails $settings_result_details
throwOnDifferentTestId(TestSettings $setting)