ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ILIAS\Course\Grouping\Table\AssignmentRetrieval Class Reference
+ Inheritance diagram for ILIAS\Course\Grouping\Table\AssignmentRetrieval:
+ Collaboration diagram for ILIAS\Course\Grouping\Table\AssignmentRetrieval:

Public Member Functions

 __construct (protected int $content_obj_id, protected ilObjCourseGrouping $grouping, protected ilObjUser $user, protected ilTree $tree, protected UIFactory $ui_factory, protected ilLanguage $lng, protected DataFactory $data_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.g. More...
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 
 getAllEligibleRefIDs ()
 

Protected Member Functions

 buildPath (ReferenceId $ref_id)
 
 sortRecords (array $records, Order $order)
 

Detailed Description

Definition at line 38 of file AssignmentRetrieval.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Course\Grouping\Table\AssignmentRetrieval::__construct ( protected int  $content_obj_id,
protected ilObjCourseGrouping  $grouping,
protected ilObjUser  $user,
protected ilTree  $tree,
protected UIFactory  $ui_factory,
protected ilLanguage  $lng,
protected DataFactory  $data_factory 
)

Definition at line 40 of file AssignmentRetrieval.php.

48  {
49  }

Member Function Documentation

◆ buildPath()

ILIAS\Course\Grouping\Table\AssignmentRetrieval::buildPath ( ReferenceId  $ref_id)
protected

Definition at line 120 of file AssignmentRetrieval.php.

References ILIAS\Data\ReferenceId\toInt().

Referenced by ILIAS\Course\Grouping\Table\AssignmentRetrieval\getRows().

120  : string
121  {
122  $titles = [];
123  foreach ($this->tree->getPathFull($ref_id->toInt()) as $step) {
124  $titles[] = $step['title'];
125  }
126  return implode(' > ', $titles);
127  }
$ref_id
Definition: ltiauth.php:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllEligibleRefIDs()

ILIAS\Course\Grouping\Table\AssignmentRetrieval::getAllEligibleRefIDs ( )
Returns
ReferenceId[]

Definition at line 100 of file AssignmentRetrieval.php.

References ilUtil\_getObjectsByOperations(), ilObject\_lookupType(), and ILIAS\Repository\user().

Referenced by ILIAS\Course\Grouping\Table\AssignmentRetrieval\getRows(), and ILIAS\Course\Grouping\Table\AssignmentRetrieval\getTotalRowCount().

100  : array
101  {
102  $type = ilObject::_lookupType($this->content_obj_id);
103  $item_ref_ids = ilUtil::_getObjectsByOperations(
104  $type,
105  'write',
106  $this->user->getId(),
107  -1
108  );
109 
110  $filtered_ref_ids = [];
111  foreach ($item_ref_ids as $item_ref_id) {
112  if ($this->tree->checkForParentType($item_ref_id, 'adm')) {
113  continue;
114  }
115  $filtered_ref_ids[] = $this->data_factory->refId($item_ref_id);
116  }
117  return $filtered_ref_ids;
118  }
static _getObjectsByOperations( $a_obj_type, string $a_operation, int $a_usr_id=0, int $limit=0)
Get all objects of a specific type and check access This function is not recursive, instead it parses the serialized rbac_pa entries.
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRows()

ILIAS\Course\Grouping\Table\AssignmentRetrieval::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.g.

yield $row_builder->buildStandardRow($row_id, $record).

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 51 of file AssignmentRetrieval.php.

References $ref_id, ilObject\_lookupTitle(), ILIAS\UI\Component\Table\DataRowBuilder\buildDataRow(), ILIAS\Course\Grouping\Table\AssignmentRetrieval\buildPath(), ILIAS\Course\Grouping\Table\AssignmentHandler\COL_ASSIGNED, ILIAS\Course\Grouping\Table\AssignmentHandler\COL_PATH, ILIAS\Course\Grouping\Table\AssignmentHandler\COL_TITLE, ILIAS\Course\Grouping\Table\AssignmentRetrieval\getAllEligibleRefIDs(), ILIAS\Data\Range\getLength(), ILIAS\Data\Range\getStart(), ILIAS\Repository\lng(), and ILIAS\Course\Grouping\Table\AssignmentRetrieval\sortRecords().

58  : Generator {
59  $ref_ids = $this->getAllEligibleRefIDs();
60 
61  $assigned = $this->grouping->getAssignedItems();
62  $assigned_ref_ids = [];
63  foreach ($assigned as $item) {
64  $assigned_ref_ids[] = $item['target_ref_id'];
65  }
66 
67  $ok_icon = $this->ui_factory->symbol()->icon()->custom(
68  'assets/images/standard/icon_ok.svg',
69  $this->lng->txt('assigned')
70  );
71 
72  $records = [];
73  foreach ($ref_ids as $ref_id) {
74  $record = [
75  AssignmentHandler::COL_TITLE => ilObject::_lookupTitle($ref_id->toObjectId()->toInt()),
76  AssignmentHandler::COL_PATH => $this->buildPath($ref_id),
77  ];
78  if (in_array($ref_id->toInt(), $assigned_ref_ids)) {
79  $record[AssignmentHandler::COL_ASSIGNED] = $ok_icon;
80  }
81  $records[$ref_id->toInt()] = $record;
82  }
83 
84  $records = $this->sortRecords($records, $order);
85  $records = array_slice($records, $range->getStart(), $range->getLength(), true);
86 
87  foreach ($records as $ref_id => $record) {
88  yield $row_builder->buildDataRow((string) $ref_id, $record);
89  }
90  }
$ref_id
Definition: ltiauth.php:65
static _lookupTitle(int $obj_id)
+ Here is the call graph for this function:

◆ getTotalRowCount()

ILIAS\Course\Grouping\Table\AssignmentRetrieval::getTotalRowCount ( ?array  $filter_data,
?array  $additional_parameters 
)

Mainly for the purpose of pagination-support, it is important to know about the total number of records available.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 92 of file AssignmentRetrieval.php.

References ILIAS\Course\Grouping\Table\AssignmentRetrieval\getAllEligibleRefIDs().

92  : ?int
93  {
94  return count($this->getAllEligibleRefIDs());
95  }
+ Here is the call graph for this function:

◆ sortRecords()

ILIAS\Course\Grouping\Table\AssignmentRetrieval::sortRecords ( array  $records,
Order  $order 
)
protected

Definition at line 129 of file AssignmentRetrieval.php.

References Vendor\Package\$a, Vendor\Package\$b, ILIAS\Data\Order\ASC, ILIAS\Course\Grouping\Table\AssignmentHandler\COL_ASSIGNED, ILIAS\Course\Grouping\Table\AssignmentHandler\COL_PATH, ILIAS\Course\Grouping\Table\AssignmentHandler\COL_TITLE, and ILIAS\Data\Order\get().

Referenced by ILIAS\Course\Grouping\Table\AssignmentRetrieval\getRows().

129  : array
130  {
131  $order_field = array_keys($order->get())[0] ?? AssignmentHandler::COL_TITLE;
132  $order_direction = $order->get()[$order_field] ?? Order::ASC;
133 
134  $ordering_callable_without_direction = match ($order_field) {
136  fn($a, $b) => $a[$order_field] ?? '' <=> $b[$order_field] ?? '',
138  fn($a, $b) => isset($a[$order_field]) <=> isset($b[$order_field])
139  };
140  $ordering_callable = fn($a, $b) => $order_direction === Order::ASC ?
141  $ordering_callable_without_direction($a, $b) :
142  $ordering_callable_without_direction($b, $a);
143 
144  uasort($records, $ordering_callable);
145  return $records;
146  }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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