ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilExcAssMemberStateRepository.php
Go to the documentation of this file.
1<?php
2
27{
28 protected ilDBInterface $db;
29
30 public function __construct(?ilDBInterface $db = null)
31 {
32 global $DIC;
33
34 $this->db = (is_null($db))
35 ? $DIC->database()
36 : $db;
37 }
38
46 array $exc_ids,
47 int $user_id
48 ): array {
49 $db = $this->db;
50 $set = $db->queryF(
51 'SELECT ass.id FROM exc_assignment ass LEFT JOIN exc_idl idl
52 ON (ass.id = idl.ass_id AND idl.member_id = %s)
53 WHERE ' . $db->in("ass.exc_id", $exc_ids, false, "integer") . '
54 AND (( ass.deadline_mode = %s
55 AND (ass.start_time IS NULL OR ass.start_time < %s )
56 AND (ass.time_stamp IS NULL OR ass.time_stamp > %s OR ass.deadline2 > %s OR idl.tstamp > %s))
57 ) OR (
58 ass.deadline_mode = %s
59 AND (idl.starting_ts > 0)
60 AND (idl.starting_ts + (ass.relative_deadline * 24 * 60 * 60) > %s)
61 )',
62 array("integer", "integer", "integer", "integer", "integer", "integer", "integer", "integer"),
63 array($user_id, 0, time(), time(), time(), time(), 1, time())
64 );
65 $ids = [];
66 while ($rec = $db->fetchAssoc($set)) {
67 $ids[] = $rec["id"];
68 }
69 return $ids;
70 }
71
78 public function getAssignmentIdsWithGradingNeeded(array $exc_ids): array
79 {
80 $db = $this->db;
81
82 $set = $db->queryF(
83 'SELECT ass.id, COUNT(*) open_grading FROM exc_mem_ass_status st LEFT JOIN exc_assignment ass
84 ON (st.ass_id = ass.id)
85 WHERE ' . $db->in("ass.exc_id", $exc_ids, false, "integer") . '
86 AND st.status = %s
87 AND st.returned = %s
88 GROUP BY (ass.id)',
89 array("text","integer"),
90 array("notgraded", 1)
91 );
92 $open_gradings = [];
93 while ($rec = $db->fetchAssoc($set)) {
94 $open_gradings[$rec["id"]] = (int) $rec["open_grading"];
95 }
96 return $open_gradings;
97 }
98
106 array $exc_ids,
107 int $user_id
108 ): array {
109 $db = $this->db;
110
111 // peer groups exist
112 $set = $db->queryF(
113 'SELECT ass.id, count(*) nr_given, ass.peer_dl, ass.peer_min, max(idl.tstamp) maxidl, max(peer.tstamp) maxpeer
114 FROM exc_assignment ass
115 LEFT JOIN exc_assignment_peer peer ON (ass.id = peer.ass_id)
116 LEFT JOIN exc_idl idl ON (ass.id = idl.ass_id)
117 WHERE ' . $db->in("ass.exc_id", $exc_ids, false, "integer") . '
118 AND ass.deadline_mode = %s
119 AND ass.time_stamp < %s
120 AND (ass.deadline2 < %s OR ass.deadline2 IS NULL)
121 AND ass.peer = %s
122 AND (peer.giver_id = %s)
123 AND (ass.peer_dl > %s OR ass.peer_dl IS NULL)
124 AND (peer.is_valid = %s)
125 GROUP BY (ass.id)
126 HAVING (ass.peer_min > nr_given) AND (maxidl < %s OR maxidl IS NULL)
127 ',
128 array("integer", "integer", "integer", "integer", "integer", "integer", "integer", "integer"),
129 array(0, time(), time(), 1, $user_id, time(), 1, time())
130 );
131 $ids = [];
132 while ($rec = $db->fetchAssoc($set)) {
133 $ids[] = $rec["id"];
134 }
135
136 // peer groups do not exist
137 $set = $db->queryF(
138 'SELECT ass.id, count(*) nr_given, ass.peer_dl, ass.peer_min, max(idl.tstamp) maxidl, max(peer.tstamp) maxpeer
139 FROM exc_assignment ass
140 LEFT JOIN exc_assignment_peer peer ON (ass.id = peer.ass_id)
141 LEFT JOIN exc_idl idl ON (ass.id = idl.ass_id)
142 WHERE ' . $db->in("ass.exc_id", $exc_ids, false, "integer") . '
143 AND ass.deadline_mode = %s
144 AND ass.time_stamp < %s
145 AND (ass.deadline2 < %s OR ass.deadline2 IS NULL)
146 AND ass.peer = %s
147 AND (peer.giver_id IS NULL)
148 AND (ass.peer_dl > %s OR ass.peer_dl IS NULL)
149 AND (peer.tstamp IS NULL)
150 GROUP BY (ass.id)
151 HAVING (maxpeer IS NULL) AND (maxidl < %s OR maxidl IS NULL)
152 ',
153 array("integer", "integer", "integer", "integer", "integer", "integer"),
154 array(0, time(), time(), 1, time(), time())
155 );
156 while ($rec = $db->fetchAssoc($set)) {
157 $ids[] = $rec["id"];
158 }
159
160 return $ids;
161 }
162}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getAssignmentIdsWithPeerFeedbackNeeded(array $exc_ids, int $user_id)
Get all assignments for a user where the user may hand in submissions.
getSubmitableAssignmentIdsOfUser(array $exc_ids, int $user_id)
Get all assignments for a user where the user may hand in submissions.
getAssignmentIdsWithGradingNeeded(array $exc_ids)
Get assignments with open gradings.
Interface ilDBInterface.
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
in(string $field, array $values, bool $negate=false, string $type="")
global $DIC
Definition: shib_login.php:26