19 declare(strict_types=1);
48 $this->db = $DIC->database();
66 $query =
'SELECT id FROM ecs_course_assignments ' .
67 'WHERE usr_id = ' .
$ilDB->quote($a_usr_id,
'text');
70 $assignments = array();
72 $assignments[] =
new self((
int) $row->id);
86 $query =
'DELETE FROM ecs_course_assignments ' .
87 'WHERE obj_id = ' .
$ilDB->quote($a_obj_id,
'integer');
88 $ilDB->manipulate($query);
101 $query =
'DELETE FROM ecs_course_assignments ' .
102 'WHERE sid = ' .
$ilDB->quote($a_server_id,
'integer');
103 $ilDB->manipulate($query);
110 public static function lookupUserIds(
int $a_cms_id, ?
int $a_cms_sub_id,
int $a_obj_id): array
114 $ilDB = $DIC[
'ilDB'];
116 if (is_null($a_cms_sub_id)) {
117 $cms_sub_id_query =
'AND (cms_sub_id IS NULL OR cms_sub_id = 0) ';
119 $cms_sub_id_query =
'AND cms_sub_id = ' .
$ilDB->quote($a_cms_sub_id,
'integer') .
' ';
122 $query =
'SELECT usr_id FROM ecs_course_assignments ' .
123 'WHERE cms_id = ' .
$ilDB->quote($a_cms_id,
'integer') .
' ' .
125 'AND obj_id = ' .
$ilDB->quote($a_obj_id,
'integer');
130 $usr_ids[] = $row->usr_id;
142 $ilDB = $DIC[
'ilDB'];
144 if (is_null($a_cms_sub_id)) {
145 $cms_sub_id_query =
'AND (cms_sub_id IS NULL OR cms_sub_id = 0) ';
147 $cms_sub_id_query =
'AND cms_sub_id = ' .
$ilDB->quote($a_cms_sub_id,
'integer') .
' ';
150 $query =
'SELECT id FROM ecs_course_assignments ' .
151 'WHERE cms_id = ' .
$ilDB->quote($a_cms_id,
'integer') .
' ' .
153 'AND obj_id = ' .
$ilDB->quote($a_obj_id,
'integer') .
' ' .
154 'AND usr_id = ' .
$ilDB->quote($a_usr_id,
'text');
173 $this->
server = $a_server;
196 $this->cms_id = $a_id;
206 $this->cms_sub_id = $a_id;
216 $this->obj_id = $a_id;
224 public function setUid(
string $a_id): void
236 $this->status = $a_status;
247 'id' => [
'integer', $this->
getId()],
248 'sid' => [
'integer', $this->
getServer()],
249 'mid' => [
'integer', $this->
getMid()],
250 'cms_id' => [
'integer', $this->
getCmsId()],
252 'obj_id' => [
'integer', $this->
getObjId()],
253 'usr_id' => [
'text', $this->
getUid()],
254 'status' => [
'integer', $this->
getStatus()],
262 $this->
id = $this->db->nextId(
'ecs_course_assignments');
264 $assignment = self::lookupAssignment(
270 if ($assignment instanceof
self) {
271 $assignment->update();
295 public function delete():
bool 297 $query =
'DELETE FROM ecs_course_assignments ' .
298 'WHERE id = ' . $this->db->quote($this->
getId(),
'integer');
299 $this->db->manipulate($query);
308 protected function read(): bool
310 if (!$this->
getId()) {
313 $r = $this->db->queryF(
314 "SELECT sid,mid,cms_id,cms_sub_id,obj_id,usr_id,status FROM ecs_course_assignments WHERE id = %d",
318 $row = $this->db->fetchObject(
$r);
320 $this->
setMid((
int) $row->mid);
321 $this->
setCmsId((
int) $row->cms_id);
323 $this->
setObjId((
int) $row->obj_id);
324 $this->
setUid($row->usr_id);
update()
Update assignemt.
server()
description: > This example shows how a Progress Bar can be rendered and updated by the server...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setStatus(bool $a_status)
static lookupAssignment(int $a_cms_id, ?int $a_cms_sub_id, int $a_obj_id, string $a_usr_id)
Lookup assignment of user.
static deleteByServerId(int $a_server_id)
Delete by server id.
static lookupUserIds(int $a_cms_id, ?int $a_cms_sub_id, int $a_obj_id)
Lookup user ids.
static deleteByObjId(int $a_obj_id)
Delete by obj_id.
setServer(int $a_server)
Set server.
Storage of ecs course assignments.
static lookupMissingAssignmentsOfUser(string $a_usr_id)
Lookup missing assignments;.
__construct(int $a_id=0)
Constructor.
const STATUS_LOCAL_DELETED