ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilAssIncompleteQuestionPurger.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
12{
16 protected $db;
17
18 protected $ownerId;
19
21
22 public function __construct(ilDBInterface $db)
23 {
24 $this->db = $db;
25
26 $this->ignoredContainerObjectTypes = array('lm');
27 }
28
29 public function getOwnerId()
30 {
31 return $this->ownerId;
32 }
33
34 public function setOwnerId($ownerId)
35 {
36 $this->ownerId = $ownerId;
37 }
38
39 public function purge()
40 {
41 $questionIds = $this->getPurgableQuestionIds();
42 $this->purgeQuestionIds($questionIds);
43 }
44
45 private function getPurgableQuestionIds()
46 {
47 $INtypes = $this->db->in('object_data.type', $this->getIgnoredContainerObjectTypes(), true, 'text');
48
49 $query = "
50 SELECT qpl_questions.question_id
51 FROM qpl_questions
52 INNER JOIN object_data
53 ON object_data.obj_id = qpl_questions.obj_fi
54 AND $INtypes
55 WHERE qpl_questions.owner = %s
56 AND qpl_questions.tstamp = %s
57 ";
58
59 $res = $this->db->queryF($query, array('integer', 'integer'), array($this->getOwnerId(), 0));
60
61 $questionIds = array();
62
63 while ($row = $this->db->fetchAssoc($res)) {
64 $questionIds[] = $row['question_id'];
65 }
66
67 return $questionIds;
68 }
69
70 private function purgeQuestionIds($questionIds)
71 {
72 require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
73
74 foreach ($questionIds as $questionId) {
75 $question = assQuestion::_instantiateQuestion($questionId);
76 $question->delete($questionId);
77 }
78 }
79
81 {
82 $this->ignoredContainerObjectTypes = $ignoredContainerObjectTypes;
83 }
84
85 protected function getIgnoredContainerObjectTypes()
86 {
88 }
89}
An exception for terminatinating execution or to throw for unit testing.
static _instantiateQuestion($question_id)
setIgnoredContainerObjectTypes($ignoredContainerObjectTypes)
Interface ilDBInterface.
$row
$query
foreach($_POST as $key=> $value) $res