ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 12 of file class.ilTestSkillLevelThresholdList.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestSkillLevelThresholdList::__construct ( ilDBInterface  $db)

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

References $db.

Member Function Documentation

◆ addThreshold()

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

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

Referenced by loadFromDb().

92  {
93  $skillKey = $threshold->getSkillBaseId().':'.$threshold->getSkillTrefId();
94  $this->thresholds[$skillKey][$threshold->getSkillLevelId()] = $threshold;
95  }
+ Here is the caller graph for this function:

◆ buildSkillLevelThresholdByArray()

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

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

References $data.

Referenced by loadFromDb().

102  {
103  $threshold = new ilTestSkillLevelThreshold($this->db);
104 
105  $threshold->setTestId($data['test_fi']);
106  $threshold->setSkillBaseId($data['skill_base_fi']);
107  $threshold->setSkillTrefId($data['skill_tref_fi']);
108  $threshold->setSkillLevelId($data['skill_level_fi']);
109  $threshold->setThreshold($data['threshold']);
110 
111  return $threshold;
112  }
+ Here is the caller graph for this function:

◆ cloneListForTest()

ilTestSkillLevelThresholdList::cloneListForTest (   $testId)

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

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

145  {
146  foreach($this->thresholds as $skillKey => $data)
147  {
148  foreach($data as $levelId => $threshold)
149  {
150  /* @var ilTestSkillLevelThreshold $threshold */
151 
152  $threshold->setTestId($testId);
153  $threshold->saveToDb();
154 
155  $threshold->setTestId($this->getTestId());
156  }
157  }
158  }
+ Here is the call graph for this function:

◆ getTestId()

ilTestSkillLevelThresholdList::getTestId ( )
Returns
int

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

References getTestId().

121  {
122  $skillKey = $skillBaseId . ':' . $skillTrefId;
123 
124  if( isset($this->thresholds[$skillKey]) && isset($this->thresholds[$skillKey][$skillLevelId]) )
125  {
126  return $this->thresholds[$skillKey][$skillLevelId];
127  }
128 
129  if( $forceObject )
130  {
131  $threshold = new ilTestSkillLevelThreshold($this->db);
132 
133  $threshold->setTestId($this->getTestId());
134  $threshold->setSkillBaseId($skillBaseId);
135  $threshold->setSkillTrefId($skillTrefId);
136  $threshold->setSkillLevelId($skillLevelId);
137 
138  return $threshold;
139  }
140 
141  return null;
142  }
+ Here is the call graph for this function:

◆ loadFromDb()

ilTestSkillLevelThresholdList::loadFromDb ( )

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

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

56  {
57  $this->resetThresholds();
58 
59  $query = "
60  SELECT test_fi, skill_base_fi, skill_tref_fi, skill_level_fi, threshold
61  FROM tst_skl_thresholds
62  WHERE test_fi = %s
63  ";
64 
65  $res = $this->db->queryF( $query, array('integer'), array($this->getTestId()) );
66 
67  while( $row = $this->db->fetchAssoc($res) )
68  {
69  $threshold = $this->buildSkillLevelThresholdByArray($row);
70  $this->addThreshold($threshold);
71  }
72  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ resetThresholds()

ilTestSkillLevelThresholdList::resetThresholds ( )

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

References array.

Referenced by loadFromDb().

51  {
52  $this->thresholds = array();
53  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ saveToDb()

ilTestSkillLevelThresholdList::saveToDb ( )

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

77  {
78  foreach($this->thresholds as $skillKey => $skillLevels)
79  {
80  foreach($skillLevels as $levelThreshold)
81  {
82  /* @var ilTestSkillLevelThreshold $levelThreshold */
83  $levelThreshold->saveToDb();
84  }
85  }
86  }

◆ setTestId()

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

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

References $testId.

Field Documentation

◆ $db

ilTestSkillLevelThresholdList::$db
private

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

Referenced by __construct().

◆ $testId

ilTestSkillLevelThresholdList::$testId
private

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

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

◆ $thresholds

ilTestSkillLevelThresholdList::$thresholds = array()
private

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


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