ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  $this->assignments[$assignment->getQuestionId()] = array();
98  }
99 
100  $this->assignments[$assignment->getQuestionId()][] = $assignment;
101  }
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 179 of file class.ilAssQuestionSkillAssignmentList.php.

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

180  {
181  return $skillBaseId . ':' . $skillTrefId;
182  }
+ Here is the caller graph for this function:

◆ buildSkillQuestionAssignmentByArray()

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

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

References $data.

Referenced by loadFromDb().

166  {
167  $assignment = new ilAssQuestionSkillAssignment($this->db);
168 
169  $assignment->setParentObjId($data['obj_fi']);
170  $assignment->setQuestionId($data['question_fi']);
171  $assignment->setSkillBaseId($data['skill_base_fi']);
172  $assignment->setSkillTrefId($data['skill_tref_fi']);
173  $assignment->setSkillPoints($data['skill_points']);
174  $assignment->setEvalMode($data['eval_mode']);
175 
176  return $assignment;
177  }
+ Here is the caller graph for this function:

◆ getAssignmentsByQuestionId()

ilAssQuestionSkillAssignmentList::getAssignmentsByQuestionId (   $questionId)

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

References array.

194  {
195  if (!isset($this->assignments[$questionId])) {
196  return array();
197  }
198 
199  return $this->assignments[$questionId];
200  }
Create styles array
The data for the language used.

◆ getMaxPointsBySkill()

ilAssQuestionSkillAssignmentList::getMaxPointsBySkill (   $skillBaseId,
  $skillTrefId 
)

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

References buildSkillKey().

Referenced by getUniqueAssignedSkills().

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

◆ getNumAssignsBySkill()

ilAssQuestionSkillAssignmentList::getNumAssignsBySkill (   $skillBaseId,
  $skillTrefId 
)

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

References buildSkillKey().

Referenced by getUniqueAssignedSkills().

274  {
275  return $this->numAssignsBySkill[$this->buildSkillKey($skillBaseId, $skillTrefId)];
276  }
+ 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 223 of file class.ilAssQuestionSkillAssignmentList.php.

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

Referenced by hasSkillsAssignedLowerThanBarrier(), and isAssignedSkill().

224  {
225  require_once 'Services/Skill/classes/class.ilBasicSkill.php';
226 
227  $skills = array();
228 
229  foreach ($this->assignments as $assignmentsByQuestion) {
230  foreach ($assignmentsByQuestion as $assignment) {
231  /* @var ilAssQuestionSkillAssignment $assignment */
232 
233  $key = $this->buildSkillKey($assignment->getSkillBaseId(), $assignment->getSkillTrefId());
234 
235  if (!isset($skills[$key])) {
236  $skills[$key] = array(
237  'skill' => new ilBasicSkill($assignment->getSkillBaseId()),
238  'skill_base_id' => $assignment->getSkillBaseId(),
239  'skill_tref_id' => $assignment->getSkillTrefId(),
240  'skill_title' => $assignment->getSkillTitle(),
241  'skill_path' => $assignment->getSkillPath(),
242  'num_assigns' => $this->getNumAssignsBySkill(
243  $assignment->getSkillBaseId(),
244  $assignment->getSkillTrefId()
245  ),
246  'max_points' => $this->getMaxPointsBySkill(
247  $assignment->getSkillBaseId(),
248  $assignment->getSkillTrefId()
249  )
250  );
251  }
252  }
253  }
254 
255  return $skills;
256  }
Create styles array
The data for the language used.
Basic Skill.
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWhereConditions()

ilAssQuestionSkillAssignmentList::getWhereConditions ( )
private

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

References array, and getQuestionIdFilter().

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

◆ hasSkillsAssignedLowerThanBarrier()

ilAssQuestionSkillAssignmentList::hasSkillsAssignedLowerThanBarrier ( )

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

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

284  {
285  require_once 'Modules/Test/classes/class.ilObjAssessmentFolder.php';
287 
288  foreach ($this->getUniqueAssignedSkills() as $skillData) {
289  if ($skillData['num_assigns'] < $globalBarrier) {
290  return true;
291  }
292  }
293 
294  return false;
295  }
+ Here is the call graph for this function:

◆ incrementMaxPointsBySkill()

ilAssQuestionSkillAssignmentList::incrementMaxPointsBySkill ( ilAssQuestionSkillAssignment  $assignment)
private

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

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

Referenced by loadFromDb().

115  {
116  $key = $this->buildSkillKey($assignment->getSkillBaseId(), $assignment->getSkillTrefId());
117 
118  if (!isset($this->maxPointsBySkill[$key])) {
119  $this->maxPointsBySkill[$key] = 0;
120  }
121 
122  $this->maxPointsBySkill[$key] += $assignment->getMaxSkillPoints();
123  }
$key
Definition: croninfo.php:18
+ 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 103 of file class.ilAssQuestionSkillAssignmentList.php.

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

Referenced by loadFromDb().

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

◆ isAssignedSkill()

ilAssQuestionSkillAssignmentList::isAssignedSkill (   $skillBaseId,
  $skillTrefId 
)

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

References getUniqueAssignedSkills().

259  {
260  foreach ($this->getUniqueAssignedSkills() as $assignedSkill) {
261  if ($assignedSkill['skill_base_id'] != $skillBaseId) {
262  continue;
263  }
264 
265  if ($assignedSkill['skill_tref_id'] == $skillTrefId) {
266  return true;
267  }
268  }
269 
270  return false;
271  }
+ Here is the call graph for this function:

◆ isAssignedToQuestionId()

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

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

203  {
204  if (!isset($this->assignments[$questionId])) {
205  return false;
206  }
207 
208  foreach ($this->assignments[$questionId] as $assignment) {
209  if ($assignment->getSkillBaseId() != $skillBaseId) {
210  continue;
211  }
212 
213  if ($assignment->getSkillTrefId() != $skillTrefId) {
214  continue;
215  }
216 
217  return true;
218  }
219 
220  return false;
221  }

◆ loadAdditionalSkillData()

ilAssQuestionSkillAssignmentList::loadAdditionalSkillData ( )

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

185  {
186  foreach ($this->assignments as $assignmentsByQuestion) {
187  foreach ($assignmentsByQuestion as $assignment) {
188  $assignment->loadAdditionalSkillData();
189  }
190  }
191  }

◆ loadFromDb()

ilAssQuestionSkillAssignmentList::loadFromDb ( )

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

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

126  {
127  $this->reset();
128 
129  $res = $this->db->query("
130  SELECT obj_fi, question_fi, skill_base_fi, skill_tref_fi, skill_points, eval_mode
131  FROM qpl_qst_skl_assigns
132  WHERE {$this->getWhereConditions()}
133  ");
134 
135  while ($row = $this->db->fetchAssoc($res)) {
136  $assignment = $this->buildSkillQuestionAssignmentByArray($row);
137 
138  if ($assignment->hasEvalModeBySolution()) {
139  $assignment->loadComparisonExpressions(); // db query
140  }
141 
142  $this->addAssignment($assignment);
143  $this->incrementNumAssignsBySkill($assignment);
144  $this->incrementMaxPointsBySkill($assignment);
145  }
146  }
incrementMaxPointsBySkill(ilAssQuestionSkillAssignment $assignment)
addAssignment(ilAssQuestionSkillAssignment $assignment)
foreach($_POST as $key=> $value) $res
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: