ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 function getDefaultMode()
21  {
23  }
24 
25  public function getValidModes()
26  {
27  return array(
31  );
32  }
33 
34  public function isAnonymized()
35  {
36  include_once './Modules/Test/classes/class.ilObjTest.php';
37  return (bool)ilObjTest::_lookupAnonymity($this->obj_id);
38  }
39 
43  public function setTestObject(\ilObjTest $test)
44  {
45  $this->testObj = $test;
46  }
47 
48  protected function resetCustomLPDataForUserIds(array $a_user_ids, $a_recursive = true)
49  {
50  /* @var ilObjTest $testOBJ */
51  if($this->testObj)
52  {
53  // #19247
54  $testOBJ = $this->testObj;
55  }
56  else
57  {
58  require_once 'Services/Object/classes/class.ilObjectFactory.php';
59  $testOBJ = ilObjectFactory::getInstanceByObjId($this->obj_id);
60  }
61  $testOBJ->removeTestResultsByUserIds($a_user_ids);
62 
63  // :TODO: there has to be a better way
64  $test_ref_id = (int)$_REQUEST["ref_id"];
65  if($this->testObj && $this->testObj->getRefId())
66  {
67  $test_ref_id = $this->testObj->getRefId();
68  }
69  if($test_ref_id)
70  {
71  require_once "Modules/Course/classes/Objectives/class.ilLOSettings.php";
72  $course_obj_id = ilLOSettings::isObjectiveTest($test_ref_id);
73  if($course_obj_id)
74  {
75  // is test initial and/or qualified?
76  $lo_settings = ilLOSettings::getInstanceByObjId($course_obj_id);
77  $is_i = ($lo_settings->getInitialTest() == $test_ref_id);
78  $is_q = ($lo_settings->getQualifiedTest() == $test_ref_id);
79 
80  // remove objective results data
81  require_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php";
82  ilLOUserResults::deleteResultsFromLP($course_obj_id, $a_user_ids, $is_i, $is_q);
83 
84  // refresh LP - see ilLPStatusWrapper::_updateStatus()
85  require_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
86  $lp_status = ilLPStatusFactory::_getInstance($course_obj_id);
87  if (strtolower(get_class($lp_status)) != "illpstatus")
88  {
89  foreach($a_user_ids as $user_id)
90  {
91  $lp_status->_updateStatus($course_obj_id, $user_id);
92  }
93  }
94  }
95  }
96  }
97 
98  protected static function isLPMember(array &$a_res, $a_usr_id, array $a_obj_ids)
99  {
100  global $ilDB;
101 
102  // if active id
103  $set = $ilDB->query("SELECT tt.obj_fi".
104  " FROM tst_active ta".
105  " JOIN tst_tests tt ON (ta.test_fi = tt.test_id)".
106  " WHERE ".$ilDB->in("tt.obj_fi", $a_obj_ids, "", "integer").
107  " AND ta.user_fi = ".$ilDB->quote($a_usr_id, "integer"));
108  while($row = $ilDB->fetchAssoc($set))
109  {
110  $a_res[$row["obj_fi"]] = true;
111  }
112 
113  return true;
114  }
115 }
116 
117 ?>
static getInstanceByObjId($a_obj_id)
get singleton instance
_lookupAnonymity($a_obj_id)
Returns the anonymity status of a test with a given object id.
static isObjectiveTest($a_trst_ref_id)
Check if test ref_id is used in an objective course.
resetCustomLPDataForUserIds(array $a_user_ids, $a_recursive=true)
_getInstance($a_obj_id, $a_mode=NULL)
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static deleteResultsFromLP($a_course_id, array $a_user_ids, $a_remove_initial, $a_remove_qualified)
Delete all (qualified) result entries for course members.
setTestObject(\ilObjTest $test)
global $ilDB
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
static isLPMember(array &$a_res, $a_usr_id, array $a_obj_ids)
$test
Definition: Utf8Test.php:85