Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
smeyer-ilias committed Aug 21, 2015
1 parent 4575aaf commit f501c1d
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 19 deletions.
5 changes: 3 additions & 2 deletions Modules/Course/classes/Objectives/class.ilLOEditorGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,15 @@ protected function materials()
*/
protected function testsOverview()
{
$this->setTestType((int) $_REQUEST['tt']);
$this->ctrl->setParameter($this,'tt',$this->getTestType());

$GLOBALS['ilToolbar']->setFormAction($this->ctrl->getFormAction($this));
$GLOBALS['ilToolbar']->addButton(
$this->lng->txt('crs_loc_btn_new_assignment'),
$this->ctrl->getLinkTarget($this,'testAssignment')
);

$this->setTestType((int) $_REQUEST['tt']);
$this->ctrl->setParameter($this,'tt',$this->getTestType());

$settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId());
switch($this->getTestType())
Expand Down
8 changes: 8 additions & 0 deletions Modules/Course/classes/Objectives/class.ilLOSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ public function isQualifyingTestStart()
return $this->qt_start;
}

/**
* Check if separate initial test are configured
*/
public function hasSeparateInitialTests()
{
return $this->getInitialTestType() == self::TYPE_INITIAL_PLACEMENT_SELECTED || $this->getInitialTestType() == self::TYPE_INITIAL_QUALIFYING_SELECTED;
}

/**
* Check if test ref_id is used in an objective course
* @param int ref_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,17 @@ public function getAssignmentsByType($a_type)
/**
* Get assignment by objective
* @param type $a_objective_id
* @param type initial or final
* @return ilLOTestAssignment
*/
public function getAssignmentByObjective($a_objective_id)
public function getAssignmentByObjective($a_objective_id, $a_type)
{
foreach($this->assignments as $assignment)
{
if($assignment->getObjectiveId() == $a_objective_id)
if(
($assignment->getObjectiveId() == $a_objective_id) &&
($assignment->getAssignmentType() == $a_type)
)
{
return $assignment;
}
Expand Down
66 changes: 51 additions & 15 deletions Modules/Course/classes/class.ilCourseObjectivesTableGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,26 +210,42 @@ protected function fillRow($a_set)
// begin-patch lok
if($this->getSettings()->worksWithInitialTest())
{
foreach($a_set['self'] as $test)
if($this->getSettings()->hasSeparateInitialTests())
{
// begin-patch lok
foreach((array) $test['questions'] as $question)
if($a_set['initial'])
{
$this->tpl->setCurrentBlock('self_qst_row');
$this->tpl->setVariable('SELF_QST_TITLE',$question['title']);
$obj_id = ilObject::_lookupObjId($a_set['initial']);
$this->tpl->setCurrentBlock('initial_test_per_objective');
$this->tpl->setVariable('IT_IMG', ilObject::_getIcon($obj_id, 'tiny'));
$this->tpl->setVariable('IT_ALT', $this->lng->txt('obj_tst'));
$this->tpl->setVariable('IT_TITLE',ilObject::_lookupTitle($obj_id));
$this->tpl->parseCurrentBlock();
}
#$this->tpl->setCurrentBlock('self_test_row');
#$this->tpl->setVariable('SELF_TST_ALT',$this->lng->txt('obj_tst'));
#$this->tpl->setVariable('SELF_TST_TITLE',ilObject::_lookupTitle($test['obj_id']));
#$this->tpl->parseCurrentBlock();
// end-patch lok
else
{
$this->tpl->touchBlock('initial_test_per_objective');
}
}
// begin-patch lok
if(!count($a_set['self']))
else
{
$this->tpl->touchBlock('self_qst_row');
foreach($a_set['self'] as $test)
{
// begin-patch lok
foreach((array) $test['questions'] as $question)
{
$this->tpl->setCurrentBlock('self_qst_row');
$this->tpl->setVariable('SELF_QST_TITLE',$question['title']);
$this->tpl->parseCurrentBlock();
}
// end-patch lok
}
// begin-patch lok
if(!count($a_set['self']))
{
$this->tpl->touchBlock('self_qst_row');
}
}

// end-patch lok
}
// end-patch lok
Expand Down Expand Up @@ -376,7 +392,27 @@ public function parse($a_objective_ids)
// begin-patch lok
if($this->getSettings()->worksWithInitialTest())
{
if(ilLOUtils::lookupRandomTest(ilObject::_lookupObjId($this->getSettings()->getInitialTest())))
if($this->getSettings()->hasSeparateInitialTests())
{
include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
$assignments = ilLOTestAssignments::getInstance($this->course_obj->getId());
$assignment = $assignments->getAssignmentByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL);

$objective_data['initial'] = 0;
if($assignment instanceof ilLOTestAssignment)
{
$test_id = $assignment->getTestRefId();

include_once './Services/Object/classes/class.ilObjectFactory.php';
$factory = new ilObjectFactory();
$test_candidate = $factory->getInstanceByRefId($test_id,FALSE);
if($test_candidate instanceof ilObjTest)
{
$objective_data['initial'] = $test_id;
}
}
}
elseif(ilLOUtils::lookupRandomTest(ilObject::_lookupObjId($this->getSettings()->getInitialTest())))
{
$test = array();
include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
Expand Down Expand Up @@ -420,7 +456,7 @@ public function parse($a_objective_ids)
{
include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
$assignments = ilLOTestAssignments::getInstance($this->course_obj->getId());
$assignment = $assignments->getAssignmentByObjective($objective_id);
$assignment = $assignments->getAssignmentByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED);

$objective_data['final'] = 0;
if($assignment instanceof ilLOTestAssignment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
<!-- BEGIN with_self_test -->
<td class="std">
<!-- BEGIN self_qst_row --><p>{SELF_QST_TITLE}</p><!-- END self_qst_row -->
<!-- BEGIN initial_test_per_objective -->
<img src="{IT_IMG}" alt="{IT_ALT}" title="{IT_ALT}" /> {IT_TITLE}
<!-- END initial_test_per_objective -->
</td>
<!-- END with_self_test -->
<td class="std">
Expand Down

0 comments on commit f501c1d

Please sign in to comment.