ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilAssQuestionUserSolutionAdopter Class Reference
+ Collaboration diagram for ilAssQuestionUserSolutionAdopter:

Public Member Functions

 __construct (private ilDBInterface $db, ilSetting $ass_settings)
 
 getUserId ()
 
 setUserId (int $user_id)
 
 getActiveId ()
 
 setActiveId (int $active_id)
 
 getTargetPass ()
 
 setTargetPass (int $target_pass)
 
 getQuestionIds ()
 
 setQuestionIds (array $question_ids)
 
 perform ()
 

Protected Member Functions

 adoptQuestionAnswer (int $question_id)
 
 resetTargetSolution (int $question_id)
 
 resetTargetResult (int $question_id)
 
 adoptSourceSolution (int $question_id)
 
 adoptSourceResult (int $question_id, int $source_pass)
 
 getPreparedDeleteSolutionRecordsStatement ()
 
 getPreparedSelectSolutionRecordsStatement ()
 
 getPreparedInsertSolutionRecordStatement ()
 
 getPreparedDeleteResultRecordStatement ()
 
 getPreparedSelectResultRecordStatement ()
 
 getPreparedInsertResultRecordStatement ()
 

Protected Attributes

int $active_id = null
 
int $target_pass = null
 
array $question_ids = []
 

Static Protected Attributes

static ilDBStatement $prepared_delete_solution_records_statement = null
 
static ilDBStatement $prepared_select_solution_records_statement = null
 
static ilDBStatement $prepared_insert_solution_record_statement = null
 
static ilDBStatement $prepared_delete_result_record_statement = null
 
static ilDBStatement $prepared_select_result_record_statement = null
 
static ilDBStatement $prepared_insert_result_record_statement = null
 

Private Attributes

ilAssQuestionProcessLockerFactory $process_locker_factory
 
int $user_id = null
 

Detailed Description

Definition at line 27 of file class.ilAssQuestionUserSolutionAdopter.php.

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionUserSolutionAdopter::__construct ( private ilDBInterface  $db,
ilSetting  $ass_settings 
)

Definition at line 46 of file class.ilAssQuestionUserSolutionAdopter.php.

49 {
50 $this->process_locker_factory = new ilAssQuestionProcessLockerFactory($ass_settings, $db);
51 }

Member Function Documentation

◆ adoptQuestionAnswer()

ilAssQuestionUserSolutionAdopter::adoptQuestionAnswer ( int  $question_id)
protected

Definition at line 110 of file class.ilAssQuestionUserSolutionAdopter.php.

110 : void
111 {
112 $this->resetTargetSolution($question_id);
113 $this->resetTargetResult($question_id);
114
115 $source_pass = $this->adoptSourceSolution($question_id);
116
117 if ($source_pass !== null) {
118 $this->adoptSourceResult($question_id, $source_pass);
119 }
120 }
adoptSourceResult(int $question_id, int $source_pass)

References adoptSourceResult(), adoptSourceSolution(), resetTargetResult(), and resetTargetSolution().

Referenced by perform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adoptSourceResult()

ilAssQuestionUserSolutionAdopter::adoptSourceResult ( int  $question_id,
int  $source_pass 
)
protected

Definition at line 165 of file class.ilAssQuestionUserSolutionAdopter.php.

165 : void
166 {
167 $res = $this->db->execute(
169 [$this->getActiveId(), $question_id, $source_pass]
170 );
171
172 $row = $this->db->fetchAssoc($res);
173
174 $result_id = $this->db->nextId('tst_test_result');
175
176 $this->db->execute($this->getPreparedInsertResultRecordStatement(), [
177 $result_id, $this->getActiveId(), $question_id, $this->getTargetPass(), time(),
178 $row['points'], $row['manual'], $row['answered']
179 ]);
180 }
$res
Definition: ltiservices.php:69

References $res, getActiveId(), getPreparedInsertResultRecordStatement(), getPreparedSelectResultRecordStatement(), and getTargetPass().

Referenced by adoptQuestionAnswer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adoptSourceSolution()

