19 declare(strict_types=0);
41 $this->db = $DIC->database();
43 $this->container_id = $a_container_id;
50 if (isset(self::$instances[$a_container_id])) {
51 return self::$instances[$a_container_id];
53 return self::$instances[$a_container_id] =
new self($a_container_id);
62 $query =
'SELECT container_id FROM loc_tst_assignments ' .
63 'WHERE tst_ref_id = ' .
$ilDB->quote($a_test_ref_id,
'integer');
66 return $row->container_id;
94 $ilDB = $DIC->database();
95 $query =
'DELETE FROM loc_tst_assignments ' .
96 'WHERE container_id = ' .
$ilDB->quote($a_container_id,
'integer');
97 $ilDB->manipulate($query);
107 foreach ($this->assignments as $assignment) {
108 if ($assignment->getAssignmentType() === $a_type) {
109 $by_type[] = $assignment;
125 $tests[] = $this->
getSettings()->getQualifiedTest();
127 foreach ($this->assignments as $assignment) {
128 $tests[] = $assignment->getTestRefId();
137 if (!$this->
getSettings()->hasSeparateInitialTests()) {
143 if (!$this->
getSettings()->hasSeparateQualifiedTests()) {
151 return $assignment->getTestRefId();
158 if (!$this->
getSettings()->hasSeparateInitialTests()) {
159 if ($this->
getSettings()->getInitialTest() == $a_test_ref_id) {
163 if (!$this->
getSettings()->hasSeparateQualifiedTests()) {
164 if ($this->
getSettings()->getQualifiedTest() == $a_test_ref_id) {
174 if ($this->
getSettings()->getInitialTest() == $a_test_ref_id) {
177 } elseif ($this->
getSettings()->worksWithInitialTest()) {
178 foreach ($this->assignments as $assignment) {
179 if ($assignment->getTestRefId() == $a_test_ref_id) {
184 if (!$this->
getSettings()->hasSeparateQualifiedTests()) {
185 if ($this->
getSettings()->getQualifiedTest() == $a_test_ref_id) {
189 foreach ($this->assignments as $assignment) {
190 if ($assignment->getTestRefId() == $a_test_ref_id) {
200 foreach ($this->assignments as $assignment) {
202 ($assignment->getObjectiveId() === $a_objective_id) &&
203 ($assignment->getAssignmentType() === $a_type)
213 $query =
'SELECT assignment_id FROM loc_tst_assignments ' .
214 'WHERE container_id = ' . $this->db->quote($this->
getContainerId(),
'integer');
215 $res = $this->db->query($query);
219 $this->assignments[] = $assignment;
226 if ($assignment->getObjectiveId() != $a_objective_id) {
233 'refId' => $assignment->getTestRefId(),
234 'testType' => $assignment->getAssignmentType()
244 $ilDB = $DIC->database();
246 $query =
'SELECT objective_id FROM loc_tst_assignments ' .
247 'WHERE tst_ref_id = ' .
$ilDB->quote($a_test_ref_id,
'integer');
static deleteByContainer(int $a_container_id)
getAssignmentsByType(int $a_type)
Get assignments by type.
toXml(ilXmlWriter $writer, int $a_objective_id)
__construct(int $a_container_id)
isSeparateTest(int $a_test_ref_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getTypeByTest(int $a_test_ref_id)
static lookupObjectivesForTest(int $a_test_ref_id)
getAssignments()
Get assignments.
static getInstanceByObjId(int $a_obj_id)
getAssignmentByObjective(int $a_objective_id, int $a_type)
static getInstance(int $a_container_id)
const TYPE_TEST_QUALIFIED
static lookupContainerForTest(int $a_test_ref_id)
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
const TYPE_TEST_UNDEFINED
getTestByObjective(int $a_objective_id, int $a_type)