ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
13{
14
18 public static function getConditionOperators()
19 {
20 return array(
23 );
24 }
25
26
35 public static function checkCondition($a_exc_id, $a_operator, $a_value, $a_usr_id)
36 {
37 switch ($a_operator) {
39 if (ilExerciseMembers::_lookupStatus($a_exc_id, $a_usr_id) == "passed") {
40 return true;
41 } else {
42 return false;
43 }
44 break;
45
47 return ilExerciseMembers::_lookupStatus($a_exc_id, $a_usr_id) == 'failed';
48
49 default:
50 return true;
51 }
52 return true;
53 }
54
55
68 public static function _getCommands()
69 {
70 $commands = array(
71 array("permission" => "read", "cmd" => "showOverview", "lang_var" => "show",
72 "default" => true),
73 array("permission" => "write", "cmd" => "listAssignments", "lang_var" => "edit_assignments"),
74 array("permission" => "write", "cmd" => "edit", "lang_var" => "settings")
75 );
76
77 return $commands;
78 }
79
80 public static function _lookupRemainingWorkingTimeString($a_obj_id)
81 {
82 global $DIC;
83
84 $ilDB = $DIC->database();
85
86 // #14077 - mind peer deadline, too
87
88 $dl = null;
89 $cnt = array();
90
91 $q = "SELECT id, time_stamp, deadline2, peer_dl" .
92 " FROM exc_assignment WHERE exc_id = " . $ilDB->quote($a_obj_id, "integer") .
93 " AND (time_stamp > " . $ilDB->quote(time(), "integer") .
94 " OR (peer_dl > " . $ilDB->quote(time(), "integer") .
95 " AND peer > " . $ilDB->quote(0, "integer") . "))";
96 $set = $ilDB->query($q);
97 while ($row = $ilDB->fetchAssoc($set)) {
98 if ($row["time_stamp"] > time() &&
99 ($row["time_stamp"] < $dl || !$dl)) {
100 $dl = $row["time_stamp"];
101 }
102 /* extended deadline should not be presented anywhere
103 if($row["deadline2"] > time() &&
104 ($row["deadline2"] < $dl || !$dl))
105 {
106 $dl = $row["deadline2"];
107 }
108 */
109 if ($row["peer_dl"] > time() &&
110 ($row["peer_dl"] < $dl || !$dl)) {
111 $dl = $row["peer_dl"];
112 }
113 $cnt[$row["id"]] = true;
114 }
115
116 // :TODO: mind personal deadline?
117
118 if ($dl) {
120 }
121
122 return array(
123 "mtime" => $dl,
124 "cnt" => sizeof($cnt)
125 );
126 }
127
131 public static function _checkGoto($a_target)
132 {
133 global $DIC;
134
135 $ilAccess = $DIC->access();
136
137 $t_arr = explode("_", $a_target);
138
139 if ($t_arr[0] != "exc" || ((int) $t_arr[1]) <= 0) {
140 return false;
141 }
142
143 if ($ilAccess->checkAccess("read", "", $t_arr[1]) ||
144 $ilAccess->checkAccess("visible", "", $t_arr[1])) {
145 return true;
146 }
147 return false;
148 }
149
155 public function canBeDelivered(ilWACPath $ilWACPath)
156 {
157 global $ilAccess;
158
159 return true;
160
161 // to do: check the path, extract the IDs from the path
162 // determine the object ID of the corresponding exercise
163 // get all ref IDs of the exercise from the object id and check if use
164 // has read access to any of these ref ids (if yes, return true)
165
166 preg_match("/\\/poll_([\\d]*)\\//uism", $ilWACPath->getPath(), $results);
167
168 foreach (ilObject2::_getAllReferences($results[1]) as $ref_id) {
169 if ($ilAccess->checkAccess('read', '', $ref_id)) {
170 return true;
171 }
172 }
173
174 return false;
175 }
176}
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface for condition handling.
$results
global $ilDB
$DIC
Definition: xapitoken.php:46