ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjExerciseAccess.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Object/classes/class.ilObjectAccess.php");
5include_once './Services/AccessControl/interfaces/interface.ilConditionHandling.php';
6
17{
18
22 public static function getConditionOperators()
23 {
24 include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
25 return array(
28 );
29 }
30
31
40 public static function checkCondition($a_exc_id, $a_operator, $a_value, $a_usr_id)
41 {
42 include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
43 include_once './Modules/Exercise/classes/class.ilExerciseMembers.php';
44
45 switch ($a_operator) {
47 if (ilExerciseMembers::_lookupStatus($a_exc_id, $a_usr_id) == "passed") {
48 return true;
49 } else {
50 return false;
51 }
52 break;
53
55 return ilExerciseMembers::_lookupStatus($a_exc_id, $a_usr_id) == 'failed';
56
57 default:
58 return true;
59 }
60 return true;
61 }
62
63
76 public static function _getCommands()
77 {
78 $commands = array(
79 array("permission" => "read", "cmd" => "showOverview", "lang_var" => "show",
80 "default" => true),
81 array("permission" => "write", "cmd" => "listAssignments", "lang_var" => "edit_assignments"),
82 array("permission" => "write", "cmd" => "edit", "lang_var" => "settings")
83 );
84
85 return $commands;
86 }
87
88 public static function _lookupRemainingWorkingTimeString($a_obj_id)
89 {
90 global $DIC;
91
92 $ilDB = $DIC->database();
93
94 // #14077 - mind peer deadline, too
95
96 $dl = null;
97 $cnt = array();
98
99 $q = "SELECT id, time_stamp, deadline2, peer_dl" .
100 " FROM exc_assignment WHERE exc_id = " . $ilDB->quote($a_obj_id, "integer") .
101 " AND (time_stamp > " . $ilDB->quote(time(), "integer") .
102 " OR (peer_dl > " . $ilDB->quote(time(), "integer") .
103 " AND peer > " . $ilDB->quote(0, "integer") . "))";
104 $set = $ilDB->query($q);
105 while ($row = $ilDB->fetchAssoc($set)) {
106 if ($row["time_stamp"] > time() &&
107 ($row["time_stamp"] < $dl || !$dl)) {
108 $dl = $row["time_stamp"];
109 }
110 /* extended deadline should not be presented anywhere
111 if($row["deadline2"] > time() &&
112 ($row["deadline2"] < $dl || !$dl))
113 {
114 $dl = $row["deadline2"];
115 }
116 */
117 if ($row["peer_dl"] > time() &&
118 ($row["peer_dl"] < $dl || !$dl)) {
119 $dl = $row["peer_dl"];
120 }
121 $cnt[$row["id"]] = true;
122 }
123
124 // :TODO: mind personal deadline?
125
126 if ($dl) {
128 }
129
130 return array(
131 "mtime" => $dl,
132 "cnt" => sizeof($cnt)
133 );
134 }
135
139 public static function _checkGoto($a_target)
140 {
141 global $DIC;
142
143 $ilAccess = $DIC->access();
144
145 $t_arr = explode("_", $a_target);
146
147 if ($t_arr[0] != "exc" || ((int) $t_arr[1]) <= 0) {
148 return false;
149 }
150
151 if ($ilAccess->checkAccess("read", "", $t_arr[1])) {
152 return true;
153 }
154 return false;
155 }
156
162 public function canBeDelivered(ilWACPath $ilWACPath)
163 {
164 global $ilAccess;
165
166 return true;
167
168 // to do: check the path, extract the IDs from the path
169 // determine the object ID of the corresponding exercise
170 // get all ref IDs of the exercise from the object id and check if use
171 // has read access to any of these ref ids (if yes, return true)
172
173 preg_match("/\\/poll_([\\d]*)\\//uism", $ilWACPath->getPath(), $results);
174
175 foreach (ilObject2::_getAllReferences($results[1]) as $ref_id) {
176 if ($ilAccess->checkAccess('read', '', $ref_id)) {
177 return true;
178 }
179 }
180
181 return false;
182 }
183}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
@classDescription Date and time handling
static _lookupStatus($a_obj_id, $a_user_id)
Lookup current status (notgraded|passed|failed)
Class ilObjExerciseAccess.
static _checkGoto($a_target)
check whether goto script will succeed
static _getCommands()
get commands
static checkCondition($a_exc_id, $a_operator, $a_value, $a_usr_id)
check condition
canBeDelivered(ilWACPath $ilWACPath)
static getConditionOperators()
Get possible conditions operators.
static _lookupRemainingWorkingTimeString($a_obj_id)
static _getAllReferences($a_id)
get all reference ids of object
Class ilObjectAccess.
static period2String(ilDateTime $a_from, $a_to=null)
Return a string of time period.
Class ilWACPath.
Interface for condition handling.
global $DIC
Definition: saml.php:7
global $ilDB
$results
Definition: svg-scanner.php:47