ILIAS  release_8 Revision v8.24
class.ilLPStatusStudyProgramme.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
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
39 //determine a status based on a single users collection of assignments.
40 protected static function getStatusForAssignments(array $assignments, int $prg_obj_id): int
41 {
42 $now = new DateTimeImmutable();
43 $pgss = [];
44 foreach ($assignments as $ass) {
45 $pgs = $ass->getProgressForNode($prg_obj_id);
46 $pgss[$ass->getId()] = $pgs;
47 }
48
49 //use the highest assignment first
50 sort($pgss);
51 $pgss = array_reverse($pgss);
52 $pgs = reset($pgss);
53
54 if (!$pgs || !$pgs->isRelevant()) {
56 }
57
58 if ($pgs->hasValidQualification($now)) {
60 }
61
62 //successful, but expired
63 //or failed
64 if ($pgs->isSuccessful() || $pgs->isFailed()) {
66 }
67
69 }
70
74 protected static function getAssignmentsLPMatrix(array $assignments, int $prg_obj_id): array
75 {
76 $matrix = [
81 ];
82
83 $user_centric = [];
84 foreach ($assignments as $ass) {
85 $usr_id = $ass->getUserId();
86 if (!array_key_exists($usr_id, $user_centric)) {
87 $user_centric[$usr_id] = [];
88 }
89 $user_centric[$usr_id][] = $ass;
90 }
91 foreach ($user_centric as $usr_id => $assignments) {
92 $status = self::getStatusForAssignments($assignments, $prg_obj_id);
93 $matrix[$status][] = $usr_id;
94 }
95
96 return $matrix;
97 }
98
99 public static function _getCountInProgress($a_obj_id): int
100 {
101 throw new \Exception('called');
102 return count(self::_getInProgress($a_obj_id));
103 }
104
105 public static function _getInProgress($a_obj_id): array
106 {
107 $assignments = self::getAssignments((int) $a_obj_id);
108 $matrix = self::getAssignmentsLPMatrix($assignments, (int) $a_obj_id);
110 }
111
112 public static function _getCountCompleted($a_obj_id): int
113 {
114 return count(self::_getCompleted($a_obj_id));
115 }
116
117 public static function _getCompleted($a_obj_id): array
118 {
119 $assignments = self::getAssignments((int) $a_obj_id);
120 $matrix = self::getAssignmentsLPMatrix($assignments, (int) $a_obj_id);
122 }
123
124 public static function _getFailed($a_obj_id): array
125 {
126 $assignments = self::getAssignments((int) $a_obj_id);
127 $matrix = self::getAssignmentsLPMatrix($assignments, (int) $a_obj_id);
128 return $matrix[ilLPStatus::LP_STATUS_FAILED_NUM];
129 }
130
131 public function determineStatus($a_obj_id, $a_user_id, $a_obj = null): int
132 {
133 $assignments = self::getAssignments((int) $a_obj_id, (int) $a_user_id);
134 return self::getStatusForAssignments($assignments, (int) $a_obj_id);
135 }
136}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getStatusForAssignments(array $assignments, int $prg_obj_id)
determineStatus($a_obj_id, $a_user_id, $a_obj=null)
static getAssignments(int $obj_id, int $usr_id=null)
static getAssignmentsLPMatrix(array $assignments, int $prg_obj_id)
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: result.php:32