ILIAS  release_7 Revision v7.30-3-g800a261c036
AppraiseeDBRepository.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998- ILIAS open source, Extended GPL, see docs/LICENSE */
4
6
14{
18 protected $db;
19
23 public function __construct(\ilDBInterface $db = null)
24 {
25 global $DIC;
26
27 $this->db = (is_null($db))
28 ? $DIC->database()
29 : $db;
30 }
31
38 public function getAppraiseesForRater(int $rater_id) : array
39 {
40 $db = $this->db;
41
42 $set = $db->queryF(
43 "SELECT obj_id, appr_id FROM svy_360_rater " .
44 " WHERE user_id = %s ",
45 ["integer"],
46 [$rater_id]
47 );
48 $appraisee = [];
49 while ($rec = $db->fetchAssoc($set)) {
50 $appraisee[] = [
51 "survey_id" => $rec["obj_id"],
52 "appr_id" => $rec["appr_id"]
53 ];
54 }
55 return $appraisee;
56 }
57
58
65 public function getClosedAppraiseesForSurveys(array $survey_ids)
66 {
67 $db = $this->db;
68
69 $set = $db->queryF(
70 "SELECT obj_id, user_id FROM svy_360_appr " .
71 " WHERE " . $db->in("obj_id", $survey_ids, false, "integer") .
72 "AND has_closed = %s",
73 ["integer"],
74 [1]
75 );
76 $closed_appraisees = [];
77 while ($rec = $db->fetchAssoc($set)) {
78 $closed_appraisees[] = [
79 "survey_id" => $rec["obj_id"],
80 "appr_id" => $rec["user_id"]
81 ];
82 }
83 return $closed_appraisees;
84 }
85
92 public function getUnclosedSurveysForAppraisee(int $appr_user_id) : array
93 {
94 $db = $this->db;
95
96 $set = $db->queryF(
97 "SELECT DISTINCT obj_id FROM svy_360_appr " .
98 "WHERE user_id = %s " .
99 "AND has_closed = %s",
100 ["integer", "integer"],
101 [$appr_user_id, 0]
102 );
103 $unclosed_surveys = [];
104 while ($rec = $db->fetchAssoc($set)) {
105 $unclosed_surveys[] = $rec["obj_id"];
106 }
107 return $unclosed_surveys;
108 }
109}
An exception for terminatinating execution or to throw for unit testing.
Apraisee / Rater DB repository Tables: svy_360_rater, svy_360_appr.
getUnclosedSurveysForAppraisee(int $appr_user_id)
Get all unclosed surveys of an appraisee.
getClosedAppraiseesForSurveys(array $survey_ids)
Get closed appraisees for a number of surveys.
getAppraiseesForRater(int $rater_id)
Get surveys for Rater.
__construct(\ilDBInterface $db=null)
Constructor.
global $DIC
Definition: goto.php:24
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...