ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilTestService Class Reference

Service class for tests. More...

+ Collaboration diagram for ilTestService:

Public Member Functions

 __construct (protected ilObjTest $object, protected ilDBInterface $db, protected GeneralQuestionPropertiesRepository $questionrepository)
 public More...
 
 getPassOverviewData (int $active_id, bool $short=false)
 
 buildVirtualSequence (ilTestSession $testSession)
 
 getVirtualSequenceUserResults (ilTestVirtualSequence $virtualSequence)
 
 getQuestionSummaryData (ilTestSequenceSummaryProvider $testSequence)
 

Static Public Member Functions

static isManScoringDone (int $active_id)
 
static setManScoringDone (int $activeId, bool $manScoringDone)
 

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 32 of file class.ilTestService.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestService::__construct ( protected ilObjTest  $object,
protected ilDBInterface  $db,
protected GeneralQuestionPropertiesRepository  $questionrepository 
)

public

Parameters
ilObjTest$a_object

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

42  {
43  }

Member Function Documentation

◆ buildVirtualSequence()

ilTestService::buildVirtualSequence ( ilTestSession  $testSession)

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

References ilTestSession\getActiveId(), and ILIAS\Repository\object().

129  {
130  $test_sequence_factory = new ilTestSequenceFactory($this->object, $this->db, $this->questionrepository);
131 
132  if ($this->object->isRandomTest()) {
133  $virtual_sequence = new ilTestVirtualSequenceRandomQuestionSet($this->db, $this->object, $test_sequence_factory);
134  } else {
135  $virtual_sequence = new ilTestVirtualSequence($this->db, $this->object, $test_sequence_factory);
136  }
137 
138  $virtual_sequence->setActiveId($testSession->getActiveId());
139 
140  $virtual_sequence->init();
141 
142  return $virtual_sequence;
143  }
+ Here is the call graph for this function:

◆ getPassOverviewData()

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

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

References ilObjTest\_getPass(), and ilObjTest\lookupPassResultsUpdateTimestamp().

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

◆ getQuestionSummaryData()

ilTestService::getQuestionSummaryData ( ilTestSequenceSummaryProvider  $testSequence)

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

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

180  : array
181  {
182  $result_array = $testSequence->getSequenceSummary();
183 
184  $marked_questions = [];
185 
186  if ($this->object->getShowMarker()) {
187  $marked_questions = ilObjTest::_getSolvedQuestions($testSequence->getActiveId());
188  }
189 
190  $data = [];
191  $firstQuestion = true;
192 
193  foreach ($result_array as $key => $value) {
194  $disableLink = (
195  $this->object->isFollowupQuestionAnswerFixationEnabled()
196  && !$value['presented'] && !$firstQuestion
197  );
198 
199  $description = "";
200  if ($this->object->getListOfQuestionsDescription()) {
201  $description = $value["description"];
202  }
203 
204  $points = "";
205  if (!$this->object->getTitleOutput()) {
206  $points = $value["points"];
207  }
208 
209  $marked = false;
210  if (count($marked_questions)) {
211  if (array_key_exists($value["qid"], $marked_questions)) {
212  $obj = $marked_questions[$value["qid"]];
213  if ($obj["solved"] == 1) {
214  $marked = true;
215  }
216  }
217  }
218 
219  $data[] = [
220  'order' => $value['nr'],
221  'title' => $this->object->getQuestionTitle($value['title'], $value['nr'], $value['points']),
222  'description' => $description,
223  'disabled' => $disableLink,
224  'worked_through' => $value['worked_through'],
225  'postponed' => $value['postponed'],
226  'points' => $points,
227  'marked' => $marked,
228  'sequence' => $value['sequence'],
229  'isAnswered' => $value['isAnswered'],
230  'has_authorized_answer' => $value['has_authorized_answer']
231  ];
232  $firstQuestion = false;
233  // fau.
234  }
235 
236  return $data;
237  }
static _getSolvedQuestions($active_id, $question_fi=null)
get solved questions
+ Here is the call graph for this function:

◆ getVirtualSequenceUserResults()

ilTestService::getVirtualSequenceUserResults ( ilTestVirtualSequence  $virtualSequence)

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

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

145  : array
146  {
147  $resultsByPass = [];
148 
149  foreach ($virtualSequence->getUniquePasses() as $pass) {
150  $results = $this->object->getTestResult(
151  $virtualSequence->getActiveId(),
152  $pass,
153  false,
154  true,
155  true
156  );
157 
158  $resultsByPass[$pass] = $results;
159  }
160 
161  $virtualPassResults = [];
162 
163  foreach ($virtualSequence->getQuestionsPassMap() as $questionId => $pass) {
164  foreach ($resultsByPass[$pass] as $key => $questionResult) {
165  if ($key === 'test' || $key === 'pass') {
166  continue;
167  }
168 
169  if ($questionResult['qid'] == $questionId) {
170  $questionResult['pass'] = $pass;
171  $virtualPassResults[$questionId] = $questionResult;
172  break;
173  }
174  }
175  }
176 
177  return $virtualPassResults;
178  }
$results
+ Here is the call graph for this function:

◆ isManScoringDone()

static ilTestService::isManScoringDone ( int  $active_id)
static

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

Referenced by ILIAS\Test\Scoring\Manual\TestScoringByParticipantGUI\buildManScoringParticipantForm(), and ilObjTest\getManualFeedback().

118  : bool
119  {
120  return (new TestManScoringDoneHelper())->isDone($active_id);
121  }
+ Here is the caller graph for this function:

◆ setManScoringDone()

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

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

Referenced by ILIAS\Test\Scoring\Manual\TestScoringByParticipantGUI\saveManScoringParticipantScreen().

123  : void
124  {
125  (new TestManScoringDoneHelper())->setDone($activeId, $manScoringDone);
126  }
+ Here is the caller graph for this function:

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