ILIAS  release_8 Revision v8.24
ilLOUtils Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilLOUtils:

Static Public Member Functions

static isCompleted (int $a_cont_oid, int $a_test_rid, int $a_objective_id, int $max_points, int $reached, int $limit_perc)
 Check if objective is completed. More...
 
static lookupObjectiveRequiredPercentage (int $a_container_id, int $a_objective_id, int $a_test_ref_id, int $a_max_points)
 
static lookupMaxAttempts (int $a_container_id, int $a_objective_id, int $a_test_ref_id)
 
static lookupRandomTest (int $a_test_obj_id)
 
static lookupQplBySequence (int $a_test_ref_id, int $a_sequence_id)
 Lookup assigned qpl name (including taxonomy) by sequence. More...
 
static hasActiveRun (int $a_container_id, int $a_test_ref_id, int $a_objective_id)
 
static getTestResultLinkForUser (int $a_test_ref_id, int $a_user_id)
 

Static Protected Member Functions

static buildQplTitleByDefinition (ilTestRandomQuestionSetSourcePoolDefinition $def, ilTestTaxonomyFilterLabelTranslater $trans)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Settings for LO courses

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 24 of file class.ilLOUtils.php.

Member Function Documentation

◆ buildQplTitleByDefinition()

static ilLOUtils::buildQplTitleByDefinition ( ilTestRandomQuestionSetSourcePoolDefinition  $def,
ilTestTaxonomyFilterLabelTranslater  $trans 
)
staticprotected

Definition at line 155 of file class.ilLOUtils.php.

158 : string {
159 $title = $def->getPoolTitle();
160 $filterTitle = array();
161 $filterTitle[] = $trans->getTaxonomyFilterLabel($def->getMappedTaxonomyFilter());
162 $filterTitle[] = $trans->getTypeFilterLabel($def->getTypeFilter());
163 if (!empty($filterTitle)) {
164 $title .= ' -> ' . implode(' / ', $filterTitle);
165 }
166 return $title;
167 }
getTaxonomyFilterLabel($filter=array(), $filterDelimiter='+', $taxNodeDelimiter=':', $nodesDelimiter=', ')
Get the label for a taxonomy filter.
getTypeFilterLabel($filter=array())
Get the label for a type filter.

◆ getTestResultLinkForUser()

static ilLOUtils::getTestResultLinkForUser ( int  $a_test_ref_id,
int  $a_user_id 
)
static

Definition at line 174 of file class.ilLOUtils.php.

174 : string
175 {
176 global $DIC;
177
178 $ilCtrl = $DIC->ctrl();
179 $ilUser = $DIC->user();
180 $ilAccess = $DIC->access();
181
182 if ($ilUser->getId() == ANONYMOUS_USER_ID) {
183 return '';
184 }
185
186 $valid = $tutor = false;
187 if ($a_user_id == $ilUser->getId()) {
188 $valid = $ilAccess->checkAccess('read', '', $a_test_ref_id);
189 }
190 if (!$valid) {
191 $valid = $ilAccess->checkAccess('write', '', $a_test_ref_id);
192 $tutor = true;
193 }
194 if ($valid) {
195 $testObjId = ilObject::_lookupObjId($a_test_ref_id);
196 if (!$tutor) {
197 if (ilObjTestAccess::visibleUserResultExists($testObjId, $a_user_id)) {
198 $ilCtrl->setParameterByClass('ilObjTestGUI', 'ref_id', $a_test_ref_id);
199 $ctrlClasses = array('ilRepositoryGUI', 'ilObjTestGUI', 'ilTestResultsGUI');
200 $link = $ilCtrl->getLinkTargetByClass($ctrlClasses);
201 $ilCtrl->setParameterByClass('ilObjTestGUI', 'ref_id', '');
202 return $link;
203 }
204 } else {
205 $testId = ilObjTest::_getTestIDFromObjectID($testObjId);
206 if ($testId) {
207 $userActiveId = ilObjTest::_getActiveIdOfUser($a_user_id, $testId);
208 if ($userActiveId) {
209 $ilCtrl->setParameterByClass('ilTestEvaluationGUI', 'ref_id', $a_test_ref_id);
210 $ilCtrl->setParameterByClass('ilTestEvaluationGUI', 'active_id', $userActiveId);
211 $link = $ilCtrl->getLinkTargetByClass(array('ilRepositoryGUI',
212 'ilObjTestGUI',
213 'ilTestEvaluationGUI'
214 ), 'outParticipantsResultsOverview');
215 $ilCtrl->setParameterByClass('ilTestEvaluationGUI', 'ref_id', '');
216 $ilCtrl->setParameterByClass('ilTestEvaluationGUI', 'active_id', '');
217 return $link;
218 }
219 }
220 }
221 }
222 return '';
223 }
static visibleUserResultExists($testObjId, $userId)
static _getTestIDFromObjectID($object_id)
Returns the ILIAS test id for a given object id.
static _getActiveIdOfUser($user_id="", $test_id="")
static _lookupObjId(int $ref_id)
const ANONYMOUS_USER_ID
Definition: constants.php:27
$valid
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34