ilAssQuestionUserSolutionAdopter::adoptSourceSolution ( int  $question_id)
protected

Definition at line 138 of file class.ilAssQuestionUserSolutionAdopter.php.

138 : ?int
139 {
140 $res = $this->db->execute(
142 [$this->getActiveId(), $question_id, $this->getTargetPass()]
143 );
144
145 $source_pass = null;
146
147 while ($row = $this->db->fetchAssoc($res)) {
148 if ($source_pass === null) {
149 $source_pass = $row['pass'];
150 } elseif ($row['pass'] < $source_pass) {
151 break;
152 }
153
154 $solution_id = $this->db->nextId('tst_solutions');
155
156 $this->db->execute($this->getPreparedInsertSolutionRecordStatement(), [
157 $solution_id, $this->getActiveId(), $question_id, $this->getTargetPass(), time(),
158 $row['points'], $row['value1'], $row['value2']
159 ]);
160 }
161
162 return $source_pass;
163 }

References $res, getActiveId(), getPreparedInsertSolutionRecordStatement(), getPreparedSelectSolutionRecordsStatement(), and getTargetPass().

Referenced by adoptQuestionAnswer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActiveId()

ilAssQuestionUserSolutionAdopter::getActiveId ( )

Definition at line 63 of file class.ilAssQuestionUserSolutionAdopter.php.

References $active_id.

Referenced by adoptSourceResult(), adoptSourceSolution(), resetTargetResult(), and resetTargetSolution().

+ Here is the caller graph for this function:

◆ getPreparedDeleteResultRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedDeleteResultRecordStatement ( )
protected

Definition at line 231 of file class.ilAssQuestionUserSolutionAdopter.php.

232 {
233 if (self::$prepared_delete_result_record_statement === null) {
234 self::$prepared_delete_result_record_statement = $this->db->prepareManip(
235 "DELETE FROM tst_test_result WHERE active_fi = ? AND question_fi = ? AND pass = ?",
236 ['integer', 'integer', 'integer']
237 );
238 }
239
241 }
Interface ilDBStatement.

References $prepared_delete_result_record_statement.

Referenced by resetTargetResult().

+ Here is the caller graph for this function:

◆ getPreparedDeleteSolutionRecordsStatement()

ilAssQuestionUserSolutionAdopter::getPreparedDeleteSolutionRecordsStatement ( )
protected

Definition at line 182 of file class.ilAssQuestionUserSolutionAdopter.php.

183 {
184 if (self::$prepared_delete_solution_records_statement === null) {
185 self::$prepared_delete_solution_records_statement = $this->db->prepareManip(
186 "DELETE FROM tst_solutions WHERE active_fi = ? AND question_fi = ? AND pass = ?",
187 ['integer', 'integer', 'integer']
188 );
189 }
190
192 }

References $prepared_delete_solution_records_statement.

Referenced by resetTargetSolution().

+ Here is the caller graph for this function:

◆ getPreparedInsertResultRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedInsertResultRecordStatement ( )
protected

Definition at line 260 of file class.ilAssQuestionUserSolutionAdopter.php.

261 {
262 if (self::$prepared_insert_result_record_statement === null) {
263 $query = "
264 INSERT INTO tst_test_result (
265 test_result_id, active_fi, question_fi, pass, tstamp,
266 points, manual, answered
267 ) VALUES (
268 ?, ?, ?, ?, ?, ?, ?, ?
269 )
270 ";
271
272 self::$prepared_insert_result_record_statement = $this->db->prepareManip(
273 $query,
274 ['integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer']
275 );
276 }
277
279 }

References $prepared_insert_result_record_statement.

Referenced by adoptSourceResult().

+ Here is the caller graph for this function:

◆ getPreparedInsertSolutionRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedInsertSolutionRecordStatement ( )
protected

Definition at line 211 of file class.ilAssQuestionUserSolutionAdopter.php.

