ILIAS  release_8 Revision v8.24
class.ilAssQuestionProcessLockerDb.php
Go to the documentation of this file.
1<?php
2
26{
30 protected $db;
31
35 protected $atom_query;
36
40 private $assessmentLogEnabled = false;
41
45 public function __construct(ilDBInterface $db)
46 {
47 $this->db = $db;
48 }
49
50 public function isAssessmentLogEnabled(): bool
51 {
53 }
54
56 {
57 $this->assessmentLogEnabled = $assessmentLogEnabled;
58 }
59
63 private function getTablesUsedDuringAssessmentLog(): array
64 {
65 return array(
66 array('name' => 'qpl_questions', 'sequence' => false),
67 array('name' => 'tst_tests', 'sequence' => false),
68 array('name' => 'tst_active', 'sequence' => false),
69 array('name' => 'ass_log', 'sequence' => true)
70 );
71 }
72
76 private function getTablesUsedDuringSolutionUpdate(): array
77 {
78 return array(
79 array('name' => 'tst_solutions', 'sequence' => true)
80 );
81 }
82
86 private function getTablesUsedDuringResultUpdate(): array
87 {
88 return array(
89 array('name' => 'tst_test_result', 'sequence' => true)
90 );
91 }
92
97 {
98 $tables = $this->getTablesUsedDuringSolutionUpdate();
99
100 if ($this->isAssessmentLogEnabled()) {
101 $tables = array_merge($tables, $this->getTablesUsedDuringAssessmentLog());
102 }
103
104 $this->atom_query = $this->db->buildAtomQuery();
105 foreach ($tables as $table) {
106 $this->atom_query->addTableLock($table['name'])->lockSequence((bool) $table['sequence']);
107 }
108 }
109
114 {
115 $this->atom_query = $this->db->buildAtomQuery();
116 foreach ($this->getTablesUsedDuringResultUpdate() as $table) {
117 $this->atom_query->addTableLock($table['name'])->lockSequence((bool) $table['sequence']);
118 }
119 }
120
125 {
126 $this->atom_query = $this->db->buildAtomQuery();
127 foreach (array_merge(
130 ) as $table) {
131 $this->atom_query->addTableLock($table['name'])->lockSequence((bool) $table['sequence']);
132 }
133 }
134
139 {
140 $this->atom_query = $this->db->buildAtomQuery();
141 $this->atom_query->addTableLock('tst_result_cache');
142 $this->atom_query->addTableLock('tst_test_result')->lockSequence(true);
143 $this->atom_query->addTableLock('tst_solutions')->lockSequence(true);
144 }
145
149 protected function executeOperation(callable $operation): void
150 {
151 if ($this->atom_query) {
152 $this->atom_query->addQueryCallable(function (ilDBInterface $ilDB) use ($operation) {
153 $operation();
154 });
155 $this->atom_query->run();
156 } else {
157 $operation();
158 }
159
160 $this->atom_query = null;
161 }
162}
Interface ilDBInterface.