ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilAssQuestionUserSolutionAdopter Class Reference
+ Collaboration diagram for ilAssQuestionUserSolutionAdopter:

Public Member Functions

 __construct (ilDBInterface $db, ilSetting $assSettings, $isAssessmentLogEnabled)
 
 getUserId ()
 
 setUserId ($userId)
 
 getActiveId ()
 
 setActiveId ($activeId)
 
 getTargetPass ()
 
 setTargetPass ($targetPass)
 
 getQuestionIds ()
 
 setQuestionIds ($questionIds)
 
 perform ()
 

Protected Member Functions

 adoptQuestionAnswer ($questionId)
 
 resetTargetSolution ($questionId)
 
 resetTargetResult ($questionId)
 
 adoptSourceSolution ($questionId)
 
 adoptSourceResult ($questionId, $sourcePass)
 
 getPreparedDeleteSolutionRecordsStatement ()
 
 getPreparedSelectSolutionRecordsStatement ()
 
 getPreparedInsertSolutionRecordStatement ()
 
 getPreparedDeleteResultRecordStatement ()
 
 getPreparedSelectResultRecordStatement ()
 
 getPreparedInsertResultRecordStatement ()
 

Protected Attributes

 $db
 
 $processLockerFactory
 
 $userId
 
 $activeId
 
 $targetPass
 
 $questionIds
 

Static Protected Attributes

static $preparedDeleteSolutionRecordsStatement = null
 
static $preparedSelectSolutionRecordsStatement = null
 
static $preparedInsertSolutionRecordStatement = null
 
static $preparedDeleteResultRecordStatement = null
 
static $preparedSelectResultRecordStatement = null
 
static $preparedInsertResultRecordStatement = null
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionUserSolutionAdopter::__construct ( ilDBInterface  $db,
ilSetting  $assSettings,
  $isAssessmentLogEnabled 
)
Parameters
ilDBInterface$db
ilSetting$assSettings
bool$isAssessmentLogEnabled

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

79 {
80 $this->db = $db;
81
82 $this->userId = null;
83 $this->activeId = null;
84 $this->targetPass = null;
85 $this->questionIds = array();
86
87 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLockerFactory.php';
88 $this->processLockerFactory = new ilAssQuestionProcessLockerFactory($assSettings, $db);
89 $this->processLockerFactory->setAssessmentLogEnabled($isAssessmentLogEnabled);
90 }

References $db.

Member Function Documentation

◆ adoptQuestionAnswer()

ilAssQuestionUserSolutionAdopter::adoptQuestionAnswer (   $questionId)
protected

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

174 {
175 $this->resetTargetSolution($questionId);
176 $this->resetTargetResult($questionId);
177
178 $sourcePass = $this->adoptSourceSolution($questionId);
179
180 if( $sourcePass !== null )
181 {
182 $this->adoptSourceResult($questionId, $sourcePass);
183 }
184 }

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 (   $questionId,
  $sourcePass 
)
protected

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

234 {
235 $res = $this->db->execute(
237 array($this->getActiveId(), $questionId, $sourcePass)
238 );
239
240 $row = $this->db->fetchAssoc($res);
241
242 $resultId = $this->db->nextId('tst_test_result');
243
244 $this->db->execute($this->getPreparedInsertResultRecordStatement(), array(
245 $resultId, $this->getActiveId(), $questionId, $this->getTargetPass(), time(),
246 $row['points'], $row['manual'], $row['hint_count'], $row['hint_points'], $row['answered']
247 ));
248 }

References $res, $row, 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 (   $questionId)
protected

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

203 {
204 $res = $this->db->execute(
206 array($this->getActiveId(), $questionId, $this->getTargetPass())
207 );
208
209 $sourcePass = null;
210
211 while($row = $this->db->fetchAssoc($res))
212 {
213 if($sourcePass === null)
214 {
215 $sourcePass = $row['pass'];
216 }
217 elseif($row['pass'] < $sourcePass)
218 {
219 break;
220 }
221
222 $solutionId = $this->db->nextId('tst_solutions');
223
224 $this->db->execute($this->getPreparedInsertSolutionRecordStatement(), array(
225 $solutionId, $this->getActiveId(), $questionId, $this->getTargetPass(), time(),
226 $row['points'], $row['value1'], $row['value2']
227 ));
228 }
229
230 return $sourcePass;
231 }

References $res, $row, 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 ( )
Returns
int

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

References $activeId.

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

+ Here is the caller graph for this function:

◆ getPreparedDeleteResultRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedDeleteResultRecordStatement ( )
protected

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

301 {
302 if( self::$preparedDeleteResultRecordStatement === null )
303 {
304 self::$preparedDeleteResultRecordStatement = $this->db->prepareManip(
305 "DELETE FROM tst_test_result WHERE active_fi = ? AND question_fi = ? AND pass = ?",
306 array('integer', 'integer', 'integer')
307 );
308 }
309
311 }

References $preparedDeleteResultRecordStatement.

Referenced by resetTargetResult().

+ Here is the caller graph for this function:

◆ getPreparedDeleteSolutionRecordsStatement()

ilAssQuestionUserSolutionAdopter::getPreparedDeleteSolutionRecordsStatement ( )
protected

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

251 {
252 if( self::$preparedDeleteSolutionRecordsStatement === null )
253 {
254 self::$preparedDeleteSolutionRecordsStatement = $this->db->prepareManip(
255 "DELETE FROM tst_solutions WHERE active_fi = ? AND question_fi = ? AND pass = ?",
256 array('integer', 'integer', 'integer')
257 );
258 }
259
261 }

References $preparedDeleteSolutionRecordsStatement.

Referenced by resetTargetSolution().

+ Here is the caller graph for this function:

◆ getPreparedInsertResultRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedInsertResultRecordStatement ( )
protected

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

331 {
332 if( self::$preparedInsertResultRecordStatement === null )
333 {
334 $query = "
335 INSERT INTO tst_test_result (
336 test_result_id, active_fi, question_fi, pass, tstamp,
337 points, manual, hint_count, hint_points, answered
338 ) VALUES (
339 ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
340 )
341 ";
342
343 self::$preparedInsertResultRecordStatement = $this->db->prepareManip(
344 $query, array('integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer')
345 );
346 }
347
349 }

References $preparedInsertResultRecordStatement, and $query.

Referenced by adoptSourceResult().

+ Here is the caller graph for this function:

◆ getPreparedInsertSolutionRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedInsertSolutionRecordStatement ( )
protected

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

281 {
282 if( self::$preparedInsertSolutionRecordStatement === null )
283 {
284 $query = "
285 INSERT INTO tst_solutions (
286 solution_id, active_fi, question_fi, pass, tstamp, points, value1, value2
287 ) VALUES (
288 ?, ?, ?, ?, ?, ?, ?, ?
289 )
290 ";
291
292 self::$preparedInsertSolutionRecordStatement = $this->db->prepareManip(
293 $query, array('integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'text', 'text')
294 );
295 }
296
298 }

References $preparedInsertSolutionRecordStatement, and $query.

Referenced by adoptSourceSolution().

+ Here is the caller graph for this function:

◆ getPreparedSelectResultRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedSelectResultRecordStatement ( )
protected

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

314 {
315 if( self::$preparedSelectResultRecordStatement === null )
316 {
317 $query = "
318 SELECT points, manual, hint_count, hint_points, answered FROM tst_test_result
319 WHERE active_fi = ? AND question_fi = ? AND pass = ?
320 ";
321
322 self::$preparedSelectResultRecordStatement = $this->db->prepare(
323 $query, array('integer', 'integer', 'integer')
324 );
325 }
326
328 }

References $preparedSelectResultRecordStatement, and $query.

Referenced by adoptSourceResult().

+ Here is the caller graph for this function:

◆ getPreparedSelectSolutionRecordsStatement()

ilAssQuestionUserSolutionAdopter::getPreparedSelectSolutionRecordsStatement ( )
protected

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

264 {
265 if( self::$preparedSelectSolutionRecordsStatement === null )
266 {
267 $query = "
268 SELECT pass, points, value1, value2 FROM tst_solutions
269 WHERE active_fi = ? AND question_fi = ? AND pass < ? ORDER BY pass DESC
270 ";
271
272 self::$preparedSelectSolutionRecordsStatement = $this->db->prepare(
273 $query, array('integer', 'integer', 'integer')
274 );
275 }
276
278 }

References $preparedSelectSolutionRecordsStatement, and $query.

Referenced by adoptSourceSolution().

+ Here is the caller graph for this function:

◆ getQuestionIds()

ilAssQuestionUserSolutionAdopter::getQuestionIds ( )
Returns
array

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

References $questionIds.

Referenced by perform().

+ Here is the caller graph for this function:

◆ getTargetPass()

ilAssQuestionUserSolutionAdopter::getTargetPass ( )
Returns
int

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

References $targetPass.

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

+ Here is the caller graph for this function:

◆ getUserId()

ilAssQuestionUserSolutionAdopter::getUserId ( )
Returns
int

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

References $userId.

Referenced by perform().

+ Here is the caller graph for this function:

◆ perform()

ilAssQuestionUserSolutionAdopter::perform ( )

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

157 {
158 $this->processLockerFactory->setUserId($this->getUserId());
159
160 foreach($this->getQuestionIds() as $questionId)
161 {
162 $this->processLockerFactory->setQuestionId($questionId);
163 $processLocker = $this->processLockerFactory->getLocker();
164
165 $processLocker->executeUserTestResultUpdateLockOperation(function() use ($questionId) {
166
167 $this->adoptQuestionAnswer($questionId);
168
169 });
170 }
171 }

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

+ Here is the call graph for this function:

◆ resetTargetResult()

ilAssQuestionUserSolutionAdopter::resetTargetResult (   $questionId)
protected

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

195 {
196 $this->db->execute(
198 array($this->getActiveId(), $questionId, $this->getTargetPass())
199 );
200 }

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 (   $questionId)
protected

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

187 {
188 $this->db->execute(
190 array($this->getActiveId(), $questionId, $this->getTargetPass())
191 );
192 }

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 (   $activeId)
Parameters
int$activeId

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

120 {
121 $this->activeId = $activeId;
122 }

References $activeId.

◆ setQuestionIds()

ilAssQuestionUserSolutionAdopter::setQuestionIds (   $questionIds)
Parameters
array$questionIds

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

152 {
153 $this->questionIds = $questionIds;
154 }

References $questionIds.

◆ setTargetPass()

ilAssQuestionUserSolutionAdopter::setTargetPass (   $targetPass)
Parameters
int$targetPass

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

136 {
137 $this->targetPass = $targetPass;
138 }

References $targetPass.

◆ setUserId()

ilAssQuestionUserSolutionAdopter::setUserId (   $userId)
Parameters
int$userId

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

104 {
105 $this->userId = $userId;
106 }

References $userId.

Field Documentation

◆ $activeId

ilAssQuestionUserSolutionAdopter::$activeId
protected

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

Referenced by getActiveId(), and setActiveId().

◆ $db

ilAssQuestionUserSolutionAdopter::$db
protected

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

Referenced by __construct().

◆ $preparedDeleteResultRecordStatement

ilAssQuestionUserSolutionAdopter::$preparedDeleteResultRecordStatement = null
staticprotected

◆ $preparedDeleteSolutionRecordsStatement

ilAssQuestionUserSolutionAdopter::$preparedDeleteSolutionRecordsStatement = null
staticprotected

◆ $preparedInsertResultRecordStatement

ilAssQuestionUserSolutionAdopter::$preparedInsertResultRecordStatement = null
staticprotected

◆ $preparedInsertSolutionRecordStatement

ilAssQuestionUserSolutionAdopter::$preparedInsertSolutionRecordStatement = null
staticprotected

◆ $preparedSelectResultRecordStatement

ilAssQuestionUserSolutionAdopter::$preparedSelectResultRecordStatement = null
staticprotected

◆ $preparedSelectSolutionRecordsStatement

ilAssQuestionUserSolutionAdopter::$preparedSelectSolutionRecordsStatement = null
staticprotected

◆ $processLockerFactory

ilAssQuestionUserSolutionAdopter::$processLockerFactory
protected

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

◆ $questionIds

ilAssQuestionUserSolutionAdopter::$questionIds
protected

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

Referenced by getQuestionIds(), and setQuestionIds().

◆ $targetPass

ilAssQuestionUserSolutionAdopter::$targetPass
protected

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

Referenced by getTargetPass(), and setTargetPass().

◆ $userId

ilAssQuestionUserSolutionAdopter::$userId
protected

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

Referenced by getUserId(), and setUserId().


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