ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTestService Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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 27 of file class.ilTestService.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestService::__construct ( ilObjTest  $a_object)

public

Parameters
ilObjTest$a_object

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

40  {
41  $this->object = $a_object;
42  }

Member Function Documentation

◆ buildVirtualSequence()

ilTestService::buildVirtualSequence ( ilTestSession  $testSession)

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

References $DIC, $ilDB, $lng, ILIAS\Repository\$refinery, ilTestSession\getActiveId(), and ILIAS\Repository\object().

195  {
196  global $DIC;
197  $ilDB = $DIC['ilDB'];
198  $lng = $DIC['lng'];
199  $refinery = $DIC['refinery'];
200  $component_repository = $DIC['component.repository'];
201 
202  $testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $refinery, $component_repository, $this->object);
203 
204  if ($this->object->isRandomTest()) {
205  $virtualSequence = new ilTestVirtualSequenceRandomQuestionSet($ilDB, $this->object, $testSequenceFactory);
206  } else {
207  $virtualSequence = new ilTestVirtualSequence($ilDB, $this->object, $testSequenceFactory);
208  }
209 
210  $virtualSequence->setActiveId($testSession->getActiveId());
211 
212  $virtualSequence->init();
213 
214  return $virtualSequence;
215  }
$lng
global $DIC
Definition: feed.php:28
Refinery Factory $refinery
+ 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

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

References ilObjAssessmentFolder\_getManualScoring().

134  : array
135  {
136  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
137  $manScoringQuestionTypes = ilObjAssessmentFolder::_getManualScoring();
138 
139  $testResultData = $this->object->getTestResult($activeId, $pass);
140 
141  $manScoringQuestionGuiList = array();
142 
143  foreach ($testResultData as $questionData) {
144  if (!isset($questionData['qid'])) {
145  continue;
146  }
147 
148  if (!isset($questionData['type'])) {
149  throw new ilTestException('no question type given!');
150  }
151 
152  $questionGUI = $this->object->createQuestionGUI("", $questionData['qid']);
153 
154  if (!in_array($questionGUI->object->getQuestionTypeID(), $manScoringQuestionTypes)) {
155  continue;
156  }
157 
158  $manScoringQuestionGuiList[ $questionData['qid'] ] = $questionGUI;
159  }
160 
161  return $manScoringQuestionGuiList;
162  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 51 of file class.ilTestService.php.

References $DIC, $ilUser, ilObjTest\_getPass(), and ilObjTest\lookupPassResultsUpdateTimestamp().

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

◆ getQuestionSummaryData()

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

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

References $data, ILIAS\LTI\ToolProvider\$key, ilObjTest\_getSolvedQuestions(), ilTestSequenceSummaryProvider\getActiveId(), ilTestSequenceSummaryProvider\getSequenceSummary(), and ILIAS\Repository\object().

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

◆ getVirtualSequenceUserResults()

ilTestService::getVirtualSequenceUserResults ( ilTestVirtualSequence  $virtualSequence)

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

References ILIAS\LTI\ToolProvider\$key, $results, ilTestVirtualSequence\getActiveId(), ilTestVirtualSequence\getQuestionsPassMap(), and ilTestVirtualSequence\getUniquePasses().

217  : array
218  {
219  $resultsByPass = array();
220 
221  foreach ($virtualSequence->getUniquePasses() as $pass) {
222  $results = $this->object->getTestResult(
223  $virtualSequence->getActiveId(),
224  $pass,
225  false,
226  true,
227  true
228  );
229 
230  $resultsByPass[$pass] = $results;
231  }
232 
233  $virtualPassResults = array();
234 
235  foreach ($virtualSequence->getQuestionsPassMap() as $questionId => $pass) {
236  foreach ($resultsByPass[$pass] as $key => $questionResult) {
237  if ($key === 'test' || $key === 'pass') {
238  continue;
239  }
240 
241  if ($questionResult['qid'] == $questionId) {
242  $questionResult['pass'] = $pass;
243  $virtualPassResults[$questionId] = $questionResult;
244  break;
245  }
246  }
247  }
248 
249  return $virtualPassResults;
250  }
string $key
Consumer key/client ID value.
Definition: System.php:193
$results
+ 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 173 of file class.ilTestService.php.

Referenced by ilTestScoringGUI\buildManScoringParticipantForm(), and ilObjTest\getManualFeedback().

173  : bool
174  {
175  $assessmentSetting = new ilSetting("assessment");
176  return $assessmentSetting->get("manscoring_done_" . $activeId, false);
177  }
+ 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 188 of file class.ilTestService.php.

Referenced by ilTestScoringGUI\saveManScoringParticipantScreen().

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

Field Documentation

◆ $object

ilTestService::$object = null
protected

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


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