ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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) {
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 {
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 {
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", (int) $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 {
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 {
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 ilExAssignment::sendFeedbackNotifications($this->ass_id, $this->user_id);
252 }
253 }
254
255 protected function postUpdateStatus()
256 {
257 $ass = new ilExAssignment($this->ass_id);
258 $exc = new ilObjExercise($ass->getExerciseId(), false);
259 $exc->updateUserStatus($this->user_id);
260 }
261
262 public function getStatusIcon()
263 {
264 switch ($this->getStatus()) {
265 case "passed":
266 return "scorm/passed.svg";
267
268 case "failed":
269 return "scorm/failed.svg";
270
271 default:
272 return "scorm/not_attempted.svg";
273 }
274 }
275
279 public static function lookupAnyExerciseSent($a_ass_id)
280 {
281 global $DIC;
282
283 $ilDB = $DIC->database();
284
285 $q = "SELECT count(*) AS cnt" .
286 " FROM exc_mem_ass_status" .
287 " WHERE NOT sent_time IS NULL" .
288 " AND ass_id = " . $ilDB->quote($a_ass_id, "integer");
289 $set = $ilDB->query($q);
290 $rec = $ilDB->fetchAssoc($set);
291 return ($rec["cnt"] > 0);
292 }
293}
An exception for terminatinating execution or to throw for unit testing.
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.
comment()
Definition: comment.php:2
$keys
Definition: metadata.php:187
global $ilDB
$DIC
Definition: xapitoken.php:46