ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLPStatusStudyProgramme.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected static function getAssignments(int $obj_id, ?int $usr_id = null): array
24 {
26 $repo = $dic['repo.assignment'];
27
28 if ($usr_id) {
29 $usr_id = [$usr_id];
30 }
31 $assignments = $repo->getAllForNodeIsContained((int) $obj_id, $usr_id);
32
33 //restarted assignments will lose validity for LPStatus
34 $assignments = array_filter($assignments, fn($ass) => !$ass->isRestarted());
35
36 return $assignments;
37 }
38
42 protected static function getStatusForAssignments(array $assignments, int $prg_obj_id): int
43 {
44 if($assignments === []) {
46 }
47 $now = new DateTimeImmutable();
48 $pgss = [];
49 $sorting = [];
50 foreach ($assignments as $ass) {
51 $pgs = $ass->getProgressForNode($prg_obj_id);
52 $pgss[$ass->getId()] = $pgs;
53 $sorting[] = $ass->getId();
54 }
55
56 //use the highest assignment first
57 sort($sorting);
58 $sorting = array_reverse($sorting);
59 $pgs = $pgss[reset($sorting)];
60
61 if (!$pgs || !$pgs->isRelevant()) {
63 }
64
65 if ($pgs->hasValidQualification($now)) {
67 }
68
69 if ($pgs->isSuccessful() || $pgs->isFailed()) {
71 }
72
74 }
75
79 protected static function getAssignmentsLPMatrix(array $assignments, int $prg_obj_id): array
80 {
81 $matrix = [
86 ];
87
88 $user_centric = [];
89 foreach ($assignments as $ass) {
90 $usr_id = $ass->getUserId();
91 if (!array_key_exists($usr_id, $user_centric)) {
92 $user_centric[$usr_id] = [];
93 }
94 $user_centric[$usr_id][] = $ass;
95 }
96 foreach ($user_centric as $usr_id => $assignments) {
97 $status = self::getStatusForAssignments($assignments, $prg_obj_id);
98 $matrix[$status][] = $usr_id;
99 }
100
101 return $matrix;
102 }
103
104 public static function _getCountInProgress($a_obj_id): int
105 {
106 throw new \Exception('called');
107 return count(self::_getInProgress($a_obj_id));
108 }
109
110 public static function _getInProgress($a_obj_id): array
111 {
112 $assignments = self::getAssignments((int) $a_obj_id);
113 $matrix = self::getAssignmentsLPMatrix($assignments, (int) $a_obj_id);
115 }
116
117 public static function _getCountCompleted($a_obj_id): int
118 {
119 return count(self::_getCompleted($a_obj_id));
120 }
121
122 public static function _getCompleted($a_obj_id): array
123 {
124 $assignments = self::getAssignments((int) $a_obj_id);
125 $matrix = self::getAssignmentsLPMatrix($assignments, (int) $a_obj_id);
127 }
128
129 public static function _getFailed($a_obj_id): array
130 {
131 $assignments = self::getAssignments((int) $a_obj_id);
132 $matrix = self::getAssignmentsLPMatrix($assignments, (int) $a_obj_id);
133 return $matrix[ilLPStatus::LP_STATUS_FAILED_NUM];
134 }
135
136 public function determineStatus($a_obj_id, $a_user_id, $a_obj = null): int
137 {
138 $assignments = self::getAssignments((int) $a_obj_id, (int) $a_user_id);
139 return self::getStatusForAssignments($assignments, (int) $a_obj_id);
140 }
141}
static getStatusForAssignments(array $assignments, int $prg_obj_id)
determine a status based on a single users collection of assignments.
determineStatus($a_obj_id, $a_user_id, $a_obj=null)
static getAssignmentsLPMatrix(array $assignments, int $prg_obj_id)
static getAssignments(int $obj_id, ?int $usr_id=null)
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
const LP_STATUS_FAILED_NUM
$dic
Definition: ltiresult.php:33