ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PassPresentedVariablesRepo Class Reference

Stores random-generated parts of questions in order to present the user with a fixed question during a test attempt. More...

+ Collaboration diagram for PassPresentedVariablesRepo:

Public Member Functions

 __construct (protected ilDBInterface $db)
 
 getFor (int $question_id, int $active_id, int $pass)
 
 store (int $question_id, int $active_id, int $pass, array $values)
 

Data Fields

const TABLE_NAME = 'tst_qst_var_presented'
 

Detailed Description

Stores random-generated parts of questions in order to present the user with a fixed question during a test attempt.

Definition at line 25 of file PassPresentedVariablesRepo.php.

Constructor & Destructor Documentation

◆ __construct()

PassPresentedVariablesRepo::__construct ( protected ilDBInterface  $db)

Definition at line 29 of file PassPresentedVariablesRepo.php.

31 {
32 }

Member Function Documentation

◆ getFor()

PassPresentedVariablesRepo::getFor ( int  $question_id,
int  $active_id,
int  $pass 
)

Definition at line 34 of file PassPresentedVariablesRepo.php.

38 : ?array {
39 $query = 'SELECT variable, value FROM ' . self::TABLE_NAME . ' WHERE '
40 . 'question_id = %s AND '
41 . 'active_id = %s AND '
42 . 'pass = %s';
43
44 $result = $this->db->queryF(
45 $query,
46 ['integer','integer','integer'],
47 [$question_id, $active_id, $pass]
48 );
49
50 if($result->numRows() === 0) {
51 return null;
52 }
53
54 $values = [];
55 while ($row = $this->db->fetchAssoc($result)) {
56 $values[$row['variable']] = $row['value'];
57 }
58 return $values;
59 }

◆ store()

PassPresentedVariablesRepo::store ( int  $question_id,
int  $active_id,
int  $pass,
array  $values 
)

Definition at line 61 of file PassPresentedVariablesRepo.php.

66 : void {
67 $query = 'INSERT INTO ' . self::TABLE_NAME
68 . ' (question_id, active_id, pass, variable, value) '
69 . ' VALUES (%s,%s,%s,%s,%s)';
70
71 foreach ($values as $k => $v) {
72 $this->db->manipulateF(
73 $query,
74 ['integer','integer','integer', 'text', 'text'],
75 [$question_id, $active_id, $pass, $k, $v]
76 );
77 }
78 }

Field Documentation

◆ TABLE_NAME

const PassPresentedVariablesRepo::TABLE_NAME = 'tst_qst_var_presented'

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