ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
MarkSchemaFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24{
28 public function createMarkSchemaFromDBRow(array $rows, int $test_id): MarkSchema
29 {
30 if ($rows === []) {
31 return $this->createSimpleSchema($test_id);
32 }
33
34 $schema = new MarkSchema($test_id);
35
36 $mark_steps = [];
37 foreach ($rows as $mark) {
38 $mark_steps[] = new Mark(
39 $mark['short_name'],
40 $mark['official_name'],
41 (float) $mark['minimum_level'],
42 (bool) $mark['passed']
43 );
44 }
45
46 return $schema->withMarkSteps($mark_steps);
47 }
48
65 public function createSimpleSchema(
66 int $test_id,
67 string $txt_failed_short = 'failed',
68 string $txt_failed_official = 'failed',
69 float $percentage_failed = 0,
70 bool $failed_passed = false,
71 string $txt_passed_short = 'passed',
72 string $txt_passed_official = 'passed',
73 float $percentage_passed = 50,
74 bool $passed_passed = true
75 ): MarkSchema {
76 return (new MarkSchema($test_id))->withMarkSteps([
77 new Mark($txt_failed_short, $txt_failed_official, $percentage_failed, $failed_passed),
78 new Mark($txt_passed_short, $txt_passed_official, $percentage_passed, $passed_passed)
79 ]);
80 }
81}
createSimpleSchema(int $test_id, string $txt_failed_short='failed', string $txt_failed_official='failed', float $percentage_failed=0, bool $failed_passed=false, string $txt_passed_short='passed', string $txt_passed_official='passed', float $percentage_passed=50, bool $passed_passed=true)
Creates a simple mark schema for two mark steps: failed and passed.
createMarkSchemaFromDBRow(array $rows, int $test_id)
A class defining mark schemas for assessment test objects.
Definition: MarkSchema.php:37
A class defining marks for assessment test objects.
Definition: Mark.php:37
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...