ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilTestSkillLevelThresholdList Class Reference
+ Collaboration diagram for ilTestSkillLevelThresholdList:

Public Member Functions

 __construct (ilDBInterface $db)
 
 setTestId ($testId)
 
 getTestId ()
 
 resetThresholds ()
 
 loadFromDb ()
 
 saveToDb ()
 
 addThreshold ($threshold)
 
 getThreshold ( $skill_base_id, $skill_tref_id, $skill_level_id, $force_object=false)
 
 getThesholdsOfBaseAndTrefId (int $skill_base_id, int $skill_tref_id)
 
 cloneListForTest ($testId)
 

Private Member Functions

 buildSkillLevelThresholdByArray ($data)
 

Private Attributes

 $db
 
 $testId
 
 $thresholds = []
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilTestSkillLevelThresholdList::__construct ( ilDBInterface  $db)

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

References $db.

Member Function Documentation

◆ addThreshold()

ilTestSkillLevelThresholdList::addThreshold (   $threshold)
Parameters
ilTestSkillLevelThreshold$threshold

Definition at line 103 of file class.ilTestSkillLevelThresholdList.php.

Referenced by loadFromDb().

104  {
105  $skillKey = $threshold->getSkillBaseId() . ':' . $threshold->getSkillTrefId();
106  $this->thresholds[$skillKey][$threshold->getSkillLevelId()] = $threshold;
107  }
+ Here is the caller graph for this function:

◆ buildSkillLevelThresholdByArray()

ilTestSkillLevelThresholdList::buildSkillLevelThresholdByArray (   $data)
private
Parameters
array$data
Returns
ilTestSkillLevelThreshold

Definition at line 113 of file class.ilTestSkillLevelThresholdList.php.

References $data.

Referenced by loadFromDb().

114  {
115  $threshold = new ilTestSkillLevelThreshold($this->db);
116 
117  $threshold->setTestId($data['test_fi']);
118  $threshold->setSkillBaseId($data['skill_base_fi']);
119  $threshold->setSkillTrefId($data['skill_tref_fi']);
120  $threshold->setSkillLevelId($data['skill_level_fi']);
121  $threshold->setThreshold($data['threshold']);
122 
123  return $threshold;
124  }
+ Here is the caller graph for this function:

◆ cloneListForTest()

ilTestSkillLevelThresholdList::cloneListForTest (   $testId)

Definition at line 159 of file class.ilTestSkillLevelThresholdList.php.

References $data, $testId, and getTestId().

160  {
161  foreach ($this->thresholds as $data) {
162  foreach ($data as $threshold) {
163  /* @var ilTestSkillLevelThreshold $threshold */
164 
165  $threshold->setTestId($testId);
166  $threshold->saveToDb();
167 
168  $threshold->setTestId($this->getTestId());
169  }
170  }
171  }
+ Here is the call graph for this function:

◆ getTestId()

ilTestSkillLevelThresholdList::getTestId ( )
Returns
int

Definition at line 60 of file class.ilTestSkillLevelThresholdList.php.

References $testId.

Referenced by cloneListForTest(), getThreshold(), and loadFromDb().

+ Here is the caller graph for this function:

◆ getThesholdsOfBaseAndTrefId()

ilTestSkillLevelThresholdList::getThesholdsOfBaseAndTrefId ( int  $skill_base_id,
int  $skill_tref_id 
)

Definition at line 152 of file class.ilTestSkillLevelThresholdList.php.

155  : array {
156  return $this->thresholds["{$skill_base_id}:{$skill_tref_id}"] ?? [];
157  }

◆ getThreshold()

ilTestSkillLevelThresholdList::getThreshold (   $skill_base_id,
  $skill_tref_id,
  $skill_level_id,
  $force_object = false 
)

Definition at line 126 of file class.ilTestSkillLevelThresholdList.php.

References getTestId(), and null.

132  $skillKey = $skill_base_id . ':' . $skill_tref_id;
133 
134  if (isset($this->thresholds[$skillKey]) && isset($this->thresholds[$skillKey][$skill_level_id])) {
135  return $this->thresholds[$skillKey][$skill_level_id];
136  }
137 
138  if ($force_object) {
139  $threshold = new ilTestSkillLevelThreshold($this->db);
140 
141  $threshold->setTestId($this->getTestId());
142  $threshold->setSkillBaseId($skill_base_id);
143  $threshold->setSkillTrefId($skill_tref_id);
144  $threshold->setSkillLevelId($skill_level_id);
145 
146  return $threshold;
147  }
148 
149  return null;
150  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ loadFromDb()

ilTestSkillLevelThresholdList::loadFromDb ( )

Definition at line 70 of file class.ilTestSkillLevelThresholdList.php.

References $res, addThreshold(), buildSkillLevelThresholdByArray(), getTestId(), and resetThresholds().

71  {
72  $this->resetThresholds();
73 
74  $query = "
75  SELECT test_fi, skill_base_fi, skill_tref_fi, skill_level_fi, threshold
76  FROM tst_skl_thresholds
77  WHERE test_fi = %s
78  ";
79 
80  $res = $this->db->queryF($query, ['integer'], [$this->getTestId()]);
81 
82  while ($row = $this->db->fetchAssoc($res)) {
83  $threshold = $this->buildSkillLevelThresholdByArray($row);
84  $this->addThreshold($threshold);
85  }
86  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:

◆ resetThresholds()

ilTestSkillLevelThresholdList::resetThresholds ( )

Definition at line 65 of file class.ilTestSkillLevelThresholdList.php.

Referenced by loadFromDb().

66  {
67  $this->thresholds = [];
68  }
+ Here is the caller graph for this function:

◆ saveToDb()

ilTestSkillLevelThresholdList::saveToDb ( )

Definition at line 90 of file class.ilTestSkillLevelThresholdList.php.

91  {
92  foreach ($this->thresholds as $skillKey => $skillLevels) {
93  foreach ($skillLevels as $levelThreshold) {
94  /* @var ilTestSkillLevelThreshold $levelThreshold */
95  $levelThreshold->saveToDb();
96  }
97  }
98  }

◆ setTestId()

ilTestSkillLevelThresholdList::setTestId (   $testId)
Parameters
int$testId

Definition at line 52 of file class.ilTestSkillLevelThresholdList.php.

References $testId.

Field Documentation

◆ $db

ilTestSkillLevelThresholdList::$db
private

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

Referenced by __construct().

◆ $testId

ilTestSkillLevelThresholdList::$testId
private

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

Referenced by cloneListForTest(), getTestId(), and setTestId().

◆ $thresholds

ilTestSkillLevelThresholdList::$thresholds = []
private

Definition at line 42 of file class.ilTestSkillLevelThresholdList.php.


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