45 $this->db = $DIC->database();
47 $this->obj_id = $a_obj_id;
48 $this->usr_id = $a_usr_id;
60 $query =
"DELETE FROM ut_lp_marks " .
61 "WHERE obj_id = " .
$ilDB->quote($a_obj_id,
'integer');
70 public function setMark(
string $a_mark): void
72 $this->mark = $a_mark;
92 $this->completed = $a_status;
112 if (!$this->has_entry) {
115 $query =
"UPDATE ut_lp_marks " .
116 "SET mark = " . $this->db->quote($this->
getMark(),
'text') .
", " .
117 "u_comment = " . $this->db->quote(
121 "completed = " . $this->db->quote(
125 "WHERE obj_id = " . $this->db->quote(
129 "AND usr_id = " . $this->db->quote($this->
getUserId(),
'integer');
130 $res = $this->db->manipulate($query);
138 $ilDB = $DIC[
'ilDB'];
140 $query =
"SELECT * FROM ut_lp_marks " .
141 "WHERE usr_id = " .
$ilDB->quote($a_usr_id,
'integer') .
" " .
142 "AND obj_id = " .
$ilDB->quote($a_obj_id,
'integer');
146 return (
bool) $row->completed;
158 $ilDB = $DIC[
'ilDB'];
160 $query =
"SELECT * FROM ut_lp_marks " .
161 "WHERE usr_id = " .
$ilDB->quote($user_id,
'integer') .
162 " AND status = " .
$ilDB->quote(
166 " AND status_changed >= " .
$ilDB->quote($from,
"timestamp") .
167 " AND status_changed <= " .
$ilDB->quote($to,
"timestamp");
169 $set =
$ilDB->query($query);
170 $completions = array();
171 while ($rec =
$ilDB->fetchAssoc($set)) {
173 'obj_id' => (
int) $rec[
'obj_id'],
174 'usr_id' => (
int) $rec[
'usr_id'],
175 'completed' => (bool) $rec[
'completed'],
176 'mark' => (
string) $rec[
'mark'],
177 'comment' => (string) $rec[
'u_comment'],
178 'status' => (
int) $rec[
'status'],
179 'status_changed' => (string) $rec[
'status_changed'],
180 'status_dirty' => (
int) $rec[
'status_changed'],
181 'percentage' => (
int) $rec[
'percentage']
183 $completions[] = $completion;
188 public static function _lookupMark(
int $a_usr_id,
int $a_obj_id): string
192 $ilDB = $DIC[
'ilDB'];
194 $query =
"SELECT * FROM ut_lp_marks " .
195 "WHERE usr_id = " .
$ilDB->quote($a_usr_id,
'integer') .
" " .
196 "AND obj_id = " .
$ilDB->quote($a_obj_id,
'integer');
200 return (
string) $row->mark;
209 $ilDB = $DIC[
'ilDB'];
211 $query =
"SELECT * FROM ut_lp_marks " .
212 "WHERE usr_id = " .
$ilDB->quote($a_usr_id,
'integer') .
" " .
213 "AND obj_id = " .
$ilDB->quote($a_obj_id,
'integer');
217 return (
string) $row->u_comment;
225 $res = $this->db->query(
226 "SELECT * FROM ut_lp_marks " .
227 "WHERE obj_id = " . $this->db->quote(
231 "AND usr_id = " . $this->db->quote($this->usr_id,
'integer')
234 $this->has_entry =
true;
235 $this->completed = (
int) $row->completed;
236 $this->comment = (
string) $row->u_comment;
237 $this->mark = (string) $row->mark;
238 $this->status_changed = (
string) $row->status_changed;
246 $query =
"INSERT INTO ut_lp_marks (mark,u_comment, completed,obj_id,usr_id) " .
248 $this->db->quote($this->
getMark(),
'text') .
", " .
249 $this->db->quote($this->
getComment(),
'text') .
", " .
250 $this->db->quote($this->
getCompleted(),
'integer') .
", " .
251 $this->db->quote($this->
getObjId(),
'integer') .
", " .
252 $this->db->quote($this->
getUserId(),
'integer') .
" " .
254 $res = $this->db->manipulate($query);
255 $this->has_entry =
true;
264 $ilDB = $DIC[
'ilDB'];
266 "DELETE FROM ut_lp_marks" .
267 " WHERE obj_id = " .
$ilDB->quote($a_obj_id,
"integer") .
268 " AND " .
$ilDB->in(
"usr_id", $a_user_ids,
"",
"integer")
276 $ilDB = $DIC[
'ilDB'];
280 "SELECT usr_id FROM ut_lp_marks" .
281 " WHERE obj_id = " .
$ilDB->quote($a_obj_id,
"integer")
283 while ($row =
$ilDB->fetchAssoc($set)) {
const LP_STATUS_COMPLETED_NUM
static _lookupComment(int $a_usr_id, int $a_obj_id)
ilObjectDataCache $ilObjectDataCache
static _getAllUserIds(int $a_obj_id)
static getCompletionsOfUser(int $user_id, string $from, string $to)
__construct(int $a_obj_id, int $a_usr_id)
static _hasCompleted(int $a_usr_id, int $a_obj_id)
static deleteObject(int $a_obj_id)
static _deleteForUsers(int $a_obj_id, array $a_user_ids)
static _lookupMark(int $a_usr_id, int $a_obj_id)
setComment(string $a_comment)
setCompleted(bool $a_status)