19 declare(strict_types=1);
39 if (($participants_list = $this->test_obj->getAccessFilteredParticipantList()) !==
null) {
40 return $participants_list->getAllActiveIds();
42 return array_keys($this->test_obj->getTestParticipants());
51 SELECT tst_test_result.question_fi, 52 tst_test_result.points result_points, 53 tst_test_result.answered, 54 tst_test_result.manual, 56 qpl_questions.original_id, 57 qpl_questions.title questiontitle, 58 qpl_questions.points qpl_maxpoints, 62 tst_active.last_finished_pass, 73 LEFT JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi 74 LEFT JOIN tst_test_result ON tst_active.active_id = tst_test_result.active_fi AND tst_test_result.pass = tst_pass_result.pass 75 LEFT JOIN qpl_questions ON qpl_questions.question_id = tst_test_result.question_fi 76 LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id 78 WHERE tst_active.test_fi = %s 81 ORDER BY tst_active.active_id ASC, tst_pass_result.pass ASC, tst_test_result.tstamp DESC 85 $result = $this->db->query(
88 $this->db->quote($this->test_obj->getTestId(),
'integer'),
89 $this->db->in(
'tst_active.active_id', $active_ids,
false,
'integer'),
92 while ($row = $this->db->fetchAssoc($result)) {
100 $current_user =
null;
101 $current_attempt =
null;
104 $active_id = $row[
'active_id'];
105 $pass = $row[
'pass'];
107 if ($current_user !== $active_id) {
108 $current_user = $active_id;
109 $current_attempt =
null;
113 if ($current_attempt !== $pass) {
114 $current_attempt = $pass;
119 $user_eval_data->addPass($pass, $attempt);
120 $participants[$active_id] = $user_eval_data;
129 $current_user =
null;
130 $current_attempt =
null;
132 foreach ($eval_data_rows as $row) {
133 if ($row[
'pass'] ===
null) {
137 if ($current_user !== $row[
'active_id']) {
138 $current_user = $row[
'active_id'];
139 $current_attempt =
null;
146 if ($row[
'pass'] !==
null && $current_attempt !== $row[
'pass']) {
147 $current_attempt = $row[
'pass'];
154 if ($start_time !==
null) {
155 $attempt->setStartTime($start_time);
157 $attempt->setStatusOfAttempt(
158 StatusOfAttempt::build($current_attempt, $row[
'last_finished_pass'], $row[
'finalized_by'])
163 $participants[$row[
'active_id']] = $user_eval_data;
177 $this->test_obj->buildName($row[
'usr_id'], $row[
'firstname'], $row[
'lastname'])
180 if ($row[
'login'] !==
null) {
181 $user_data->setLogin($row[
'login']);
183 if ($row[
'usr_id'] !==
null) {
184 $user_data->setUserID($row[
'usr_id']);
186 $user_data->setSubmitted((
bool) $row[
'submitted']);
187 $user_data->setLastFinishedPass($row[
'last_finished_pass']);
193 $attempt = new \ilTestEvaluationPassData();
194 $attempt->setPass($row[
'pass']);
195 $attempt->setReachedPoints($row[
'points']);
196 $attempt->setNrOfAnsweredQuestions($row[
'answeredquestions']);
197 $attempt->setWorkingTime($row[
'workingtime']);
198 $attempt->setExamId((
string) $row[
'exam_id']);
206 $visiting_time = $this->test_obj->getVisitingTimeOfParticipant($active_id);
208 $user_data->
setLastVisit($visiting_time[
'last_access']);
216 if ($row[
'questioncount'] !== 0) {
222 list($count, $points) = array_values(
223 $this->test_obj->getQuestionCountAndPointsForPassOfParticipant($row[
'active_id'], $row[
'pass'])
234 if ($row[
'question_fi'] ===
null) {
240 $row[
"qpl_maxpoints"],
241 $row[
"result_points"],
242 (
bool) $row[
'answered'],
253 $add_user_questions = $this->test_obj->isRandomTest() ?
257 $this->test_obj->getQuestionCountWithoutReloading()
261 foreach ($add_user_questions as
$q) {
262 $user_eval_data->addQuestion(
272 return $evaluation_data;
281 for ($testpass = 0; $testpass <= $user_eval_data->
getLastPass(); $testpass++) {
282 $this->db->setLimit($question_count, 0);
284 SELECT tst_test_rnd_qst.sequence, tst_test_rnd_qst.question_fi, qpl_questions.original_id, 285 tst_test_rnd_qst.pass, qpl_questions.points, qpl_questions.title 286 FROM tst_test_rnd_qst, qpl_questions 287 WHERE tst_test_rnd_qst.question_fi = qpl_questions.question_id 288 AND tst_test_rnd_qst.pass = %s 289 AND tst_test_rnd_qst.active_fi = %s ORDER BY tst_test_rnd_qst.sequence 292 $result = $this->db->queryF(
294 [
'integer',
'integer'],
295 [$testpass, $active_id]
298 if ($result->numRows()) {
299 while ($row = $this->db->fetchAssoc($result)) {
300 $tpass = array_key_exists(
'pass', $row) ? $row[
'pass'] : 0;
303 !isset($row[
'question_fi'], $row[
'points'], $row[
'sequence']) ||
304 !is_numeric($row[
'question_fi']) || !is_numeric($row[
'points']) || !is_numeric($row[
'sequence'])
310 'original_id' => (
int) $row[
'original_id'],
311 'question_id' => (
int) $row[
'question_fi'],
312 'max_points' => (float) $row[
'points'],
313 'sequence' => (
int) $row[
'sequence'],
315 'title' => $row[
'title']
329 SELECT tst_test_question.sequence, tst_test_question.question_fi, 330 qpl_questions.points, qpl_questions.title, qpl_questions.original_id 331 FROM tst_test_question, tst_active, qpl_questions 332 WHERE tst_test_question.question_fi = qpl_questions.question_id 333 AND tst_active.active_id = %s 334 AND tst_active.test_fi = tst_test_question.test_fi 335 ORDER BY tst_test_question.sequence 338 $result = $this->db->queryF(
344 if ($result->numRows()) {
345 $questionsbysequence = [];
346 while ($row = $this->db->fetchAssoc($result)) {
347 $questionsbysequence[$row[
'sequence']] = $row;
350 $seqresult = $this->db->queryF(
351 'SELECT * FROM tst_sequence WHERE active_fi = %s',
356 while ($seqrow = $this->db->fetchAssoc($seqresult)) {
357 $questionsequence = unserialize($seqrow[
"sequence"]);
358 foreach ($questionsequence as $sidx => $seq) {
359 if (!isset($questionsbysequence[$seq])) {
363 'original_id' => $questionsbysequence[$seq][
'original_id'] ?? 0,
364 'question_id' => $questionsbysequence[$seq][
'question_fi'],
365 'max_points' => $questionsbysequence[$seq][
'points'],
366 'sequence' => $sidx + 1,
367 'pass' => $seqrow[
'pass'],
368 'title' => $questionsbysequence[$seq][
"title"]
378 $mark_schema = $this->test_obj->getMarkSchema();
383 $mark = $mark_schema->getMatchingMark(
384 $user_eval_data->getReachedPointsInPercent()
387 if ($mark ===
null) {
391 $user_eval_data->setMark($mark);
392 for ($i = 0; $i < $user_eval_data->getPassCount(); $i++) {
393 $pass_data = $user_eval_data->getPass($i);
394 if ($pass_data ===
null) {
397 $mark = $mark_schema->getMatchingMark(
398 $pass_data->getReachedPointsInPercent()
400 if ($mark !==
null) {
401 $pass_data->setMark($mark);
406 return $evaluation_data;
412 SELECT active_fi, pass 413 FROM tst_active actives 414 INNER JOIN tst_pass_result passes 415 ON active_fi = active_id 419 $res = $this->db->queryF($query, [
'integer'], [$this->test_obj->getTestId()]);
422 while ($row = $this->db->fetchAssoc(
$res)) {
423 if (!isset($passes[$row[
'active_fi']])) {
424 $passes[$row[
'active_fi']] = [];
427 $passes[$row[
'active_fi']][] = $row[
'pass'];
435 $times = $this->db->fetchAssoc(
437 'SELECT MIN(started) AS first_access ' 438 .
'FROM tst_times WHERE active_fi = %s AND pass = %s',
439 [
'integer',
'integer'],
440 [$active_id, $attempt]
444 return $times[
'first_access'];
retrieveQuestionsForParticipantPassesForSequencedTests(int $active_id)
getCorrectionsEvaluationData()
setFirstVisit(?\DateTimeImmutable $time)
retrieveEvaluationData(array $active_ids)
addPointsAndQuestionCountToAttempt(ilTestEvaluationPassData $attempt, array $row)
addQuestionsToParticipantPasses(ilTestEvaluationData $evaluation_data)
setQuestionCount(int $questioncount)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
buildBasicUserEvaluationDataFromDB(array $row)
addAnsweredQuestion(int $question_id, float $max_points, float $reached_points, bool $is_answered, ?int $sequence=null, int $manual=0)
setMaxPoints(float $maxpoints)
getFirstVisitForActiveIdAndAttempt(int $active_id, int $attempt)
retrieveQuestionsForParticipantPassesForRandomTests(int $active_id, ilTestEvaluationUserData $user_eval_data, int $question_count)
buildBasicAttemptEvaluationDataFromDB(array $row)
setLastVisit(?\DateTimeImmutable $time)
addVisitingTimeToUserEvalData(ilTestEvaluationUserData $user_data, int $active_id)
addMarksToParticipants(ilTestEvaluationData $evaluation_data)
addQuestionToAttempt(ilTestEvaluationPassData $attempt, array $row)
addQuestionTitle(int $question_id, string $question_title)
__construct(protected ilDBInterface $db, protected ilObjTest $test_obj)
getParticipant(int $active_id)
getAccessFilteredActiveIds()