ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Skill\Profile\SkillProfileCompletionDBRepository Class Reference

Repository for skill profile completion. More...

+ Collaboration diagram for ILIAS\Skill\Profile\SkillProfileCompletionDBRepository:

Public Member Functions

 __construct (?\ilDBInterface $db=null, ?Service\SkillInternalFactoryService $factory_service=null)
 
 getEntries (int $user_id, int $profile_id)
 Get profile completion entries for given user-profile-combination. More...
 
 addFulfilmentEntry (int $user_id, int $profile_id)
 Add profile fulfilment entry to given user-profile-combination. More...
 
 addNonFulfilmentEntry (int $user_id, int $profile_id)
 Add profile non-fulfilment entry to given user-profile-combination. More...
 
 getFulfilledEntriesForUser (int $user_id)
 Get all fulfilled profile completion entries for a user. More...
 
 getAllEntriesForUser (int $user_id)
 Get all profile completion entries for a user. More...
 
 getAllEntriesForProfile (int $profile_id)
 Get all completion entries for a single profile. More...
 
 deleteEntriesForProfile (int $profile_id)
 Delete all profile completion entries for a profile. More...
 
 deleteEntriesForUser (int $user_id)
 Delete all profile completion entries for a user. More...
 

Protected Member Functions

 getFromRecord (array $rec)
 

Protected Attributes

ilDBInterface $db
 
Service SkillInternalFactoryService $factory_service
 

Detailed Description

Repository for skill profile completion.

Author
Thomas Famula famul.nosp@m.a@le.nosp@m.ifos..nosp@m.de

Definition at line 30 of file class.SkillProfileCompletionDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::__construct ( ?\ilDBInterface  $db = null,
?Service\SkillInternalFactoryService  $factory_service = null 
)

Member Function Documentation

◆ addFulfilmentEntry()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::addFulfilmentEntry ( int  $user_id,
int  $profile_id 
)

Add profile fulfilment entry to given user-profile-combination.

Definition at line 83 of file class.SkillProfileCompletionDBRepository.php.

83 : void
84 {
86
87 $set = $ilDB->query(
88 "SELECT * FROM skl_profile_completion " .
89 " WHERE profile_id = " . $ilDB->quote($profile_id, "integer") .
90 " AND user_id = " . $ilDB->quote($user_id, "integer") .
91 " ORDER BY date DESC" .
92 " LIMIT 1"
93 );
94
95 $entry = null;
96 while ($rec = $ilDB->fetchAssoc($set)) {
97 $entry = $rec["fulfilled"];
98 }
99
100 if ($entry == 0) {
101 $now = \ilUtil::now();
102 $ilDB->manipulate("INSERT INTO skl_profile_completion " .
103 "(profile_id, user_id, date, fulfilled) VALUES (" .
104 $ilDB->quote($profile_id, "integer") . "," .
105 $ilDB->quote($user_id, "integer") . "," .
106 $ilDB->quote($now, "timestamp") . "," .
107 $ilDB->quote(1, "integer") .
108 ")");
109 }
110 }
static now()
Return current timestamp in Y-m-d H:i:s format.

References ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\$db, $ilDB, $user_id, and ilUtil\now().

+ Here is the call graph for this function:

◆ addNonFulfilmentEntry()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::addNonFulfilmentEntry ( int  $user_id,
int  $profile_id 
)

Add profile non-fulfilment entry to given user-profile-combination.

Definition at line 115 of file class.SkillProfileCompletionDBRepository.php.

115 : void
116 {
118
119 $set = $ilDB->query(
120 "SELECT * FROM skl_profile_completion " .
121 " WHERE profile_id = " . $ilDB->quote($profile_id, "integer") .
122 " AND user_id = " . $ilDB->quote($user_id, "integer") .
123 " ORDER BY date DESC" .
124 " LIMIT 1"
125 );
126
127 $entry = null;
128 while ($rec = $ilDB->fetchAssoc($set)) {
129 $entry = $rec["fulfilled"];
130 }
131
132 if (is_null($entry) || $entry == 1) {
133 $now = \ilUtil::now();
134 $ilDB->manipulate("INSERT INTO skl_profile_completion " .
135 "(profile_id, user_id, date, fulfilled) VALUES (" .
136 $ilDB->quote($profile_id, "integer") . "," .
137 $ilDB->quote($user_id, "integer") . "," .
138 $ilDB->quote($now, "timestamp") . "," .
139 $ilDB->quote(0, "integer") .
140 ")");
141 }
142 }

References ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\$db, $ilDB, $user_id, and ilUtil\now().

+ Here is the call graph for this function:

◆ deleteEntriesForProfile()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::deleteEntriesForProfile ( int  $profile_id)

Delete all profile completion entries for a profile.

Definition at line 208 of file class.SkillProfileCompletionDBRepository.php.

