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