ILIAS  trunk Revision v5.2.0beta1-34132-g2d4d73d4a0
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  $this->processLockerFactory = new ilAssQuestionProcessLockerFactory($assSettings, $db);
84  $this->processLockerFactory->setAssessmentLogEnabled($isAssessmentLogEnabled);
85  }

Member Function Documentation

◆ adoptQuestionAnswer()

ilAssQuestionUserSolutionAdopter::adoptQuestionAnswer (   $questionId)
protected

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

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

Referenced by perform().

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

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

Referenced by adoptQuestionAnswer().

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

◆ adoptSourceSolution()

ilAssQuestionUserSolutionAdopter::adoptSourceSolution (   $questionId)
protected

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

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

Referenced by adoptQuestionAnswer().

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

◆ getActiveId()

ilAssQuestionUserSolutionAdopter::getActiveId ( )
Returns
int

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

Referenced by resetTargetResult().

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

◆ getPreparedDeleteSolutionRecordsStatement()

ilAssQuestionUserSolutionAdopter::getPreparedDeleteSolutionRecordsStatement ( )
protected

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

Referenced by resetTargetSolution().

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

◆ getPreparedInsertResultRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedInsertResultRecordStatement ( )
protected

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

Referenced by adoptSourceResult().

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

◆ getPreparedInsertSolutionRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedInsertSolutionRecordStatement ( )
protected

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

Referenced by adoptSourceSolution().

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

◆ getPreparedSelectResultRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedSelectResultRecordStatement ( )
protected

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

Referenced by adoptSourceResult().

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

◆ getPreparedSelectSolutionRecordsStatement()

ilAssQuestionUserSolutionAdopter::getPreparedSelectSolutionRecordsStatement ( )
protected

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

Referenced by adoptSourceSolution().

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

◆ getQuestionIds()

ilAssQuestionUserSolutionAdopter::getQuestionIds ( )
Returns
array

Definition at line 138 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 122 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 90 of file class.ilAssQuestionUserSolutionAdopter.php.

References $userId.

Referenced by perform().

+ Here is the caller graph for this function:

◆ perform()

ilAssQuestionUserSolutionAdopter::perform ( )

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

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

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

◆ resetTargetResult()

ilAssQuestionUserSolutionAdopter::resetTargetResult (   $questionId)
protected

Definition at line 185 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 177 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 114 of file class.ilAssQuestionUserSolutionAdopter.php.

References $activeId.

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

◆ setQuestionIds()

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

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

References $questionIds.

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

◆ setTargetPass()

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

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

References $targetPass.

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

◆ setUserId()

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

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

References $userId.

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

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: