19declare(strict_types=0);
44 $this->
logger = $DIC->logger()->crs();
45 $this->user_id = $a_user_id;
46 $this->container_id = $a_course_id;
67 $relevant_objective_ids = array();
68 if (!$this->
getSettings()->hasSeparateInitialTests()) {
69 if ($a_tst_ref_id === $this->
getSettings()->getInitialTest()) {
70 $relevant_objective_ids = $objective_ids;
72 } elseif (!$this->
getSettings()->hasSeparateQualifiedTests()) {
73 if ($a_tst_ref_id === $this->
getSettings()->getQualifiedTest()) {
74 $relevant_objective_ids = $objective_ids;
78 foreach ($objective_ids as $objective_id) {
80 if ($assigned_itest === $a_tst_ref_id) {
81 $relevant_objective_ids[] = $objective_id;
84 if ($assigned_qtest === $a_tst_ref_id) {
85 $relevant_objective_ids[] = $objective_id;
89 $relevant_objective_ids = array_unique($relevant_objective_ids);
91 if (count($relevant_objective_ids) <= 1) {
92 return $relevant_objective_ids;
99 $passed =
$results->getCompletedObjectiveIds();
100 $this->
logger->debug(
'Passed objectives are ' . print_r($passed,
true) .
' for test type: ' . $test_type);
103 if (count($passed) >= count($relevant_objective_ids)) {
104 return $relevant_objective_ids;
108 foreach ($relevant_objective_ids as $objective_id) {
109 if (!in_array($objective_id, $passed)) {
110 $unpassed[] = $objective_id;
126 $this->
logger->debug(
'Notify test start: ' . print_r($relevant_objectives,
true));
135 foreach ($relevant_objectives as $oid) {
136 $this->
logger->debug(
'Adding new run for objective with id: ' . $oid);
155 $this->
logger->debug(
'Prepare test pass called');
180 $testType = $this->assignments->getTypeByTest($this->
getTestRefId());
195 $objectiveIds = array($this->getRelatedObjectivesForSeparatedTest($this->getTestRefId()));
206 foreach ($a_test_sequence->getQuestionIds() as $questionId) {
208 $definitionId = $a_test_sequence->getResponsibleSourcePoolDefinitionId($questionId);
209 $objectiveIds = $this->lookupObjectiveIdByRandomQuestionSelectionDefinitionId($definitionId);
211 $objectiveIds = $this->lookupObjectiveIdByFixedQuestionId($questionId);
214 if ($objectiveIds !== []) {
232 foreach ($this->getAssignments()->getAssignments() as $assignment) {
233 if ($assignment->getTestRefId() === $testRefId) {
234 return $assignment->getObjectiveId();
247 return $this->container_id;
252 return $this->settings;
257 return $this->assignments;
264 $is_qualified_run =
false;
265 if ($this->isQualifiedStartRun($session)) {
266 $is_qualified_run =
true;
269 foreach ($this->run as $run) {
273 $run->getObjectiveId(),
274 $this->getAssignments()->getTypeByTest($session->
getRefId())
279 $run->getObjectiveId(),
286 $run->getObjectiveId(),
290 $this->
logger->debug(
'Max attempts = ' . $max_attempts);
295 $this->
logger->debug(
'Checking for qualified test...');
296 if (!$is_qualified_run) {
297 $this->
logger->debug(
' and increasing attempts.');
298 ++$old_result[
'tries'];
300 $old_result[
'is_final'] = ($old_result[
'tries'] >= $max_attempts);
304 $ur->saveObjectiveResult(
305 $run->getObjectiveId(),
306 $this->getAssignments()->getTypeByTest($session->
getRefId()),
307 $old_result[
'status'],
308 $old_result[
'result_perc'],
310 $old_result[
'tries'],
311 $old_result[
'is_final']
322 $this->
logger->debug(
'Initial test');
326 if ($session->
getRefId() !== $this->getSettings()->getQualifiedTest()) {
327 $this->
logger->debug(
'No qualified test run');
331 $this->
logger->debug(
'No start object');
337 $container_ref_id = end($container_ref_ids);
341 $this->getContainerId()
343 if ($start->isFullfilled($this->getUserId(), $session->
getRefId())) {
344 $this->
logger->debug(
'Is fullfilled');
347 $this->
logger->debug(
'Is not fullfilled');
356 foreach ($this->run as $run) {
357 if ($run->questionExists($qst->
getId())) {
362 $run->setQuestionResult(
368 $res = $run->getResult();
373 $run->getObjectiveId(),
374 $this->getAssignments()->getTypeByTest($session->
getRefId())
378 $ur->saveObjectiveResult(
379 $run->getObjectiveId(),
380 $this->getAssignments()->getTypeByTest($session->
getRefId()),
384 $run->getObjectiveId(),
387 $old_result[
'limit_perc']
391 (
float)
$res[
'percentage'],
392 $old_result[
'limit_perc'],
393 $old_result[
'tries'],
394 $old_result[
'is_final']
406 if (!$this->isInRun($qid)) {
417 if (!$this->isInRun($qid)) {
434 foreach ($this->run as $tst_run) {
441 if ($this->getAssignments()->isSeparateTest($session->
getRefId())) {
442 $this->updateSeparateTestQuestions($session, $seq);
446 $this->updateFixedQuestions($session, $seq);
450 $this->updateRandomQuestions($session, $seq);
456 foreach ($this->run as $tst_run) {
457 $tst_run->clearQuestions();
460 $tst_run->addQuestion($qst_id);
463 $tst_run->setMaxPoints((
int) $points);
469 foreach ($this->run as $tst_run) {
470 $tst_run->clearQuestions();
473 $tst_run->getObjectiveId()
476 foreach ($qst as
$id) {
477 $tst_run->addQuestion(
$id);
480 $tst_run->setMaxPoints((
int) $points);
486 foreach ($this->run as $tst_run) {
488 $tst_run->clearQuestions();
492 $tst_run->getObjectiveId(),
495 ($this->getSettings()->getQualifiedTest() === $session->
getRefId()) ?
504 $tst_run->addQuestion($qst);
508 $tst_run->setMaxPoints((
int) $points);
514 foreach ($this->run as $run) {
515 if ($run->questionExists($a_qid)) {
529 $adapter->setTestRefId($a_test_session->
getRefId());
530 $adapter->initTestRun($a_test_session);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
getReachedPoints(int $active_id, int $pass)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static isStartObject(int $a_container_id, int $a_item_ref_id)
static lookupQuestionsByObjective(int $a_test_id, int $a_objective)
static lookupObjectivesOfQuestion(int $a_qid)
static _lookupMaximumPointsOfQuestion(int $a_question_id)
static _getObjectiveIds(int $course_id, bool $a_activated_only=false)
static lookupObjectiveIdsBySequence(int $a_container_id, int $a_seq_id)
static lookupSequencesByType(int $a_container_id, int $a_objective_id, int $a_test_id, int $a_test_type)
const TYPE_TEST_QUALIFIED
static getInstanceByObjId(int $a_obj_id)
const HIDE_PASSED_OBJECTIVE_QST
const MARK_PASSED_OBJECTIVE_QST
getTestByObjective(int $a_objective_id, int $a_type)
getTypeByTest(int $a_test_ref_id)
static getInstance(int $a_container_id)
setQuestionsOptional(ilTestSequence $seq)
notifyTestStart(ilTestSession $a_test_session, int $a_test_obj_id)
Called from learning objective test on actual test start.
isQualifiedStartRun(ilTestSession $session)
Check if current run is a start object run.
getRelatedObjectivesForSeparatedTest(int $testRefId)
buildQuestionRelatedObjectiveListByQuestions(ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
ilLOTestAssignments $assignments
buildQuestionRelatedObjectiveListByTest(ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
prepareTestPass(ilTestSession $a_test_session, ilTestSequence $a_test_sequence)
Called from learning objective test.
buildQuestionRelatedObjectiveList(ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
__construct(int $a_user_id, int $a_course_id)
hideQuestions(ilTestSequence $seq)
initTestRun(ilTestSession $session)
lookupObjectiveIdByFixedQuestionId(int $a_question_id)
updateQuestions(ilTestSession $session, ilTestSequence $seq)
updateQuestionResult(ilTestSession $session, assQuestion $qst)
update question result of run
updateSeparateTestQuestions(ilTestSession $session, ilTestSequence $seq)
updateRandomQuestions(ilTestSession $session, ilTestSequenceRandomQuestionSet $seq)
lookupObjectiveIdByRandomQuestionSelectionDefinitionId(int $a_id)
initUserResult(ilTestSession $session)
lookupRelevantObjectiveIdsForTest(int $a_container_id, int $a_tst_ref_id, int $a_user_id)
static getInstance(ilTestSession $a_test_session)
updateFixedQuestions(ilTestSession $session, ilTestSequence $seq)
setTestRefId(int $testRefId)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static deleteRun(int $a_container_id, int $a_user_id, int $a_test_id)
static getRun(int $a_container_id, int $a_user_id, int $a_test_id)
static lookupResult(int $a_course_obj_id, int $a_user_id, int $a_objective_id, int $a_tst_type)
static lookupObjectiveRequiredPercentage(int $a_container_id, int $a_objective_id, int $a_test_ref_id, int $a_max_points)
static isCompleted(int $a_cont_oid, int $a_test_rid, int $a_objective_id, int $max_points, int $reached, int $limit_perc)
Check if objective is completed.
static lookupMaxAttempts(int $a_container_id, int $a_objective_id, int $a_test_ref_id)
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
Component logger with individual log levels by component id.
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupObjId(int $ref_id)
getResponsibleSourcePoolDefinitionId(int $question_id)
saveToDb()
Saves the sequence data for a given pass to the database.
hideQuestion(int $question_id)
setQuestionOptional(int $question_id)
getObjectiveOrientedContainerId()