ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 25 of file class.ilTestSkillLevelThresholdList.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestSkillLevelThresholdList::__construct ( ilDBInterface  $db)

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

References $db.

Member Function Documentation

◆ addThreshold()

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

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

Referenced by loadFromDb().

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

◆ buildSkillLevelThresholdByArray()

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

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

References $data.

Referenced by loadFromDb().

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

◆ cloneListForTest()

ilTestSkillLevelThresholdList::cloneListForTest (   $testId)

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

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

153  {
154  foreach ($this->thresholds as $skillKey => $data) {
155  foreach ($data as $levelId => $threshold) {
156  /* @var ilTestSkillLevelThreshold $threshold */
157 
158  $threshold->setTestId($testId);
159  $threshold->saveToDb();
160 
161  $threshold->setTestId($this->getTestId());
162  }
163  }
164  }
+ Here is the call graph for this function:

◆ getTestId()

ilTestSkillLevelThresholdList::getTestId ( )
Returns
int

Definition at line 58 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 130 of file class.ilTestSkillLevelThresholdList.php.

References getTestId().

131  {
132  $skillKey = $skillBaseId . ':' . $skillTrefId;
133 
134  if (isset($this->thresholds[$skillKey]) && isset($this->thresholds[$skillKey][$skillLevelId])) {
135  return $this->thresholds[$skillKey][$skillLevelId];
136  }
137 
138  if ($forceObject) {
139  $threshold = new ilTestSkillLevelThreshold($this->db);
140 
141  $threshold->setTestId($this->getTestId());
142  $threshold->setSkillBaseId($skillBaseId);
143  $threshold->setSkillTrefId($skillTrefId);
144  $threshold->setSkillLevelId($skillLevelId);
145 
146  return $threshold;
147  }
148 
149  return null;
150  }
+ Here is the call graph for this function:

◆ loadFromDb()

ilTestSkillLevelThresholdList::loadFromDb ( )

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

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

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

◆ resetThresholds()

ilTestSkillLevelThresholdList::resetThresholds ( )

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

Referenced by loadFromDb().

64  {
65  $this->thresholds = array();
66  }
+ Here is the caller graph for this function:

◆ saveToDb()

ilTestSkillLevelThresholdList::saveToDb ( )

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

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

◆ setTestId()

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

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

References $testId.

Field Documentation

◆ $db

ilTestSkillLevelThresholdList::$db
private

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

Referenced by __construct().

◆ $testId

ilTestSkillLevelThresholdList::$testId
private

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

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

◆ $thresholds

ilTestSkillLevelThresholdList::$thresholds = array()
private

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


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