ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilTestService Class Reference

Service class for tests. More...

+ Collaboration diagram for ilTestService:

Public Member Functions

 __construct (ilObjTest $a_object)
 public More...
 
 getPassOverviewData ($active_id, $short=false)
 public ilObjUser $ilUser More...
 
 getManScoringQuestionGuiList ($activeId, $pass)
 Returns the list of answers of a users test pass and offers a scoring option. More...
 
 buildVirtualSequence (ilTestSession $testSession)
 
 getVirtualSequenceUserResults (ilTestVirtualSequence $virtualSequence)
 
 getQuestionSummaryData (ilTestSequenceSummaryProvider $testSequence, $obligationsFilterEnabled)
 

Static Public Member Functions

static isManScoringDone ($activeId)
 reads the flag wether manscoring is done for the given test active or not from the global settings (scope: assessment / key: manscoring_done_<activeId>) More...
 
static setManScoringDone ($activeId, $manScoringDone)
 stores the flag wether manscoring is done for the given test active or not within the global settings (scope: assessment / key: manscoring_done_<activeId>) More...
 

Protected Attributes

 $object = null
 

Detailed Description

Service class for tests.

Author
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 12 of file class.ilTestService.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestService::__construct ( ilObjTest  $a_object)

public

Parameters
ilObjTest$a_object

Definition at line 24 of file class.ilTestService.php.

25  {
26  $this->object = $a_object;
27  }

Member Function Documentation

◆ buildVirtualSequence()

ilTestService::buildVirtualSequence ( ilTestSession  $testSession)

Definition at line 192 of file class.ilTestService.php.

References $ilDB, $lng, ilTestSession\getActiveId(), and object.

193  {
194  global $ilDB, $lng, $ilPluginAdmin;
195 
196  require_once 'Modules/Test/classes/class.ilTestVirtualSequence.php';
197  $testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $ilPluginAdmin, $this->object);
198 
199  if( $this->object->isRandomTest() )
200  {
201  require_once 'Modules/Test/classes/class.ilTestVirtualSequenceRandomQuestionSet.php';
202  $virtualSequence = new ilTestVirtualSequenceRandomQuestionSet($ilDB, $this->object, $testSequenceFactory);
203  }
204  else
205  {
206  require_once 'Modules/Test/classes/class.ilTestVirtualSequence.php';
207  $virtualSequence = new ilTestVirtualSequence($ilDB, $this->object, $testSequenceFactory);
208  }
209 
210  $virtualSequence->setActiveId($testSession->getActiveId());
211 
212  $virtualSequence->init();
213 
214  return $virtualSequence;
215  }
Create new PHPExcel object
obj_idprivate
global $lng
Definition: privfeed.php:17
global $ilDB
+ Here is the call graph for this function:

◆ getManScoringQuestionGuiList()

ilTestService::getManScoringQuestionGuiList (   $activeId,
  $pass 
)

Returns the list of answers of a users test pass and offers a scoring option.

public

Parameters
integer$active_idActive ID of the active user
integer$passTest pass
Returns
string HTML code of the list of answers

Definition at line 128 of file class.ilTestService.php.

References $pass, ilObjAssessmentFolder\_getManualScoring(), and array.

129  {
130  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
131  $manScoringQuestionTypes = ilObjAssessmentFolder::_getManualScoring();
132 
133  $testResultData = $this->object->getTestResult($activeId, $pass);
134 
135  $manScoringQuestionGuiList = array();
136 
137  foreach($testResultData as $questionData)
138  {
139  if( !isset($questionData['qid']) )
140  {
141  continue;
142  }
143 
144  if( !isset($questionData['type']) )
145  {
146  throw new ilTestException('no question type given!');
147  }
148 
149  $questionGUI = $this->object->createQuestionGUI("", $questionData['qid']);
150 
151  if( !in_array($questionGUI->object->getQuestionTypeID(), $manScoringQuestionTypes) )
152  {
153  continue;
154  }
155 
156  $manScoringQuestionGuiList[ $questionData['qid'] ] = $questionGUI;
157  }
158 
159  return $manScoringQuestionGuiList;
160  }
Base Exception for all Exceptions relating to Modules/Test.
Create styles array
The data for the language used.
static _getManualScoring()
Retrieve the manual scoring settings.
+ Here is the call graph for this function:

