ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
class.ilLTIToolResult.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29{
30 private const string TABLE_NAME = 'lti_consumer_results';
31
32 private function __construct(private readonly ?float $result)
33 {
34 }
35
39 public static function getByKeys(int $obj_id, int $usr_id): ?self
40 {
41 global $DIC;
42
43 $db = $DIC->database();
44 $row = $db->fetchAssoc($db->queryF(
45 'SELECT result FROM ' . self::TABLE_NAME . ' WHERE obj_id = %s AND usr_id = %s',
46 ['integer', 'integer'],
47 [$obj_id, $usr_id]
48 ));
49 if ($row === null) {
50 return null;
51 }
52
53 return new self($row['result'] === null ? null : (float) $row['result']);
54 }
55
60 public static function start(int $obj_id, int $usr_id): void
61 {
62 global $DIC;
63
64 $db = $DIC->database();
65 if (self::getByKeys($obj_id, $usr_id) === null) {
66 $db->insert(self::TABLE_NAME, [
67 'id' => ['integer', $db->nextId(self::TABLE_NAME)],
68 'obj_id' => ['integer', $obj_id],
69 'usr_id' => ['integer', $usr_id],
70 'result' => ['float', null],
71 'attended' => ['integer', 0],
72 ]);
73 }
74 ilLPStatusWrapper::_updateStatus($obj_id, $usr_id);
75 }
76
80 public function getResult(): ?float
81 {
82 return $this->result;
83 }
84}
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
The result a tool reported for a user of an LTI object, as the learning progress and the certificate ...
__construct(private readonly ?float $result)
static getByKeys(int $obj_id, int $usr_id)
The result of the user for the object, null when the tool has not reported any.
static start(int $obj_id, int $usr_id)
A launch starts the attempt of the user, in progress until the tool reports a result.
getResult()
The share of the maximum result, between 0 and 1, null when the user only launched the tool.
global $DIC
Definition: shib_login.php:26