29 $this->db = $DIC->database();
30 $this->
user = $DIC->user();
31 $this->assignment = $a_assignment;
32 $this->assignment_id = $a_assignment->
getId();
39 $set =
$ilDB->query(
"SELECT count(*) cnt" .
40 " FROM exc_assignment_peer" .
41 " WHERE ass_id = " .
$ilDB->quote($this->assignment_id,
"integer"));
42 $cnt =
$ilDB->fetchAssoc($set);
43 return (
bool) $cnt[
"cnt"];
53 $set =
$ilDB->query(
"SELECT DISTINCT(user_id)" .
54 " FROM exc_returned" .
55 " WHERE ass_id = " .
$ilDB->quote($this->assignment_id,
"integer") .
56 " AND (filename IS NOT NULL OR atext IS NOT NULL)");
58 $user_ids[] =
$row[
"user_id"];
69 if (!$this->assignment->afterDeadlineStrict()) {
76 include_once(
"./Modules/Exercise/PeerReview/class.ExcPeerReviewDistribution.php");
77 $distribution = new \ILIAS\Exercise\PeerReview\ExcPeerReviewDistribution($user_ids, $this->assignment->getPeerReviewMin());
79 foreach ($user_ids as $rater_id) {
80 foreach ($distribution->getPeersOfRater($rater_id) as $peer_id) {
81 $ilDB->manipulate(
"INSERT INTO exc_assignment_peer" .
82 " (ass_id, giver_id, peer_id)" .
83 " VALUES (" .
$ilDB->quote($this->assignment_id,
"integer") .
84 ", " .
$ilDB->quote($rater_id,
"integer") .
85 ", " .
$ilDB->quote($peer_id,
"integer") .
")");
100 foreach (array_keys($reviews) as $giver_id) {
103 foreach ($this->assignment->getPeerReviewCriteriaCatalogueItems() as $crit) {
104 $crit->setPeerReviewContext($this->assignment, $giver_id, $peer_id);
105 $crit->resetReview();
111 $ilDB->manipulate(
"DELETE FROM exc_assignment_peer" .
112 " WHERE ass_id = " .
$ilDB->quote($this->assignment_id,
"integer"));
121 include_once
"./Modules/Exercise/classes/class.ilExerciseMembers.php";
125 $peer_ids = $invalid_peer_ids = $invalid_giver_ids = $all_reviews = array();
127 $peer_ids[] = $peer_id;
129 if (!in_array($peer_id, $all_valid) ||
130 !in_array($peer_id, $all_exc)) {
131 $invalid_peer_ids[] = $peer_id;
133 foreach ($reviews as $giver_id =>
$valid) {
134 if (!in_array($giver_id, $all_valid) ||
135 !in_array($peer_id, $all_exc)) {
136 $invalid_giver_ids[] = $giver_id;
138 $all_reviews[$peer_id][$giver_id] =
$valid;
142 $invalid_giver_ids = array_unique($invalid_giver_ids);
144 $missing_user_ids = array();
145 foreach ($all_valid as $user_id) {
147 if (!in_array($user_id, $peer_ids)) {
148 $missing_user_ids[] = $user_id;
152 $not_returned_ids = array();
153 foreach ($all_exc as $user_id) {
154 if (!in_array($user_id, $all_valid)) {
155 $not_returned_ids[] = $user_id;
160 "invalid" => (
sizeof($missing_user_ids) ||
161 sizeof($invalid_peer_ids) ||
162 sizeof($invalid_giver_ids)),
163 "missing_user_ids" => $missing_user_ids,
164 "not_returned_ids" => $not_returned_ids,
165 "invalid_peer_ids" => $invalid_peer_ids,
166 "invalid_giver_ids" => $invalid_giver_ids,
167 "reviews" => $all_reviews);
175 if ($item[
"peer_id"] == $a_peer_id) {
182 $data = $peer[
"pcomment"];
184 $items = @unserialize(
$data);
185 if (!is_array($items)) {
187 $items = array(
"text" =>
$data);
201 $set =
$ilDB->query(
"SELECT *" .
202 " FROM exc_assignment_peer" .
203 " WHERE giver_id = " .
$ilDB->quote($a_user_id,
"integer") .
204 " AND ass_id = " .
$ilDB->quote($this->assignment_id,
"integer") .
205 " ORDER BY peer_id");
207 $row[
"seq"] = ++$idx;
218 if ($peer[
"peer_id"] == $a_peer_id) {
230 $data = $a_data[
"pcomment"];
246 foreach ($this->assignment->getPeerReviewCriteriaCatalogueItems() as $crit) {
247 $crit_id = $crit->getId()
250 $crit->setPeerReviewContext(
255 if (!$crit->validate(
$values[$crit_id])) {
258 if ($crit->hasValue(
$values[$crit_id])) {
273 $set =
$ilDB->query(
"SELECT *" .
274 " FROM exc_assignment_peer" .
275 " WHERE peer_id = " .
$ilDB->quote($a_user_id,
"integer") .
276 " AND ass_id = " .
$ilDB->quote($this->assignment_id,
"integer") .
277 " ORDER BY peer_id");
279 if (!$a_only_valid ||
283 $row[
"seq"] = ++$idx;
297 $set =
$ilDB->query(
"SELECT *" .
298 " FROM exc_assignment_peer" .
299 " WHERE ass_id = " .
$ilDB->quote($this->assignment_id,
"integer") .
300 " ORDER BY peer_id");
303 if (!$a_only_valid ||
317 $set =
$ilDB->query(
"SELECT ass_id" .
318 " FROM exc_assignment_peer" .
319 " WHERE giver_id = " .
$ilDB->quote(
$ilUser->getId(),
"integer") .
320 " AND peer_id = " .
$ilDB->quote($a_peer_id,
"integer") .
321 " AND ass_id = " .
$ilDB->quote($this->assignment_id,
"integer"));
323 return (
bool)
$row[
"ass_id"];
331 $ilDB->manipulate(
"UPDATE exc_assignment_peer" .
333 " WHERE giver_id = " .
$ilDB->quote(
$ilUser->getId(),
"integer") .
334 " AND peer_id = " .
$ilDB->quote($a_peer_id,
"integer") .
335 " AND ass_id = " .
$ilDB->quote($this->assignment_id,
"integer"));
343 $sql =
"UPDATE exc_assignment_peer" .
345 ",pcomment = " .
$ilDB->quote(serialize($a_values),
"text") .
346 " WHERE giver_id = " .
$ilDB->quote(
$ilUser->getId(),
"integer") .
347 " AND peer_id = " .
$ilDB->quote($a_peer_id,
"integer") .
348 " AND ass_id = " .
$ilDB->quote($this->assignment_id,
"integer");
350 $ilDB->manipulate($sql);
364 include_once
'./Services/Rating/classes/class.ilRating.php';
366 $set =
$ilDB->query(
"SELECT *" .
367 " FROM exc_assignment_peer" .
368 " WHERE ass_id = " .
$ilDB->quote($this->assignment_id,
"integer") .
369 " AND giver_id = " .
$ilDB->quote($a_user_id,
"integer"));
371 if (!(
bool) $a_validate ||
385 $set =
$ilDB->query(
"SELECT COUNT(DISTINCT(user_id)) cnt" .
386 " FROM exc_returned" .
387 " WHERE ass_id = " .
$ilDB->quote($this->assignment_id,
"integer"));
388 $cnt =
$ilDB->fetchAssoc($set);
389 $cnt = (int) $cnt[
"cnt"];
403 if (!$this->assignment->getPeerReviewSimpleUnlock()) {
404 $needed = $this->assignment->getPeerReviewMin();
410 $min = min($max, $needed);
423 if (!$this->assignment->afterDeadlineStrict()) {
435 switch ($this->assignment->getPeerReviewValid()) {
437 return (
bool) $no_of_feedbacks;
441 $min = min($max, $this->assignment->getPeerReviewMin());
443 return (($min - $no_of_feedbacks) < 1);
451 $ilDB = $DIC->database();
455 "SELECT DISTINCT(giver_id) FROM exc_assignment_peer " .
456 " WHERE ass_id = " .
$ilDB->quote($a_ass_id,
"integer") .
457 " AND tstamp is NULL" 461 array_push($user_ids,
$row[
"giver_id"]);
updatePeerReview($a_peer_id, array $a_values)
getId()
Get assignment id.
countGivenFeedback($a_validate=true, $a_user_id=null)
isFeedbackValidForPassed($a_user_id)
static now()
Return current timestamp in Y-m-d H:i:s format.
const PEER_REVIEW_VALID_ALL
hasPeerReviewAccess($a_peer_id)
getPeerMaskedId($a_giver_id, $a_peer_id)
const PEER_REVIEW_VALID_ONE
getAllPeerReviews($a_only_valid=true)
updatePeerReviewTimestamp($a_peer_id)
foreach($_POST as $key=> $value) $res
static lookupGiversWithPendingFeedback($a_ass_id)
getNumberOfMissingFeedbacksForReceived()
validatePeerReview(array $a_data)
getPeerReviewsByGiver($a_user_id)
getValidPeerReviewUsers()
const PEER_REVIEW_VALID_NONE
getPeerReviewsByPeerId($a_user_id, $a_only_valid=false)
getPeerReviewValues($a_giver_id, $a_peer_id)
static _getMembers($a_obj_id)
getMaxPossibleFeedbacks()
__construct(ilExAssignment $a_assignment)
validatePeerReviewGroups()