212 {
213 if (self::$prepared_insert_solution_record_statement === null) {
214 $query = "
215 INSERT INTO tst_solutions (
216 solution_id, active_fi, question_fi, pass, tstamp, points, value1, value2
217 ) VALUES (
218 ?, ?, ?, ?, ?, ?, ?, ?
219 )
220 ";
221
222 self::$prepared_insert_solution_record_statement = $this->db->prepareManip(
223 $query,
224 ['integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'text', 'text']
225 );
226 }
227
229 }

References $prepared_insert_solution_record_statement.

Referenced by adoptSourceSolution().

+ Here is the caller graph for this function:

◆ getPreparedSelectResultRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedSelectResultRecordStatement ( )
protected

Definition at line 243 of file class.ilAssQuestionUserSolutionAdopter.php.

244 {
245 if (self::$prepared_select_result_record_statement === null) {
246 $query = "
247 SELECT points, manual, answered FROM tst_test_result
248 WHERE active_fi = ? AND question_fi = ? AND pass = ?
249 ";
250
251 self::$prepared_select_result_record_statement = $this->db->prepare(
252 $query,
253 ['integer', 'integer', 'integer']
254 );
255 }
256
258 }

References $prepared_select_result_record_statement.

Referenced by adoptSourceResult().

+ Here is the caller graph for this function:

◆ getPreparedSelectSolutionRecordsStatement()

ilAssQuestionUserSolutionAdopter::getPreparedSelectSolutionRecordsStatement ( )
protected

Definition at line 194 of file class.ilAssQuestionUserSolutionAdopter.php.

195 {
196 if (self::$prepared_select_solution_records_statement === null) {
197 $query = "
198 SELECT pass, points, value1, value2 FROM tst_solutions
199 WHERE active_fi = ? AND question_fi = ? AND pass < ? ORDER BY pass DESC
200 ";
201
202 self::$prepared_select_solution_records_statement = $this->db->prepare(
203 $query,
204 ['integer', 'integer', 'integer']
205 );
206 }
207
209 }

References $prepared_select_solution_records_statement.

Referenced by adoptSourceSolution().

+ Here is the caller graph for this function:

◆ getQuestionIds()

ilAssQuestionUserSolutionAdopter::getQuestionIds ( )

Definition at line 83 of file class.ilAssQuestionUserSolutionAdopter.php.

References $question_ids.

Referenced by perform().

+ Here is the caller graph for this function:

◆ getTargetPass()

ilAssQuestionUserSolutionAdopter::getTargetPass ( )

Definition at line 73 of file class.ilAssQuestionUserSolutionAdopter.php.

References $target_pass.

Referenced by adoptSourceResult(), adoptSourceSolution(), resetTargetResult(), and resetTargetSolution().

+ Here is the caller graph for this function:

◆ getUserId()

ilAssQuestionUserSolutionAdopter::getUserId ( )

Definition at line 53 of file class.ilAssQuestionUserSolutionAdopter.php.

References $user_id.

Referenced by perform().

+ Here is the caller graph for this function:

◆ perform()

ilAssQuestionUserSolutionAdopter::perform ( )

Definition at line 96 of file class.ilAssQuestionUserSolutionAdopter.php.

96 : void
97 {
98 $this->process_locker_factory->setUserId($this->getUserId());
99
100 foreach ($this->getQuestionIds() as $question_id) {
101 $this->process_locker_factory->setQuestionId($question_id);
102 $processLocker = $this->process_locker_factory->getLocker();
103
104 $processLocker->executeUserTestResultUpdateLockOperation(function () use ($question_id) {
105 $this->adoptQuestionAnswer($question_id);
106 });
107 }
108 }

References adoptQuestionAnswer(), getQuestionIds(), and getUserId().

+ Here is the call graph for this function:

◆ resetTargetResult()

ilAssQuestionUserSolutionAdopter::resetTargetResult ( int  $question_id)
protected

Definition at line 130 of file class.ilAssQuestionUserSolutionAdopter.php.

130 : void
131 {
132 $this->db->execute(
134 [$this->getActiveId(), $question_id, $this->getTargetPass()]
135 );
136 }

References getActiveId(), getPreparedDeleteResultRecordStatement(), and getTargetPass().

Referenced by adoptQuestionAnswer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetTargetSolution()

ilAssQuestionUserSolutionAdopter::resetTargetSolution ( int  $question_id)
protected

Definition at line 122 of file class.ilAssQuestionUserSolutionAdopter.php.

122 : void
123 {
124 $this->db->execute(
126 [$this->getActiveId(), $question_id, $this->getTargetPass()]
127 );
128 }

References getActiveId(), getPreparedDeleteSolutionRecordsStatement(), and getTargetPass().

Referenced by adoptQuestionAnswer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setActiveId()

ilAssQuestionUserSolutionAdopter::setActiveId ( int  $active_id)

Definition at line 68 of file class.ilAssQuestionUserSolutionAdopter.php.

68 : void
69 {
70 $this->active_id = $active_id;
71 }

References $active_id.

◆ setQuestionIds()

ilAssQuestionUserSolutionAdopter::setQuestionIds ( array  $question_ids)
Parameters
array<int>$question_ids

Definition at line 91 of file class.ilAssQuestionUserSolutionAdopter.php.

91 : void
92 {
93 $this->question_ids = $question_ids;
94 }

References $question_ids.

◆ setTargetPass()

ilAssQuestionUserSolutionAdopter::setTargetPass ( int  $target_pass)

Definition at line 78 of file class.ilAssQuestionUserSolutionAdopter.php.

78 : void
79 {
80 $this->target_pass = $target_pass;
81 }

References $target_pass.

◆ setUserId()

ilAssQuestionUserSolutionAdopter::setUserId ( int  $user_id)

Definition at line 58 of file class.ilAssQuestionUserSolutionAdopter.php.

58 : void
59 {
60 $this->user_id = $user_id;
61 }

References $user_id.

Field Documentation

◆ $active_id

int ilAssQuestionUserSolutionAdopter::$active_id = null
protected

Definition at line 38 of file class.ilAssQuestionUserSolutionAdopter.php.

Referenced by getActiveId(), and setActiveId().

◆ $prepared_delete_result_record_statement

ilDBStatement ilAssQuestionUserSolutionAdopter::$prepared_delete_result_record_statement = null
staticprotected

◆ $prepared_delete_solution_records_statement

ilDBStatement ilAssQuestionUserSolutionAdopter::$prepared_delete_solution_records_statement = null
staticprotected

◆ $prepared_insert_result_record_statement

ilDBStatement ilAssQuestionUserSolutionAdopter::$prepared_insert_result_record_statement = null
staticprotected

◆ $prepared_insert_solution_record_statement

ilDBStatement ilAssQuestionUserSolutionAdopter::$prepared_insert_solution_record_statement = null
staticprotected

◆ $prepared_select_result_record_statement

ilDBStatement ilAssQuestionUserSolutionAdopter::$prepared_select_result_record_statement = null
staticprotected

◆ $prepared_select_solution_records_statement

ilDBStatement ilAssQuestionUserSolutionAdopter::$prepared_select_solution_records_statement = null
staticprotected

◆ $process_locker_factory

ilAssQuestionProcessLockerFactory ilAssQuestionUserSolutionAdopter::$process_locker_factory
private

Definition at line 36 of file class.ilAssQuestionUserSolutionAdopter.php.

◆ $question_ids

array ilAssQuestionUserSolutionAdopter::$question_ids = []
protected

Definition at line 44 of file class.ilAssQuestionUserSolutionAdopter.php.

Referenced by getQuestionIds(), and setQuestionIds().

◆ $target_pass

int ilAssQuestionUserSolutionAdopter::$target_pass = null
protected

Definition at line 39 of file class.ilAssQuestionUserSolutionAdopter.php.

Referenced by getTargetPass(), and setTargetPass().

◆ $user_id

int ilAssQuestionUserSolutionAdopter::$user_id = null
private

Definition at line 37 of file class.ilAssQuestionUserSolutionAdopter.php.

Referenced by getUserId(), and setUserId().


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