ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilAssQuestionSkillAssignmentList Class Reference
+ Collaboration diagram for ilAssQuestionSkillAssignmentList:

Public Member Functions

 __construct (ilDBInterface $db)
 
 setParentObjId ($parentObjId)
 
 getParentObjId ()
 
 getQuestionIdFilter ()
 
 setQuestionIdFilter ($questionIdFilter)
 
 reset ()
 
 addAssignment (ilAssQuestionSkillAssignment $assignment)
 
 loadFromDb ()
 
 loadAdditionalSkillData ()
 
 getAssignmentsByQuestionId ($questionId)
 
 isAssignedToQuestionId ($skillBaseId, $skillTrefId, $questionId)
 
 getUniqueAssignedSkills ()
 
 isAssignedSkill ($skillBaseId, $skillTrefId)
 
 getNumAssignsBySkill ($skillBaseId, $skillTrefId)
 
 getMaxPointsBySkill ($skillBaseId, $skillTrefId)
 
 hasSkillsAssignedLowerThanBarrier ()
 

Private Member Functions

 incrementNumAssignsBySkill (ilAssQuestionSkillAssignment $assignment)
 
 incrementMaxPointsBySkill (ilAssQuestionSkillAssignment $assignment)
 
 getWhereConditions ()
 
 buildSkillQuestionAssignmentByArray ($data)
 
 buildSkillKey ($skillBaseId, $skillTrefId)
 

Private Attributes

 $db
 
 $parentObjId
 
 $assignments
 
 $numAssignsBySkill
 
 $maxPointsBySkill
 
 $questionIdFilter
 

Detailed Description

Definition at line 12 of file class.ilAssQuestionSkillAssignmentList.php.

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionSkillAssignmentList::__construct ( ilDBInterface  $db)

Definition at line 44 of file class.ilAssQuestionSkillAssignmentList.php.

References $db, and array.

45  {
46  $this->db = $db;
47 
48  $this->parentObjId = null;
49  $this->assignments = array();
50  $this->numAssignsBySkill = array();
51  $this->maxPointsBySkill = array();
52  $this->questionIdFilter = null;
53  }
Create styles array
The data for the language used.

Member Function Documentation

◆ addAssignment()

ilAssQuestionSkillAssignmentList::addAssignment ( ilAssQuestionSkillAssignment  $assignment)

Definition at line 94 of file class.ilAssQuestionSkillAssignmentList.php.

References array, and ilAssQuestionSkillAssignment\getQuestionId().

Referenced by loadFromDb().

