Skip to content

Commit

Permalink
lok3 ILIAS-eLearning#6 (smeyer)
Browse files Browse the repository at this point in the history
  • Loading branch information
smeyer-ilias committed Aug 20, 2015
1 parent 9d14077 commit 4575aaf
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 30 deletions.
22 changes: 6 additions & 16 deletions Modules/Course/classes/Objectives/class.ilLOEditorGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -685,15 +685,17 @@ protected function deleteTest()
*/
protected function testAssignment(ilPropertyFormGUI $form = null)
{
$this->ctrl->setParameter($this,'tt',(int) $_REQUEST['tt']);
$this->setTestType((int) $_REQUEST['tt']);
$this->ctrl->setParameter($this,'tt',$this->getTestType());

switch($this->getTestType())
{
case ilLOSettings::TYPE_TEST_INITIAL:
$GLOBALS['ilTabs']->activateSubTab('itest');
$GLOBALS['ilTabs']->activateSubTab('itests');
break;

case ilLOSettings::TYPE_TEST_QUALIFIED:
$GLOBALS['ilTabs']->activateSubTab('qtest');
$GLOBALS['ilTabs']->activateSubTab('qtests');
break;
}
if(!$form instanceof ilPropertyFormGUI)
Expand Down Expand Up @@ -809,19 +811,13 @@ protected function initTestForm($a_as_multi_assignment = FALSE)

// title
$ti = new ilTextInputGUI($this->lng->txt("title"), "title");
$ti->setValue(
ilObject::_lookupTitle(ilObject::_lookupObjId($this->getSettings()->getTestByType($this->getTestType())))
);
$ti->setMaxLength(128);
$ti->setSize(40);
$ti->setRequired(true);
$new->addSubItem($ti);

// description
$ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
$ta->setValue(
ilObject::_lookupDescription(ilObject::_lookupObjId($this->getSettings()->getTestByType($this->getTestType())))
);
$ta->setCols(40);
$ta->setRows(2);
$new->addSubItem($ta);
Expand All @@ -831,11 +827,6 @@ protected function initTestForm($a_as_multi_assignment = FALSE)
$this->lng->loadLanguageModule('assessment');
$qst = new ilRadioGroupInputGUI($this->lng->txt('tst_question_set_type'),'qtype');
$qst->setRequired(true);
$qst->setValue(
$this->getSettings()->isRandomTestType($this->getTestType()) ?
ilObjTest::QUESTION_SET_TYPE_RANDOM:
ilObjTest::QUESTION_SET_TYPE_FIXED
);

$random = new ilRadioOption(
$this->lng->txt('tst_question_set_type_random'),
Expand Down Expand Up @@ -901,8 +892,7 @@ protected function initTestForm($a_as_multi_assignment = FALSE)
$objective->setRequired(TRUE);
$objective->setOptions($options);
$form->addItem($objective);
}

}

return $form;
}
Expand Down
17 changes: 17 additions & 0 deletions Modules/Course/classes/Objectives/class.ilLOTestAssignments.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ public function getAssignmentsByType($a_type)
}
return $by_type;
}

/**
* Get assignment by objective
* @param type $a_objective_id
* @return ilLOTestAssignment
*/
public function getAssignmentByObjective($a_objective_id)
{
foreach($this->assignments as $assignment)
{
if($assignment->getObjectiveId() == $a_objective_id)
{
return $assignment;
}
}
return FALSE;
}

/**
* Read assignments
Expand Down
2 changes: 0 additions & 2 deletions Modules/Course/classes/class.ilCourseObjectiveQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,6 @@ public static function lookupQuestionsByObjective($a_test_id, $a_objective)
'AND obj_id = '.$ilDB->quote($a_test_id,'integer');
$res = $ilDB->query($query);

$GLOBALS['ilLog']->write($query);

$questions = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
Expand Down
74 changes: 62 additions & 12 deletions Modules/Course/classes/class.ilCourseObjectivesTableGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,14 @@ public function __construct($a_parent_obj,$a_course_obj)
$this->addColumn($this->lng->txt('crs_objective_self_assessment'),'self');
}
// end-patch lok
$this->addColumn($this->lng->txt('crs_objective_final_test'),'final');
if($this->getSettings()->getQualifyingTestType() == ilLOSettings::TYPE_QUALIFYING_SELECTED)
{
$this->addColumn($this->lng->txt('crs_objective_tbl_col_final_tsts'),'final');
}
else
{
$this->addColumn($this->lng->txt('crs_objective_final_test'),'final');
}
$this->addColumn($this->lng->txt(''),'5em');

$this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
Expand Down Expand Up @@ -123,6 +130,8 @@ public function getSettings()
*/
protected function fillRow($a_set)
{
$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($a_set,TRUE));

