Skip to content

Commit

Permalink
Legacy Buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
mbecker-databay committed Oct 2, 2023
1 parent e6bef8b commit abf8b4b
Show file tree
Hide file tree
Showing 24 changed files with 279 additions and 360 deletions.
30 changes: 14 additions & 16 deletions Modules/Test/classes/class.ilMarkSchemaGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ protected function addMarkStep(): void
{
$this->ensureMarkSchemaCanBeEdited();

if ($this->saveMarkSchemaFormData()) {
$this->object->getMarkSchema()->addMarkStep();
} else {
$this->tpl->setOnScreenMessage('failure', $this->lng->txt('mark_schema_invalid'), true);
}
$this->object->getMarkSchema()->addMarkStep();
$this->showMarkSchema();
}

Expand Down Expand Up @@ -212,17 +208,19 @@ protected function showMarkSchema(): void
$mark_schema_table = new ilMarkSchemaTableGUI($this, 'showMarkSchema', $this->object);

if ($this->object->canEditMarks()) {
$create_simple_mark_schema_button = ilSubmitButton::getInstance();
$create_simple_mark_schema_button->setCaption($this->lng->txt('tst_mark_create_simple_mark_schema'), false);
$create_simple_mark_schema_button->setCommand('addSimpleMarkSchema');
$this->toolbar->addButtonInstance($create_simple_mark_schema_button);

$create_new_mark_step_button = ilButton::getInstance();
$create_new_mark_step_button->setCaption($this->lng->txt('tst_mark_create_new_mark_step'), false);
$create_new_mark_step_button->setButtonType(ilButton::BUTTON_TYPE_SUBMIT);
$create_new_mark_step_button->setForm('form_' . $mark_schema_table->getId());
$create_new_mark_step_button->setName('addMarkStep');
$this->toolbar->addButtonInstance($create_new_mark_step_button);
global $DIC;
$button = $DIC->ui()->factory()->button()->standard(
$this->lng->txt('tst_mark_create_simple_mark_schema'),
$this->ctrl->getFormAction($this, 'addSimpleMarkSchema')
);
$this->toolbar->addComponent($button);

$button = $DIC->ui()->factory()->button()->standard(
$this->lng->txt('tst_mark_create_new_mark_step'),
$this->ctrl->getFormAction($this, 'addMarkStep')
);
$this->toolbar->addComponent($button);

}


