ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Skill\Personal\AssignedMaterialDBRepository Class Reference
+ Collaboration diagram for ILIAS\Skill\Personal\AssignedMaterialDBRepository:

Public Member Functions

 __construct (?\ilDBInterface $db=null, ?Service\SkillInternalFactoryService $factory_service=null)
 
 assign (int $user_id, int $top_skill_id, int $tref_id, int $basic_skill_id, int $level_id, int $wsp_id)
 Assign material to skill level. More...
 
 get (int $user_id, int $tref_id, int $level_id)
 Get assigned materials (for a skill level and user) More...
 
 getAll (int $user_id, int $skill_id, int $tref_id)
 Get all assigned materials (for a skill and user) More...
 
 count (int $user_id, int $tref_id, int $level_id)
 Count assigned materials (for a skill level and user) More...
 
 remove (int $user_id, int $tref_id, int $level_id, int $wsp_id)
 
 removeAllForUser (int $user_id)
 
 removeAllForSkill (int $skill_node_id, bool $is_reference)
 

Protected Member Functions

 getFromRecord (array $rec)
 

Protected Attributes

ilDBInterface $db
 
Service SkillInternalFactoryService $factory_service
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 33 of file class.AssignedMaterialDBRepository.php.

References ILIAS\Skill\Personal\AssignedMaterialDBRepository\$db, $DIC, and ILIAS\Skill\Personal\AssignedMaterialDBRepository\$factory_service.

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

Member Function Documentation

◆ assign()

ILIAS\Skill\Personal\AssignedMaterialDBRepository::assign ( int  $user_id,
int  $top_skill_id,
int  $tref_id,
int  $basic_skill_id,
int  $level_id,
int  $wsp_id 
)

Assign material to skill level.

Parameters
int$user_iduser id
int$top_skill_idthe "selectable" top skill
int$tref_idtemplate reference id
int$basic_skill_idthe basic skill the level belongs to
int$level_idlevel id
int$wsp_idworkspace object

Definition at line 53 of file class.AssignedMaterialDBRepository.php.

References ILIAS\Skill\Personal\AssignedMaterialDBRepository\$db, and $ilDB.

60  : void {
61  $ilDB = $this->db;
62 
63  $set = $ilDB->query(
64  "SELECT * FROM skl_assigned_material " .
65  " WHERE user_id = " . $ilDB->quote($user_id, "integer") .
66  " AND top_skill_id = " . $ilDB->quote($top_skill_id, "integer") .
67  " AND tref_id = " . $ilDB->quote($tref_id, "integer") .
68  " AND skill_id = " . $ilDB->quote($basic_skill_id, "integer") .
69  " AND level_id = " . $ilDB->quote($level_id, "integer") .
70  " AND wsp_id = " . $ilDB->quote($wsp_id, "integer")
71  );
72  if (!$ilDB->fetchAssoc($set)) {
73  $ilDB->manipulate("INSERT INTO skl_assigned_material " .
74  "(user_id, top_skill_id, tref_id, skill_id, level_id, wsp_id) VALUES (" .
75  $ilDB->quote($user_id, "integer") . "," .
76  $ilDB->quote($top_skill_id, "integer") . "," .
77  $ilDB->quote($tref_id, "integer") . "," .
78  $ilDB->quote($basic_skill_id, "integer") . "," .
79  $ilDB->quote($level_id, "integer") . "," .
80  $ilDB->quote($wsp_id, "integer") .
81  ")");
82  }
83  }

◆ count()

ILIAS\Skill\Personal\AssignedMaterialDBRepository::count ( int  $user_id,
int  $tref_id,
int  $level_id 
)

Count assigned materials (for a skill level and user)

Definition at line 149 of file class.AssignedMaterialDBRepository.php.

References ILIAS\Skill\Personal\AssignedMaterialDBRepository\$db, and $ilDB.

149  : int
150  {
151  $ilDB = $this->db;
152 
153  $set = $ilDB->query(
154  "SELECT count(*) as cnt FROM skl_assigned_material " .
155  " WHERE level_id = " . $ilDB->quote($level_id, "integer") .
156  " AND tref_id = " . $ilDB->quote($tref_id, "integer") .
157  " AND user_id = " . $ilDB->quote($user_id, "integer")
158  );
159  $rec = $ilDB->fetchAssoc($set);
160  return (int) $rec["cnt"];
161  }

◆ get()

ILIAS\Skill\Personal\AssignedMaterialDBRepository::get ( int  $user_id,
int  $tref_id,
int  $level_id 
)

Get assigned materials (for a skill level and user)

Returns
AssignedMaterial[]

Definition at line 89 of file class.AssignedMaterialDBRepository.php.

References ILIAS\Skill\Personal\AssignedMaterialDBRepository\$db, $ilDB, and ILIAS\Skill\Personal\AssignedMaterialDBRepository\getFromRecord().

