ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilAssQuestionProcessLockerDb.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLocker.php';
5
13{
17 protected $db;
18
22 protected $atom_query;
23
27 private $assessmentLogEnabled = false;
28
32 public function __construct(ilDBInterface $db)
33 {
34 $this->db = $db;
35 }
36
37 public function isAssessmentLogEnabled()
38 {
40 }
41
43 {
44 $this->assessmentLogEnabled = $assessmentLogEnabled;
45 }
46
51 {
52 return array(
53 array('name' => 'qpl_questions', 'sequence' => false),
54 array('name' => 'tst_tests', 'sequence' => false),
55 array('name' => 'tst_active', 'sequence' => false),
56 array('name' => 'ass_log', 'sequence' => true)
57 );
58 }
59
64 {
65 return array(
66 array('name' => 'tst_solutions', 'sequence' => true)
67 );
68 }
69
74 {
75 return array(
76 array('name' => 'tst_test_result', 'sequence' => true)
77 );
78 }
79
84 {
85 $tables = $this->getTablesUsedDuringSolutionUpdate();
86
87 if ($this->isAssessmentLogEnabled()) {
88 $tables = array_merge($tables, $this->getTablesUsedDuringAssessmentLog());
89 }
90
91 $this->atom_query = $this->db->buildAtomQuery();
92 foreach ($tables as $table) {
93 $this->atom_query->addTableLock($table['name'])->lockSequence((bool) $table['sequence']);
94 }
95 }
96
101 {
102 $this->atom_query = $this->db->buildAtomQuery();
103 foreach ($this->getTablesUsedDuringResultUpdate() as $table) {
104 $this->atom_query->addTableLock($table['name'])->lockSequence((bool) $table['sequence']);
105 }
106 }
107
112 {
113 $this->atom_query = $this->db->buildAtomQuery();
114 foreach (array_merge(
117 ) as $table) {
118 $this->atom_query->addTableLock($table['name'])->lockSequence((bool) $table['sequence']);
119 }
120 }
121
126 {
127 $this->atom_query = $this->db->buildAtomQuery();
128 $this->atom_query->addTableLock('tst_result_cache');
129 $this->atom_query->addTableLock('tst_test_result')->lockSequence(true);
130 $this->atom_query->addTableLock('tst_solutions')->lockSequence(true);
131 }
132
136 protected function executeOperation(callable $operation)
137 {
138 if ($this->atom_query) {
139 $this->atom_query->addQueryCallable(function (ilDBInterface $ilDB) use ($operation) {
140 $operation();
141 });
142 $this->atom_query->run();
143 } else {
144 $operation();
145 }
146
147 $this->atom_query = null;
148 }
149}
An exception for terminatinating execution or to throw for unit testing.
Interface ilDBInterface.
global $ilDB