$this->tpl->setVariable('VAL_ID',$a_set['id']);
$this->tpl->setVariable('VAL_POSITION',$a_set['position']);

Expand Down Expand Up @@ -226,20 +235,40 @@ protected function fillRow($a_set)
// end-patch lok

// final test questions
foreach((array) $a_set['final'] as $test)
if($this->getSettings()->getQualifyingTestType() == ilLOSettings::TYPE_QUALIFYING_SELECTED)
{
foreach((array) $test['questions'] as $question)
if($a_set['final'])
{
$this->tpl->setCurrentBlock('final_qst_row');
$this->tpl->setVariable('FINAL_QST_TITLE',$question['title']);
$obj_id = ilObject::_lookupObjId($a_set['final']);
$this->tpl->setCurrentBlock('final_test_per_objective');
$this->tpl->setVariable('FT_IMG', ilObject::_getIcon($obj_id, 'tiny'));
$this->tpl->setVariable('FT_ALT', $this->lng->txt('obj_tst'));
$this->tpl->setVariable('FT_TITLE',ilObject::_lookupTitle($obj_id));
$this->tpl->parseCurrentBlock();
}
// begin-patch lok
#$this->tpl->setCurrentBlock('final_test_row');
#$this->tpl->setVariable('FINAL_TST_ALT',$this->lng->txt('obj_tst'));
#$this->tpl->setVariable('FINAL_TST_TITLE',ilObject::_lookupTitle($test['obj_id']));
#$this->tpl->parseCurrentBlock();
// end-patch lok
else
{
$this->tpl->touchBlock('final_test_per_objective');
}
}
else
{
foreach((array) $a_set['final'] as $test)
{
foreach((array) $test['questions'] as $question)
{
$this->tpl->setCurrentBlock('final_qst_row');
$this->tpl->setVariable('FINAL_QST_TITLE',$question['title']);
$this->tpl->parseCurrentBlock();
}
// begin-patch lok
#$this->tpl->setCurrentBlock('final_test_row');
#$this->tpl->setVariable('FINAL_TST_IMG',ilUtil::getImagePath('icon_tst_s.png'));
#$this->tpl->setVariable('FINAL_TST_ALT',$this->lng->txt('obj_tst'));
#$this->tpl->setVariable('FINAL_TST_TITLE',ilObject::_lookupTitle($test['obj_id']));
#$this->tpl->parseCurrentBlock();
// end-patch lok
}
}

// begin-patch lok
Expand Down Expand Up @@ -386,7 +415,28 @@ public function parse($a_objective_ids)

// final test questions
// begin-patch lok
if($this->getSettings()->getQualifiedTest())
// single test assignments
if($this->getSettings()->getQualifyingTestType() == ilLOSettings::TYPE_QUALIFYING_SELECTED)
{
include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
$assignments = ilLOTestAssignments::getInstance($this->course_obj->getId());
$assignment = $assignments->getAssignmentByObjective($objective_id);

$objective_data['final'] = 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['final'] = $test_id;
}
}
}
elseif($this->getSettings()->getQualifiedTest())
{
if(ilLOUtils::lookupRandomTest(ilObject::_lookupObjId($this->getSettings()->getQualifiedTest())))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
<!-- BEGIN final_test_rnd -->
{SELF_QST_RND_TITLE}
<!-- BEGIN final_test_rnd -->
<!-- BEGIN final_test_per_objective -->
<img src="{FT_IMG}" alt="{FT_ALT}" title="{FT_ALT}" /> {FT_TITLE}
<!-- END final_test_per_objective -->
</td>
<td class="std">
<div class="editLink">
Expand Down

0 comments on commit 4575aaf

Please sign in to comment.