ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTestQuestionRelatedObjectivesList Class Reference
+ Collaboration diagram for ilTestQuestionRelatedObjectivesList:

Public Member Functions

 __construct ()
 
 addQuestionRelatedObjectives ($questionId, $objectiveIds)
 
 hasQuestionRelatedObjectives ($questionId)
 
 getQuestionRelatedObjectives ($questionId)
 
 loadObjectivesTitles ()
 
 getQuestionRelatedObjectiveTitles ($questionId)
 
 getUniqueObjectivesString ()
 
 getUniqueObjectivesStringForQuestions ($questionIds)
 
 getObjectiveTitleById ($objectiveId)
 
 getObjectives ()
 
 isQuestionRelatedToObjective ($questionId, $objectiveId)
 
 filterResultsByObjective ($testResults, $objectiveId)
 

Protected Attributes

 $objectivesByQuestion
 
 $objectivesTitles
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTestQuestionRelatedObjectivesList::__construct ( )

Definition at line 23 of file class.ilTestQuestionRelatedObjectivesList.php.

24  {
25  $this->objectivesByQuestion = array();
26  $this->objectivesTitles = array();
27  }

Member Function Documentation

◆ addQuestionRelatedObjectives()

ilTestQuestionRelatedObjectivesList::addQuestionRelatedObjectives (   $questionId,
  $objectiveIds 
)
Parameters
integer$questionId
string$objectiveTitle

Definition at line 33 of file class.ilTestQuestionRelatedObjectivesList.php.

Referenced by ilLOTestQuestionAdapter\buildQuestionRelatedObjectiveListByQuestions(), and ilLOTestQuestionAdapter\buildQuestionRelatedObjectiveListByTest().

34  {
35  $this->objectivesByQuestion[$questionId] = $objectiveIds;
36  }
+ Here is the caller graph for this function:

◆ filterResultsByObjective()

ilTestQuestionRelatedObjectivesList::filterResultsByObjective (   $testResults,
  $objectiveId 
)

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

References isQuestionRelatedToObjective().

133  {
134  $filteredResults = array();
135 
136  foreach ($testResults as $questionId => $resultData) {
137  if (!$this->isQuestionRelatedToObjective($questionId, $objectiveId)) {
138  continue;
139  }
140 
141  $filteredResults[$questionId] = $resultData;
142  }
143 
144  return $filteredResults;
145  }
+ Here is the call graph for this function:

◆ getObjectives()

ilTestQuestionRelatedObjectivesList::getObjectives ( )

◆ getObjectiveTitleById()

ilTestQuestionRelatedObjectivesList::getObjectiveTitleById (   $objectiveId)

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

112  {
113  return $this->objectivesTitles[$objectiveId];
114  }

◆ getQuestionRelatedObjectives()

ilTestQuestionRelatedObjectivesList::getQuestionRelatedObjectives (   $questionId)
Parameters
integer$questionId
Returns
string

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

56  {
57  return $this->objectivesByQuestion[$questionId];
58  }

◆ getQuestionRelatedObjectiveTitles()

ilTestQuestionRelatedObjectivesList::getQuestionRelatedObjectiveTitles (   $questionId)
Parameters
integer$questionId
Returns
string

Definition at line 78 of file class.ilTestQuestionRelatedObjectivesList.php.

79  {
80  $titles = array();
81 
82  foreach ((array) $this->objectivesByQuestion[$questionId] as $objectiveId) {
83  $titles[] = $this->objectivesTitles[$objectiveId];
84  }
85 
86  return implode(', ', $titles);
87  }

◆ getUniqueObjectivesString()

ilTestQuestionRelatedObjectivesList::getUniqueObjectivesString ( )

Definition at line 89 of file class.ilTestQuestionRelatedObjectivesList.php.

90  {
91  return implode(', ', $this->objectivesTitles);
92  }

◆ getUniqueObjectivesStringForQuestions()

ilTestQuestionRelatedObjectivesList::getUniqueObjectivesStringForQuestions (   $questionIds)

Definition at line 94 of file class.ilTestQuestionRelatedObjectivesList.php.

95  {
96  $objectiveTitles = array();
97 
98  foreach ($this->objectivesByQuestion as $questionId => $objectiveIds) {
99  if (!in_array($questionId, $questionIds)) {
100  continue;
101  }
102 
103  foreach ($objectiveIds as $objectiveId) {
104  $objectiveTitles[$objectiveId] = $this->objectivesTitles[$objectiveId];
105  }
106  }
107 
108  return implode(', ', $objectiveTitles);
109  }

◆ hasQuestionRelatedObjectives()

ilTestQuestionRelatedObjectivesList::hasQuestionRelatedObjectives (   $questionId)
Parameters
integer$questionId
Returns
bool

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

43  {
44  if (!isset($this->objectivesByQuestion[$questionId])) {
45  return false;
46  }
47 
48  return (bool) count($this->objectivesByQuestion[$questionId]);
49  }

◆ isQuestionRelatedToObjective()

ilTestQuestionRelatedObjectivesList::isQuestionRelatedToObjective (   $questionId,
  $objectiveId 
)

Definition at line 121 of file class.ilTestQuestionRelatedObjectivesList.php.

Referenced by filterResultsByObjective().

122  {
123  foreach ($this->objectivesByQuestion[$questionId] as $relatedObjectiveId) {
124  if ($relatedObjectiveId == $objectiveId) {
125  return true;
126  }
127  }
128 
129  return false;
130  }
+ Here is the caller graph for this function:

◆ loadObjectivesTitles()

ilTestQuestionRelatedObjectivesList::loadObjectivesTitles ( )

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

References ilCourseObjective\lookupObjectiveTitle().

61  {
62  require_once 'Modules/Course/classes/class.ilCourseObjective.php';
63 
64  foreach ($this->objectivesByQuestion as $objectiveIds) {
65  foreach ($objectiveIds as $objectiveId) {
66  if (!isset($this->objectivesTitles[$objectiveId])) {
67  $objectiveTitle = ilCourseObjective::lookupObjectiveTitle($objectiveId);
68  $this->objectivesTitles[$objectiveId] = $objectiveTitle;
69  }
70  }
71  }
72  }
static lookupObjectiveTitle($a_objective_id, $a_add_description=false)
+ Here is the call graph for this function:

Field Documentation

◆ $objectivesByQuestion

ilTestQuestionRelatedObjectivesList::$objectivesByQuestion
protected

◆ $objectivesTitles

ilTestQuestionRelatedObjectivesList::$objectivesTitles
protected

Definition at line 21 of file class.ilTestQuestionRelatedObjectivesList.php.

Referenced by getObjectives().


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