ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilTestRandomQuestionsSrcPoolDefinitionQuantitiesCalculation.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
28 {
30  protected int $overallQuestionAmount;
31  protected int $exclusiveQuestionAmount;
33 
34  public function __construct(
35  protected readonly ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition
36  ) {
37  }
38 
40  {
41  return $this->sourcePoolDefinition;
42  }
43 
45  {
47  }
48 
50  ilTestRandomQuestionSetSourcePoolDefinitionList $intersectionQuantitySharingDefinitionList
51  ): void {
52  $this->intersectionQuantitySharingDefinitionList = $intersectionQuantitySharingDefinitionList;
53  }
54 
55  public function getOverallQuestionAmount(): int
56  {
58  }
59 
60  public function setOverallQuestionAmount(int $overallQuestionAmount): void
61  {
62  $this->overallQuestionAmount = $overallQuestionAmount;
63  }
64 
65  public function getExclusiveQuestionAmount(): int
66  {
68  }
69 
70  public function setExclusiveQuestionAmount(int $exclusiveQuestionAmount): void
71  {
72  $this->exclusiveQuestionAmount = $exclusiveQuestionAmount;
73  }
74 
76  {
78  }
79 
80  public function setAvailableSharedQuestionAmount(int $availableSharedQuestionAmount): void
81  {
82  $this->availableSharedQuestionAmount = $availableSharedQuestionAmount;
83  }
84 
85  protected function getReservedSharedQuestionAmount(): int
86  {
87  return $this->getOverallQuestionAmount() - (
89  );
90  }
91 
93  {
94  $requiredQuestionAmount = $this->getSourcePoolDefinition()->getQuestionAmount();
95  $exclusiveQuestionAmount = $this->getExclusiveQuestionAmount();
96 
97  return $requiredQuestionAmount - $exclusiveQuestionAmount;
98  }
99 
101  {
102  $requiredQuestionAmount = $this->getSourcePoolDefinition()->getQuestionAmount();
103  $overallQuestionAmount = $this->getOverallQuestionAmount();
104 
105  return $overallQuestionAmount >= $requiredQuestionAmount;
106  }
107 
109  {
110  $requiredQuestionAmount = $this->getSourcePoolDefinition()->getQuestionAmount();
111  $exclusiveQuestionAmount = $this->getExclusiveQuestionAmount();
112 
113  return $exclusiveQuestionAmount >= $requiredQuestionAmount;
114  }
115 
117  {
118  $remainingRequiredQuestionAmount = $this->getRemainingRequiredQuestionAmount();
119  $availableSharedQuestionAmount = $this->getAvailableSharedQuestionAmount();
120 
121  return $availableSharedQuestionAmount >= $remainingRequiredQuestionAmount;
122  }
123 
124  protected function sourcePoolDefinitionIntersectionsExist(): bool
125  {
126  if ($this->getIntersectionQuantitySharingDefinitionList()->getDefinitionCount() > 0) {
127  return true;
128  }
129 
130  return false;
131  }
132 
133  public function isRequiredAmountGuaranteedAvailable(): bool
134  {
136  return true;
137  }
138 
140  return true;
141  }
142 
143  return false;
144  }
145 
146  public function getDistributionReport(ilLanguage $lng): string
147  {
148  $report = $this->getRuleSatisfactionResultMessage($lng);
149 
151  $report .= ' ' . $this->getConcurrentRuleConflictMessage($lng);
152  }
153 
154  return $report;
155  }
156 
158  {
160  return sprintf(
161  $lng->txt('tst_msg_rand_quest_set_rule_not_satisfied_reserved'),
162  $this->getSourcePoolDefinition()->getSequencePosition(),
163  $this->getSourcePoolDefinition()->getQuestionAmount(),
164  $this->getOverallQuestionAmount()
165  );
166  }
167 
168  return sprintf(
169  $lng->txt('tst_msg_rand_quest_set_rule_not_satisfied_missing'),
170  $this->getSourcePoolDefinition()->getSequencePosition(),
171  $this->getSourcePoolDefinition()->getQuestionAmount(),
172  $this->getOverallQuestionAmount()
173  );
174  }
175 
177  {
178  $definitionsString = '<br />' . $this->buildIntersectionQuestionSharingDefinitionsString($lng);
179 
181  return sprintf(
182  $lng->txt('tst_msg_rand_quest_set_rule_not_satisfied_reserved_shared'),
184  $definitionsString
185  );
186  }
187 
188  return sprintf(
189  $lng->txt('tst_msg_rand_quest_set_rule_not_satisfied_missing_shared'),
191  $definitionsString
192  );
193  }
194 
196  {
197  $definitionsString = [];
198 
199  foreach ($this->getIntersectionQuantitySharingDefinitionList() as $definition) {
200  $definitionsString[] = sprintf(
201  $lng->txt('tst_msg_rand_quest_set_rule_label'),
202  $definition->getSequencePosition()
203  );
204  }
205 
206  $definitionsString = '<ul><li>' . implode('</li><li>', $definitionsString) . '</li></ul>';
207  return $definitionsString;
208  }
209 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setIntersectionQuantitySharingDefinitionList(ilTestRandomQuestionSetSourcePoolDefinitionList $intersectionQuantitySharingDefinitionList)
__construct(protected readonly ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition)
global $lng
Definition: privfeed.php:32