ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilStudyProgrammeProgress.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2015 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
5require_once(dirname(__FILE__)."/../../../../Services/ActiveRecord/class.ActiveRecord.php");
6
21
22 // The progress of a user on a program node can have different status that
23 // determine how the node is taken into account for calculation of the learning
24 // progress.
25
26 // User needs to be successful in the node, but currently isn't.
28 // User has completed the node successfully according to the program nodes
29 // mode.
31 // User was marked as successful in the node without actually having
32 // successfully completed the program node according to his mode.
34 // The user does not need to be successful in this node.
36
41 );
42
46 static function returnDbTableName() {
47 return "prg_usr_progress";
48 }
49
68 protected $id;
69
80 protected $assignment_id;
81
92 protected $prg_id;
93
105 protected $usr_id;
118 protected $points;
119
130 protected $points_cur;
131
142 protected $status;
143
157 protected $completion_by;
158
159
170 protected $last_change;
171
183
184
191 static public function createFor( ilStudyProgramme $a_prg
193 $prg = new ilStudyProgrammeProgress();
194 $prg->setAssignmentId($a_ass->getId())
195 ->setNodeId($a_prg->getObjId())
196 ->setUserId($a_ass->getUserId())
198 ->setAmountOfPoints($a_prg->getPoints())
199 ->setCurrentAmountOfPoints(0)
200 ->setCompletionBy(null)
201 ->setLastChangeBy(null)
202 ->updateLastChange()
203 ->create();
204 return $prg;
205 }
206
212 public function getAssignmentId() {
214 }
215
216 protected function setAssignmentId($a_id) {
217 $this->assignment_id = $a_id;
218 return $this;
219 }
220
226 public function getNodeId() {
227 return $this->prg_id;
228 }
229
230 protected function setNodeId($a_id) {
231 $this->prg_id = $a_id;
232 return $this;
233 }
234
240 public function getUserId() {
241 return $this->usr_id;
242 }
243
244 protected function setUserId($a_id) {
245 $this->usr_id = $a_id;
246 return $this;
247 }
248
256 public function getAmountOfPoints() {
257 return $this->points;
258 }
259
270 public function setAmountOfPoints($a_points) {
271 if (!is_numeric($a_points) || $a_points < 0) {
272 throw new ilException("ilStudyProgrammeProgress::setAmountOfPoints: "
273 ."Expected a number >= 0 as argument, got '$a_points'");
274 }
275
276 $this->points = (int)$a_points;
277
278 $this->updateLastChange();
279 return $this;
280 }
281
287 public function getCurrentAmountOfPoints() {
288 return $this->points_cur;
289 }
290
299 public function setCurrentAmountOfPoints($a_points) {
300 if (!is_numeric($a_points) || $a_points < 0) {
301 throw new ilException("ilStudyProgrammeProgress::setCurrentAmountOfPoints: "
302 ."Expected a number >= 0 as argument, got '$a_points'.");
303 }
304
305 $this->points_cur = (int)$a_points;
306 $this->updateLastChange();
307 return $this;
308 }
309
315 public function getStatus() {
316 return $this->status;
317 }
318
329 public function setStatus($a_status) {
330 $a_status = (int)$a_status;
331 if (!in_array($a_status, self::$STATUS)) {
332 throw new ilException("ilStudyProgrammeProgress::setStatus: No status: "
333 ."'$a_status'");
334 }
335
336 $this->status = $a_status;
337 $this->updateLastChange();
338 return $this;
339 }
340
347 public function setCompletionBy($a_id) {
348 if ($a_id !== null) {
349 $a_id = (int)$a_id;
350 }
351 $this->completion_by = $a_id;
352 $this->updateLastChange();
353 return $this;
354 }
355
362 public function getCompletionBy() {
364 }
370 public function getLastChangeBy() {
372 }
373
382 public function setLastChangeBy($a_usr_id) {
383 if ($a_usr_id !== null && ilObject::_lookupType($a_usr_id) != "usr") {
384 throw new ilException("ilStudyProgrammeProgress::setLastChangeBy: '$a_usr_id' "
385 ."is no id of a user.");
386 }
387 $this->last_change_by = $a_usr_id;
388 return $this;
389 }
390
396 public function getLastChange() {
397 return new ilDateTime($this->last_change, IL_CAL_DATETIME);
398 }
399
410 public function updateLastChange() {
412 return $this;
413 }
414
424 public function setLastChange(ilDateTime $a_timestamp) {
425 if (ilDateTime::_before($a_timestamp, $this->getLastChange())) {
426 throw new ilException("ilStudyProgrammeProgress::setLastChange: Given "
427 ."timestamp is before current timestamp. That "
428 ."is logically impossible.");
429 }
430
431 $this->last_change = $a_timestamp->get(IL_CAL_DATETIME);
432 return $this;
433 }
434}
435
436?>
Class ActiveRecord.
const IL_CAL_DATETIME
@classDescription Date and time handling
get($a_format, $a_format_str='', $a_tz='')
get formatted date
static _before(ilDateTime $start, ilDateTime $end, $a_compare_field='', $a_tz='')
compare two dates and check start is before end This method does not consider tz offsets.
Base class for ILIAS Exception handling.
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilStudyProgrammeAssignment.
getUserId()
Get the id of the user who is assigned.
getId()
Get the id of the assignment.
Class ilStudyProgrammeProgress.
setCurrentAmountOfPoints($a_points)
Set the amount of points the user currently has achieved on this node.
getAssignmentId()
Get the assignment, this progress belongs to.
setLastChangeBy($a_usr_id)
Set the id of the user who did the last change on this progress.
getAmountOfPoints()
Get the amount of points the user needs to achieve on the subnodes of this node.
getStatus()
Get the status the user has on this node.
setAmountOfPoints($a_points)
Get the amount of points the user needs to achieve on the subnodes of this node.
getUserId()
Get the id of the user this progress is for.
getLastChange()
Get the timestamp of the last change on this progress.
updateLastChange()
Update the last change timestamp to the current time.
getCompletionBy()
Get the id of object or user that lead to the successful completion of this node.
getLastChangeBy()
Get the id of the user who did the last change on this assignment.
setStatus($a_status)
Set the status of this node.
getCurrentAmountOfPoints()
Get the amount of points the user currently has achieved on the node.
setLastChange(ilDateTime $a_timestamp)
Set the last change timestamp to the given time.
setCompletionBy($a_id)
Set the completion_by field.
static createFor(ilStudyProgramme $a_prg, ilStudyProgrammeAssignment $a_ass)
Create a new progress object for a given program node and assignment.
getNodeId()
Get the id of the program node this progress belongs to.
Class ilStudyProgramme.
getPoints()
Get the amount of points.
getObjId()
Get the id of the study program.
static now()
Return current timestamp in Y-m-d H:i:s format.