References $DIC, $ilUser, $valid, ilObjTest\_getActiveIdOfUser(), ilObjTest\_getTestIDFromObjectID(), ilObject\_lookupObjId(), ANONYMOUS_USER_ID, and ilObjTestAccess\visibleUserResultExists().

Referenced by ilLOMemberTestResultTableGUI\createTestResultLink().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasActiveRun()

static ilLOUtils::hasActiveRun ( int  $a_container_id,
int  $a_test_ref_id,
int  $a_objective_id 
)
static

Definition at line 169 of file class.ilLOUtils.php.

169 : bool
170 {
171 return false;
172 }

Referenced by ilContainerObjectiveGUI\showObjectives().

+ Here is the caller graph for this function:

◆ isCompleted()

static ilLOUtils::isCompleted ( int  $a_cont_oid,
int  $a_test_rid,
int  $a_objective_id,
int  $max_points,
int  $reached,
int  $limit_perc 
)
static

Check if objective is completed.

Definition at line 29 of file class.ilLOUtils.php.

36 : bool {
38
39 if (self::lookupRandomTest(ilObject::_lookupObjId($a_test_rid))) {
40 if ($max_points === 0) {
41 return true;
42 } else {
43 return ($reached / $max_points * 100) >= $limit_perc;
44 }
45 } else {
47 $a_cont_oid,
48 $a_objective_id,
49 $a_test_rid,
50 $max_points
51 );
52
53 if ($max_points === 0) {
54 return true;
55 } else {
56 return ($reached / $max_points * 100) >= $required_perc;
57 }
58 }
59 }
static getInstanceByObjId(int $a_obj_id)
static lookupObjectiveRequiredPercentage(int $a_container_id, int $a_objective_id, int $a_test_ref_id, int $a_max_points)
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200

Referenced by ilLOTestQuestionAdapter\updateQuestionResult().

+ Here is the caller graph for this function:

◆ lookupMaxAttempts()

static ilLOUtils::lookupMaxAttempts ( int  $a_container_id,
int  $a_objective_id,
int  $a_test_ref_id 
)
static

Definition at line 91 of file class.ilLOUtils.php.

91 : int
92 {
93 global $DIC;
94
95 $ilDB = $DIC->database();
96
97 $assignments = ilLOTestAssignments::getInstance($a_container_id);
98 if (!$assignments->isSeparateTest($a_test_ref_id)) {
99 // no limit of tries for tests assigned to multiple objectives.
100 return 0;
101 }
102
103 $query = 'SELECT nr_of_tries FROM tst_tests ' .
104 'WHERE obj_fi = ' . $ilDB->quote(ilObject::_lookupObjId($a_test_ref_id), 'integer');
105 $res = $ilDB->query($query);
106 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
107 return (int) $row->nr_of_tries;
108 }
109 return 0;
110 }
static getInstance(int $a_container_id)
$res
Definition: ltiservices.php:69
$query

