ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 
)

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

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

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

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.

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

83  : void
84  {
85  $ilDB = $this->db;
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.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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.

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

115  : void
116  {
117  $ilDB = $this->db;
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  }
static now()
Return current timestamp in Y-m-d H:i:s format.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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.

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

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

◆ 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.

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

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

◆ 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.

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

189  : array
190  {
191  $ilDB = $this->db;
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  }
+ 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.

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

169  : array
170  {
171  $ilDB = $this->db;
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  }
+ 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.

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

49  : array
50  {
51  $ilDB = $this->db;
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  }
+ 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.

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

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  }
+ 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.

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

148  : array
149  {
150  $ilDB = $this->db;
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  }
+ 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: