ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

References $db, and array.

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  }
Create styles array
The data for the language used.

Member Function Documentation

◆ adoptQuestionAnswer()

ilAssQuestionUserSolutionAdopter::adoptQuestionAnswer (   $questionId)
protected

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

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

Referenced by perform().

171  {
172  $this->resetTargetSolution($questionId);
173  $this->resetTargetResult($questionId);
174 
175  $sourcePass = $this->adoptSourceSolution($questionId);
176 
177  if ($sourcePass !== null) {
178  $this->adoptSourceResult($questionId, $sourcePass);
179  }
180  }
+ 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 225 of file class.ilAssQuestionUserSolutionAdopter.php.

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

Referenced by adoptQuestionAnswer().

226  {
227  $res = $this->db->execute(
229  array($this->getActiveId(), $questionId, $sourcePass)
230  );
231 
232  $row = $this->db->fetchAssoc($res);
233 
234  $resultId = $this->db->nextId('tst_test_result');
235 
236  $this->db->execute($this->getPreparedInsertResultRecordStatement(), array(
237  $resultId, $this->getActiveId(), $questionId, $this->getTargetPass(), time(),
238  $row['points'], $row['manual'], $row['hint_count'], $row['hint_points'], $row['answered']
239  ));
240  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adoptSourceSolution()

ilAssQuestionUserSolutionAdopter::adoptSourceSolution (   $questionId)
protected

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

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

Referenced by adoptQuestionAnswer().

199  {
200  $res = $this->db->execute(
202  array($this->getActiveId(), $questionId, $this->getTargetPass())
203  );
204 
205  $sourcePass = null;
206 
207  while ($row = $this->db->fetchAssoc($res)) {
208  if ($sourcePass === null) {
209  $sourcePass = $row['pass'];
210  } elseif ($row['pass'] < $sourcePass) {
211  break;
212  }
213 
214  $solutionId = $this->db->nextId('tst_solutions');
215 
216  $this->db->execute($this->getPreparedInsertSolutionRecordStatement(), array(
217  $solutionId, $this->getActiveId(), $questionId, $this->getTargetPass(), time(),
218  $row['points'], $row['value1'], $row['value2']
219  ));
220  }
221 
222  return $sourcePass;
223  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ 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 291 of file class.ilAssQuestionUserSolutionAdopter.php.

References array.

Referenced by resetTargetResult().

292  {
293  if (self::$preparedDeleteResultRecordStatement === null) {
294  self::$preparedDeleteResultRecordStatement = $this->db->prepareManip(
295  "DELETE FROM tst_test_result WHERE active_fi = ? AND question_fi = ? AND pass = ?",
296  array('integer', 'integer', 'integer')
297  );
298  }
299 
300  return self::$preparedDeleteResultRecordStatement;
301  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getPreparedDeleteSolutionRecordsStatement()

ilAssQuestionUserSolutionAdopter::getPreparedDeleteSolutionRecordsStatement ( )
protected

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

References array.

Referenced by resetTargetSolution().

243  {
244  if (self::$preparedDeleteSolutionRecordsStatement === null) {
245  self::$preparedDeleteSolutionRecordsStatement = $this->db->prepareManip(
246  "DELETE FROM tst_solutions WHERE active_fi = ? AND question_fi = ? AND pass = ?",
247  array('integer', 'integer', 'integer')
248  );
249  }
250 
251  return self::$preparedDeleteSolutionRecordsStatement;
252  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getPreparedInsertResultRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedInsertResultRecordStatement ( )
protected

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

References $query, and array.

Referenced by adoptSourceResult().

321  {
322  if (self::$preparedInsertResultRecordStatement === null) {
323  $query = "
324  INSERT INTO tst_test_result (
325  test_result_id, active_fi, question_fi, pass, tstamp,
326  points, manual, hint_count, hint_points, answered
327  ) VALUES (
328  ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
329  )
330  ";
331 
332  self::$preparedInsertResultRecordStatement = $this->db->prepareManip(
333  $query,
334  array('integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer')
335  );
336  }
337 
338  return self::$preparedInsertResultRecordStatement;
339  }
$query
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getPreparedInsertSolutionRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedInsertSolutionRecordStatement ( )
protected

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

References $query, and array.

Referenced by adoptSourceSolution().

272  {
273  if (self::$preparedInsertSolutionRecordStatement === null) {
274  $query = "
275  INSERT INTO tst_solutions (
276  solution_id, active_fi, question_fi, pass, tstamp, points, value1, value2
277  ) VALUES (
278  ?, ?, ?, ?, ?, ?, ?, ?
279  )
280  ";
281 
282  self::$preparedInsertSolutionRecordStatement = $this->db->prepareManip(
283  $query,
284  array('integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'text', 'text')
285  );
286  }
287 
288  return self::$preparedInsertSolutionRecordStatement;
289  }
$query
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getPreparedSelectResultRecordStatement()

ilAssQuestionUserSolutionAdopter::getPreparedSelectResultRecordStatement ( )
protected

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

References $query, and array.

Referenced by adoptSourceResult().

304  {
305  if (self::$preparedSelectResultRecordStatement === null) {
306  $query = "
307  SELECT points, manual, hint_count, hint_points, answered FROM tst_test_result
308  WHERE active_fi = ? AND question_fi = ? AND pass = ?
309  ";
310 
311  self::$preparedSelectResultRecordStatement = $this->db->prepare(
312  $query,
313  array('integer', 'integer', 'integer')
314  );
315  }
316 
317  return self::$preparedSelectResultRecordStatement;
318  }
$query
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getPreparedSelectSolutionRecordsStatement()

ilAssQuestionUserSolutionAdopter::getPreparedSelectSolutionRecordsStatement ( )
protected

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

References $query, and array.

Referenced by adoptSourceSolution().

255  {
256  if (self::$preparedSelectSolutionRecordsStatement === null) {
257  $query = "
258  SELECT pass, points, value1, value2 FROM tst_solutions
259  WHERE active_fi = ? AND question_fi = ? AND pass < ? ORDER BY pass DESC
260  ";
261 
262  self::$preparedSelectSolutionRecordsStatement = $this->db->prepare(
263  $query,
264  array('integer', 'integer', 'integer')
265  );
266  }
267 
268  return self::$preparedSelectSolutionRecordsStatement;
269  }
$query
Create styles array
The data for the language used.
+ 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.

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

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

◆ resetTargetResult()

ilAssQuestionUserSolutionAdopter::resetTargetResult (   $questionId)
protected

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

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

Referenced by adoptQuestionAnswer().

191  {
192  $this->db->execute(
194  array($this->getActiveId(), $questionId, $this->getTargetPass())
195  );
196  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetTargetSolution()

ilAssQuestionUserSolutionAdopter::resetTargetSolution (   $questionId)
protected

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

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

Referenced by adoptQuestionAnswer().

183  {
184  $this->db->execute(
186  array($this->getActiveId(), $questionId, $this->getTargetPass())
187  );
188  }
Create styles array
The data for the language used.
+ 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.

References $activeId.

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

◆ setQuestionIds()

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

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

References $questionIds.

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

◆ setTargetPass()

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

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

References $targetPass.

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

◆ setUserId()

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

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

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

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

◆ $preparedDeleteSolutionRecordsStatement

ilAssQuestionUserSolutionAdopter::$preparedDeleteSolutionRecordsStatement = null
staticprotected

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

◆ $preparedInsertResultRecordStatement

ilAssQuestionUserSolutionAdopter::$preparedInsertResultRecordStatement = null
staticprotected

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

◆ $preparedInsertSolutionRecordStatement

ilAssQuestionUserSolutionAdopter::$preparedInsertSolutionRecordStatement = null
staticprotected

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

◆ $preparedSelectResultRecordStatement

ilAssQuestionUserSolutionAdopter::$preparedSelectResultRecordStatement = null
staticprotected

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

◆ $preparedSelectSolutionRecordsStatement

ilAssQuestionUserSolutionAdopter::$preparedSelectSolutionRecordsStatement = null
staticprotected

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

◆ $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: