ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilExAssignmentMemberStatus.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 {
15  protected $db;
16 
17  protected $ass_id; // [int]
18  protected $user_id; // [int]
19  protected $notice; // [string]
20  protected $returned; // [int]
21  protected $solved; // [int] - obsolete?!
22  protected $sent; // [int]
23  protected $sent_time; // [datetime]
24  protected $feedback; // [int]
25  protected $feedback_time; // [datetime]
26  protected $status = "notgraded"; // [string]
27  protected $status_time; // [datetime]
28  protected $mark; // [string]
29  protected $comment; // [string]
30  protected $db_exists; // [bool]
31  protected $returned_update; // [bool]
32  protected $status_update; // [bool]
33 
34  public function __construct($a_ass_id, $a_user_id)
35  {
36  global $DIC;
37 
38  $this->db = $DIC->database();
39  $this->ass_id = $a_ass_id;
40  $this->user_id = $a_user_id;
41 
42  $this->read();
43  }
44 
45  public function setNotice($a_value)
46  {
47  $this->notice = $a_value;
48  }
49 
50  public function getNotice()
51  {
52  return $this->notice;
53  }
54 
55  public function setReturned($a_value)
56  {
57  if ($a_value &&
58  !$this->returned) {
59  $this->returned_update = true;
60  }
61  $this->returned = $a_value;
62  }
63 
64  public function getReturned()
65  {
66  return $this->returned;
67  }
68 
69  public function setSolved($a_value)
70  {
71  $this->solved = $a_value;
72  }
73 
74  public function getSolved()
75  {
76  return $this->solved;
77  }
78 
79  protected function setStatusTime($a_value)
80  {
81  $this->status_time = $a_value;
82  }
83 
84  public function getStatusTime()
85  {
86  return $this->status_time;
87  }
88 
89  public function setSent($a_value)
90  {
91  if ($a_value && $a_value != $this->sent) {
92  $this->setSentTime(ilUtil::now());
93  }
94  $this->sent = $a_value;
95  }
96 
97  public function getSent()
98  {
99  return $this->sent;
100  }
101 
102  protected function setSentTime($a_value)
103  {
104  $this->sent_time = $a_value;
105  }
106 
107  public function getSentTime()
108  {
109  return $this->sent_time;
110  }
111 
112  public function setFeedback($a_value)
113  {
114  if ($a_value != $this->sent) {
115  $this->setFeedbackTime(ilUtil::now());
116  }
117  $this->feedback = $a_value;
118  }
119 
120  public function getFeedback()
121  {
122  return $this->feedback;
123  }
124 
125  protected function setFeedbackTime($a_value)
126  {
127  $this->feedback_time = $a_value;
128  }
129 
130  public function getFeedbackTime()
131  {
132  return $this->feedback_time;
133  }
134 
135  public function setStatus($a_value)
136  {
137  if ($a_value != $this->status) {
138  $this->setStatusTime(ilUtil::now());
139  $this->status = $a_value;
140  $this->status_update = true;
141  }
142  }
143 
144  public function getStatus()
145  {
146  return $this->status;
147  }
148 
149  public function setMark($a_value)
150  {
151  if ($a_value != $this->mark) {
152  $this->setStatusTime(ilUtil::now());
153  }
154  $this->mark = $a_value;
155  }
156 
157  public function getMark()
158  {
159  return $this->mark;
160  }
161 
162  public function setComment($a_value)
163  {
164  $this->comment = $a_value;
165  }
166 
167  public function getComment()
168  {
169  return $this->comment;
170  }
171 
172  protected function read()
173  {
174  $ilDB = $this->db;
175 
176  $set = $ilDB->query("SELECT * FROM exc_mem_ass_status" .
177  " WHERE ass_id = " . $ilDB->quote($this->ass_id, "integer") .
178  " AND usr_id = " . $ilDB->quote($this->user_id, "integer"));
179  if ($ilDB->numRows($set)) {
180  $row = $ilDB->fetchAssoc($set);
181 
182  // not using setters to circumvent any datetime-logic/-magic
183  $this->notice = $row["notice"];
184  $this->returned = $row["returned"];
185  $this->solved = $row["solved"];
186  $this->status_time = $row["status_time"];
187  $this->sent = $row["sent"];
188  $this->sent_time = $row["sent_time"];
189  $this->feedback_time = $row["feedback_time"];
190  $this->feedback = $row["feedback"];
191  $this->status = $row["status"];
192  $this->mark = $row["mark"];
193  $this->comment = $row["u_comment"];
194  $this->db_exists = true;
195  }
196  }
197 
198  protected function getFields()
199  {
200  return array(
201  "notice" => array("text", $this->getNotice())
202  ,"returned" => array("integer", $this->getReturned())
203  ,"solved" => array("integer", $this->getSolved())
204  ,"status_time" => array("timestamp", $this->getStatusTime())
205  ,"sent" => array("integer", $this->getSent())
206  ,"sent_time" => array("timestamp", $this->getSentTime())
207  ,"feedback_time" => array("timestamp", $this->getFeedbackTime())
208  ,"feedback" => array("integer", $this->getFeedback())
209  ,"status" => array("text", $this->getStatus())
210  ,"mark" => array("text", $this->getMark())
211  ,"u_comment" => array("text", $this->getComment())
212  );
213  }
214 
215  public function update()
216  {
217  $ilDB = $this->db;
218 
219  $keys = array(
220  "ass_id" => array("integer", $this->ass_id)
221  ,"usr_id" => array("integer", $this->user_id)
222  );
223  $fields = $this->getFields();
224  if (!$this->db_exists) {
225  $fields = array_merge($keys, $fields);
226  $ilDB->insert("exc_mem_ass_status", $fields);
227  } else {
228  $ilDB->update("exc_mem_ass_status", $fields, $keys);
229  }
230 
231  if ($this->returned_update) {
232  $this->postUpdateReturned();
233  }
234  if ($this->status_update) {
235  $this->postUpdateStatus();
236  }
237  }
238 
239  protected function postUpdateReturned()
240  {
241  $ilDB = $this->db;
242 
243  // first upload => notification on submission?
244  $set = $ilDB->query("SELECT fb_cron, fb_date, fb_file" .
245  " FROM exc_assignment" .
246  " WHERE id = " . $ilDB->quote($this->ass_id, "integer"));
247  $row = $ilDB->fetchAssoc($set);
248  if ($row["fb_cron"] &&
249  $row["fb_file"] &&
250  $row["fb_date"] == ilExAssignment::FEEDBACK_DATE_SUBMISSION) { // #16200
251  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
252  ilExAssignment::sendFeedbackNotifications($this->ass_id, $this->user_id);
253  }
254  }
255 
256  protected function postUpdateStatus()
257  {
258  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
259  $ass = new ilExAssignment($this->ass_id);
260  $exc = new ilObjExercise($ass->getExerciseId(), false);
261  $exc->updateUserStatus($this->user_id);
262  }
263 
264  public function getStatusIcon()
265  {
266  switch ($this->getStatus()) {
267  case "passed":
268  return "scorm/passed.svg";
269 
270  case "failed":
271  return "scorm/failed.svg";
272 
273  default:
274  return "scorm/not_attempted.svg";
275  }
276  }
277 
281  public static function lookupAnyExerciseSent($a_ass_id)
282  {
283  global $DIC;
284 
285  $ilDB = $DIC->database();
286 
287  $q = "SELECT count(*) AS cnt" .
288  " FROM exc_mem_ass_status" .
289  " WHERE NOT sent_time IS NULL" .
290  " AND ass_id = " . $ilDB->quote($a_ass_id, "integer");
291  $set = $ilDB->query($q);
292  $rec = $ilDB->fetchAssoc($set);
293  return ($rec["cnt"] > 0);
294  }
295 }
Exercise assignment member status.
Exercise assignment.
static sendFeedbackNotifications($a_ass_id, $a_user_id=null)
global $DIC
Definition: saml.php:7
$keys
static now()
Return current timestamp in Y-m-d H:i:s format.
static lookupAnyExerciseSent($a_ass_id)
Check whether exercise has been sent to any student per mail.
Class ilObjExercise.
comment()
Definition: comment.php:2
Create styles array
The data for the language used.
updateUserStatus($a_user_id=0)
Update exercise status of user.
global $ilDB