ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
MarkSchemaTable.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Test\Scoring\Marks;
22 
31 
33 {
34  public const DELETE_ACTION_NAME = 'delete';
35  public const EDIT_ACTION_NAME = 'edit';
36 
37  public function __construct(
38  private MarkSchema $mark_schema,
39  private bool $marks_editable,
40  private \ilLanguage $lng,
41  private URLBuilder $url_builder,
42  private URLBuilderToken $action_parameter_token,
43  private URLBuilderToken $row_id_token,
44  private UIFactory $ui_factory
45  ) {
46  }
47 
48  public function getTable(): DataTable
49  {
50  $f = $this->ui_factory->table();
51 
52  $table = $f->data(
53  $this,
54  $this->lng->txt('mark_schema'),
55  [
56  'name' => $f->column()->text($this->lng->txt('tst_mark_short_form')),
57  'official_name' => $f->column()->text($this->lng->txt('tst_mark_official_form')),
58  'minimum_level' => $f->column()->text($this->lng->txt('tst_mark_minimum_level')),
59  'passed' => $f->column()->boolean(
60  $this->lng->txt('tst_mark_passed'),
61  $this->ui_factory->symbol()->icon()->custom(
62  'assets/images/standard/icon_checked.svg',
63  $this->lng->txt('yes'),
64  'small'
65  ),
66  $this->ui_factory->symbol()->icon()->custom(
67  'assets/images/standard/icon_unchecked.svg',
68  $this->lng->txt('no'),
69  'small'
70  )
71  )
72  ],
73  );
74 
75  if (!$this->marks_editable) {
76  return $table;
77  }
78 
79  return $table->withActions(
80  [
81  self::EDIT_ACTION_NAME => $f->action()->single(
82  $this->lng->txt('edit'),
83  $this->url_builder->withParameter($this->action_parameter_token, self::EDIT_ACTION_NAME),
84  $this->row_id_token
85  )->withAsync(),
86  self::DELETE_ACTION_NAME => $f->action()->single(
87  $this->lng->txt('delete'),
88  $this->url_builder->withParameter($this->action_parameter_token, self::DELETE_ACTION_NAME),
89  $this->row_id_token
90  )->withAsync()
91  ]
92  );
93  }
94 
95  public function getRows(
96  DataRowBuilder $row_builder,
97  array $visible_column_ids,
98  Range $range,
99  Order $order,
100  ?array $filter_data,
101  ?array $additional_parameters
102  ): \Generator {
103  foreach ($this->mark_schema->getMarkSteps() as $index => $mark) {
104  yield $row_builder->buildDataRow(
105  (string) $index,
106  [
107  'name' => $mark->getShortName(),
108  'official_name' => $mark->getOfficialName(),
109  'minimum_level' => $mark->getMinimumLevel(),
110  'passed' => $mark->getPassed()
111  ]
112  )->withDisabledAction('edit', !$this->marks_editable)
113  ->withDisabledAction(
114  'delete',
115  !$this->marks_editable
116  || $mark->getMinimumLevel() === 0.0 && $this->mark_schema->hasSingleZeroPercentageMark()
117  || $mark->getPassed() && $this->mark_schema->hasSinglePassedMark()
118  );
119  }
120  }
121 
122  public function getTotalRowCount(
123  ?array $filter_data,
124  ?array $additional_parameters
125  ): ?int {
126  return count($this->mark_schema->getMarkSteps());
127  }
128 }
A class defining mark schemas for assessment test objects.
Definition: MarkSchema.php:35
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Both the subject and the direction need to be specified when expressing an order. ...
Definition: Order.php:28
buildDataRow(string $id, array $record)
__construct(private MarkSchema $mark_schema, private bool $marks_editable, private \ilLanguage $lng, private URLBuilder $url_builder, private URLBuilderToken $action_parameter_token, private URLBuilderToken $row_id_token, private UIFactory $ui_factory)
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
This is called by the table to retrieve rows; map data-records to rows using the $row_builder e...
global $lng
Definition: privfeed.php:31
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
URLBuilder.
Definition: URLBuilder.php:40
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:28