ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilLOTestQuestionAdapter Class Reference

Test question filter. More...

+ Collaboration diagram for ilLOTestQuestionAdapter:

Public Member Functions

 __construct ($a_user_id, $a_course_id)

Static Public Member Functions

static filterQuestions (ilTestSession $a_test_session, ilTestSequence $a_test_sequence)
 Called from learning objective test.
static updateObjectiveStatus (ilTestSession $a_test_session, ilTestSequence $a_test_sequence, assQuestion $a_question)
 Store result and update objective status.

Protected Member Functions

 getUserId ()
 getContainerId ()
 getSettings ()
 Get loc settings.
 initUserResult (ilTestSession $session)
 init user result
 isQualifiedStartRun (ilTestSession $session)
 Check if current run is a start object run.
 updateQuestionResult (ilTestSession $session, assQuestion $qst)
 update question result of run
 hideQuestions (ilTestSequence $seq)
 Hide questions.
 initTestRun (ilTestSession $session)
 storeTestRun ()
 Store test run in DB.
 updateQuestions (ilTestSession $session, ilTestSequence $seq)
 updateFixedQuestions (ilTestSession $session, ilTestSequence $seq)
 updateRandomQuestions (ilTestSession $session, ilTestSequenceRandomQuestionSet $seq)
 isInRun ($a_qid)

Protected Attributes

 $settings = NULL
 $user_id = 0
 $container_id = 0

Static Private Member Functions

static getQuestionData ($testObjId, $questionIds)

Detailed Description

Test question filter.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilLOTestQuestionAdapter.php.

Constructor & Destructor Documentation

ilLOTestQuestionAdapter::__construct (   $a_user_id,
  $a_course_id 
)
Parameters
type$a_user_id
type$a_course_id

Definition at line 26 of file class.ilLOTestQuestionAdapter.php.

References ilLOSettings\getInstanceByObjId().

{
$this->user_id = $a_user_id;
$this->container_id = $a_course_id;
$this->settings = ilLOSettings::getInstanceByObjId($this->container_id);
}

+ Here is the call graph for this function:

Member Function Documentation

static ilLOTestQuestionAdapter::filterQuestions ( ilTestSession  $a_test_session,
ilTestSequence  $a_test_sequence 
)
static

Called from learning objective test.

Parameters
ilTestSession$a_test_session
ilTestSequence$a_test_sequence

Definition at line 42 of file class.ilLOTestQuestionAdapter.php.

References $GLOBALS, ilTestSession\getObjectiveOrientedContainerId(), ilTestSession\getUserId(), and ilTestSequence\saveToDb().

Referenced by ilTestOutputGUI\filterTestSequenceByObjectives().

{
$adapter = new self(
$a_test_session->getUserId(),
);
$adapter->initTestRun($a_test_session);
$adapter->updateQuestions($a_test_session, $a_test_sequence);
$adapter->hideQuestions($a_test_sequence);
$adapter->storeTestRun();
$adapter->initUserResult($a_test_session);
// Save test sequence
$a_test_sequence->saveToDb();
$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($a_test_sequence,true));
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLOTestQuestionAdapter::getContainerId ( )
protected

Definition at line 105 of file class.ilLOTestQuestionAdapter.php.

References $container_id.

Referenced by isQualifiedStartRun().

{
}

+ Here is the caller graph for this function:

static ilLOTestQuestionAdapter::getQuestionData (   $testObjId,
  $questionIds 
)
staticprivate

Definition at line 406 of file class.ilLOTestQuestionAdapter.php.

References $ilDB, $lng, and ilAssQuestionList\QUESTION_INSTANCE_TYPE_DUPLICATES.

{
global $ilDB, $lng, $ilPluginAdmin;
require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
$questionList = new ilAssQuestionList($ilDB, $lng, $ilPluginAdmin, $testObjId);
$questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_DUPLICATES);
$questionList->setQuestionIdsFilter($questionIds);
$questionList->load();
return $questionList->getQuestionDataArray();
}
ilLOTestQuestionAdapter::getSettings ( )
protected

Get loc settings.

Returns
ilLOSettings

Definition at line 114 of file class.ilLOTestQuestionAdapter.php.

References $settings.

Referenced by initUserResult(), isQualifiedStartRun(), updateQuestionResult(), and updateRandomQuestions().

{
}

+ Here is the caller graph for this function:

ilLOTestQuestionAdapter::getUserId ( )
protected

Definition at line 100 of file class.ilLOTestQuestionAdapter.php.

References $user_id.

{
}
ilLOTestQuestionAdapter::hideQuestions ( ilTestSequence  $seq)
protected

Hide questions.

Parameters
ilTestSequence$seq

Definition at line 292 of file class.ilLOTestQuestionAdapter.php.

References ilTestSequence\clearHiddenQuestions(), ilTestSequence\getQuestionIds(), ilTestSequence\hideQuestion(), and isInRun().

{
// first unhide all questions
foreach($seq->getQuestionIds() as $qid)
{
if(!$this->isInRun($qid))
{
$seq->hideQuestion($qid);
}
}
}

+ Here is the call graph for this function:

ilLOTestQuestionAdapter::initTestRun ( ilTestSession  $session)
protected

Definition at line 306 of file class.ilLOTestQuestionAdapter.php.

References ilObject\_lookupObjId(), ilTestSession\getRefId(), and ilLOTestRun\getRun().

{
include_once './Modules/Course/classes/Objectives/class.ilLOTestRun.php';
$this->run = ilLOTestRun::getRun(
$this->container_id,
$this->user_id,
);
#$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($this->run,true));
}

+ Here is the call graph for this function:

ilLOTestQuestionAdapter::initUserResult ( ilTestSession  $session)
protected

init user result

Definition at line 122 of file class.ilLOTestQuestionAdapter.php.

References $GLOBALS, ilTestSession\getRefId(), getSettings(), isQualifiedStartRun(), ilLOUtils\lookupMaxAttempts(), ilLOUtils\lookupObjectiveRequiredPercentage(), ilLOUserResults\lookupResult(), ilLOUserResults\TYPE_INITIAL, ilLOUserResults\TYPE_QUALIFIED, ilLOSettings\TYPE_TEST_INITIAL, and ilLOSettings\TYPE_TEST_QUALIFIED.

{
// check if current test is start object and fullfilled
// if yes => do not increase tries.
$is_qualified_run = false;
if($this->isQualifiedStartRun($session))
{
$is_qualified_run = true;
}
foreach($this->run as $run)
{
include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
$this->container_id,
$this->user_id,
$run->getObjectiveId(),
($this->getSettings()->getQualifiedTest() == $session->getRefId()) ?
);
include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
$this->container_id,
$run->getObjectiveId(),
($this->getSettings()->getQualifiedTest() == $session->getRefId()) ?
$run->getMaxPoints()
);
$max_attempts = ilLOUtils::lookupMaxAttempts($this->container_id, $run->getObjectiveId());
if($max_attempts)
{
// check if current test is start object and fullfilled
// if yes => do not increase tries.
$GLOBALS['ilLog']->write(__METHOD__.': check for qualified...');
if(!$is_qualified_run)
{
$GLOBALS['ilLog']->write(__METHOD__.': and increase attempts');
++$old_result['tries'];
}
$old_result['is_final'] = ($old_result['tries'] >= $max_attempts);
}
$ur = new ilLOUserResults($this->container_id,$this->user_id);
$ur->saveObjectiveResult(
$run->getObjectiveId(),
($this->getSettings()->getQualifiedTest() == $session->getRefId()) ?
$old_result['status'],
$old_result['result_perc'],
$limit,
$old_result['tries'],
$old_result['is_final']
);
}
}

+ Here is the call graph for this function:

ilLOTestQuestionAdapter::isInRun (   $a_qid)
protected

Definition at line 393 of file class.ilLOTestQuestionAdapter.php.

Referenced by hideQuestions().

{
foreach($this->run as $run)
{
if($run->questionExists($a_qid))
{
return true;
}
}
return false;
}

+ Here is the caller graph for this function:

ilLOTestQuestionAdapter::isQualifiedStartRun ( ilTestSession  $session)
protected

Check if current run is a start object run.

Parameters
ilTestSession$session
Returns
boolean

Definition at line 191 of file class.ilLOTestQuestionAdapter.php.

References $GLOBALS, ilObject\_getAllReferences(), getContainerId(), ilTestSession\getRefId(), getSettings(), and ilContainerStartObjects\isStartObject().

Referenced by initUserResult().

{
if($session->getRefId() == $this->getSettings()->getInitialTest())
{
$GLOBALS['ilLog']->write(__METHOD__.': is intial');
return false;
}
if($session->getRefId() != $this->getSettings()->getQualifiedTest())
{
$GLOBALS['ilLog']->write(__METHOD__.': is not qualified');
return false;
}
include_once './Services/Container/classes/class.ilContainerStartObjects.php';
{
$GLOBALS['ilLog']->write(__METHOD__.': no start object');
return false;
}
// Check if start object is fullfilled
$container_ref_ids = ilObject::_getAllReferences($this->getContainerId());
$container_ref_id = end($container_ref_ids);
$container_ref_id,
$this->getContainerId()
);
if($start->isFullfilled($this->getUserId(),$session->getRefId()))
{
$GLOBALS['ilLog']->write(__METHOD__.': is fullfilled');
return false;
}
$GLOBALS['ilLog']->write(__METHOD__.': is not fullfilled');
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLOTestQuestionAdapter::storeTestRun ( )
protected

Store test run in DB.

Definition at line 320 of file class.ilLOTestQuestionAdapter.php.

{
foreach ($this->run as $tst_run)
{
$tst_run->update();
}
}
ilLOTestQuestionAdapter::updateFixedQuestions ( ilTestSession  $session,
ilTestSequence  $seq 
)
protected

Definition at line 342 of file class.ilLOTestQuestionAdapter.php.

References $GLOBALS, ilCourseObjectiveQuestion\_lookupMaximumPointsOfQuestion(), ilObject\_lookupObjId(), ilTestSession\getRefId(), and ilCourseObjectiveQuestion\lookupQuestionsByObjective().

Referenced by updateQuestions().

{
foreach ($this->run as $tst_run)
{
$tst_run->clearQuestions();
include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
$tst_run->getObjectiveId()
);
$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($qst,true));
$points = 0;
foreach($qst as $id)
{
$tst_run->addQuestion($id);
}
$tst_run->setMaxPoints($points);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilLOTestQuestionAdapter::updateObjectiveStatus ( ilTestSession  $a_test_session,
ilTestSequence  $a_test_sequence,
assQuestion  $a_question 
)
static

Store result and update objective status.

Parameters
ilTestSession$a_test_session
ilTestSequence$a_test_sequence
assQuestion$a_question

Definition at line 68 of file class.ilLOTestQuestionAdapter.php.

References ilTestSession\getObjectiveOrientedContainerId(), and ilTestSession\getUserId().

Referenced by ilTestOutputGUI\updateContainerObjectivesWithAnsweredQuestion().

{
$adapter = new self(
$a_test_session->getUserId(),
);
$adapter->initTestRun($a_test_session);
$adapter->updateQuestionResult($a_test_session,$a_question);
return true;
/*
$usr_id = $a_test_session->getUserId();
$crs_id = $a_test_session->getObjectiveOrientedContainerId();
$question_id = $a_question->getId();
$points_reached = $a_question->getReachedPoints($a_test_session->getActiveId(), $a_test_session->getPass());
//$points_max = $a_question->getMaxPoints();
if( $a_test_sequence instanceof ilTestSequenceFixedQuestionSet )
{
// make some noise (with question id only)
}
elseif( $a_test_sequence instanceof ilTestSequenceRandomQuestionSet )
{
$respSrcPoolDefId = $a_test_sequence->getResponsibleSourcePoolDefinitionId($question_id);
// make some noise (with question id and responsible source pool definition)
}
*/
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilLOTestQuestionAdapter::updateQuestionResult ( ilTestSession  $session,
assQuestion  $qst 
)
protected

update question result of run

Parameters
ilTestSession$session
assQuestion$qst

Definition at line 233 of file class.ilLOTestQuestionAdapter.php.

References $GLOBALS, $res, ilLPStatusWrapper\_updateStatus(), ilTestSession\getActiveId(), assQuestion\getId(), ilTestSession\getPass(), assQuestion\getReachedPoints(), ilTestSession\getRefId(), getSettings(), ilLOUtils\isCompleted(), ilLOUserResults\lookupResult(), ilLOUserResults\STATUS_COMPLETED, ilLOUserResults\STATUS_FAILED, ilLOUserResults\TYPE_INITIAL, and ilLOUserResults\TYPE_QUALIFIED.

{
foreach($this->run as $run)
{
if($run->questionExists($qst->getId()))
{
$GLOBALS['ilLog']->write(__METHOD__.': reached points are '.$qst->getReachedPoints($session->getActiveId(),$session->getPass()));
$run->setQuestionResult(
$qst->getId(),
$qst->getReachedPoints($session->getActiveId(),$session->getPass())
);
$run->update();
$res = $run->getResult();
include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
$this->container_id,
$this->user_id,
$run->getObjectiveId(),
($this->getSettings()->getQualifiedTest() == $session->getRefId()) ?
);
$ur = new ilLOUserResults($this->container_id,$this->user_id);
$ur->saveObjectiveResult(
$run->getObjectiveId(),
($this->getSettings()->getQualifiedTest() == $session->getRefId()) ?
$this->container_id,
$session->getRefId(),
$run->getObjectiveId(),
$res['max'],$res['reached'],$old_result['limit_perc']) ?
(int) $res['percentage'],
$old_result['limit_perc'],
$old_result['tries'],
$old_result['is_final']
);
$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($run->getResult(),true));
include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
ilLPStatusWrapper::_updateStatus($this->container_id,$this->user_id);
}
}
return false;
}

+ Here is the call graph for this function:

ilLOTestQuestionAdapter::updateQuestions ( ilTestSession  $session,
ilTestSequence  $seq 
)
protected

Definition at line 329 of file class.ilLOTestQuestionAdapter.php.

References updateFixedQuestions(), and updateRandomQuestions().

{
if($seq instanceof ilTestSequenceFixedQuestionSet)
{
$this->updateFixedQuestions($session, $seq);
}
if($seq instanceof ilTestSequenceRandomQuestionSet)
{
$this->updateRandomQuestions($session, $seq);
}
}

+ Here is the call graph for this function:

ilLOTestQuestionAdapter::updateRandomQuestions ( ilTestSession  $session,
ilTestSequenceRandomQuestionSet  $seq 
)
protected

Definition at line 363 of file class.ilLOTestQuestionAdapter.php.

References ilCourseObjectiveQuestion\_lookupMaximumPointsOfQuestion(), ilTestSequence\getQuestionIds(), ilTestSession\getRefId(), ilTestSequenceRandomQuestionSet\getResponsibleSourcePoolDefinitionId(), getSettings(), ilLOSettings\TYPE_TEST_INITIAL, and ilLOSettings\TYPE_TEST_QUALIFIED.

Referenced by updateQuestions().

{
include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
foreach($this->run as $tst_run)
{
// Clear questions of previous run
$tst_run->clearQuestions();
$this->container_id,
$tst_run->getObjectiveId(),
($this->getSettings()->getQualifiedTest() == $session->getRefId() ?
);
$stored_sequence_id = $rnd->getQplSequence();
$points = 0;
foreach($seq->getQuestionIds() as $qst)
{
if($stored_sequence_id == $seq->getResponsibleSourcePoolDefinitionId($qst))
{
$tst_run->addQuestion($qst);
}
}
$tst_run->setMaxPoints($points);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilLOTestQuestionAdapter::$container_id = 0
protected

Definition at line 17 of file class.ilLOTestQuestionAdapter.php.

Referenced by getContainerId().

ilLOTestQuestionAdapter::$settings = NULL
protected

Definition at line 14 of file class.ilLOTestQuestionAdapter.php.

Referenced by getSettings().

ilLOTestQuestionAdapter::$user_id = 0
protected

Definition at line 16 of file class.ilLOTestQuestionAdapter.php.

Referenced by getUserId().


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