ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTestLP.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
31class ilTestLP extends ilObjectLP
32{
34 protected ?ilObjTest $test_object = null;
35
36 public function __construct(int $obj_id)
37 {
38 $this->request = TestDIC::dic()['request_data_collector'];
39
41 }
42
43 public static function getDefaultModes(bool $a_lp_active): array
44 {
45 return [
49 ];
50 }
51
52 public function getDefaultMode(): int
53 {
55 }
56
57 public function getValidModes(): array
58 {
59 return [
63 ];
64 }
65
66 public function isAnonymized(): bool
67 {
68 if ($this->test_object === null) {
70 }
71 return (bool) $this->test_object->getAnonymity();
72 }
73
77 public function setTestObject(\ilObjTest $test)
78 {
79 $this->test_object = $test;
80 }
81
82 protected function resetCustomLPDataForUserIds(array $user_ids, bool $recursive = true): void
83 {
84 /* @var ilObjTest $testOBJ */
85 if ($this->test_object) {
86 // #19247
87 $testOBJ = $this->test_object;
88 } else {
89 $testOBJ = ilObjectFactory::getInstanceByObjId($this->obj_id);
90 }
91 $testOBJ->removeTestResultsByUserIds($user_ids);
92
93 // :TODO: there has to be a better way
94 $test_ref_id = $this->request->int('ref_id');
95 if ($this->test_object && $this->test_object->getRefId()) {
96 $test_ref_id = $this->test_object->getRefId();
97 }
98
99 if ($test_ref_id === 0) {
100 return;
101 }
102
103 $course_obj_id = ilLOTestAssignments::lookupContainerForTest($test_ref_id);
104 if ($course_obj_id === 0) {
105 return;
106 }
107
108 // remove objective results data
109 $lo_assignments = ilLOTestAssignments::getInstance($course_obj_id);
111 $course_obj_id,
112 $user_ids,
113 $lo_assignments->getTypeByTest($test_ref_id) === ilLOSettings::TYPE_TEST_INITIAL,
114 $lo_assignments->getTypeByTest($test_ref_id) === ilLOSettings::TYPE_TEST_QUALIFIED,
116 );
117 $lp_status = ilLPStatusFactory::_getInstance($course_obj_id);
118 if (strtolower(get_class($lp_status)) !== 'illpstatus') {
119 foreach ($user_ids as $user_id) {
120 $lp_status->_updateStatus($course_obj_id, $user_id);
121 }
122 }
123 }
124
125 protected static function isLPMember(array &$a_res, int $a_usr_id, array $a_obj_ids): bool
126 {
127 global $DIC;
128 $ilDB = $DIC['ilDB'];
129
130 // if active id
131 $set = $ilDB->query("SELECT tt.obj_fi" .
132 " FROM tst_active ta" .
133 " JOIN tst_tests tt ON (ta.test_fi = tt.test_id)" .
134 " WHERE " . $ilDB->in("tt.obj_fi", (array) $a_obj_ids, false, "integer") .
135 " AND ta.user_fi = " . $ilDB->quote($a_usr_id, "integer"));
136 while ($row = $ilDB->fetchAssoc($set)) {
137 $a_res[$row["obj_fi"]] = true;
138 }
139
140 return true;
141 }
142}
static lookupContainerForTest(int $a_test_ref_id)
static lookupObjectivesForTest(int $a_test_ref_id)
static getInstance(int $a_container_id)
static deleteResultsFromLP(int $a_course_id, array $a_user_ids, bool $a_remove_initial, bool $a_remove_qualified, array $a_objective_ids)
static _getInstance(int $a_obj_id, ?int $a_mode=null)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Base class for object lp connectors.
resetCustomLPDataForUserIds(array $user_ids, bool $recursive=true)
static isLPMember(array &$a_res, int $a_usr_id, array $a_obj_ids)
Find (lp-relevant) members for given object ids.
__construct(int $obj_id)
static getDefaultModes(bool $a_lp_active)
Get available type-specific default modes (no administration needed)
setTestObject(\ilObjTest $test)
ilObjTest $test_object
RequestDataCollector $request
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26