ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ScoreSettingsTest Class Reference
+ Inheritance diagram for ScoreSettingsTest:
+ Collaboration diagram for ScoreSettingsTest:

Public Member Functions

 testScoreSettingsBuild ()
 
 testScoreSettingsScoring ()
 
 testScoreSettingsSummary ()
 
 testScoreSettingsDetails ()
 
 testScoreSettingsGamification ()
 
 testScoreSettingsSectionScoring ()
 
 getUIFactory ()
 
 testScoreSettingsSectionSummary ()
 
 testScoreSettingsSectionDetails ()
 
 testScoreSettingsSectionGamification ()
 
 testScoreSettingsDirectlyAccessedByTestObj ()
 
- Public Member Functions inherited from ilTestBaseTestCase
 createInstanceOf (string $class_name, array $explicit_parameters=[])
 
 createTraitInstanceOf (string $class_name, array $explicit_parameters=[])
 

Protected Member Functions

 getUIPack ()
 
- Protected Member Functions inherited from ilTestBaseTestCase
 setUp ()
 
 tearDown ()
 

Additional Inherited Members

- Static Public Member Functions inherited from ilTestBaseTestCase
static callMethod ($obj, $name, array $args=[])
 
static getNonPublicPropertyValue (object $obj, string $name)
 
- Data Fields inherited from ilTestBaseTestCase
const string MOCKED_METHOD_WITHOUT_OUTPUT = 'MOCKED_METHOD_WITHOUT_OUTPUT'
 
const string DYNAMIC_CLASS = 'DynamicClass'
 
- Protected Attributes inherited from ilTestBaseTestCase
Container $dic = null
 
Container $backup_dic = null
 
- Static Protected Attributes inherited from ilTestBaseTestCase
static int $DYNAMIC_CLASS_COUNT = 0
 

Detailed Description

Definition at line 33 of file ScoreSettingsTest.php.

Member Function Documentation

◆ getUIFactory()

ScoreSettingsTest::getUIFactory ( )

Definition at line 224 of file ScoreSettingsTest.php.

225 {
226 return new class () extends NoUIFactory {
227 public function symbol(): S\Factory
228 {
229 return new S\Factory(
230 new S\Icon\Factory(),
231 new S\Glyph\Factory(),
232 new S\Avatar\Factory()
233 );
234 }
235 };
236 }

References ILIAS\Repository\symbol().

+ Here is the call graph for this function:

◆ getUIPack()

ScoreSettingsTest::getUIPack ( )
protected

Definition at line 125 of file ScoreSettingsTest.php.

126 {
127 return [
128 $this->getLanguage(),
129 $this->getFieldFactory(),
130 $this->getRefinery()
131 ];
132 }
getLanguage()

References getLanguage().

+ Here is the call graph for this function:

◆ testScoreSettingsBuild()

ScoreSettingsTest::testScoreSettingsBuild ( )

Definition at line 38 of file ScoreSettingsTest.php.

38 : void
39 {
40 $id = -666;
41 $s = new ScoreSettings(
42 $id,
43 new SettingsScoring(),
47 );
48 $this->assertInstanceOf(ScoreSettings::class, $s);
49 $this->assertInstanceOf(SettingsScoring::class, $s->getScoringSettings());
50 $this->assertInstanceOf(SettingsResultSummary::class, $s->getResultSummarySettings());
51 $this->assertInstanceOf(SettingsResultDetails::class, $s->getResultDetailsSettings());
52 $this->assertInstanceOf(SettingsGamification::class, $s->getGamificationSettings());
53 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id.

◆ testScoreSettingsDetails()

ScoreSettingsTest::testScoreSettingsDetails ( )

Definition at line 81 of file ScoreSettingsTest.php.

81 : void
82 {
83 $s = new SettingsResultDetails(-666);
84 $this->assertEquals(192, $s->withResultsPresentation(192)->getResultsPresentation(192));
85 $this->assertTrue($s->withShowExamIdInTestResults(true)->getShowExamIdInTestResults());
86 $this->assertTrue($s->withShowPassDetails(true)->getShowPassDetails());
87 $this->assertFalse($s->withShowPassDetails(false)->getShowPassDetails());
88 $this->assertTrue($s->withShowSolutionPrintview(true)->getShowSolutionPrintview());
89 $this->assertFalse($s->withShowSolutionPrintview(false)->getShowSolutionPrintview());
90 $this->assertTrue($s->withShowSolutionFeedback(true)->getShowSolutionFeedback());
91 $this->assertFalse($s->withShowSolutionFeedback(false)->getShowSolutionFeedback());
92 $this->assertTrue($s->withShowSolutionAnswersOnly(true)->getShowSolutionAnswersOnly());
93 $this->assertFalse($s->withShowSolutionAnswersOnly(false)->getShowSolutionAnswersOnly());
94 $this->assertTrue($s->withShowSolutionSignature(true)->getShowSolutionSignature());
95 $this->assertFalse($s->withShowSolutionSignature(false)->getShowSolutionSignature());
96 $this->assertTrue($s->withShowSolutionSuggested(true)->getShowSolutionSuggested());
97 $this->assertFalse($s->withShowSolutionSuggested(false)->getShowSolutionSuggested());
98 $this->assertTrue($s->withShowSolutionListComparison(true)->getShowSolutionListComparison());
99 $this->assertFalse($s->withShowSolutionListComparison(false)->getShowSolutionListComparison());
100 $this->assertTrue($s->withShowPassDetails(true)->getShowPassDetails());
101 }

◆ testScoreSettingsDirectlyAccessedByTestObj()

ScoreSettingsTest::testScoreSettingsDirectlyAccessedByTestObj ( )

Definition at line 516 of file ScoreSettingsTest.php.

516 : void
517 {
518 $s = new ScoreSettings(
519 0,
520 new SettingsScoring(),
524 );
525
526 $t = new class ($s) extends ilObjTest {
527 public function __construct($s)
528 {
529 $this->score_settings = $s;
530 }
531 };
532
533 $this->assertIsInt($t->getCountSystem());
534 $this->assertIsInt($t->getScoreCutting());
535 $this->assertIsInt($t->getPassScoring());
536 $this->assertIsBool($t->getShowPassDetails());
537 $this->assertIsBool($t->getShowSolutionAnswersOnly());
538 $this->assertIsBool($t->getShowSolutionSignature());
539 $this->assertIsBool($t->getShowSolutionSuggested());
540 $this->assertIsBool($t->getShowSolutionListComparison());
541 $this->assertIsBool($t->isPassDeletionAllowed());
542 $this->assertIsInt($t->getExportSettings());
543 $this->assertIsBool($t->getHighscoreEnabled());
544 $this->assertIsBool($t->getHighscoreAnon());
545 $this->assertIsBool($t->getHighscoreAchievedTS());
546 $this->assertIsBool($t->getHighscoreScore());
547 $this->assertIsBool($t->getHighscorePercentage());
548 $this->assertIsBool($t->getHighscoreWTime());
549 $this->assertIsBool($t->getHighscoreOwnTable());
550 $this->assertIsBool($t->getHighscoreTopTable());
551 $this->assertIsInt($t->getHighscoreTopNum());
552 $this->assertIsInt($t->getHighscoreMode());
553 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

◆ testScoreSettingsGamification()

ScoreSettingsTest::testScoreSettingsGamification ( )

Definition at line 103 of file ScoreSettingsTest.php.

103 : void
104 {
105 $s = new SettingsGamification(-666);
106 $this->assertTrue($s->withHighscoreEnabled(true)->getHighscoreEnabled());
107 $this->assertFalse($s->withHighscoreEnabled(false)->getHighscoreEnabled());
108 $this->assertTrue($s->withHighscoreAnon(true)->getHighscoreAnon());
109 $this->assertFalse($s->withHighscoreAnon(false)->getHighscoreAnon());
110 $this->assertTrue($s->withHighscoreAchievedTS(true)->getHighscoreAchievedTS());
111 $this->assertFalse($s->withHighscoreAchievedTS(false)->getHighscoreAchievedTS());
112 $this->assertTrue($s->withHighscoreScore(true)->getHighscoreScore());
113 $this->assertFalse($s->withHighscoreScore(false)->getHighscoreScore());
114 $this->assertTrue($s->withHighscorePercentage(true)->getHighscorePercentage());
115 $this->assertFalse($s->withHighscorePercentage(false)->getHighscorePercentage());
116 $this->assertTrue($s->withHighscoreWTime(true)->getHighscoreWTime());
117 $this->assertFalse($s->withHighscoreWTime(false)->getHighscoreWTime());
118 $this->assertTrue($s->withHighscoreOwnTable(true)->getHighscoreOwnTable());
119 $this->assertFalse($s->withHighscoreOwnTable(false)->getHighscoreOwnTable());
120 $this->assertTrue($s->withHighscoreTopTable(true)->getHighscoreTopTable());
121 $this->assertFalse($s->withHighscoreTopTable(false)->getHighscoreTopTable());
122 $this->assertEquals(15, $s->withHighscoreTopNum(15)->getHighscoreTopNum());
123 }

◆ testScoreSettingsScoring()

ScoreSettingsTest::testScoreSettingsScoring ( )

Definition at line 55 of file ScoreSettingsTest.php.

55 : void
56 {
57 $s = new SettingsScoring();
58 $this->assertEquals(2, $s->withCountSystem(2)->getCountSystem());
59 $this->assertEquals(4, $s->withScoreCutting(4)->getScoreCutting());
60 $this->assertEquals(5, $s->withPassScoring(5)->getPassScoring());
61 }

◆ testScoreSettingsSectionDetails()

ScoreSettingsTest::testScoreSettingsSectionDetails ( )

Definition at line 384 of file ScoreSettingsTest.php.

384 : void
385 {
386 $s = new SettingsResultDetails(666);
387 $tax_ids = [1,2];
388 $actual = $this->render(
389 $s->toForm(
390 ...array_merge(
391 $this->getUIPack(),
392 [['taxonomy_options' => $tax_ids]]
393 )
394 )
395 );
396 $opts = [
397 ['tst_results_print_best_solution', 'tst_results_print_best_solution_info'],
398 ['tst_show_solution_feedback', 'tst_show_solution_feedback_desc'],
399 ['tst_show_solution_suggested', 'tst_show_solution_suggested_desc'],
400 ['tst_show_solution_printview', 'tst_show_solution_printview_desc'],
401 ['tst_hide_pagecontents', 'tst_hide_pagecontents_desc'],
402 ['tst_show_solution_signature', 'tst_show_solution_signature_desc'],
403 ['examid_in_test_res', 'examid_in_test_res_desc'],
404 ];
405 $options = '';
406 foreach ($opts as $index => $entry) {
407 list($label, $byline) = $entry;
408 $nr = (string) ($index + 1);
409 $checked = $index === 6 ? ' checked="checked"' : '';
410 $field_html = '<input type="checkbox" id="id_' . $nr . '" value="checked"' . $checked . ' class="c-field-checkbox" />';
411 $options .= $this->getFormWrappedHtml(
412 'checkbox-field-input',
413 $label,
414 $field_html,
415 $byline,
416 'id_' . $nr,
417 null,
418 ''
419 );
420 }
421
422 $expected = $this->getFormWrappedHtml(
423 'section-field-input',
424 'tst_results_details_options',
425 $options,
426 null,
427 null,
428 null,
429 ''
430 );
431 $this->assertEquals($expected, $this->brutallyTrimSignals($actual));
432 }

References ILIAS\UI\Implementation\Component\Input\Field\$options.

◆ testScoreSettingsSectionGamification()

ScoreSettingsTest::testScoreSettingsSectionGamification ( )

Definition at line 435 of file ScoreSettingsTest.php.

435 : void
436 {
437 $s = new SettingsGamification(666);
438 $actual = $this->render(
439 $s->toForm(...$this->getUIPack())
440 );
441
442 $fields = $this->getFormWrappedHtml(
443 'radio-field-input',
444 'tst_highscore_mode<span class="asterisk" aria-label="required_field">*</span>',
445 '<div class="c-field-radio">
446 <div class="c-field-radio__item">
447 <input type="radio" id="id_2_1_opt" value="1" /><label for="id_2_1_opt">tst_highscore_own_table</label><div class="c-input__help-byline">tst_highscore_own_table_description</div>
448 </div>
449 <div class="c-field-radio__item">
450 <input type="radio" id="id_2_2_opt" value="2" /><label for="id_2_2_opt">tst_highscore_top_table</label><div class="c-input__help-byline">tst_highscore_top_table_description</div>
451 </div>
452 <div class="c-field-radio__item">
453 <input type="radio" id="id_2_3_opt" value="3" checked="checked" /><label for="id_2_3_opt">tst_highscore_all_tables</label><div class="c-input__help-byline">tst_highscore_all_tables_description</div>
454 </div>
455 </div>',
456 null,
457 null,
458 null,
459 ''
460 );
461 $fields .= $this->getFormWrappedHtml(
462 'numeric-field-input',
463 'tst_highscore_top_num<span class="asterisk" aria-label="required_field">*</span>',
464 '<input id="id_3" type="number" step="1" value="10" class="c-field-number" />',
465 'tst_highscore_top_num_description',
466 'id_3',
467 null,
468 ''
469 );
470
471
472 $opts = [
473 ['tst_highscore_anon', 'tst_highscore_anon_description'],
474 ['tst_highscore_achieved_ts', 'tst_highscore_achieved_ts_description'],
475 ['tst_highscore_score', 'tst_highscore_score_description'],
476 ['tst_highscore_percentage', 'tst_highscore_percentage_description'],
477 ['tst_highscore_wtime', 'tst_highscore_wtime_description']
478 ];
479 foreach ($opts as $index => $entry) {
480 list($label, $byline) = $entry;
481 $nr = (string) ($index + 4);
482 $field_html = '<input type="checkbox" id="id_' . $nr . '" value="checked" checked="checked" class="c-field-checkbox" />';
483 $fields .= $this->getFormWrappedHtml(
484 'checkbox-field-input',
485 $label,
486 $field_html,
487 $byline,
488 'id_' . $nr,
489 null,
490 ''
491 );
492 }
493
494 $group = $this->getFormWrappedHtml(
495 'optional-group-field-input',
496 '<span>tst_highscore_enabled</span><input type="checkbox" id="id_1" value="checked" />',
497 $fields,
498 'tst_highscore_description',
499 'id_1',
500 null,
501 ''
502 );
503
504 $expected = $this->getFormWrappedHtml(
505 'section-field-input',
506 'tst_results_gamification',
507 $group,
508 null,
509 null,
510 null,
511 ''
512 );
513 $this->assertHTMLEquals($expected, $this->brutallyTrimSignals($actual));
514 }

◆ testScoreSettingsSectionScoring()

ScoreSettingsTest::testScoreSettingsSectionScoring ( )

Definition at line 134 of file ScoreSettingsTest.php.

134 : void
135 {
136 $s = new SettingsScoring(666);
137 $actual = $this->render(
138 $s->toForm(...$this->getUIPack())
139 );
140
141 $i1 = $this->getFormWrappedHtml(
142 'radio-field-input',
143 'tst_text_count_system',
144 '
145 <div class="c-field-radio">
146 <div class="c-field-radio__item">
147 <input type="radio" id="id_1_0_opt" value="0" checked="checked" />
148 <label for="id_1_0_opt">tst_count_partial_solutions</label>
149 <div class="c-input__help-byline">tst_count_partial_solutions_desc</div>
150 </div>
151
152 <div class="c-field-radio__item">
153 <input type="radio" id="id_1_1_opt" value="1" />
154 <label for="id_1_1_opt">tst_count_correct_solutions</label>
155 <div class="c-input__help-byline">tst_count_correct_solutions_desc</div>
156 </div>
157 </div>
158 ',
159 null,
160 null,
161 null,
162 ''
163 );
164 $i2 = $this->getFormWrappedHtml(
165 'radio-field-input',
166 'tst_score_cutting',
167 '
168 <div class="c-field-radio">
169 <div class="c-field-radio__item">
170 <input type="radio" id="id_2_0_opt" value="0" checked="checked" />
171 <label for="id_2_0_opt">tst_score_cut_question</label>
172 <div class="c-input__help-byline">tst_score_cut_question_desc</div>
173 </div>
174
175 <div class="c-field-radio__item">
176 <input type="radio" id="id_2_1_opt" value="1" />
177 <label for="id_2_1_opt">tst_score_cut_test</label>
178 <div class="c-input__help-byline">tst_score_cut_test_desc</div>
179 </div>
180 </div>
181 ',
182 null,
183 null,
184 null,
185 ''
186 );
187 $i3 = $this->getFormWrappedHtml(
188 'radio-field-input',
189 'tst_pass_scoring',
190 '
191 <div class="c-field-radio">
192 <div class="c-field-radio__item">
193 <input type="radio" id="id_3_0_opt" value="0" checked="checked" />
194 <label for="id_3_0_opt">tst_pass_last_pass</label>
195 <div class="c-input__help-byline">tst_pass_last_pass_desc</div>
196 </div>
197
198 <div class="c-field-radio__item">
199 <input type="radio" id="id_3_1_opt" value="1" />
200 <label for="id_3_1_opt">tst_pass_best_pass</label>
201 <div class="c-input__help-byline">tst_pass_best_pass_desc</div>
202 </div>
203 </div>
204 ',
205 null,
206 null,
207 null,
208 ''
209 );
210
211 $expected = $this->getFormWrappedHtml(
212 'section-field-input',
213 'test_scoring',
214 $i1 . $i2 . $i3,
215 null,
216 null,
217 null,
218 ''
219 );
220 $this->assertHTMLEquals($expected, $this->brutallyTrimSignals($actual));
221 }

◆ testScoreSettingsSectionSummary()

ScoreSettingsTest::testScoreSettingsSectionSummary ( )

Definition at line 238 of file ScoreSettingsTest.php.

238 : void
239 {
240 $data_factory = new \ILIAS\Data\Factory();
241 $language = $this->getLanguage();
242 $refinery = new \ILIAS\Refinery\Factory($data_factory, $language);
243
245 $this->createMock(\ILIAS\UI\Implementation\Component\Input\Field\Node\Factory::class),
246 $this->createMock(\ILIAS\UI\Implementation\Component\Input\UploadLimitResolver::class),
247 new \ILIAS\UI\Implementation\Component\SignalGenerator(),
248 $data_factory,
249 $refinery,
250 $language
251 );
252 $ui = [$language, $field_factory, $refinery];
253
254 $s = new SettingsResultSummary(666);
255 $actual = $this->render(
256 $s->toForm(...array_merge($ui, [[
257 'user_time_zone' => 'Europe/Berlin',
258 'user_date_format' => $data_factory->dateFormat()->withTime24(
259 $data_factory->dateFormat()->standard()
260 )
261 ]]))
262 );
263
264 $i1_1_1 = $this->getFormWrappedHtml(
265 'group-field-input',
266 '<input type="radio" id="id_2" value="2" /><span>tst_results_access_always</span>',
267 '',
268 'tst_results_access_always_desc',
269 'id_2',
270 null,
271 ''
272 );
273 $i1_1_2 = $this->getFormWrappedHtml(
274 'group-field-input',
275 '<input type="radio" id="id_3" value="1" /><span>tst_results_access_finished</span>',
276 '',
277 'tst_results_access_finished_desc',
278 'id_3',
279 null,
280 ''
281 );
282 $i1_1_3 = $this->getFormWrappedHtml(
283 'group-field-input',
284 '<input type="radio" id="id_4" value="4" /><span>tst_results_access_passed</span>',
285 '',
286 'tst_results_access_passed_desc',
287 'id_4',
288 null,
289 ''
290 );
291
292 $i1_1_4_1 = $this->getFormWrappedHtml(
293 'date-time-field-input',
294 'tst_reporting_date<span class="asterisk" aria-label="required_field">*</span>',
295 '<div class="c-input-group">
296 <input id="id_6" type="datetime-local" class="c-field-datetime" />
297 </div>',
298 null,
299 'id_6',
300 null,
301 ''
302 );
303
304 $i1_1_4 = $this->getFormWrappedHtml(
305 'group-field-input',
306 '<input type="radio" id="id_5" value="3" /><span>tst_results_access_date</span><span class="asterisk" aria-label="required_field">*</span>',
307 $i1_1_4_1,
308 'tst_results_access_date_desc',
309 'id_5',
310 null,
311 ''
312 );
313
314 $i1_1 = $this->getFormWrappedHtml(
315 'switchable-group-field-input',
316 'tst_results_access_setting<span class="asterisk" aria-label="required_field">*</span>',
317 $i1_1_1 . $i1_1_2 . $i1_1_3 . $i1_1_4,
318 null,
319 null,
320 null,
321 ''
322 );
323
324 $i1_2 = $this->getFormWrappedHtml(
325 'checkbox-field-input',
326 'tst_results_grading_opt_show_status',
327 '<input type="checkbox" id="id_7" value="checked" class="c-field-checkbox" />',
328 'tst_results_grading_opt_show_status_desc',
329 'id_7',
330 null,
331 ''
332 );
333 $i1_3 = $this->getFormWrappedHtml(
334 'checkbox-field-input',
335 'tst_results_grading_opt_show_mark',
336 '<input type="checkbox" id="id_8" value="checked" class="c-field-checkbox" />',
337 'tst_results_grading_opt_show_mark_desc',
338 'id_8',
339 null,
340 ''
341 );
342 $i1_4 = $this->getFormWrappedHtml(
343 'checkbox-field-input',
344 'tst_results_grading_opt_show_details',
345 '<input type="checkbox" id="id_9" value="checked" class="c-field-checkbox" />',
346 'tst_results_grading_opt_show_details_desc',
347 'id_9',
348 null,
349 ''
350 );
351 $i1_5 = $this->getFormWrappedHtml(
352 'checkbox-field-input',
353 'tst_pass_deletion',
354 '<input type="checkbox" id="id_10" value="checked" class="c-field-checkbox" />',
355 'tst_pass_deletion_allowed',
356 'id_10',
357 null,
358 ''
359 );
360
361 $i1 = $this->getFormWrappedHtml(
362 'optional-group-field-input',
363 '<span>tst_results_access_enabled</span><input type="checkbox" id="id_1" value="checked" />',
364 $i1_1 . $i1_2 . $i1_3 . $i1_4 . $i1_5,
365 'tst_results_access_enabled_desc',
366 'id_1',
367 null,
368 ''
369 );
370
371 $expected = $this->getFormWrappedHtml(
372 'section-field-input',
373 'test_results',
374 $i1,
375 null,
376 null,
377 null,
378 ''
379 );
380 $this->assertEquals($expected, $this->brutallyTrimSignals($actual));
381 }
Factory for Date Formats.
Definition: Factory.php:27
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References ILIAS\UI\examples\Layout\Page\Mail\$refinery, and getLanguage().

+ Here is the call graph for this function:

◆ testScoreSettingsSummary()

ScoreSettingsTest::testScoreSettingsSummary ( )

Definition at line 63 of file ScoreSettingsTest.php.

63 : void
64 {
65 $dat = new \DateTimeImmutable();
66 $s = new SettingsResultSummary(-666);
67 $this->assertEquals(
68 ScoreReportingTypes::SCORE_REPORTING_AFTER_PASSED,
69 $s->withScoreReporting(ScoreReportingTypes::SCORE_REPORTING_AFTER_PASSED)->getScoreReporting()
70 );
71 $this->assertTrue($s->withShowGradingStatusEnabled(true)->getShowGradingStatusEnabled());
72 $this->assertFalse($s->withShowGradingStatusEnabled(false)->getShowGradingStatusEnabled());
73 $this->assertTrue($s->withShowGradingMarkEnabled(true)->getShowGradingMarkEnabled());
74 $this->assertFalse($s->withShowGradingMarkEnabled(false)->getShowGradingMarkEnabled());
75 $this->assertTrue($s->withPassDeletionAllowed(true)->getPassDeletionAllowed());
76 $this->assertFalse($s->withPassDeletionAllowed(false)->getPassDeletionAllowed());
77 $this->assertTrue($s->withShowPassDetails(true)->getShowPassDetails());
78 $this->assertFalse($s->withShowPassDetails(false)->getShowPassDetails());
79 }

The documentation for this class was generated from the following file: