ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.RunDBRepository.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
6
16{
20 protected $db;
21
25 public function __construct(\ilDBInterface $db = null)
26 {
27 global $DIC;
28
29 $this->db = (is_null($db))
30 ? $DIC->database()
31 : $db;
32 }
33
34
41 public function getFinishedSurveysOfUser(int $user_id) : array
42 {
43 $db = $this->db;
44
45 $set = $db->queryF(
46 "SELECT survey_fi FROM svy_finished " .
47 " WHERE user_fi = %s AND state = %s",
48 ["integer", "integer"],
49 [$user_id, 1]
50 );
51 $items = [];
52 while ($rec = $db->fetchAssoc($set)) {
53 $items[] = (int) $rec["survey_fi"];
54 }
55 return $items;
56 }
57
64 public function getUnfinishedSurveysOfUser(int $user_id) : array
65 {
66 $db = $this->db;
67
68 $set = $db->queryF(
69 "SELECT survey_fi FROM svy_finished " .
70 " WHERE user_fi = %s AND state = %s",
71 ["integer", "integer"],
72 [$user_id, 0]
73 );
74 $items = [];
75 while ($rec = $db->fetchAssoc($set)) {
76 $items[] = $rec["survey_fi"];
77 }
78 return $items;
79 }
80
87 public function getFinishedAppraiseesForRater(int $rater_id) : array
88 {
89 $db = $this->db;
90
91 $set = $db->queryF(
92 "SELECT survey_fi, appr_id FROM svy_finished " .
93 " WHERE user_fi = %s AND state = %s",
94 ["integer", "integer"],
95 [$rater_id, 1]
96 );
97 $appraisee = [];
98 while ($rec = $db->fetchAssoc($set)) {
99 $appraisee[] = [
100 "survey_id" => $rec["survey_fi"],
101 "appr_id" => $rec["appr_id"]
102 ];
103 }
104 return $appraisee;
105 }
106}
An exception for terminatinating execution or to throw for unit testing.
getUnfinishedSurveysOfUser(int $user_id)
Get all unfinished surveys of a user.
getFinishedSurveysOfUser(int $user_id)
Get all finished surveys of a user.
getFinishedAppraiseesForRater(int $rater_id)
Get finished appraisees for a rater.
__construct(\ilDBInterface $db=null)
Constructor.
Interface ilDBInterface.
$DIC
Definition: xapitoken.php:46