ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
GradesRetrieval.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use ILIAS\Repository\RetrievalBase;
28
30{
31 use RetrievalBase;
32
36 public function __construct(
37 protected InternalDomainService $domain,
38 protected \ilObjExercise $exercise,
39 protected \ilExerciseMembers $members,
40 protected array $assignments
41 ) {
42 }
43
44 public function getData(
45 array $fields,
46 ?Range $range = null,
47 ?Order $order = null,
48 array $filter = [],
49 array $parameters = []
50 ): \Generator {
51 $data = $this->collectData();
52 $data = $this->applyOrder($data, $order ?? new Order('name', Order::ASC));
53 $data = $this->applyRange($data, $range);
54
55 foreach ($data as $row) {
56 yield $row;
57 }
58 }
59
60 public function count(array $filter = [], array $parameters = []): int
61 {
62 return count($this->collectData());
63 }
64
65 public function isFieldNumeric(string $field): bool
66 {
67 return $field === 'id';
68 }
69
70 protected function collectData(): array
71 {
72 $data = [];
73 $user_ids = $this->domain->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
74 'edit_submissions_grades',
75 'edit_submissions_grades',
76 $this->exercise->getRefId(),
77 $this->members->getMembers()
78 );
79
80 foreach ($user_ids as $user_id) {
82 $row = [
83 'id' => (int) $user_id,
84 'name' => $user['lastname'] . ', ' . $user['firstname'],
85 'login' => $user['login'],
86 'mark' => (string) \ilLPMarks::_lookupMark($user_id, $this->exercise->getId()),
87 'remark' => (string) \ilLPMarks::_lookupComment($user_id, $this->exercise->getId()),
88 'total' => \ilExerciseMembers::_lookupStatus($this->exercise->getId(), $user_id)
89 ];
90
91 foreach ($this->assignments as $assignment) {
92 $status = new \ilExAssignmentMemberStatus($assignment->getId(), $user_id);
93 $row['assignment_' . $assignment->getId()] = $status->getStatus();
94 }
95
96 $data[] = $row;
97 }
98
99 return $data;
100 }
101}
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
__construct(protected InternalDomainService $domain, protected \ilObjExercise $exercise, protected \ilExerciseMembers $members, protected array $assignments)
getData(array $fields, ?Range $range=null, ?Order $order=null, array $filter=[], array $parameters=[])
count(array $filter=[], array $parameters=[])
Class ilExerciseMembers.
static _lookupStatus(int $a_obj_id, int $a_user_id)
Lookup current status (notgraded|passed|failed)
static _lookupComment(int $a_usr_id, int $a_obj_id)
static _lookupMark(int $a_usr_id, int $a_obj_id)
Class ilObjExercise.
static _lookupName(int $a_user_id)
$data
Definition: storeScorm.php:45
ilObjExercise $exercise