ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilTestQuestionRelatedObjectivesList.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
12 {
17 
21  protected $objectivesTitles;
22 
23  public function __construct()
24  {
25  $this->objectivesByQuestion = array();
26  $this->objectivesTitles = array();
27  }
28 
33  public function addQuestionRelatedObjectives($questionId, $objectiveIds)
34  {
35  $this->objectivesByQuestion[$questionId] = $objectiveIds;
36  }
37 
42  public function hasQuestionRelatedObjectives($questionId)
43  {
44  if( !isset($this->objectivesByQuestion[$questionId]) )
45  {
46  return false;
47  }
48 
49  return (bool)count($this->objectivesByQuestion[$questionId]);
50  }
51 
56  public function getQuestionRelatedObjectives($questionId)
57  {
58  return $this->objectivesByQuestion[$questionId];
59  }
60 
61  public function loadObjectivesTitles()
62  {
63  require_once 'Modules/Course/classes/class.ilCourseObjective.php';
64 
65  foreach( $this->objectivesByQuestion as $objectiveIds )
66  {
67  foreach( $objectiveIds as $objectiveId )
68  {
69  if( !isset($this->objectivesTitles[$objectiveId]) )
70  {
71  $objectiveTitle = ilCourseObjective::lookupObjectiveTitle($objectiveId);
72  $this->objectivesTitles[$objectiveId] = $objectiveTitle;
73  }
74  }
75  }
76  }
77 
82  public function getQuestionRelatedObjectiveTitles($questionId)
83  {
84  $titles = array();
85 
86  foreach((array) $this->objectivesByQuestion[$questionId] as $objectiveId)
87  {
88  $titles[] = $this->objectivesTitles[$objectiveId];
89  }
90 
91  return implode(', ', $titles);
92  }
93 
94  public function getUniqueObjectivesString()
95  {
96  return implode(', ', $this->objectivesTitles);
97  }
98 
99  public function getUniqueObjectivesStringForQuestions($questionIds)
100  {
101  $objectiveTitles = array();
102 
103  foreach( $this->objectivesByQuestion as $questionId => $objectiveIds )
104  {
105  if( !in_array($questionId, $questionIds) )
106  {
107  continue;
108  }
109 
110  foreach( $objectiveIds as $objectiveId )
111  {
112  $objectiveTitles[$objectiveId] = $this->objectivesTitles[$objectiveId];
113  }
114  }
115 
116  return implode(', ', $objectiveTitles);
117  }
118 
119  public function getObjectiveTitleById($objectiveId)
120  {
121  return $this->objectivesTitles[$objectiveId];
122  }
123 
124  public function getObjectives()
125  {
127  }
128 
129  public function isQuestionRelatedToObjective($questionId, $objectiveId)
130  {
131  foreach($this->objectivesByQuestion[$questionId] as $relatedObjectiveId)
132  {
133  if($relatedObjectiveId == $objectiveId)
134  {
135  return true;
136  }
137  }
138 
139  return false;
140  }
141 
142  public function filterResultsByObjective($testResults, $objectiveId)
143  {
144  $filteredResults = array();
145 
146  foreach($testResults as $questionId => $resultData)
147  {
148  if( !$this->isQuestionRelatedToObjective($questionId, $objectiveId) )
149  {
150  continue;
151  }
152 
153  $filteredResults[$questionId] = $resultData;
154  }
155 
156  return $filteredResults;
157  }
158 }
static lookupObjectiveTitle($a_objective_id, $a_add_description=false)
Create styles array
The data for the language used.