19declare(strict_types=1);
30 private const string TABLE_NAME =
'lti_consumer_results';
39 public static function getByKeys(
int $obj_id,
int $usr_id): ?self
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'],
53 return new self($row[
'result'] ===
null ? null : (float) $row[
'result']);
60 public static function start(
int $obj_id,
int $usr_id): void
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],
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)