ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\Questions\Temp\AttemptRepository Class Reference
+ Collaboration diagram for ILIAS\Questions\Temp\AttemptRepository:

Public Member Functions

 __construct (private readonly \ilDBInterface $db, private readonly UuidFactory $uuid_factory)
 
 get (int $user_id,)
 
 storeNew (int $user_id, Uuid $attempt_id)
 
 storeSolved (Attempt $attempt)
 

Data Fields

const string TABLE_NAME = 'qsts_temp_attempt'
 

Detailed Description

Definition at line 27 of file AttemptRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Questions\Temp\AttemptRepository::__construct ( private readonly \ilDBInterface  $db,
private readonly UuidFactory  $uuid_factory 
)

Definition at line 31 of file AttemptRepository.php.

34 {
35 }

Member Function Documentation

◆ get()

ILIAS\Questions\Temp\AttemptRepository::get ( int  $user_id)

Definition at line 37 of file AttemptRepository.php.

39 : ?Attempt {
40 $value = $this->db->fetchObject(
41 $this->db->queryF(
42 'SELECT attempt_id, solved_questions from ' . self::TABLE_NAME . ' WHERE user_id = %s',
44 [$user_id]
45 )
46 );
47
48 if ($value === null) {
49 return null;
50 }
51
52 return new Attempt(
53 $this->uuid_factory->fromString($value->attempt_id),
54 $value->solved_questions === ''
55 ? []
56 : explode(',', $value->solved_questions)
57 );
58 }

References $user_id, and ILIAS\Database\FieldDefinition\T_INTEGER.

◆ storeNew()

ILIAS\Questions\Temp\AttemptRepository::storeNew ( int  $user_id,
Uuid  $attempt_id 
)

Definition at line 60 of file AttemptRepository.php.

63 : void {
64 $this->db->insert(
65 self::TABLE_NAME,
66 [
68 'attempt_id' => [FieldDefinition::T_TEXT, $attempt_id->toString()]
69 ]
70 );
71 }
toString()
Converts this UUID into a string representation.

◆ storeSolved()

ILIAS\Questions\Temp\AttemptRepository::storeSolved ( Attempt  $attempt)

Definition at line 73 of file AttemptRepository.php.

75 : void {
76 $this->db->update(
77 self::TABLE_NAME,
78 [
79 'solved_questions' => [FieldDefinition::T_TEXT, $attempt->getSolvedQuestionsForStorage()]
80 ],
81 [
82 'attempt_id' => [FieldDefinition::T_TEXT, $attempt->getAttemptId()->toString()]
83 ]
84 );
85 }

Field Documentation

◆ TABLE_NAME

const string ILIAS\Questions\Temp\AttemptRepository::TABLE_NAME = 'qsts_temp_attempt'

Definition at line 29 of file AttemptRepository.php.

Referenced by ILIAS\Questions\Setup\TempTables\step_1().


The documentation for this class was generated from the following file: