ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
62  // #19247
63  $testOBJ = $this->testObj;
64  }
65  else
66  {
67  require_once 'Services/Object/classes/class.ilObjectFactory.php';
68  $testOBJ = ilObjectFactory::getInstanceByObjId($this->obj_id);
69  }
70  $testOBJ->removeTestResultsByUserIds($a_user_ids);
71 
72  // :TODO: there has to be a better way
73  $test_ref_id = (int)$_REQUEST["ref_id"];
74  if($this->testObj && $this->testObj->getRefId())
75  {
76  $test_ref_id = $this->testObj->getRefId();
77  }
78  if($test_ref_id)
79  {
80  require_once "Modules/Course/classes/Objectives/class.ilLOSettings.php";
81  $course_obj_id = ilLOSettings::isObjectiveTest($test_ref_id);
82  if($course_obj_id)
83  {
84  // remove objective results data
85  $lo_settings = ilLOSettings::getInstanceByObjId($course_obj_id);
86 
87  require_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php";
88  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
90  $course_obj_id,
91  $a_user_ids,
92  ($lo_settings->getInitialTest() == $test_ref_id),
93  ($lo_settings->getQualifiedTest() == $test_ref_id),
95  );
96 
97  // refresh LP - see ilLPStatusWrapper::_updateStatus()
98  require_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
99  $lp_status = ilLPStatusFactory::_getInstance($course_obj_id);
100  if (strtolower(get_class($lp_status)) != "illpstatus")
101  {
102  foreach($a_user_ids as $user_id)
103  {
104  $lp_status->_updateStatus($course_obj_id, $user_id);
105  }
106  }
107  }
108  }
109  }
110 
111  protected static function isLPMember(array &$a_res, $a_usr_id, $a_obj_ids)
112  {
113  global $ilDB;
114 
115  // if active id
116  $set = $ilDB->query("SELECT tt.obj_fi".
117  " FROM tst_active ta".
118  " JOIN tst_tests tt ON (ta.test_fi = tt.test_id)".
119  " WHERE ".$ilDB->in("tt.obj_fi", (array)$a_obj_ids, "", "integer").
120  " AND ta.user_fi = ".$ilDB->quote($a_usr_id, "integer"));
121  while($row = $ilDB->fetchAssoc($set))
122  {
123  $a_res[$row["obj_fi"]] = true;
124  }
125 
126  return true;
127  }
128 }
129 
130 ?>
static getInstanceByObjId($a_obj_id)
get singleton instance
static isObjectiveTest($a_trst_ref_id)
Check if test ref_id is used in an objective course.
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 _getInstance($a_obj_id, $a_mode=NULL)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
static lookupObjectivesForTest($a_test_ref_id)
Get all objectives that are assigned to given test.
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