ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTestLP.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 include_once "Services/Object/classes/class.ilObjectLP.php";
5 
13 class ilTestLP extends ilObjectLP
14 {
18  protected $testObj;
19 
20  public static function getDefaultModes($a_lp_active)
21  {
22  return array(
26  );
27  }
28 
29  public function getDefaultMode()
30  {
32  }
33 
34  public function getValidModes()
35  {
36  return array(
40  );
41  }
42 
43  public function isAnonymized()
44  {
45  include_once './Modules/Test/classes/class.ilObjTest.php';
46  return (bool) ilObjTest::_lookupAnonymity($this->obj_id);
47  }
48 
52  public function setTestObject(\ilObjTest $test)
53  {
54  $this->testObj = $test;
55  }
56 
57  protected function resetCustomLPDataForUserIds(array $a_user_ids, $a_recursive = true)
58  {
59  /* @var ilObjTest $testOBJ */
60  if ($this->testObj) {
61  // #19247
62  $testOBJ = $this->testObj;
63  } else {
64  require_once 'Services/Object/classes/class.ilObjectFactory.php';
65  $testOBJ = ilObjectFactory::getInstanceByObjId($this->obj_id);
66  }
67  $testOBJ->removeTestResultsByUserIds($a_user_ids);
68 
69  // :TODO: there has to be a better way
70  $test_ref_id = (int) $_REQUEST["ref_id"];
71  if ($this->testObj && $this->testObj->getRefId()) {
72  $test_ref_id = $this->testObj->getRefId();
73  }
74  if ($test_ref_id) {
75  require_once "Modules/Course/classes/Objectives/class.ilLOSettings.php";
76  $course_obj_id = ilLOSettings::isObjectiveTest($test_ref_id);
77  if ($course_obj_id) {
78  // remove objective results data
79  $lo_settings = ilLOSettings::getInstanceByObjId($course_obj_id);
80 
81  require_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php";
82  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
84  $course_obj_id,
85  $a_user_ids,
86  ($lo_settings->getInitialTest() == $test_ref_id),
87  ($lo_settings->getQualifiedTest() == $test_ref_id),
89  );
90 
91  // refresh LP - see ilLPStatusWrapper::_updateStatus()
92  require_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
93  $lp_status = ilLPStatusFactory::_getInstance($course_obj_id);
94  if (strtolower(get_class($lp_status)) != "illpstatus") {
95  foreach ($a_user_ids as $user_id) {
96  $lp_status->_updateStatus($course_obj_id, $user_id);
97  }
98  }
99  }
100  }
101  }
102 
103  protected static function isLPMember(array &$a_res, $a_usr_id, $a_obj_ids)
104  {
105  global $DIC;
106  $ilDB = $DIC['ilDB'];
107 
108  // if active id
109  $set = $ilDB->query("SELECT tt.obj_fi" .
110  " FROM tst_active ta" .
111  " JOIN tst_tests tt ON (ta.test_fi = tt.test_id)" .
112  " WHERE " . $ilDB->in("tt.obj_fi", (array) $a_obj_ids, false, "integer") .
113  " AND ta.user_fi = " . $ilDB->quote($a_usr_id, "integer"));
114  while ($row = $ilDB->fetchAssoc($set)) {
115  $a_res[$row["obj_fi"]] = true;
116  }
117 
118  return true;
119  }
120 }
static getInstanceByObjId($a_obj_id)
get singleton instance
global $DIC
Definition: saml.php:7
static isObjectiveTest($a_trst_ref_id)
Check if test ref_id is used in an objective course.
static _getInstance($a_obj_id, $a_mode=null)
static _lookupAnonymity($a_obj_id)
Returns the anonymity status of a test with a given object id.
resetCustomLPDataForUserIds(array $a_user_ids, $a_recursive=true)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static lookupObjectivesForTest($a_test_ref_id)
Get all objectives that are assigned to given test.
$row
setTestObject(\ilObjTest $test)
static isLPMember(array &$a_res, $a_usr_id, $a_obj_ids)
global $ilDB
static getDefaultModes($a_lp_active)
static deleteResultsFromLP($a_course_id, array $a_user_ids, $a_remove_initial, $a_remove_qualified, array $a_objective_ids)
Delete all (qualified) result entries for course members.
$test
Definition: Utf8Test.php:84