Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
bheyser committed Aug 21, 2015
1 parent 56f0001 commit 39d29ab
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 57 deletions.
38 changes: 27 additions & 11 deletions Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ public function prepareTestPass(ilTestSession $a_test_session, ilTestSequence $a
$this->updateQuestions($a_test_session, $a_test_sequence);

// TODO: following if requires real condition
if($markQuestionsOptionalWhenRelatedToPassedObjective = true)
if($markQuestionsOptionalWhenRelatedToPassedObjective = false)
{
$this->setQuestionsOptional($a_test_sequence);
}
// TODO: following if requires real condition
elseif($hideQuestionsWhenRelatedToPassedObjective = false)
elseif($hideQuestionsWhenRelatedToPassedObjective = true)
{
$this->hideQuestions($a_test_sequence);
}
Expand All @@ -82,21 +82,37 @@ public function prepareTestPass(ilTestSession $a_test_session, ilTestSequence $a
* @param ilTestSequence $a_test_sequence
* @param ilTestQuestionRelatedObjectivesList $a_objectives_list
*/
public function buildQuestionRelatedObjectiveList(ilTestQuestionRelatedObjectivesList $a_objectives_list)
public function buildQuestionRelatedObjectiveList(ilTestSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
{
foreach( $a_objectives_list->getQuestionIds() as $qid )
foreach( $a_test_sequence->getQuestionIds() as $questionId )
{
foreach( $this->run as $run )
if( $a_test_sequence instanceof ilTestSequenceFixedQuestionSet )
{
/* @var ilLOTestRun $run */

if( $run->questionExists($qid) )
{
$a_objectives_list->addQuestionRelatedObjective($qid, $run->getObjectiveId());
}
$objectiveId = $this->lookupObjectiveIdByFixedQuestionId($questionId);
}
elseif( $a_test_sequence instanceof ilTestSequenceRandomQuestionSet )
{
$definitionId = $a_test_sequence->getResponsibleSourcePoolDefinitionId($questionId);
$objectiveId = $this->lookupObjectiveIdByRandomQuestionSelectionDefinitionId($definitionId);
}

$a_objectives_list->addQuestionRelatedObjective($questionId, $objectiveId);
}
}

protected function lookupObjectiveIdByFixedQuestionId($a_question_id)
{
// TODO: determine objective id related to fixed question id
$objectiveId = 0;
return $objectiveId;
}

protected function addRandomQuestionRelatedObjective($a_definition_id)
{
// TODO: determine objective id related to random question selection definition id
$objectiveId = 0;
return $objectiveId;
}

protected function getUserId()
{
Expand Down
4 changes: 3 additions & 1 deletion Modules/Test/classes/class.ilObjTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4213,7 +4213,7 @@ function pcArrayShuffle($array)
* @return array An array containing the test results for the given user
* @access public
*/
function &getTestResult($active_id, $pass = NULL, $ordered_sequence = FALSE)
function &getTestResult($active_id, $pass = NULL, $ordered_sequence = FALSE, $considerHiddenQuestions = true)
{
global $tree, $ilDB, $lng, $ilPluginAdmin;

Expand Down Expand Up @@ -4245,6 +4245,8 @@ function &getTestResult($active_id, $pass = NULL, $ordered_sequence = FALSE)
}
else
{
$testSequence->setConsiderHiddenQuestionsEnabled($considerHiddenQuestions);

$testSequence->loadFromDb();
$testSequence->loadQuestions();

Expand Down
12 changes: 9 additions & 3 deletions Modules/Test/classes/class.ilTestEvaluationGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,8 @@ function outUserPassDetails()

$this->ctrl->saveParameter($this, "pass");
$pass = $_GET["pass"];

$considerHiddenQuestions = true;

require_once 'Modules/Test/classes/class.ilTestResultHeaderLabelBuilder.php';
$testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $ilObjDataCache);
Expand All @@ -1094,9 +1096,11 @@ function outUserPassDetails()
$testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
$testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
$testResultHeaderLabelBuilder->initObjectiveOrientedMode();

$considerHiddenQuestions = false;
}

$result_array = $this->getFilteredTestResult($active_id, $pass);
$result_array = $this->getFilteredTestResult($active_id, $pass, $considerHiddenQuestions);

$command_solution_details = "";
if ($this->object->getShowSolutionDetails())
Expand Down Expand Up @@ -1917,7 +1921,7 @@ public function performDeletePass()
$this->redirectToPassDeletionContext($_POST['context']);
}

protected function getFilteredTestResult($active_id, $pass)
protected function getFilteredTestResult($active_id, $pass, $considerHiddenQuestions)
{
global $ilDB, $ilPluginAdmin;

Expand Down Expand Up @@ -1955,7 +1959,9 @@ protected function getFilteredTestResult($active_id, $pass)

$filteredTestResult = array();

foreach($this->object->getTestResult($active_id, $pass) as $resultItemKey => $resultItemValue)
$resultData = $this->object->getTestResult($active_id, $pass, false, $considerHiddenQuestions);

foreach($resultData as $resultItemKey => $resultItemValue)
{
if($resultItemKey === 'test' || $resultItemKey === 'pass')
{
Expand Down
1 change: 0 additions & 1 deletion Modules/Test/classes/class.ilTestOutputGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ protected function outWorkingForm($sequence = "", $test_id, $postpone_allowed, $

$is_postponed = $this->testSequence->isPostponedQuestion($question_gui->object->getId());
$is_optional = $this->testSequence->isQuestionOptional($question_gui->object->getId());
$this->ctrl->setParameter($this, "sequence", "$sequence");
$formaction = $this->ctrl->getFormAction($this, "gotoQuestion");

$question_gui->setSequenceNumber($this->testSequence->getPositionOfSequence($sequence));
Expand Down
8 changes: 3 additions & 5 deletions Modules/Test/classes/class.ilTestPlayerAbstractGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1190,14 +1190,12 @@ function outTestPage($directfeedback)
$this->endingTimeReached();
return;
}


$this->ctrl->setParameter($this, "sequence", $this->sequence);

if( $this->isOptionalQuestionAnsweringConfirmationRequired($this->sequence) )
{
$this->showAnswerOptionalQuestionsConfirmation();

vd($this->testSequence->questions);
vd($this->testSequence->sequencedata);
vd($this->sequence);
return;
}

Expand Down
22 changes: 0 additions & 22 deletions Modules/Test/classes/class.ilTestQuestionRelatedObjectivesList.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
*/
class ilTestQuestionRelatedObjectivesList
{
/**
* @var array
*/
protected $questionIds;

/**
* @var array
*/
Expand All @@ -27,27 +22,10 @@ class ilTestQuestionRelatedObjectivesList

public function __construct()
{
$this->questionIds = array();
$this->objectivesByQuestion = array();
$this->objectivesTitles = array();
}

/**
* @return array
*/
public function getQuestionIds()
{
return $this->questionIds;
}

/**
* @param array $questionIds
*/
public function setQuestionIds($questionIds)
{
$this->questionIds = $questionIds;
}

/**
* @param integer $questionId
* @param string $objectiveTitle
Expand Down
55 changes: 49 additions & 6 deletions Modules/Test/classes/class.ilTestSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ class ilTestSequence
* @var bool
*/
private $answeringOptionalQuestionsConfirmed;

/**
* @var bool
*/
private $considerHiddenQuestionsEnabled;

/**
* ilTestSequence constructor
Expand All @@ -92,6 +97,8 @@ function ilTestSequence($active_id, $pass, $randomtest)

$this->optionalQuestions = array();
$this->answeringOptionalQuestionsConfirmed = false;

$this->considerHiddenQuestionsEnabled = false;
}

function getActiveId()
Expand Down Expand Up @@ -407,22 +414,42 @@ function getUserQuestionCount()

function getOrderedSequence()
{
return array_keys($this->questions);
$sequenceKeys = array();

foreach(array_keys($this->questions) as $sequenceKey)
{
if( $this->isConsiderHiddenQuestionsEnabled() || !$this->isHiddenSequence($sequenceKey) )
{
$sequenceKeys[] = $sequenceKey;
}
}

return $sequenceKeys;
}

function getOrderedSequenceQuestions()
{
return $this->questions;
$questions = array();

foreach($this->questions as $questionId)
{
if( $this->isConsiderHiddenQuestionsEnabled() || !$this->isHiddenQuestion($questionId) )
{
$questions[] = $questionId;
}
}

return $questions;
}

function getUserSequence()
{
return $this->getCorrectedSequence(TRUE);
return $this->getCorrectedSequence();
}

function getUserSequenceQuestions()
{
$seq = $this->getCorrectedSequence(TRUE);
$seq = $this->getCorrectedSequence();
$found = array();
foreach ($seq as $sequence)
{
Expand All @@ -431,10 +458,10 @@ function getUserSequenceQuestions()
return $found;
}

protected function getCorrectedSequence($with_hidden_questions = FALSE)
protected function getCorrectedSequence()
{
$correctedsequence = $this->sequencedata["sequence"];
if (!$with_hidden_questions)
if( !$this->isConsiderHiddenQuestionsEnabled() )
{
if (is_array($this->sequencedata["hidden"]))
{
Expand Down Expand Up @@ -761,6 +788,22 @@ public function setAnsweringOptionalQuestionsConfirmed($answeringOptionalQuestio
{
$this->answeringOptionalQuestionsConfirmed = $answeringOptionalQuestionsConfirmed;
}

/**
* @return boolean
*/
public function isConsiderHiddenQuestionsEnabled()
{
return $this->considerHiddenQuestionsEnabled;
}

/**
* @param boolean $considerHiddenQuestionsEnabled
*/
public function setConsiderHiddenQuestionsEnabled($considerHiddenQuestionsEnabled)
{
$this->considerHiddenQuestionsEnabled = $considerHiddenQuestionsEnabled;
}
}

?>
16 changes: 8 additions & 8 deletions Modules/Test/classes/class.ilTestServiceGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,17 @@ public function getPassOverview(ilTestSession $testSession, $targetclass = "", $
$short ? ilTestPassOverviewTableGUI::CONTEXT_SHORT : ilTestPassOverviewTableGUI::CONTEXT_LONG,
(isset($_GET['pdf']) && $_GET['pdf'] == 1)
);

$considerHiddenQuestions = true;

if( $this->objectiveOrientedPresentationRequired() )
{
$table->setObjectiveOrientedPresentationEnabled(true);

require_once 'Modules/Course/classes/Objectives/class.ilLOTestQuestionAdapter.php';
$objectivesAdapter = ilLOTestQuestionAdapter::getInstance($testSession);

$considerHiddenQuestions = false;
}

$table->init();
Expand All @@ -226,15 +230,13 @@ public function getPassOverview(ilTestSession $testSession, $targetclass = "", $
$testSequence = $this->testSequenceFactory->getSequenceByPass($testSession, $pass);
$testSequence->loadFromDb();
$testSequence->loadQuestions();
$row['objectivesList'] = $this->buildQuestionRelatedObjectivesList(
$objectivesAdapter, $testSequence->getQuestionIds()
);
$row['objectivesList'] = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
$row['objectivesList']->loadObjectivesTitles();
}

if(!$short)
{
$result_array =& $this->object->getTestResult($active_id, $pass);
$result_array =& $this->object->getTestResult($active_id, $pass, false, $considerHiddenQuestions);
if(!$result_array['pass']['total_max_points'])
{
$percentage = 0;
Expand Down Expand Up @@ -959,14 +961,12 @@ protected function getGradingMessage($activeId)
return $gradingMessageBuilder->getMessage();
}

protected function buildQuestionRelatedObjectivesList(ilLOTestQuestionAdapter $objectivesAdapter, $questionIds)
protected function buildQuestionRelatedObjectivesList(ilLOTestQuestionAdapter $objectivesAdapter, ilTestSequence $testSequence)
{
require_once 'Modules/Test/classes/class.ilTestQuestionRelatedObjectivesList.php';
$questionRelatedObjectivesList = new ilTestQuestionRelatedObjectivesList();

$questionRelatedObjectivesList->setQuestionIds($questionIds);

$objectivesAdapter->buildQuestionRelatedObjectiveList($questionRelatedObjectivesList);
$objectivesAdapter->buildQuestionRelatedObjectiveList($testSequence, $questionRelatedObjectivesList);

return $questionRelatedObjectivesList;
}
Expand Down

0 comments on commit 39d29ab

Please sign in to comment.