89  : array
90  {
91  $ilDB = $this->db;
92 
93  $set = $ilDB->query(
94  "SELECT * FROM skl_assigned_material " .
95  " WHERE level_id = " . $ilDB->quote($level_id, "integer") .
96  " AND tref_id = " . $ilDB->quote($tref_id, "integer") .
97  " AND user_id = " . $ilDB->quote($user_id, "integer")
98  );
99  $mat = [];
100  while ($rec = $ilDB->fetchAssoc($set)) {
101  $mat[] = $this->getFromRecord($rec);
102  }
103  return $mat;
104  }
+ Here is the call graph for this function:

◆ getAll()

ILIAS\Skill\Personal\AssignedMaterialDBRepository::getAll ( int  $user_id,
int  $skill_id,
int  $tref_id 
)

Get all assigned materials (for a skill and user)

Returns
AssignedMaterial[]

Definition at line 110 of file class.AssignedMaterialDBRepository.php.

References ILIAS\Skill\Personal\AssignedMaterialDBRepository\$db, $ilDB, and ILIAS\Skill\Personal\AssignedMaterialDBRepository\getFromRecord().

110  : array
111  {
112  $ilDB = $this->db;
113 
114  $set = $ilDB->query(
115  "SELECT * FROM skl_assigned_material " .
116  " WHERE skill_id = " . $ilDB->quote($skill_id, "integer") .
117  " AND tref_id = " . $ilDB->quote($tref_id, "integer") .
118  " AND user_id = " . $ilDB->quote($user_id, "integer")
119  );
120  $mat = [];
121  while ($rec = $ilDB->fetchAssoc($set)) {
122  $mat[] = $this->getFromRecord($rec);
123  }
124  return $mat;
125  }
+ Here is the call graph for this function:

◆ getFromRecord()

ILIAS\Skill\Personal\AssignedMaterialDBRepository::getFromRecord ( array  $rec)
protected

Definition at line 127 of file class.AssignedMaterialDBRepository.php.

References ILIAS\Repository\int().

Referenced by ILIAS\Skill\Personal\AssignedMaterialDBRepository\get(), and ILIAS\Skill\Personal\AssignedMaterialDBRepository\getAll().

127  : AssignedMaterial
128  {
129  $rec['user_id'] = (int) $rec['user_id'];
130  $rec['top_skill_id'] = (int) $rec['top_skill_id'];
131  $rec['skill_id'] = (int) $rec['skill_id'];
132  $rec['level_id'] = (int) $rec['level_id'];
133  $rec['wsp_id'] = (int) $rec['wsp_id'];
134  $rec['tref_id'] = (int) $rec['tref_id'];
135 
136  return $this->factory_service->personal()->assignedMaterial(
137  $rec['user_id'],
138  $rec['top_skill_id'],
139  $rec['skill_id'],
140  $rec['level_id'],
141  $rec['wsp_id'],
142  $rec['tref_id']
143  );
144  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remove()

ILIAS\Skill\Personal\AssignedMaterialDBRepository::remove ( int  $user_id,
int  $tref_id,
int  $level_id,
int  $wsp_id 
)

Definition at line 163 of file class.AssignedMaterialDBRepository.php.

References ILIAS\Skill\Personal\AssignedMaterialDBRepository\$db, and $ilDB.

163  : void
164  {
165  $ilDB = $this->db;
166 
167  $t = "DELETE FROM skl_assigned_material WHERE " .
168  " user_id = " . $ilDB->quote($user_id, "integer") .
169  " AND tref_id = " . $ilDB->quote($tref_id, "integer") .
170  " AND level_id = " . $ilDB->quote($level_id, "integer") .
171  " AND wsp_id = " . $ilDB->quote($wsp_id, "integer");
172 
173  $ilDB->manipulate($t);
174  }

◆ removeAllForSkill()

ILIAS\Skill\Personal\AssignedMaterialDBRepository::removeAllForSkill ( int  $skill_node_id,
bool  $is_reference 
)

Definition at line 185 of file class.AssignedMaterialDBRepository.php.

References ILIAS\Skill\Personal\AssignedMaterialDBRepository\$db, and $ilDB.

185  : void
186  {
187  $ilDB = $this->db;
188 
189  if (!$is_reference) {
190  $t = "DELETE FROM skl_assigned_material WHERE " .
191  " skill_id = " . $ilDB->quote($skill_node_id, "integer");
192  } else {
193  $t = "DELETE FROM skl_assigned_material WHERE " .
194  " tref_id = " . $ilDB->quote($skill_node_id, "integer");
195  }
196  $ilDB->manipulate($t);
197  }

◆ removeAllForUser()

ILIAS\Skill\Personal\AssignedMaterialDBRepository::removeAllForUser ( int  $user_id)

Definition at line 176 of file class.AssignedMaterialDBRepository.php.

References ILIAS\Skill\Personal\AssignedMaterialDBRepository\$db, and $ilDB.

176  : void
177  {
178  $ilDB = $this->db;
179 
180  $t = "DELETE FROM skl_assigned_material WHERE " .
181  " user_id = " . $ilDB->quote($user_id, "integer");
182  $ilDB->manipulate($t);
183  }

Field Documentation

◆ $db

◆ $factory_service

Service SkillInternalFactoryService ILIAS\Skill\Personal\AssignedMaterialDBRepository::$factory_service
protected

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