18 declare(strict_types=0);
43 $this->
logger = $DIC->logger()->crs();
44 $this->user_id = $a_user_id;
45 $this->container_id = $a_course_id;
66 $relevant_objective_ids = array();
67 if (!$this->
getSettings()->hasSeparateInitialTests()) {
68 if ($a_tst_ref_id === $this->
getSettings()->getInitialTest()) {
69 $relevant_objective_ids = $objective_ids;
71 } elseif (!$this->
getSettings()->hasSeparateQualifiedTests()) {
72 if ($a_tst_ref_id === $this->
getSettings()->getQualifiedTest()) {
73 $relevant_objective_ids = $objective_ids;
77 foreach ($objective_ids as $objective_id) {
79 if ($assigned_itest === $a_tst_ref_id) {
80 $relevant_objective_ids[] = $objective_id;
83 if ($assigned_qtest === $a_tst_ref_id) {
84 $relevant_objective_ids[] = $objective_id;
88 $relevant_objective_ids = array_unique($relevant_objective_ids);
90 if (count($relevant_objective_ids) <= 1) {
91 return $relevant_objective_ids;
98 $passed =
$results->getCompletedObjectiveIds();
99 $this->
logger->debug(
'Passed objectives are ' . print_r($passed,
true) .
' for test type: ' . $test_type);
102 if (count($passed) >= count($relevant_objective_ids)) {
103 return $relevant_objective_ids;
107 foreach ($relevant_objective_ids as $objective_id) {
108 if (!in_array($objective_id, $passed)) {
109 $unpassed[] = $objective_id;
125 $this->
logger->debug(
'Notify test start: ' . print_r($relevant_objectives,
true));
134 foreach ($relevant_objectives as $oid) {
135 $this->
logger->debug(
'Adding new run for objective with id: ' . $oid);
154 $this->
logger->debug(
'Prepare test pass called');
177 $testType = $this->assignments->getTypeByTest($this->
getTestRefId());
205 $definitionId = $a_test_sequence->getResponsibleSourcePoolDefinitionId($questionId);
211 if ($objectiveIds !== []) {
230 if ($assignment->getTestRefId() ===
$testRefId) {
231 return $assignment->getObjectiveId();
261 $is_qualified_run =
false;
263 $is_qualified_run =
true;
266 foreach ($this->run as $run) {
270 $run->getObjectiveId(),
276 $run->getObjectiveId(),
283 $run->getObjectiveId(),
287 $this->
logger->debug(
'Max attempts = ' . $max_attempts);
292 $this->
logger->debug(
'Checking for qualified test...');
293 if (!$is_qualified_run) {
294 $this->
logger->debug(
' and increasing attempts.');
295 ++$old_result[
'tries'];
297 $old_result[
'is_final'] = ($old_result[
'tries'] >= $max_attempts);
301 $ur->saveObjectiveResult(
302 $run->getObjectiveId(),
304 $old_result[
'status'],
305 $old_result[
'result_perc'],
307 $old_result[
'tries'],
308 $old_result[
'is_final']
319 $this->
logger->debug(
'Initial test');
324 $this->
logger->debug(
'No qualified test run');
328 $this->
logger->debug(
'No start object');
334 $container_ref_id = end($container_ref_ids);
340 if ($start->isFullfilled($this->getUserId(), $session->
getRefId())) {
341 $this->
logger->debug(
'Is fullfilled');
344 $this->
logger->debug(
'Is not fullfilled');
353 foreach ($this->run as $run) {
354 if ($run->questionExists($qst->
getId())) {
359 $run->setQuestionResult(
365 $res = $run->getResult();
370 $run->getObjectiveId(),
375 $ur->saveObjectiveResult(
376 $run->getObjectiveId(),
381 $run->getObjectiveId(),
384 $old_result[
'limit_perc']
388 (
float) $res[
'percentage'],
389 $old_result[
'limit_perc'],
390 $old_result[
'tries'],
391 $old_result[
'is_final']
431 foreach ($this->run as $tst_run) {
453 foreach ($this->run as $tst_run) {
454 $tst_run->clearQuestions();
457 $tst_run->addQuestion($qst_id);
460 $tst_run->setMaxPoints((
int) $points);
466 foreach ($this->run as $tst_run) {
467 $tst_run->clearQuestions();
470 $tst_run->getObjectiveId()
473 foreach ($qst as
$id) {
474 $tst_run->addQuestion($id);
477 $tst_run->setMaxPoints((
int) $points);
483 foreach ($this->run as $tst_run) {
485 $tst_run->clearQuestions();
489 $tst_run->getObjectiveId(),
501 $tst_run->addQuestion($qst);
505 $tst_run->setMaxPoints((
int) $points);
511 foreach ($this->run as $run) {
512 if ($run->questionExists($a_qid)) {
526 $adapter->setTestRefId($a_test_session->
getRefId());
527 $adapter->initTestRun($a_test_session);
updateRandomQuestions(ilTestSession $session, ilTestSequenceRandomQuestionSet $seq)
static lookupObjectiveIdsBySequence(int $a_container_id, int $a_seq_id)
hideQuestion(int $question_id)
static _lookupMaximumPointsOfQuestion(int $a_question_id)
static lookupQuestionsByObjective(int $a_test_id, int $a_objective)
lookupObjectiveIdByFixedQuestionId(int $a_question_id)
static _getAllReferences(int $id)
get all reference ids for object ID
static deleteRun(int $a_container_id, int $a_user_id, int $a_test_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static lookupResult(int $a_course_obj_id, int $a_user_id, int $a_objective_id, int $a_tst_type)
static _getObjectiveIds(int $course_id, bool $a_activated_only=false)
getObjectiveOrientedContainerId()
setQuestionsOptional(ilTestSequence $seq)
const HIDE_PASSED_OBJECTIVE_QST
static lookupObjectiveRequiredPercentage(int $a_container_id, int $a_objective_id, int $a_test_ref_id, int $a_max_points)
static _lookupObjId(int $ref_id)
updateSeparateTestQuestions(ilTestSession $session, ilTestSequence $seq)
hideQuestions(ilTestSequence $seq)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
saveToDb()
Saves the sequence data for a given pass to the database.
static getInstance(ilTestSession $a_test_session)
setQuestionOptional(int $question_id)
getTypeByTest(int $a_test_ref_id)
updateQuestions(ilTestSession $session, ilTestSequence $seq)
initTestRun(ilTestSession $session)
buildQuestionRelatedObjectiveListByQuestions(ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
buildQuestionRelatedObjectiveList(ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
updateFixedQuestions(ilTestSession $session, ilTestSequence $seq)
const MARK_PASSED_OBJECTIVE_QST
ilLOTestAssignments $assignments
getRelatedObjectivesForSeparatedTest(int $testRefId)
static isStartObject(int $a_container_id, int $a_item_ref_id)
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 getInstanceByObjId(int $a_obj_id)
setTestRefId(int $testRefId)
updateQuestionResult(ilTestSession $session, assQuestion $qst)
update question result of run
static getRun(int $a_container_id, int $a_user_id, int $a_test_id)
isQualifiedStartRun(ilTestSession $session)
Check if current run is a start object run.
getResponsibleSourcePoolDefinitionId(int $question_id)
static lookupSequencesByType(int $a_container_id, int $a_objective_id, int $a_test_id, int $a_test_type)
buildQuestionRelatedObjectiveListByTest(ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct(int $a_user_id, int $a_course_id)
static getInstance(int $a_container_id)
notifyTestStart(ilTestSession $a_test_session, int $a_test_obj_id)
Called from learning objective test on actual test start.
const TYPE_TEST_QUALIFIED
getReachedPoints(int $active_id, int $pass)
static lookupObjectivesOfQuestion(int $a_qid)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
prepareTestPass(ilTestSession $a_test_session, ilTestSequence $a_test_sequence)
Called from learning objective test.
getTestByObjective(int $a_objective_id, int $a_type)
lookupRelevantObjectiveIdsForTest(int $a_container_id, int $a_tst_ref_id, int $a_user_id)
lookupObjectiveIdByRandomQuestionSelectionDefinitionId(int $a_id)
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)
initUserResult(ilTestSession $session)