ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLPStatusLtiOutcome.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5
14{
15 private static $userResultCache = array();
16
22 private function getLtiUserResult($objId, $usrId)
23 {
24 if (!isset(self::$userResultCache[$objId])) {
25 self::$userResultCache[$objId] = array();
26 }
27
28 if (!isset(self::$userResultCache[$objId][$usrId])) {
29 $ltiUserResult = ilLTIConsumerResult::getByKeys($objId, $usrId);
30 self::$userResultCache[$objId][$usrId] = $ltiUserResult;
31 }
32
33 return self::$userResultCache[$objId][$usrId];
34 }
35
36 private function ensureObject($objId, $object) : ilObjLTIConsumer
37 {
38 if (!($object instanceof ilObjLTIConsumer)) {
40 }
41
42 return $object;
43 }
44
45 public function determineStatus($a_obj_id, $a_usr_id, $a_obj = null)
46 {
47 $ltiResult = $this->getLtiUserResult($a_obj_id, $a_usr_id);
48
49 if ($ltiResult instanceof ilLTIConsumerResult) {
50 $object = $this->ensureObject($a_obj_id, $a_obj);
51 $ltiMasteryScore = $object->getMasteryScore();
52
53 if ($ltiResult->getResult() >= $ltiMasteryScore) {
55 }
56
58 }
59
61 }
62
63 public function determinePercentage($a_obj_id, $a_usr_id, $a_obj = null)
64 {
65 $ltiResult = $this->getLtiUserResult($a_obj_id, $a_usr_id);
66
67 if ($ltiResult instanceof ilLTIConsumerResult) {
68 return $ltiResult->getResult() * 100;
69 }
70
71 return 0;
72 }
73}
An exception for terminatinating execution or to throw for unit testing.
Class ilLPStatusLtiOutcome.
determinePercentage($a_obj_id, $a_usr_id, $a_obj=null)
Determine percentage.
determineStatus($a_obj_id, $a_usr_id, $a_obj=null)
Determine status.
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
static getByKeys($a_obj_id, $a_usr_id, $a_create=false)
Get a result by object and user key.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
$objId
Definition: xapitoken.php:39