References $DIC, $ilDB, $query, $res, ilObject\_lookupObjId(), ilDBConstants\FETCHMODE_OBJECT, and ilLOTestAssignments\getInstance().

Referenced by ilLOTestQuestionAdapter\initUserResult().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupObjectiveRequiredPercentage()

static ilLOUtils::lookupObjectiveRequiredPercentage ( int  $a_container_id,
int  $a_objective_id,
int  $a_test_ref_id,
int  $a_max_points 
)
static

Definition at line 61 of file class.ilLOUtils.php.

66 : int {
68 $assignments = ilLOTestAssignments::getInstance($a_container_id);
69 $a_test_type = $assignments->getTypeByTest($a_test_ref_id);
70
71 if ($assignments->isSeparateTest($a_test_ref_id)) {
73 $tst = $factory->getInstanceByRefId($a_test_ref_id, false);
74 if ($tst instanceof ilObjTest) {
75 $schema = $tst->getMarkSchema();
76 foreach ($schema->getMarkSteps() as $mark) {
77 if ($mark->getPassed()) {
78 return (int) $mark->getMinimumLevel();
79 }
80 }
81 }
82 }
83 $tst_ref_id = $a_test_ref_id;
84 if (self::lookupRandomTest(ilObject::_lookupObjId($tst_ref_id))) {
85 return ilLORandomTestQuestionPools::lookupLimit($a_container_id, $a_objective_id, $a_test_type);
86 } else {
87 return ilCourseObjectiveQuestion::loookupTestLimit(ilObject::_lookupObjId($tst_ref_id), $a_objective_id);
88 }
89 }
static loookupTestLimit(int $a_test_id, int $a_objective_id)
static lookupLimit(int $a_container_id, int $a_objective_id, int $a_test_type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$factory
Definition: metadata.php:75

Referenced by ilLOTestQuestionAdapter\initUserResult().

+ Here is the caller graph for this function:

◆ lookupQplBySequence()

static ilLOUtils::lookupQplBySequence ( int  $a_test_ref_id,
int  $a_sequence_id 
)
static

Lookup assigned qpl name (including taxonomy) by sequence.

Definition at line 120 of file class.ilLOUtils.php.

120 : string
121 {
122 global $DIC;
123
124 if (!$a_sequence_id) {
125 return '';
126 }
127 $tst = ilObjectFactory::getInstanceByRefId($a_test_ref_id, false);
128 if (!$tst instanceof ilObjTest) {
129 return '';
130 }
132 $DIC->database(),
133 $tst,
135 $DIC->database(),
136 $tst
137 )
138 );
139
140 $list->loadDefinitions();
141
142 $translator = new ilTestTaxonomyFilterLabelTranslater($GLOBALS['DIC']['ilDB']);
143 $translator->loadLabels($list);
144
145 $title = '';
146 foreach ($list as $definition) {
147 if ($definition->getId() != $a_sequence_id) {
148 continue;
149 }
150 $title = self::buildQplTitleByDefinition($definition, $translator);
151 }
152 return $title;
153 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static buildQplTitleByDefinition(ilTestRandomQuestionSetSourcePoolDefinition $def, ilTestTaxonomyFilterLabelTranslater $trans)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id

References $DIC, $GLOBALS, and ilObjectFactory\getInstanceByRefId().

Referenced by ilCourseObjectivesTableGUI\parse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupRandomTest()

static ilLOUtils::lookupRandomTest ( int  $a_test_obj_id)
static

Definition at line 112 of file class.ilLOUtils.php.

112 : bool
113 {
114 return ilObjTest::_lookupRandomTest($a_test_obj_id);
115 }
static _lookupRandomTest($a_obj_id)
Returns the fact wether the test with passed obj id is a random questions test or not.

References ilObjTest\_lookupRandomTest().

Referenced by ilLOEditorStatus\lookupQuestionsAssigned(), and ilCourseObjectivesTableGUI\parse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: