Skip to content

Commit

Permalink
moved char selector btn #1
Browse files Browse the repository at this point in the history
  • Loading branch information
bheyser committed Aug 20, 2015
1 parent d4fd950 commit 7b0281c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 70 deletions.
36 changes: 0 additions & 36 deletions Modules/Test/classes/class.ilTestNavigationToolbarGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ class ilTestNavigationToolbarGUI extends ilToolbarGUI
*/
private $questionTreeVisible = false;

/**
* @var bool
*/
private $charSelectorButtonEnabled = false;

/**
* @var string
*/
Expand Down Expand Up @@ -141,22 +136,6 @@ public function setQuestionTreeVisible($questionTreeVisible)
$this->questionTreeVisible = $questionTreeVisible;
}

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

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

/**
* @return string
*/
Expand Down Expand Up @@ -206,11 +185,6 @@ public function build()
$this->addQuestionTreeButton();
}

if( $this->isCharSelectorButtonEnabled() )
{
$this->addCharSelectorButton();
}

$this->addFinishTestButton();
}

Expand Down Expand Up @@ -248,16 +222,6 @@ private function addQuestionTreeButton()
$this->addButtonInstance($btn);
}

private function addCharSelectorButton()
{
$btn = ilLinkButton::getInstance();
$btn->setId('charselectorbutton');
$btn->addCSSClass('ilCharSelectorToggle');
$btn->setCaption('char_selector_btn_label');
$btn->setDisabled($this->isDisabledStateEnabled());
$this->addButtonInstance($btn);
}

private function addFinishTestButton()
{
$btn = ilSubmitButton::getInstance();
Expand Down
62 changes: 28 additions & 34 deletions Modules/Test/classes/class.ilTestPlayerAbstractGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ protected function populateCharSelectorIfRequired()

protected function buildTestNavigationToolbarGUI($charSelectorAvailable, $isEditState)
{
global $ilUser, $ilSetting;
global $ilUser;

require_once 'Modules/Test/classes/class.ilTestNavigationToolbarGUI.php';
$navigationToolbarGUI = new ilTestNavigationToolbarGUI($this->ctrl, $this->lng, $this);
Expand All @@ -1691,7 +1691,6 @@ protected function buildTestNavigationToolbarGUI($charSelectorAvailable, $isEdit
$navigationToolbarGUI->setQuestionListButtonEnabled($this->object->getListOfQuestions());
$navigationToolbarGUI->setQuestionTreeButtonEnabled($this->object->getListOfQuestions());
$navigationToolbarGUI->setQuestionTreeVisible($ilUser->getPref('side_list_of_questions'));
$navigationToolbarGUI->setCharSelectorButtonEnabled($charSelectorAvailable);
$navigationToolbarGUI->setFinishTestCommand($this->getFinishTestCommand());

$navigationToolbarGUI->setDisabledStateEnabled($isEditState);
Expand All @@ -1707,12 +1706,35 @@ protected function buildReadOnlyStateQuestionNavigationGUI($questionId)
$navigationGUI = new ilTestQuestionNavigationGUI($this->lng);

$navigationGUI->setEditSolutionCommand('editSolution');
$this->populateMarkerConfigToQuestionNavigationGUI($navigationGUI, $questionId);

if($this->object->getShowMarker())
{
include_once "./Modules/Test/classes/class.ilObjTest.php";
$solved_array = ilObjTest::_getSolvedQuestions($this->testSession->getActiveId(), $questionId);
$solved = 0;

if(count($solved_array) > 0)
{
$solved = array_pop($solved_array);
$solved = $solved["solved"];
}

if($solved == 1)
{
$navigationGUI->setQuestionMarkCommand('unmarkQuestion');
$navigationGUI->setQuestionMarked(true);
}
else
{
$navigationGUI->setQuestionMarkCommand('markQuestion');
$navigationGUI->setQuestionMarked(false);
}
}

return $navigationGUI;
}

protected function buildEditableStateQuestionNavigationGUI($questionId)
protected function buildEditableStateQuestionNavigationGUI($questionId, $charSelectorAvailable)
{
require_once 'Modules/Test/classes/class.ilTestQuestionNavigationGUI.php';
$navigationGUI = new ilTestQuestionNavigationGUI($this->lng);
Expand Down Expand Up @@ -1751,37 +1773,9 @@ protected function buildEditableStateQuestionNavigationGUI($questionId)
}
}

return $navigationGUI;
}

/**
* @param integer $questionId
* @param ilTestQuestionNavigationGUI $navigationGUI
*/
protected function populateMarkerConfigToQuestionNavigationGUI(ilTestQuestionNavigationGUI $navigationGUI, $questionId)
{
if($this->object->getShowMarker())
{
include_once "./Modules/Test/classes/class.ilObjTest.php";
$solved_array = ilObjTest::_getSolvedQuestions($this->testSession->getActiveId(), $questionId);
$solved = 0;

if(count($solved_array) > 0)
{
$solved = array_pop($solved_array);
$solved = $solved["solved"];
}
$navigationGUI->setCharSelectorButtonEnabled($charSelectorAvailable);

if($solved == 1)
{
$navigationGUI->setQuestionMarkCommand('unmarkQuestion');
$navigationGUI->setQuestionMarked(true);
} else
{
$navigationGUI->setQuestionMarkCommand('markQuestion');
$navigationGUI->setQuestionMarked(false);
}
}
return $navigationGUI;
}

/**
Expand Down
12 changes: 12 additions & 0 deletions Modules/Test/classes/class.ilTestQuestionNavigationGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,16 @@ private function parseNavigation(ilTemplate $tpl)
$tpl->setCurrentBlock('question_related_navigation');
$tpl->parseCurrentBlock();
}

private function renderCharSelectorButton(ilTemplate $tpl)
{
$button = ilLinkButton::getInstance();
$button->setId('charselectorbutton');
$button->addCSSClass('ilCharSelectorToggle');
$button->setCaption('char_selector_btn_label');

$tpl->setCurrentBlock("submit_button");
$tpl->setVariable("SUBMIT_BTN", $button->render());
$tpl->parseCurrentBlock();
}
}

0 comments on commit 7b0281c

Please sign in to comment.