ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 180 of file class.ilTestService.php.

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

181  {
182  global $DIC;
183  $ilDB = $DIC['ilDB'];
184  $lng = $DIC['lng'];
185  $ilPluginAdmin = $DIC['ilPluginAdmin'];
186 
187  require_once 'Modules/Test/classes/class.ilTestVirtualSequence.php';
188  $testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $ilPluginAdmin, $this->object);
189 
190  if ($this->object->isRandomTest()) {
191  require_once 'Modules/Test/classes/class.ilTestVirtualSequenceRandomQuestionSet.php';
192  $virtualSequence = new ilTestVirtualSequenceRandomQuestionSet($ilDB, $this->object, $testSequenceFactory);
193  } else {
194  require_once 'Modules/Test/classes/class.ilTestVirtualSequence.php';
195  $virtualSequence = new ilTestVirtualSequence($ilDB, $this->object, $testSequenceFactory);
196  }
197 
198  $virtualSequence->setActiveId($testSession->getActiveId());
199 
200  $virtualSequence->init();
201 
202  return $virtualSequence;
203  }
global $DIC
Definition: saml.php:7
$lng
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 120 of file class.ilTestService.php.

References $pass, and ilObjAssessmentFolder\_getManualScoring().

121  {
122  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
123  $manScoringQuestionTypes = ilObjAssessmentFolder::_getManualScoring();
124 
125  $testResultData = $this->object->getTestResult($activeId, $pass);
126 
127  $manScoringQuestionGuiList = array();
128 
129  foreach ($testResultData as $questionData) {
130  if (!isset($questionData['qid'])) {
131  continue;
132  }
133 
134  if (!isset($questionData['type'])) {
135  throw new ilTestException('no question type given!');
136  }
137 
138  $questionGUI = $this->object->createQuestionGUI("", $questionData['qid']);
139 
140  if (!in_array($questionGUI->object->getQuestionTypeID(), $manScoringQuestionTypes)) {
141  continue;
142  }
143 
144  $manScoringQuestionGuiList[ $questionData['qid'] ] = $questionGUI;
145  }
146 
147  return $manScoringQuestionGuiList;
148  }
Base Exception for all Exceptions relating to Modules/Test.
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 $DIC, $ilUser, $pass, ilObjTest\_getPass(), and ilObjTest\lookupPassResultsUpdateTimestamp().

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

◆ getQuestionSummaryData()

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

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

References $data, $description, $key, ilObjTest\_getSolvedQuestions(), ilTestSequenceSummaryProvider\getActiveId(), and ilTestSequenceSummaryProvider\getSequenceSummary().

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

◆ getVirtualSequenceUserResults()

ilTestService::getVirtualSequenceUserResults ( ilTestVirtualSequence  $virtualSequence)

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

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

206  {
207  $resultsByPass = array();
208 
209  foreach ($virtualSequence->getUniquePasses() as $pass) {
210  $results = $this->object->getTestResult(
211  $virtualSequence->getActiveId(),
212  $pass,
213  false,
214  true,
215  true
216  );
217 
218  $resultsByPass[$pass] = $results;
219  }
220 
221  $virtualPassResults = array();
222 
223  foreach ($virtualSequence->getQuestionsPassMap() as $questionId => $pass) {
224  foreach ($resultsByPass[$pass] as $key => $questionResult) {
225  if ($key === 'test' || $key === 'pass') {
226  continue;
227  }
228 
229  if ($questionResult['qid'] == $questionId) {
230  $questionResult['pass'] = $pass;
231  $virtualPassResults[$questionId] = $questionResult;
232  break;
233  }
234  }
235  }
236 
237  return $virtualPassResults;
238  }
$results
Definition: svg-scanner.php:47
$key
Definition: croninfo.php:18
+ 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 159 of file class.ilTestService.php.

Referenced by ilTestScoringGUI\saveReturnManScoringParticipantScreen().

160  {
161  $assessmentSetting = new ilSetting("assessment");
162  return $assessmentSetting->get("manscoring_done_" . $activeId, false);
163  }
+ 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 174 of file class.ilTestService.php.

Referenced by ilTestScoringGUI\saveManScoringParticipantScreen().

175  {
176  $assessmentSetting = new ilSetting("assessment");
177  $assessmentSetting->set("manscoring_done_" . $activeId, (bool) $manScoringDone);
178  }
+ 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: