46 $this->db =
$DIC->database();
48 $this->obj_id = $a_obj_id;
49 $this->usr_id = $a_usr_id;
61 $query =
"DELETE FROM ut_lp_marks " .
62 "WHERE obj_id = " .
$ilDB->quote($a_obj_id,
'integer');
71 public function setMark(
string $a_mark): void
73 $this->mark = $a_mark;
93 $this->completed = $a_status;
113 if (!$this->has_entry) {
116 $query =
"UPDATE ut_lp_marks " .
117 "SET mark = " . $this->db->quote($this->
getMark(),
'text') .
", " .
118 "u_comment = " . $this->db->quote(
122 "completed = " . $this->db->quote(
126 "WHERE obj_id = " . $this->db->quote(
130 "AND usr_id = " . $this->db->quote($this->
getUserId(),
'integer');
131 $res = $this->db->manipulate($query);
141 $query =
"SELECT * FROM ut_lp_marks " .
142 "WHERE usr_id = " .
$ilDB->quote($a_usr_id,
'integer') .
" " .
143 "AND obj_id = " .
$ilDB->quote($a_obj_id,
'integer');
147 return (
bool) $row->completed;
161 $query =
"SELECT * FROM ut_lp_marks " .
163 " AND status = " .
$ilDB->quote(
167 " AND status_changed >= " .
$ilDB->quote($from,
"timestamp") .
168 " AND status_changed <= " .
$ilDB->quote($to,
"timestamp");
170 $set =
$ilDB->query($query);
171 $completions = array();
172 while ($rec =
$ilDB->fetchAssoc($set)) {
174 'obj_id' => (
int) $rec[
'obj_id'],
175 'usr_id' => (
int) $rec[
'usr_id'],
176 'completed' => (bool) $rec[
'completed'],
177 'mark' => (
string) $rec[
'mark'],
178 'comment' => (string) $rec[
'u_comment'],
179 'status' => (
int) $rec[
'status'],
180 'status_changed' => (string) $rec[
'status_changed'],
181 'status_dirty' => (
int) $rec[
'status_changed'],
182 'percentage' => (
int) $rec[
'percentage']
184 $completions[] = $completion;
189 public static function _lookupMark(
int $a_usr_id,
int $a_obj_id): string
195 $query =
"SELECT * FROM ut_lp_marks " .
196 "WHERE usr_id = " .
$ilDB->quote($a_usr_id,
'integer') .
" " .
197 "AND obj_id = " .
$ilDB->quote($a_obj_id,
'integer');
201 return (
string) $row->mark;
212 $query =
"SELECT * FROM ut_lp_marks " .
213 "WHERE usr_id = " .
$ilDB->quote($a_usr_id,
'integer') .
" " .
214 "AND obj_id = " .
$ilDB->quote($a_obj_id,
'integer');
218 return (
string) $row->u_comment;
226 $res = $this->db->query(
227 "SELECT * FROM ut_lp_marks " .
228 "WHERE obj_id = " . $this->db->quote(
232 "AND usr_id = " . $this->db->quote($this->usr_id,
'integer')
235 $this->has_entry =
true;
236 $this->completed = (
int) $row->completed;
237 $this->comment = (
string) $row->u_comment;
238 $this->mark = (string) $row->mark;
239 $this->status_changed = (
string) $row->status_changed;
247 $query =
"INSERT INTO ut_lp_marks (mark,u_comment, completed,obj_id,usr_id) " .
249 $this->db->quote($this->getMark(),
'text') .
", " .
250 $this->db->quote($this->getComment(),
'text') .
", " .
251 $this->db->quote($this->getCompleted(),
'integer') .
", " .
252 $this->db->quote($this->getObjId(),
'integer') .
", " .
253 $this->db->quote($this->getUserId(),
'integer') .
" " .
255 $res = $this->db->manipulate($query);
256 $this->has_entry =
true;
267 "DELETE FROM ut_lp_marks" .
268 " WHERE obj_id = " .
$ilDB->quote($a_obj_id,
"integer") .
269 " AND " .
$ilDB->in(
"usr_id", $a_user_ids,
"",
"integer")
281 "SELECT usr_id FROM ut_lp_marks" .
282 " WHERE obj_id = " .
$ilDB->quote($a_obj_id,
"integer")
284 while ($row =
$ilDB->fetchAssoc($set)) {
static deleteObject(int $a_obj_id)
static getCompletionsOfUser(int $user_id, string $from, string $to)
setComment(string $a_comment)
static _lookupComment(int $a_usr_id, int $a_obj_id)
static _getAllUserIds(int $a_obj_id)
static _hasCompleted(int $a_usr_id, int $a_obj_id)
static _lookupMark(int $a_usr_id, int $a_obj_id)
static _deleteForUsers(int $a_obj_id, array $a_user_ids)
setCompleted(bool $a_status)
__construct(int $a_obj_id, int $a_usr_id)
ilObjectDataCache $ilObjectDataCache
const LP_STATUS_COMPLETED_NUM