◆ getPassOverviewData()

ilTestService::getPassOverviewData (   $active_id,
  $short = false 
)

public ilObjUser $ilUser

Parameters
integer$active_id
boolean$short
Returns
array $passOverwiewData

Definition at line 36 of file class.ilTestService.php.

References $ilUser, $pass, ilObjTest\_getPass(), and array.

37  {
38  $passOverwiewData = array();
39 
40  global $ilUser;
41 
42  $scoredPass = $this->object->_getResultPass($active_id);
43  $lastPass = ilObjTest::_getPass($active_id);
44 
45  $testPercentage = 0;
46  $testReachedPoints = 0;
47  $testMaxPoints = 0;
48 
49  for( $pass = 0; $pass <= $lastPass; $pass++)
50  {
51  $passFinishDate = $this->object->getPassFinishDate($active_id, $pass);
52 
53  if( $passFinishDate <= 0 )
54  {
55  continue;
56  }
57 
58  if( !$short )
59  {
60  $resultData =& $this->object->getTestResult($active_id, $pass);
61 
62  if (!$resultData["pass"]["total_max_points"])
63  {
64  $passPercentage = 0;
65  }
66  else
67  {
68  $passPercentage = ($resultData["pass"]["total_reached_points"]/$resultData["pass"]["total_max_points"])*100;
69  }
70 
71  $passMaxPoints = $resultData["pass"]["total_max_points"];
72  $passReachedPoints = $resultData["pass"]["total_reached_points"];
73 
74  $passAnsweredQuestions = $this->object->getAnsweredQuestionCount($active_id, $pass);
75  $passTotalQuestions = count($resultData) - 2;
76 
77  if( $pass == $scoredPass )
78  {
79  $isScoredPass = true;
80 
81  if (!$resultData["test"]["total_max_points"])
82  {
83  $testPercentage = 0;
84  }
85  else
86  {
87  $testPercentage = ($resultData["test"]["total_reached_points"]/$resultData["test"]["total_max_points"])*100;
88  }
89 
90  $testMaxPoints = $resultData["test"]["total_max_points"];
91  $testReachedPoints = $resultData["test"]["total_reached_points"];
92 
93  $passOverwiewData['test'] = array(
94  'active_id' => $active_id,
95  'scored_pass' => $scoredPass,
96  'max_points' => $testMaxPoints,
97  'reached_points' => $testReachedPoints,
98  'percentage' => $testPercentage
99  );
100  }
101  else $isScoredPass = false;
102 
103  $passOverwiewData['passes'][] = array(
104  'active_id' => $active_id,
105  'pass' => $pass,
106  'finishdate' => $passFinishDate,
107  'max_points' => $passMaxPoints,
108  'reached_points' => $passReachedPoints,
109  'percentage' => $passPercentage,
110  'answered_questions' => $passAnsweredQuestions,
111  'total_questions' => $passTotalQuestions,
112  'is_scored_pass' => $isScoredPass
113  );
114  }
115  }
116 
117  return $passOverwiewData;
118  }
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getQuestionSummaryData()

ilTestService::getQuestionSummaryData ( ilTestSequenceSummaryProvider  $testSequence,
  $obligationsFilterEnabled 
)
Parameters
ilTestSequenceSummaryProvider$testSequence
bool$obligationsFilter
Returns
array

Definition at line 258 of file class.ilTestService.php.

References $data, ilObjTest\_getSolvedQuestions(), array, ilTestSequenceSummaryProvider\getActiveId(), ilTestSequenceSummaryProvider\getSequenceSummary(), and object.

259  {
260  $result_array = $testSequence->getSequenceSummary($obligationsFilterEnabled);
261 
262  $marked_questions = array();
263 
264  if($this->object->getShowMarker())
265  {
266  include_once "./Modules/Test/classes/class.ilObjTest.php";
267  $marked_questions = ilObjTest::_getSolvedQuestions($testSequence->getActiveId());
268  }
269 
270  $data = array();
271 
272  foreach($result_array as $key => $value)
273  {
274  $description = "";
275  if($this->object->getListOfQuestionsDescription())
276  {
277  $description = $value["description"];
278  }
279 
280  $points = "";
281  if(!$this->object->getTitleOutput())
282  {
283  $points = $value["points"];
284  }
285 
286  $marked = false;
287  if(count($marked_questions))
288  {
289  if(array_key_exists($value["qid"], $marked_questions))
290  {
291  $obj = $marked_questions[$value["qid"]];
292  if($obj["solved"] == 1)
293  {
294  $marked = true;
295  }
296  }
297  }
298 
299 // fau: testNav - add number parameter for getQuestionTitle()
300  $data[] = array('order' => $value["nr"], 'title' => $this->object->getQuestionTitle($value["title"], $value["nr"]), 'description' => $description, 'worked_through' => $value["worked_through"], 'postponed' => $value["postponed"], 'points' => $points, 'marked' => $marked, 'sequence' => $value["sequence"], 'obligatory' => $value['obligatory'], 'isAnswered' => $value['isAnswered']);
301 // fau.
302  }
303 
304  return $data;
305  }
getSequenceSummary($obligationsFilterEnabled=false)
static _getSolvedQuestions($active_id, $question_fi=null)
get solved questions
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
+ Here is the call graph for this function:

◆ getVirtualSequenceUserResults()

ilTestService::getVirtualSequenceUserResults ( ilTestVirtualSequence  $virtualSequence)

Definition at line 217 of file class.ilTestService.php.

References $pass, $results, array, ilTestVirtualSequence\getActiveId(), ilTestVirtualSequence\getQuestionsPassMap(), and ilTestVirtualSequence\getUniquePasses().

218  {
219  $resultsByPass = array();
220 
221  foreach($virtualSequence->getUniquePasses() as $pass)
222  {
223  $results = $this->object->getTestResult(
224  $virtualSequence->getActiveId(), $pass, false, true, true
225  );
226 
227  $resultsByPass[$pass] = $results;
228  }
229 
230  $virtualPassResults = array();
231 
232  foreach($virtualSequence->getQuestionsPassMap() as $questionId => $pass)
233  {
234  foreach($resultsByPass[$pass] as $key => $questionResult)
235  {
236  if($key === 'test' || $key === 'pass')
237  {
238  continue;
239  }
240 
241  if($questionResult['qid'] == $questionId)
242  {
243  $questionResult['pass'] = $pass;
244  $virtualPassResults[$questionId] = $questionResult;
245  break;
246  }
247  }
248  }
249 
250  return $virtualPassResults;
251  }
$results
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ isManScoringDone()

static ilTestService::isManScoringDone (   $activeId)
static

reads the flag wether manscoring is done for the given test active or not from the global settings (scope: assessment / key: manscoring_done_<activeId>)

public

Parameters
integer$activeId
Returns
boolean $manScoringDone

Definition at line 171 of file class.ilTestService.php.

Referenced by ilTestScoringGUI\buildManScoringParticipantForm().

172  {
173  $assessmentSetting = new ilSetting("assessment");
174  return $assessmentSetting->get("manscoring_done_" . $activeId, false);
175  }
ILIAS Setting Class.
+ Here is the caller graph for this function:

◆ setManScoringDone()

static ilTestService::setManScoringDone (   $activeId,
  $manScoringDone 
)
static

stores the flag wether manscoring is done for the given test active or not within the global settings (scope: assessment / key: manscoring_done_<activeId>)

public

Parameters
integer$activeId
boolean$manScoringDone

Definition at line 186 of file class.ilTestService.php.

Referenced by ilTestScoringGUI\saveManScoringParticipantScreen().

187  {
188  $assessmentSetting = new ilSetting("assessment");
189  $assessmentSetting->set("manscoring_done_" . $activeId, (bool)$manScoringDone);
190  }
ILIAS Setting Class.
+ Here is the caller graph for this function:

Field Documentation

◆ $object

ilTestService::$object = null
protected

Definition at line 18 of file class.ilTestService.php.


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