208 : void
209 {
211
212 $ilDB->manipulate(
213 "DELETE FROM skl_profile_completion WHERE "
214 . " profile_id = " . $ilDB->quote($profile_id, "integer")
215 );
216 }

References ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\$db, and $ilDB.

◆ deleteEntriesForUser()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::deleteEntriesForUser ( int  $user_id)

Delete all profile completion entries for a user.

Definition at line 221 of file class.SkillProfileCompletionDBRepository.php.

221 : void
222 {
224
225 $ilDB->manipulate(
226 "DELETE FROM skl_profile_completion WHERE "
227 . " user_id = " . $ilDB->quote($user_id, "integer")
228 );
229 }

References ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\$db, $ilDB, and $user_id.

◆ getAllEntriesForProfile()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::getAllEntriesForProfile ( int  $profile_id)

Get all completion entries for a single profile.

Returns
SkillProfileCompletion[]

Definition at line 189 of file class.SkillProfileCompletionDBRepository.php.

189 : array
190 {
192
193 $set = $ilDB->query(
194 "SELECT * FROM skl_profile_completion " .
195 " WHERE profile_id = " . $ilDB->quote($profile_id, "integer")
196 );
197 $entries = [];
198 while ($rec = $ilDB->fetchAssoc($set)) {
199 $entries[] = $this->getFromRecord($rec);
200 }
201
202 return $entries;
203 }

References ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\$db, $ilDB, and ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\getFromRecord().

+ Here is the call graph for this function:

◆ getAllEntriesForUser()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::getAllEntriesForUser ( int  $user_id)

Get all profile completion entries for a user.

Returns
SkillProfileCompletion[]

Definition at line 169 of file class.SkillProfileCompletionDBRepository.php.

169 : array
170 {
172
173 $set = $ilDB->query(
174 "SELECT * FROM skl_profile_completion " .
175 " WHERE user_id = " . $ilDB->quote($user_id, "integer")
176 );
177 $entries = [];
178 while ($rec = $ilDB->fetchAssoc($set)) {
179 $entries[] = $this->getFromRecord($rec);
180 }
181
182 return $entries;
183 }

References ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\$db, $ilDB, $user_id, and ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\getFromRecord().

+ Here is the call graph for this function:

◆ getEntries()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::getEntries ( int  $user_id,
int  $profile_id 
)

Get profile completion entries for given user-profile-combination.

Returns
SkillProfileCompletion[]

Definition at line 49 of file class.SkillProfileCompletionDBRepository.php.

49 : array
50 {
52
53 $set = $ilDB->query(
54 "SELECT * FROM skl_profile_completion " .
55 " WHERE profile_id = " . $ilDB->quote($profile_id, "integer") .
56 " AND user_id = " . $ilDB->quote($user_id, "integer")
57 );
58 $entries = [];
59 while ($rec = $ilDB->fetchAssoc($set)) {
60 $entries[] = $this->getFromRecord($rec);
61 }
62
63 return $entries;
64 }

References ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\$db, $ilDB, $user_id, and ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\getFromRecord().

+ Here is the call graph for this function:

◆ getFromRecord()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::getFromRecord ( array  $rec)
protected

Definition at line 66 of file class.SkillProfileCompletionDBRepository.php.

66 : SkillProfileCompletion
67 {
68 $rec["profile_id"] = (int) $rec["profile_id"];
69 $rec["user_id"] = (int) $rec["user_id"];
70 $rec["fulfilled"] = (bool) $rec["fulfilled"];
71
72 return $this->factory_service->profile()->profileCompletion(
73 $rec["profile_id"],
74 $rec["user_id"],
75 $rec["date"],
76 $rec["fulfilled"]
77 );
78 }

References ILIAS\Repository\int().

Referenced by ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\getAllEntriesForProfile(), ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\getAllEntriesForUser(), ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\getEntries(), and ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\getFulfilledEntriesForUser().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFulfilledEntriesForUser()

ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::getFulfilledEntriesForUser ( int  $user_id)

Get all fulfilled profile completion entries for a user.

Returns
SkillProfileCompletion[]

Definition at line 148 of file class.SkillProfileCompletionDBRepository.php.

148 : array
149 {
151
152 $set = $ilDB->query(
153 "SELECT * FROM skl_profile_completion " .
154 " WHERE user_id = " . $ilDB->quote($user_id, "integer") .
155 " AND fulfilled = 1"
156 );
157 $entries = [];
158 while ($rec = $ilDB->fetchAssoc($set)) {
159 $entries[] = $this->getFromRecord($rec);
160 }
161
162 return $entries;
163 }

References ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\$db, $ilDB, $user_id, and ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\getFromRecord().

+ Here is the call graph for this function:

Field Documentation

◆ $db

◆ $factory_service

Service SkillInternalFactoryService ILIAS\Skill\Profile\SkillProfileCompletionDBRepository::$factory_service
protected

The documentation for this class was generated from the following file: