18declare(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());
192 $objectiveIds = array($this->getRelatedObjectivesForSeparatedTest($this->getTestRefId()));
203 foreach ($a_test_sequence->getQuestionIds() as $questionId) {
205 $definitionId = $a_test_sequence->getResponsibleSourcePoolDefinitionId($questionId);
206 $objectiveIds = $this->lookupObjectiveIdByRandomQuestionSelectionDefinitionId($definitionId);
208 $objectiveIds = $this->lookupObjectiveIdByFixedQuestionId($questionId);
211 if ($objectiveIds !== []) {
229 foreach ($this->getAssignments()->getAssignments() as $assignment) {
230 if ($assignment->getTestRefId() === $testRefId) {
231 return $assignment->getObjectiveId();
244 return $this->container_id;
249 return $this->settings;
254 return $this->assignments;
261 $is_qualified_run =
false;
262 if ($this->isQualifiedStartRun($session)) {
263 $is_qualified_run =
true;
266 foreach ($this->run as $run) {
270 $run->getObjectiveId(),
271 $this->getAssignments()->getTypeByTest($session->
getRefId())
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(),
303 $this->getAssignments()->getTypeByTest($session->
getRefId()),
304 $old_result[
'status'],
305 $old_result[
'result_perc'],
307 $old_result[
'tries'],
308 $old_result[
'is_final']
319 $this->
logger->debug(
'Initial test');
323 if ($session->
getRefId() !== $this->getSettings()->getQualifiedTest()) {
324 $this->
logger->debug(
'No qualified test run');
328 $this->
logger->debug(
'No start object');
334 $container_ref_id = end($container_ref_ids);
338 $this->getContainerId()
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(),
371 $this->getAssignments()->getTypeByTest($session->
getRefId())
375 $ur->saveObjectiveResult(
376 $run->getObjectiveId(),
377 $this->getAssignments()->getTypeByTest($session->
getRefId()),
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']
403 if (!$this->isInRun($qid)) {
414 if (!$this->isInRun($qid)) {
431 foreach ($this->run as $tst_run) {
438 if ($this->getAssignments()->isSeparateTest($session->
getRefId())) {
439 $this->updateSeparateTestQuestions($session, $seq);
443 $this->updateFixedQuestions($session, $seq);
447 $this->updateRandomQuestions($session, $seq);
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(),
492 ($this->getSettings()->getQualifiedTest() === $session->
getRefId()) ?
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);
$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()