95  {
96  if( !isset($this->assignments[$assignment->getQuestionId()]) )
97  {
98  $this->assignments[$assignment->getQuestionId()] = array();
99  }
100 
101  $this->assignments[$assignment->getQuestionId()][] = $assignment;
102  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildSkillKey()

ilAssQuestionSkillAssignmentList::buildSkillKey (   $skillBaseId,
  $skillTrefId 
)
private

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

Referenced by getMaxPointsBySkill(), getNumAssignsBySkill(), getUniqueAssignedSkills(), incrementMaxPointsBySkill(), and incrementNumAssignsBySkill().

186  {
187  return $skillBaseId.':'.$skillTrefId;
188  }
+ Here is the caller graph for this function:

◆ buildSkillQuestionAssignmentByArray()

ilAssQuestionSkillAssignmentList::buildSkillQuestionAssignmentByArray (   $data)
private
Parameters
array$data
Returns
ilAssQuestionSkillAssignment

Definition at line 171 of file class.ilAssQuestionSkillAssignmentList.php.

References $data.

Referenced by loadFromDb().

172  {
173  $assignment = new ilAssQuestionSkillAssignment($this->db);
174 
175  $assignment->setParentObjId($data['obj_fi']);
176  $assignment->setQuestionId($data['question_fi']);
177  $assignment->setSkillBaseId($data['skill_base_fi']);
178  $assignment->setSkillTrefId($data['skill_tref_fi']);
179  $assignment->setSkillPoints($data['skill_points']);
180  $assignment->setEvalMode($data['eval_mode']);
181 
182  return $assignment;
183  }
+ Here is the caller graph for this function:

◆ getAssignmentsByQuestionId()

ilAssQuestionSkillAssignmentList::getAssignmentsByQuestionId (   $questionId)

Definition at line 201 of file class.ilAssQuestionSkillAssignmentList.php.

References array.

202  {
203  if( !isset($this->assignments[$questionId]) )
204  {
205  return array();
206  }
207 
208  return $this->assignments[$questionId];
209  }
Create styles array
The data for the language used.

◆ getMaxPointsBySkill()

ilAssQuestionSkillAssignmentList::getMaxPointsBySkill (   $skillBaseId,
  $skillTrefId 
)

Definition at line 295 of file class.ilAssQuestionSkillAssignmentList.php.

References buildSkillKey().

Referenced by getUniqueAssignedSkills().

296  {
297  return $this->maxPointsBySkill[$this->buildSkillKey($skillBaseId, $skillTrefId)];
298  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNumAssignsBySkill()

ilAssQuestionSkillAssignmentList::getNumAssignsBySkill (   $skillBaseId,
  $skillTrefId 
)

Definition at line 290 of file class.ilAssQuestionSkillAssignmentList.php.

References buildSkillKey().

Referenced by getUniqueAssignedSkills().

291  {
292  return $this->numAssignsBySkill[$this->buildSkillKey($skillBaseId, $skillTrefId)];
293  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParentObjId()

ilAssQuestionSkillAssignmentList::getParentObjId ( )

◆ getQuestionIdFilter()

ilAssQuestionSkillAssignmentList::getQuestionIdFilter ( )
Returns
int

Definition at line 74 of file class.ilAssQuestionSkillAssignmentList.php.

References $questionIdFilter.

Referenced by getWhereConditions().

+ Here is the caller graph for this function:

◆ getUniqueAssignedSkills()

ilAssQuestionSkillAssignmentList::getUniqueAssignedSkills ( )

Definition at line 236 of file class.ilAssQuestionSkillAssignmentList.php.

References array, buildSkillKey(), getMaxPointsBySkill(), and getNumAssignsBySkill().

Referenced by hasSkillsAssignedLowerThanBarrier(), and isAssignedSkill().

237  {
238  require_once 'Services/Skill/classes/class.ilBasicSkill.php';
239 
240  $skills = array();
241 
242  foreach($this->assignments as $assignmentsByQuestion)
243  {
244  foreach($assignmentsByQuestion as $assignment)
245  {
246  /* @var ilAssQuestionSkillAssignment $assignment */
247 
248  $key = $this->buildSkillKey($assignment->getSkillBaseId(), $assignment->getSkillTrefId());
249 
250  if( !isset($skills[$key]) )
251  {
252  $skills[$key] = array(
253  'skill' => new ilBasicSkill($assignment->getSkillBaseId()),
254  'skill_base_id' => $assignment->getSkillBaseId(),
255  'skill_tref_id' => $assignment->getSkillTrefId(),
256  'skill_title' => $assignment->getSkillTitle(),
257  'skill_path' => $assignment->getSkillPath(),
258  'num_assigns' => $this->getNumAssignsBySkill(
259  $assignment->getSkillBaseId(), $assignment->getSkillTrefId()
260  ),
261  'max_points' => $this->getMaxPointsBySkill(
262  $assignment->getSkillBaseId(), $assignment->getSkillTrefId()
263  )
264  );
265  }
266  }
267  }
268 
269  return $skills;
270  }
Create styles array
The data for the language used.
Basic Skill.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWhereConditions()

ilAssQuestionSkillAssignmentList::getWhereConditions ( )
private

Definition at line 153 of file class.ilAssQuestionSkillAssignmentList.php.

References array, and getQuestionIdFilter().

154  {
155  $conditions = array(
156  'obj_fi = '.$this->db->quote($this->getParentObjId(), 'integer')
157  );
158 
159  if( $this->getQuestionIdFilter() )
160  {
161  $conditions[] = 'question_fi = '.$this->db->quote($this->getQuestionIdFilter(), 'integer');
162  }
163 
164  return implode(' AND ', $conditions);
165  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ hasSkillsAssignedLowerThanBarrier()

ilAssQuestionSkillAssignmentList::hasSkillsAssignedLowerThanBarrier ( )

Definition at line 300 of file class.ilAssQuestionSkillAssignmentList.php.

References ilObjAssessmentFolder\getSkillTriggerAnswerNumberBarrier(), and getUniqueAssignedSkills().

301  {
302  require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
304 
305  foreach($this->getUniqueAssignedSkills() as $skillData)
306  {
307  if( $skillData['num_assigns'] < $globalBarrier )
308  {
309  return true;
310  }
311  }
312 
313  return false;
314  }
+ Here is the call graph for this function:

◆ incrementMaxPointsBySkill()

ilAssQuestionSkillAssignmentList::incrementMaxPointsBySkill ( ilAssQuestionSkillAssignment  $assignment)
private

Definition at line 116 of file class.ilAssQuestionSkillAssignmentList.php.

References buildSkillKey(), ilAssQuestionSkillAssignment\getMaxSkillPoints(), ilAssQuestionSkillAssignment\getSkillBaseId(), and ilAssQuestionSkillAssignment\getSkillTrefId().

Referenced by loadFromDb().

117  {
118  $key = $this->buildSkillKey($assignment->getSkillBaseId(), $assignment->getSkillTrefId());
119 
120  if( !isset($this->maxPointsBySkill[$key]) )
121  {
122  $this->maxPointsBySkill[$key] = 0;
123  }
124 
125  $this->maxPointsBySkill[$key] += $assignment->getMaxSkillPoints();
126  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ incrementNumAssignsBySkill()

ilAssQuestionSkillAssignmentList::incrementNumAssignsBySkill ( ilAssQuestionSkillAssignment  $assignment)
private

Definition at line 104 of file class.ilAssQuestionSkillAssignmentList.php.

References buildSkillKey(), ilAssQuestionSkillAssignment\getSkillBaseId(), and ilAssQuestionSkillAssignment\getSkillTrefId().

Referenced by loadFromDb().

105  {
106  $key = $this->buildSkillKey($assignment->getSkillBaseId(), $assignment->getSkillTrefId());
107 
108  if( !isset($this->numAssignsBySkill[$key]) )
109  {
110  $this->numAssignsBySkill[$key] = 0;
111  }
112 
113  $this->numAssignsBySkill[$key]++;
114  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAssignedSkill()

ilAssQuestionSkillAssignmentList::isAssignedSkill (   $skillBaseId,
  $skillTrefId 
)

Definition at line 272 of file class.ilAssQuestionSkillAssignmentList.php.

References getUniqueAssignedSkills().

273  {
274  foreach($this->getUniqueAssignedSkills() as $assignedSkill)
275  {
276  if( $assignedSkill['skill_base_id'] != $skillBaseId )
277  {
278  continue;
279  }
280 
281  if( $assignedSkill['skill_tref_id'] == $skillTrefId )
282  {
283  return true;
284  }
285  }
286 
287  return false;
288  }
+ Here is the call graph for this function:

◆ isAssignedToQuestionId()

ilAssQuestionSkillAssignmentList::isAssignedToQuestionId (   $skillBaseId,
  $skillTrefId,
  $questionId 
)

Definition at line 211 of file class.ilAssQuestionSkillAssignmentList.php.

212  {
213  if( !isset($this->assignments[$questionId]) )
214  {
215  return false;
216  }
217 
218  foreach($this->assignments[$questionId] as $assignment)
219  {
220  if( $assignment->getSkillBaseId() != $skillBaseId )
221  {
222  continue;
223  }
224 
225  if( $assignment->getSkillTrefId() != $skillTrefId )
226  {
227  continue;
228  }
229 
230  return true;
231  }
232 
233  return false;
234  }

◆ loadAdditionalSkillData()

ilAssQuestionSkillAssignmentList::loadAdditionalSkillData ( )

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

191  {
192  foreach($this->assignments as $assignmentsByQuestion)
193  {
194  foreach($assignmentsByQuestion as $assignment)
195  {
196  $assignment->loadAdditionalSkillData();
197  }
198  }
199  }

◆ loadFromDb()

ilAssQuestionSkillAssignmentList::loadFromDb ( )

Definition at line 128 of file class.ilAssQuestionSkillAssignmentList.php.

References $res, $row, addAssignment(), buildSkillQuestionAssignmentByArray(), incrementMaxPointsBySkill(), incrementNumAssignsBySkill(), and reset().

129  {
130  $this->reset();
131 
132  $res = $this->db->query("
133  SELECT obj_fi, question_fi, skill_base_fi, skill_tref_fi, skill_points, eval_mode
134  FROM qpl_qst_skl_assigns
135  WHERE {$this->getWhereConditions()}
136  ");
137 
138  while( $row = $this->db->fetchAssoc($res) )
139  {
140  $assignment = $this->buildSkillQuestionAssignmentByArray($row);
141 
142  if( $assignment->hasEvalModeBySolution() )
143  {
144  $assignment->loadComparisonExpressions(); // db query
145  }
146 
147  $this->addAssignment($assignment);
148  $this->incrementNumAssignsBySkill($assignment);
149  $this->incrementMaxPointsBySkill($assignment);
150  }
151  }
incrementMaxPointsBySkill(ilAssQuestionSkillAssignment $assignment)
addAssignment(ilAssQuestionSkillAssignment $assignment)
incrementNumAssignsBySkill(ilAssQuestionSkillAssignment $assignment)
+ Here is the call graph for this function:

◆ reset()

ilAssQuestionSkillAssignmentList::reset ( )

Definition at line 87 of file class.ilAssQuestionSkillAssignmentList.php.

References array.

Referenced by loadFromDb().

88  {
89  $this->assignments = array();
90  $this->numAssignsBySkill = array();
91  $this->maxPointsBySkill = array();
92  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ setParentObjId()

ilAssQuestionSkillAssignmentList::setParentObjId (   $parentObjId)
Parameters
int$parentObjId

Definition at line 58 of file class.ilAssQuestionSkillAssignmentList.php.

References $parentObjId.

◆ setQuestionIdFilter()

ilAssQuestionSkillAssignmentList::setQuestionIdFilter (   $questionIdFilter)
Parameters
int$questionIdFilter

Definition at line 82 of file class.ilAssQuestionSkillAssignmentList.php.

References $questionIdFilter.

83  {
84  $this->questionIdFilter = $questionIdFilter;
85  }

Field Documentation

◆ $assignments

ilAssQuestionSkillAssignmentList::$assignments
private

Definition at line 27 of file class.ilAssQuestionSkillAssignmentList.php.

◆ $db

ilAssQuestionSkillAssignmentList::$db
private

Definition at line 17 of file class.ilAssQuestionSkillAssignmentList.php.

Referenced by __construct().

◆ $maxPointsBySkill

ilAssQuestionSkillAssignmentList::$maxPointsBySkill
private

Definition at line 37 of file class.ilAssQuestionSkillAssignmentList.php.

◆ $numAssignsBySkill

ilAssQuestionSkillAssignmentList::$numAssignsBySkill
private

Definition at line 32 of file class.ilAssQuestionSkillAssignmentList.php.

◆ $parentObjId

ilAssQuestionSkillAssignmentList::$parentObjId
private

Definition at line 22 of file class.ilAssQuestionSkillAssignmentList.php.

Referenced by getParentObjId(), and setParentObjId().

◆ $questionIdFilter

ilAssQuestionSkillAssignmentList::$questionIdFilter
private

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