ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 31 of file class.SkillProfileCompletionDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

References ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\$db, $DIC, and ILIAS\Skill\Profile\SkillProfileCompletionDBRepository\$factory_service.

39  {
40  global $DIC;
41 
42  $this->db = ($db) ?: $DIC->database();
43  $this->factory_service = ($factory_service) ?: $DIC->skills()->internal()->factory();
44  }
global $DIC
Definition: feed.php:28

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 84 of file class.SkillProfileCompletionDBRepository.php.

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

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

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

116  : void
117  {
118  $ilDB = $this->db;
119 
120  $set = $ilDB->query(
121  "SELECT * FROM skl_profile_completion " .
122  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer") .
123  " AND user_id = " . $ilDB->quote($user_id, "integer") .
124  " ORDER BY date DESC" .
125  " LIMIT 1"
126  );
127 
128  $entry = null;
129  while ($rec = $ilDB->fetchAssoc($set)) {
130  $entry = $rec["fulfilled"];
131  }
132 
133  if (is_null($entry) || $entry == 1) {
134  $now = \ilUtil::now();
135  $ilDB->manipulate("INSERT INTO skl_profile_completion " .
136  "(profile_id, user_id, date, fulfilled) VALUES (" .
137  $ilDB->quote($profile_id, "integer") . "," .
138  $ilDB->quote($user_id, "integer") . "," .
139  $ilDB->quote($now, "timestamp") . "," .
140  $ilDB->quote(0, "integer") .
141  ")");
142  }
143  }
static now()
Return current timestamp in Y-m-d H:i:s format.
+ 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 209 of file class.SkillProfileCompletionDBRepository.php.

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

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

◆ deleteEntriesForUser()

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

Delete all profile completion entries for a user.

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

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

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

◆ getAllEntriesForProfile()

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

Get all completion entries for a single profile.

Returns
SkillProfileCompletion[]

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

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

190  : array
191  {
192  $ilDB = $this->db;
193 
194  $set = $ilDB->query(
195  "SELECT * FROM skl_profile_completion " .
196  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer")
197  );
198  $entries = [];
199  while ($rec = $ilDB->fetchAssoc($set)) {
200  $entries[] = $this->getFromRecord($rec);
201  }
202 
203  return $entries;
204  }
+ 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 170 of file class.SkillProfileCompletionDBRepository.php.

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

170  : array
171  {
172  $ilDB = $this->db;
173 
174  $set = $ilDB->query(
175  "SELECT * FROM skl_profile_completion " .
176  " WHERE user_id = " . $ilDB->quote($user_id, "integer")
177  );
178  $entries = [];
179  while ($rec = $ilDB->fetchAssoc($set)) {
180  $entries[] = $this->getFromRecord($rec);
181  }
182 
183  return $entries;
184  }
+ 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 50 of file class.SkillProfileCompletionDBRepository.php.

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

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

◆ getFromRecord()

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

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

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().

67  : SkillProfileCompletion
68  {
69  $rec["profile_id"] = (int) $rec["profile_id"];
70  $rec["user_id"] = (int) $rec["user_id"];
71  $rec["fulfilled"] = (bool) $rec["fulfilled"];
72 
73  return $this->factory_service->profile()->profileCompletion(
74  $rec["profile_id"],
75  $rec["user_id"],
76  $rec["date"],
77  $rec["fulfilled"]
78  );
79  }
+ 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 149 of file class.SkillProfileCompletionDBRepository.php.

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

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