ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 25 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 74 of file class.ilAssQuestionUserSolutionAdopter.php.

References $db.

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

Member Function Documentation

◆ adoptQuestionAnswer()

ilAssQuestionUserSolutionAdopter::adoptQuestionAnswer (   $questionId)
protected

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

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

Referenced by perform().

166  : void
167  {
168  $this->resetTargetSolution($questionId);
169  $this->resetTargetResult($questionId);
170 
171  $sourcePass = $this->adoptSourceSolution($questionId);
172 
173  if ($sourcePass !== null) {
174  $this->adoptSourceResult($questionId, $sourcePass);
175  }
176  }
+ 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 221 of file class.ilAssQuestionUserSolutionAdopter.php.

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

Referenced by adoptQuestionAnswer().

221  : void
222  {
223  $res = $this->db->execute(
225  array($this->getActiveId(), $questionId, $sourcePass)
226  );
227 
228  $row = $this->db->fetchAssoc($res);
229 
230  $resultId = $this->db->nextId('tst_test_result');
231 
232  $this->db->execute($this->getPreparedInsertResultRecordStatement(), array(
233  $resultId, $this->getActiveId(), $questionId, $this->getTargetPass(), time(),
234  $row['points'], $row['manual'], $row['hint_count'], $row['hint_points'], $row['answered']
235  ));
236  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adoptSourceSolution()

ilAssQuestionUserSolutionAdopter::adoptSourceSolution (   $questionId)
protected

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

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

Referenced by adoptQuestionAnswer().

195  {
196  $res = $this->db->execute(
198  array($this->getActiveId(), $questionId, $this->getTargetPass())
199  );
200 
201  $sourcePass = null;
202 
203  while ($row = $this->db->fetchAssoc($res)) {
204  if ($sourcePass === null) {
205  $sourcePass = $row['pass'];
206  } elseif ($row['pass'] < $sourcePass) {
207  break;
208  }
209 
210  $solutionId = $this->db->nextId('tst_solutions');
211 
212  $this->db->execute($this->getPreparedInsertSolutionRecordStatement(), array(
213  $solutionId, $this->getActiveId(), $questionId, $this->getTargetPass(), time(),
214  $row['points'], $row['value1'], $row['value2']
215  ));
216  }
217 
218  return $sourcePass;
219  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActiveId()

ilAssQuestionUserSolutionAdopter::getActiveId ( )
Returns
int

Definition at line 107 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 287 of file class.ilAssQuestionUserSolutionAdopter.php.

Referenced by resetTargetResult().

287  : ilDBStatement
288  {
289  if (self::$preparedDeleteResultRecordStatement === null) {
290  self::$preparedDeleteResultRecordStatement = $this->db->prepareManip(
291  "DELETE FROM tst_test_result WHERE active_fi = ? AND question_fi = ? AND pass = ?",
292  array('integer', 'integer', 'integer')
293  );
294  }
295 
296  return self::$preparedDeleteResultRecordStatement;
297  }
+ Here is the caller graph for this function:

◆ getPreparedDeleteSolutionRecordsStatement()

ilAssQuestionUserSolutionAdopter::getPreparedDeleteSolutionRecordsStatement ( )
protected

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

Referenced by resetTargetSolution().

238  : ilDBStatement
239  {
240  if (self::$preparedDeleteSolutionRecordsStatement === null) {
241  self::$preparedDeleteSolutionRecordsStatement = $this->db->prepareManip(
242  "DELETE FROM tst_solutions WHERE active_fi = ? AND question_fi = ? AND pass = ?",
243  array('integer', 'integer', 'integer')
244  );
245  }
246 
247  return self::$preparedDeleteSolutionRecordsStatement;
248  }
+ Here is the caller graph for this function:

◆ getPreparedInsertResultRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedInsertResultRecordStatement ( )
protected

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

References $query.

Referenced by adoptSourceResult().

316  : ilDBStatement
317  {
318  if (self::$preparedInsertResultRecordStatement === null) {
319  $query = "
320  INSERT INTO tst_test_result (
321  test_result_id, active_fi, question_fi, pass, tstamp,
322  points, manual, hint_count, hint_points, answered
323  ) VALUES (
324  ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
325  )
326  ";
327 
328  self::$preparedInsertResultRecordStatement = $this->db->prepareManip(
329  $query,
330  array('integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer')
331  );
332  }
333 
334  return self::$preparedInsertResultRecordStatement;
335  }
$query
+ Here is the caller graph for this function:

◆ getPreparedInsertSolutionRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedInsertSolutionRecordStatement ( )
protected

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

References $query.

Referenced by adoptSourceSolution().

267  : ilDBStatement
268  {
269  if (self::$preparedInsertSolutionRecordStatement === null) {
270  $query = "
271  INSERT INTO tst_solutions (
272  solution_id, active_fi, question_fi, pass, tstamp, points, value1, value2
273  ) VALUES (
274  ?, ?, ?, ?, ?, ?, ?, ?
275  )
276  ";
277 
278  self::$preparedInsertSolutionRecordStatement = $this->db->prepareManip(
279  $query,
280  array('integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'text', 'text')
281  );
282  }
283 
284  return self::$preparedInsertSolutionRecordStatement;
285  }
$query
+ Here is the caller graph for this function:

◆ getPreparedSelectResultRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedSelectResultRecordStatement ( )
protected

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

References $query.

Referenced by adoptSourceResult().

299  : ilDBStatement
300  {
301  if (self::$preparedSelectResultRecordStatement === null) {
302  $query = "
303  SELECT points, manual, hint_count, hint_points, answered FROM tst_test_result
304  WHERE active_fi = ? AND question_fi = ? AND pass = ?
305  ";
306 
307  self::$preparedSelectResultRecordStatement = $this->db->prepare(
308  $query,
309  array('integer', 'integer', 'integer')
310  );
311  }
312 
313  return self::$preparedSelectResultRecordStatement;
314  }
$query
+ Here is the caller graph for this function:

◆ getPreparedSelectSolutionRecordsStatement()

ilAssQuestionUserSolutionAdopter::getPreparedSelectSolutionRecordsStatement ( )
protected

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

References $query.

Referenced by adoptSourceSolution().

250  : ilDBStatement
251  {
252  if (self::$preparedSelectSolutionRecordsStatement === null) {
253  $query = "
254  SELECT pass, points, value1, value2 FROM tst_solutions
255  WHERE active_fi = ? AND question_fi = ? AND pass < ? ORDER BY pass DESC
256  ";
257 
258  self::$preparedSelectSolutionRecordsStatement = $this->db->prepare(
259  $query,
260  array('integer', 'integer', 'integer')
261  );
262  }
263 
264  return self::$preparedSelectSolutionRecordsStatement;
265  }
$query
+ Here is the caller graph for this function:

◆ getQuestionIds()

ilAssQuestionUserSolutionAdopter::getQuestionIds ( )
Returns
array

Definition at line 139 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 123 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 91 of file class.ilAssQuestionUserSolutionAdopter.php.

References $userId.

Referenced by perform().

+ Here is the caller graph for this function:

◆ perform()

ilAssQuestionUserSolutionAdopter::perform ( )

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

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

152  : void
153  {
154  $this->processLockerFactory->setUserId($this->getUserId());
155 
156  foreach ($this->getQuestionIds() as $questionId) {
157  $this->processLockerFactory->setQuestionId($questionId);
158  $processLocker = $this->processLockerFactory->getLocker();
159 
160  $processLocker->executeUserTestResultUpdateLockOperation(function () use ($questionId) {
161  $this->adoptQuestionAnswer($questionId);
162  });
163  }
164  }
+ Here is the call graph for this function:

◆ resetTargetResult()

ilAssQuestionUserSolutionAdopter::resetTargetResult (   $questionId)
protected

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

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 178 of file class.ilAssQuestionUserSolutionAdopter.php.

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 115 of file class.ilAssQuestionUserSolutionAdopter.php.

References $activeId.

115  : void
116  {
117  $this->activeId = $activeId;
118  }

◆ setQuestionIds()

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

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

References $questionIds.

147  : void
148  {
149  $this->questionIds = $questionIds;
150  }

◆ setTargetPass()

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

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

References $targetPass.

131  : void
132  {
133  $this->targetPass = $targetPass;
134  }

◆ setUserId()

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

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

References $userId.

99  : void
100  {
101  $this->userId = $userId;
102  }

Field Documentation

◆ $activeId

ilAssQuestionUserSolutionAdopter::$activeId
protected

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

Referenced by getActiveId(), and setActiveId().

◆ $db

ilAssQuestionUserSolutionAdopter::$db
protected

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

Referenced by __construct().

◆ $preparedDeleteResultRecordStatement

ilAssQuestionUserSolutionAdopter::$preparedDeleteResultRecordStatement = null
staticprotected

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

◆ $preparedDeleteSolutionRecordsStatement

ilAssQuestionUserSolutionAdopter::$preparedDeleteSolutionRecordsStatement = null
staticprotected

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

◆ $preparedInsertResultRecordStatement

ilAssQuestionUserSolutionAdopter::$preparedInsertResultRecordStatement = null
staticprotected

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

◆ $preparedInsertSolutionRecordStatement

ilAssQuestionUserSolutionAdopter::$preparedInsertSolutionRecordStatement = null
staticprotected

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

◆ $preparedSelectResultRecordStatement

ilAssQuestionUserSolutionAdopter::$preparedSelectResultRecordStatement = null
staticprotected

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

◆ $preparedSelectSolutionRecordsStatement

ilAssQuestionUserSolutionAdopter::$preparedSelectSolutionRecordsStatement = null
staticprotected

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

◆ $processLockerFactory

ilAssQuestionUserSolutionAdopter::$processLockerFactory
protected

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

◆ $questionIds

ilAssQuestionUserSolutionAdopter::$questionIds
protected

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

Referenced by getQuestionIds(), and setQuestionIds().

◆ $targetPass

ilAssQuestionUserSolutionAdopter::$targetPass
protected

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

Referenced by getTargetPass(), and setTargetPass().

◆ $userId

ilAssQuestionUserSolutionAdopter::$userId
protected

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

Referenced by getUserId(), and setUserId().


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