ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
4 include_once("./Services/Object/classes/class.ilObjectAccess.php");
5 include_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)
46  {
48  if (ilExerciseMembers::_lookupStatus($a_exc_id, $a_usr_id) == "passed")
49  {
50  return true;
51  }
52  else
53  {
54  return false;
55  }
56  break;
57 
59  return ilExerciseMembers::_lookupStatus($a_exc_id,$a_usr_id) == 'failed';
60 
61  default:
62  return true;
63  }
64  return true;
65  }
66 
67 
80  function _getCommands()
81  {
82  $commands = array
83  (
84  array("permission" => "read", "cmd" => "showOverview", "lang_var" => "show",
85  "default" => true),
86  array("permission" => "write", "cmd" => "listAssignments", "lang_var" => "edit_assignments"),
87  array("permission" => "write", "cmd" => "edit", "lang_var" => "settings")
88  );
89 
90  return $commands;
91  }
92 
94  {
95  global $ilDB;
96 
97  // #14077 - mind peer deadline, too
98 
99  $dl = null;
100  $cnt = array();
101 
102  $q = "SELECT id, time_stamp, peer_dl".
103  " FROM exc_assignment WHERE exc_id = ".$ilDB->quote($a_obj_id, "integer").
104  " AND (time_stamp > ".$ilDB->quote(time(), "integer").
105  " OR (peer_dl > ".$ilDB->quote(time(), "integer").
106  " AND peer > ".$ilDB->quote(0, "integer")."))";
107  $set = $ilDB->query($q);
108  while($row = $ilDB->fetchAssoc($set))
109  {
110  if($row["time_stamp"] > time() &&
111  ($row["time_stamp"] < $dl || !$dl))
112  {
113  $dl = $row["time_stamp"];
114  }
115  if($row["peer_dl"] > time() &&
116  ($row["peer_dl"] < $dl || !$dl))
117  {
118  $dl = $row["peer_dl"];
119  }
120  $cnt[$row["id"]] = true;
121  }
122 
123  if($dl)
124  {
125  $time_diff = ilUtil::int2array($dl - time(), null);
126  $dl = ilUtil::timearray2string($time_diff);
127  }
128 
129  return array(
130  "mtime" => $dl,
131  "cnt" => sizeof($cnt)
132  );
133  }
134 
138  function _checkGoto($a_target)
139  {
140  global $ilAccess;
141 
142  $t_arr = explode("_", $a_target);
143 
144  if ($t_arr[0] != "exc" || ((int) $t_arr[1]) <= 0)
145  {
146  return false;
147  }
148 
149  if ($ilAccess->checkAccess("read", "", $t_arr[1]))
150  {
151  return true;
152  }
153  return false;
154  }
155 }
156 
157 ?>