Expand Down
15 changes: 13 additions & 2 deletions Modules/Test/classes/class.ilObjTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ public function getProcessingTimeAsArray(): array
{
$processing_time = $this->getMainSettings()->getTestBehaviourSettings()->getProcessingTime();
if ($processing_time && $processing_time !== '') {
if (preg_match("/(\d{2}):(\d{2}):(\d{2})/is", $processing_time, $matches)) {
if (preg_match("/(\d{2}):(\d{2}):(\d{2})/is", (string) $processing_time, $matches)) {
return array(
'hh' => $matches[1],
'mm' => $matches[2],
Expand All @@ -1020,6 +1020,17 @@ public function getProcessingTimeAsArray(): array
}
}

public function getProcessingTimeAsMinutes()
{
if ($this->processing_time !== null) {
if (preg_match("/(\d{2}):(\d{2}):(\d{2})/is", (string)$this->processing_time, $matches)) {
return ($matches[1] * 60) + $matches[2];
}
}

return self::DEFAULT_PROCESSING_TIME_MINUTES;
}

/**
* Returns the processing time for the test in seconds
*
Expand All @@ -1030,7 +1041,7 @@ public function getProcessingTimeAsArray(): array
public function getProcessingTimeInSeconds($active_id = ""): int
{
$processing_time = $this->getMainSettings()->getTestBehaviourSettings()->getProcessingTime() ?? '';
if (preg_match("/(\d{2}):(\d{2}):(\d{2})/", $processing_time, $matches)) {
if (preg_match("/(\d{2}):(\d{2}):(\d{2})/", (string)$processing_time, $matches)) {
$extratime = $this->getExtraTime($active_id) * 60;
return ($matches[1] * 3600) + ($matches[2] * 60) + $matches[3] + $extratime;
} else {
Expand Down
14 changes: 5 additions & 9 deletions Modules/Test/classes/class.ilObjTestGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -2883,7 +2883,7 @@ public function buildPageViewToolbar($qid = 0)
if ($this->create_question_mode) {
return;
}

exit;
$this->ctrl->saveParameter($this, 'q_mode');

$this->ctrl->setParameterByClass('iltestexpresspageobjectgui', 'test_express_mode', 1);
Expand Down Expand Up @@ -2921,19 +2921,15 @@ public function buildPageViewToolbar($qid = 0)
$this->toolbar->addSeparator();
}

$btn = ilLinkButton::getInstance();
$btn->setCaption("test_prev_question");
$btn->setUrl($this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'));
$this->toolbar->addButtonInstance($btn);
$btn = $this->ui[0]->linkButton()->standard($lng->txt("test_prev_question"), $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'));
$this->toolbar->addComponent($btn);

if (count($options) <= 1 || $optionKeys[0] == $qid) {
$btn->setDisabled(true);
}

$btn = ilLinkButton::getInstance();
$btn->setCaption("test_next_question");
$btn->setUrl($this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'));
$this->toolbar->addButtonInstance($btn);
$btn = $this->ui[0]->linkButton()->standard($lng->txt("test_next_question"), $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'));
$this->toolbar->addComponent($btn);

if (count($options) <= 1 || $optionKeys[count($optionKeys) - 1] == $qid) {
$btn->setDisabled(true);
Expand Down
14 changes: 9 additions & 5 deletions Modules/Test/classes/class.ilParticipantsTestResultsGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class ilParticipantsTestResultsGUI
public const CMD_PERFORM_DELETE_ALL_USER_RESULTS = 'confirmDeleteAllUserResults';
public const CMD_CONFIRM_DELETE_SELECTED_USER_RESULTS = 'deleteSingleUserResults';
public const CMD_PERFORM_DELETE_SELECTED_USER_RESULTS = 'confirmDeleteSelectedUserData';
private \ILIAS\DI\UIServices $ui;

/**
* @var ilObjTest
*/
protected $testObj;

protected ?ilObjTest $test_obj = null;
protected ?ilTestQuestionSetConfig $question_set_config = null;
Expand Down Expand Up @@ -203,10 +209,8 @@ protected function showParticipantsCmd()

protected function addDeleteAllTestResultsButton(ilToolbarGUI $toolbar)
{
$delete_all_results_btn = ilLinkButton::getInstance();
$delete_all_results_btn->setCaption('delete_all_user_data');
$delete_all_results_btn->setUrl($this->ctrl->getLinkTarget($this, 'deleteAllUserResults'));
$toolbar->addButtonInstance($delete_all_results_btn);
$delete_all_results_btn = $this->ui_factory->button()->standard($this->lng->txt('delete_all_user_data'), $this->ctrl->getLinkTarget($this, 'deleteAllUserResults'));
$toolbar->addComponent($delete_all_results_btn);
}

/**
Expand Down Expand Up @@ -362,7 +366,7 @@ protected function showUserResults($show_pass_details, $show_answers, $show_reac
}


$template = $this->createUserResults($show_pass_details, $show_answers, $show_reached_points, $show_user_results);
$template = $this->createUserResults($show_pass_details, $show_answers, $show_reached_points, (bool)$show_user_results);

if ($template instanceof ilTemplate) {
$this->main_tpl->setVariable("ADM_CONTENT", $template->get());
Expand Down
11 changes: 5 additions & 6 deletions Modules/Test/classes/class.ilTestEvaluationGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
*/
class ilTestEvaluationGUI extends ilTestServiceGUI
{
private \ILIAS\DI\UIServices $ui;
protected ilTestAccess $testAccess;
protected ilTestProcessLockerFactory $processLockerFactory;

Expand All @@ -60,9 +61,9 @@ class ilTestEvaluationGUI extends ilTestServiceGUI
public function __construct(ilObjTest $object)
{
parent::__construct($object);

global $DIC;
$this->participant_access_filter = new ilTestParticipantAccessFilterFactory($this->access);

$this->ui = $DIC->ui();
$this->processLockerFactory = new ilTestProcessLockerFactory(
new ilSetting('assessment'),
$this->db
Expand Down Expand Up @@ -358,10 +359,8 @@ public function detailedEvaluation()

$this->tpl->addCss(ilUtil::getStyleSheetLocation('output', 'test_print.css', 'Modules/Test'), 'print');

$backBtn = ilLinkButton::getInstance();
$backBtn->setCaption('back');
$backBtn->setUrl($this->ctrl->getLinkTarget($this, 'outEvaluation'));
$this->toolbar->addInputItem($backBtn);
$backBtn = $this->ui->factory()->button()->standard($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'outEvaluation'));
$this->toolbar->addComponent($backBtn);

$this->object->setAccessFilteredParticipantList(
$this->object->buildStatisticsAccessFilteredParticipantList()
Expand Down
64 changes: 23 additions & 41 deletions Modules/Test/classes/class.ilTestNavigationToolbarGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,62 +280,44 @@ public function getFinishTestModalHTML(): string

private function addSuspendTestButton()
{
$btn = ilTestPlayerNavButton::getInstance();
$btn->setNextCommand(ilTestPlayerCommands::SUSPEND_TEST);
$btn->setUrl($this->ctrl->getLinkTarget(
$this->playerGUI,
ilTestPlayerCommands::SUSPEND_TEST
));
$btn->setCaption('cancel_test');
//$btn->setDisabled($this->isDisabledStateEnabled());
$btn->addCSSClass('ilTstNavElem');
$this->addButtonInstance($btn);
$button = $this->ui->factory()->button()->standard(
$this->lng->txt('cancel_test'),
$this->ctrl->getLinkTarget($this->playerGUI, ilTestPlayerCommands::SUSPEND_TEST)
);
$this->addComponent($button);
}

private function addQuestionListButton()
{
$btn = ilTestPlayerNavButton::getInstance();
$btn->setNextCommand(ilTestPlayerCommands::QUESTION_SUMMARY);
$btn->setUrl($this->ctrl->getLinkTarget(
$this->playerGUI,
ilTestPlayerCommands::QUESTION_SUMMARY
));
$btn->setCaption('question_summary_btn');
//$btn->setDisabled($this->isDisabledStateEnabled());
$btn->addCSSClass('ilTstNavElem');
$this->addButtonInstance($btn);
$button = $this->ui->factory()->button()->standard(
$this->lng->txt('question_summary_btn'),
$this->ctrl->getLinkTarget($this->playerGUI, ilTestPlayerCommands::QUESTION_SUMMARY)
);
$this->addComponent($button);
}

private function addQuestionSelectionButton()
{
$btn = ilTestPlayerNavButton::getInstance();
$btn->setNextCommand(ilTestPlayerCommands::SHOW_QUESTION_SELECTION);
$btn->setUrl($this->ctrl->getLinkTarget(
$this->playerGUI,
ilTestPlayerCommands::SHOW_QUESTION_SELECTION
));
$btn->setCaption('tst_change_dyn_test_question_selection');
//$btn->setDisabled($this->isDisabledStateEnabled());
$btn->addCSSClass('ilTstNavElem');
$this->addButtonInstance($btn);
$button = $this->ui->factory()->button()->standard(
$this->lng->txt('tst_change_dyn_test_question_selection'),
$this->ctrl->getLinkTarget($this->playerGUI, ilTestPlayerCommands::SHOW_QUESTION_SELECTION)
);
$this->addComponent($button);
}

private function addQuestionTreeButton()
{
$btn = ilTestPlayerNavButton::getInstance();
$btn->setNextCommand(ilTestPlayerCommands::TOGGLE_SIDE_LIST);
$btn->setUrl($this->ctrl->getLinkTarget(
$this->playerGUI,
ilTestPlayerCommands::TOGGLE_SIDE_LIST
));
if ($this->isQuestionTreeVisible()) {
$btn->setCaption('tst_hide_side_list');
$btn_cap = $this->lng->txt('tst_hide_side_list');
} else {
$btn->setCaption('tst_show_side_list');
$btn_cap = $this->lng->txt('tst_show_side_list');
}
//$btn->setDisabled($this->isDisabledStateEnabled());
$btn->addCSSClass('ilTstNavElem');
$this->addButtonInstance($btn);

$button = $this->ui->factory()->button()->standard(
$btn_cap,
$this->ctrl->getLinkTarget($this->playerGUI, ilTestPlayerCommands::TOGGLE_SIDE_LIST)
);
$this->addComponent($button);
}

private function addFinishTestButton(): void
Expand Down
2 changes: 1 addition & 1 deletion Modules/Test/classes/class.ilTestOutputGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ protected function showQuestionCmd()
$this->populateTestNavigationToolbar($navigationToolbarGUI);

// fau: testNav - enable the question navigation in edit mode
$this->populateQuestionNavigation($sequence_element, false, $isNextPrimary);
$this->populateQuestionNavigation($sequence_element, $isNextPrimary);
// fau.

if ($instantResponse) {
Expand Down
18 changes: 13 additions & 5 deletions Modules/Test/classes/class.ilTestParticipantsGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,23 @@ protected function addUserSearchControls(ilToolbarGUI $toolbar): void
$search_btn->setUrl($this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI', 'start'));

$toolbar->addSeparator();
$toolbar->addButtonInstance($search_btn);

$search_btn = $DIC->ui()->factory()->button()->standard(
$DIC->language()->txt('tst_search_users'),
$DIC->ctrl()->getLinkTargetByClass('ilRepositorySearchGUI', 'start')
);
$toolbar->addComponent($search_btn);
}

protected function addFinishAllPassesButton(ilToolbarGUI $toolbar): void
{
$finish_all_user_passes_btn = ilLinkButton::getInstance();
$finish_all_user_passes_btn->setCaption('finish_all_user_passes');
$finish_all_user_passes_btn->setUrl($this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'finishAllUserPasses'));
$toolbar->addButtonInstance($finish_all_user_passes_btn);
global $DIC; /* @var ILIAS\DI\Container $DIC */

$finish_all_user_passes_btn = $DIC->ui()->factory()->button()->standard(
$DIC->language()->txt('finish_all_user_passes'),
$DIC->ctrl()->getLinkTargetByClass('iltestevaluationgui', 'finishAllUserPasses')
);
$toolbar->addComponent($finish_all_user_passes_btn);
}

protected function saveClientIpCmd(): void
Expand Down
Loading

0 comments on commit abf8b4b

Please sign in to comment.