ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilTestSkillLevelThresholdList Class Reference
+ Collaboration diagram for ilTestSkillLevelThresholdList:

Public Member Functions

 __construct (ilDBInterface $db)
 
 setTestId ($testId)
 
 getTestId ()
 
 resetThresholds ()
 
 loadFromDb ()
 
 saveToDb ()
 
 addThreshold ($threshold)
 
 getThreshold ($skillBaseId, $skillTrefId, $skillLevelId, $forceObject=false)
 
 cloneListForTest ($testId)
 

Private Member Functions

 buildSkillLevelThresholdByArray ($data)
 

Private Attributes

 $db
 
 $testId
 
 $thresholds = array()
 

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 154 of file class.ilTestSkillLevelThresholdList.php.

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

155  {
156  foreach ($this->thresholds as $data) {
157  foreach ($data as $threshold) {
158  /* @var ilTestSkillLevelThreshold $threshold */
159 
160  $threshold->setTestId($testId);
161  $threshold->saveToDb();
162 
163  $threshold->setTestId($this->getTestId());
164  }
165  }
166  }
+ 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:

◆ getThreshold()

ilTestSkillLevelThresholdList::getThreshold (   $skillBaseId,
  $skillTrefId,
  $skillLevelId,
  $forceObject = false 
)
Parameters
$skillBaseId
$skillTrefId
$skillLevelId
Returns
ilTestSkillLevelThreshold

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

References getTestId().

133  {
134  $skillKey = $skillBaseId . ':' . $skillTrefId;
135 
136  if (isset($this->thresholds[$skillKey]) && isset($this->thresholds[$skillKey][$skillLevelId])) {
137  return $this->thresholds[$skillKey][$skillLevelId];
138  }
139 
140  if ($forceObject) {
141  $threshold = new ilTestSkillLevelThreshold($this->db);
142 
143  $threshold->setTestId($this->getTestId());
144  $threshold->setSkillBaseId($skillBaseId);
145  $threshold->setSkillTrefId($skillTrefId);
146  $threshold->setSkillLevelId($skillLevelId);
147 
148  return $threshold;
149  }
150 
151  return null;
152  }
+ 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, array('integer'), array($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:69
+ 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 = array();
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 = array()
private

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


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