ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilLPStatusCourseReference.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
9{
13 private static $instances = [];
14
18 private $logger = null;
19
23 private $target_obj_id = 0;
24
25 private $status_info = [];
26
27
32 public function __construct($a_obj_id)
33 {
34 global $DIC;
35
36 $this->logger = $DIC->logger()->trac();
37
38 parent::__construct($a_obj_id);
39 $this->readTargetObjId($a_obj_id);
40 $this->readStatusInfo($a_obj_id);
41 }
42
46 public static function _getCountNotAttempted($a_obj_id)
47 {
48 $self = self::getInstanceByObjId($a_obj_id);
49 return count($self->getNotAttempted());
50 }
51
55 public static function _getNotAttempted($a_obj_id)
56 {
57 $self = self::getInstanceByObjId($a_obj_id);
58 return $self->getNotAttempted();
59 }
60
64 public function getNotAttempted()
65 {
66 return $this->status_info[\ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM];
67 }
68
72 public static function _getCountInProgress($a_obj_id)
73 {
74 $self = self::getInstanceByObjId($a_obj_id);
75 return count($self->getInProgress());
76 }
77
81 public static function _getInProgress($a_obj_id)
82 {
83 $self = self::getInstanceByObjId($a_obj_id);
84 return $self->getInProgress();
85 }
86
90 public function getInProgress()
91 {
92 return $this->status_info[\ilLPStatus::LP_STATUS_IN_PROGRESS_NUM];
93 }
94
98 public static function _getCountCompleted($a_obj_id)
99 {
100 $self = self::getInstanceByObjId($a_obj_id);
101 return count($self->getCompleted());
102 }
103
107 public static function _getCompleted($a_obj_id)
108 {
109 $self = self::getInstanceByObjId($a_obj_id);
110 return $self->getCompleted();
111 }
112
116 public function getCompleted()
117 {
118 return $this->status_info[\ilLPStatus::LP_STATUS_COMPLETED_NUM];
119 }
120
121
125 public static function _getStatusInfo($a_obj_id)
126 {
127 $self = self::getInstanceByObjId($a_obj_id);
128 return $self->getStatusInfo();
129 }
130
131 public function getStatusInfo()
132 {
133 return $this->status_info;
134 }
135
139 public function readStatusInfo($a_obj_id)
140 {
141 global $DIC;
142
143 $database = $DIC->database();
144 $query = 'select status,usr_id from ut_lp_marks ' .
145 'where obj_id = ' . $database->quote($this->target_obj_id, \ilDBConstants::T_INTEGER);
146 $res = $database->query($query);
147
148 $info = [
153 ];
154 while ($row = $res->fetchRow(\ilDBConstants::FETCHMODE_OBJECT)) {
155 if (array_key_exists((int) $row->status, $info)) {
156 $info[(int) $row->status][] = (int) $row->usr_id;
157 }
158 }
159 $this->status_info = $info;
160 }
161
162
166 public function determineStatus($a_obj_id, $a_usr_id, $a_obj = null)
167 {
168 $status = \ilLPStatus::_lookupStatus($this->target_obj_id, $a_usr_id, false);
169 if ($status) {
170 return $status;
171 }
172 return \ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM;
173 }
174
175
180 private static function getInstanceByObjId($a_reference_obj_id)
181 {
182 if (!isset(self::$instances[$a_reference_obj_id])) {
183 self::$instances[$a_reference_obj_id] = new self($a_reference_obj_id);
184 }
185 return self::$instances[$a_reference_obj_id];
186 }
187
191 private function readTargetObjId($a_obj_id)
192 {
193 $this->target_obj_id = ilObject::_lookupObjId(ilObjCourseReference::_lookupTargetRefId($a_obj_id));
194 }
195}
An exception for terminatinating execution or to throw for unit testing.
static _lookupTargetRefId($a_obj_id)
Lookup target ref_id.
Class ilLPStatusCourseReference.
static getInstanceByObjId($a_reference_obj_id)
__construct($a_obj_id)
ilLPStatusCourseReference constructor.
determineStatus($a_obj_id, $a_usr_id, $a_obj=null)
Determine status.return
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...
const LP_STATUS_COMPLETED_NUM
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
const LP_STATUS_FAILED_NUM
static _lookupObjId($a_id)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$query
foreach($_POST as $key=> $value) $res
$DIC
Definition: xapitoken.php:46