ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilExcAssMemberStateRepository.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
14 {
20  public function __construct(\ilDBInterface $db = null)
21  {
22  global $DIC;
23 
24  $this->db = (is_null($db))
25  ? $DIC->database()
26  : $db;
27  }
28 
36  public function getSubmitableAssignmentIdsOfUser(array $exc_ids, int $user_id) : array
37  {
38  $db = $this->db;
39  $set = $db->queryF(
40  'SELECT ass.id FROM exc_assignment ass LEFT JOIN exc_idl idl
41  ON (ass.id = idl.ass_id AND idl.member_id = %s)
42  WHERE ' . $db->in("ass.exc_id", $exc_ids, false, "integer") . '
43  AND (( ass.deadline_mode = %s
44  AND (ass.start_time IS NULL OR ass.start_time < %s )
45  AND (ass.time_stamp IS NULL OR ass.time_stamp > %s OR ass.deadline2 > %s OR idl.tstamp > %s))
46  ) OR (
47  ass.deadline_mode = %s
48  AND (idl.starting_ts > 0)
49  AND (idl.starting_ts + (ass.relative_deadline * 24 * 60 * 60) > %s)
50  )',
51  array("integer", "integer", "integer", "integer", "integer", "integer", "integer", "integer"),
52  array($user_id, 0, time(), time(), time(), time(), 1, time())
53  );
54  $ids = [];
55  while ($rec = $db->fetchAssoc($set)) {
56  $ids[] = $rec["id"];
57  }
58  return $ids;
59  }
60 
67  public function getAssignmentIdsWithGradingNeeded(array $exc_ids)
68  {
69  $db = $this->db;
70 
71  $set = $db->queryF(
72  'SELECT ass.id, COUNT(*) open_grading FROM exc_mem_ass_status st LEFT JOIN exc_assignment ass
73  ON (st.ass_id = ass.id)
74  WHERE ' . $db->in("ass.exc_id", $exc_ids, false, "integer") . '
75  AND st.status = %s
76  AND st.returned = %s
77  GROUP BY (ass.id)',
78  array("text","integer"),
79  array("notgraded", 1)
80  );
81  $open_gradings = [];
82  while ($rec = $db->fetchAssoc($set)) {
83  $open_gradings[$rec["id"]] = $rec["open_grading"];
84  }
85  return $open_gradings;
86  }
87 
95  public function getAssignmentIdsWithPeerFeedbackNeeded(array $exc_ids, int $user_id) : array
96  {
97  $db = $this->db;
98 
99  // peer groups exist
100  $set = $db->queryF(
101  'SELECT ass.id, count(*) nr_given, ass.peer_dl, ass.peer_min, max(idl.tstamp) maxidl, max(peer.tstamp) maxpeer
102  FROM exc_assignment ass
103  LEFT JOIN exc_assignment_peer peer ON (ass.id = peer.ass_id)
104  LEFT JOIN exc_idl idl ON (ass.id = idl.ass_id)
105  WHERE ' . $db->in("ass.exc_id", $exc_ids, false, "integer") . '
106  AND ass.deadline_mode = %s
107  AND ass.time_stamp < %s
108  AND (ass.deadline2 < %s OR ass.deadline2 IS NULL)
109  AND ass.peer = %s
110  AND (peer.giver_id = %s)
111  AND (ass.peer_dl > %s OR ass.peer_dl IS NULL)
112  AND (peer.is_valid = %s)
113  GROUP BY (ass.id)
114  HAVING (ass.peer_min > nr_given) AND (maxidl < %s OR maxidl IS NULL)
115  ',
116  array("integer", "integer", "integer", "integer", "integer", "integer", "integer", "integer"),
117  array(0, time(), time(), 1, $user_id, time(), 1, time())
118  );
119  $ids = [];
120  while ($rec = $db->fetchAssoc($set)) {
121  $ids[] = $rec["id"];
122  }
123 
124  // peer groups do not exist
125  $set = $db->queryF(
126  'SELECT ass.id, count(*) nr_given, ass.peer_dl, ass.peer_min, max(idl.tstamp) maxidl, max(peer.tstamp) maxpeer
127  FROM exc_assignment ass
128  LEFT JOIN exc_assignment_peer peer ON (ass.id = peer.ass_id)
129  LEFT JOIN exc_idl idl ON (ass.id = idl.ass_id)
130  WHERE ' . $db->in("ass.exc_id", $exc_ids, false, "integer") . '
131  AND ass.deadline_mode = %s
132  AND ass.time_stamp < %s
133  AND (ass.deadline2 < %s OR ass.deadline2 IS NULL)
134  AND ass.peer = %s
135  AND (peer.giver_id IS NULL)
136  AND (ass.peer_dl > %s OR ass.peer_dl IS NULL)
137  AND (peer.tstamp IS NULL)
138  GROUP BY (ass.id)
139  HAVING (maxpeer IS NULL) AND (maxidl < %s OR maxidl IS NULL)
140  ',
141  array("integer", "integer", "integer", "integer", "integer", "integer"),
142  array(0, time(), time(), 1, time(), time())
143  );
144  while ($rec = $db->fetchAssoc($set)) {
145  $ids[] = $rec["id"];
146  }
147 
148 
149  return $ids;
150  }
151 }
__construct(\ilDBInterface $db=null)
Constructor.
getAssignmentIdsWithGradingNeeded(array $exc_ids)
Get assignments with open gradings.
global $DIC
Definition: goto.php:24
getSubmitableAssignmentIdsOfUser(array $exc_ids, int $user_id)
Get all assignments for a user where the user may hand in submissions.
getAssignmentIdsWithPeerFeedbackNeeded(array $exc_ids, int $user_id)
Get all assignments for a user where the user may hand in submissions.
This class determines assignment member state information directly on the persistence layer...