Skip to content

Commit

Permalink
Merge pull request #4654 from HochschuleLuzern/fix_32824_trunk
Browse files Browse the repository at this point in the history
Fix 32824 trunk
  • Loading branch information
mbecker-databay authored Jun 14, 2022
2 parents ed4a317 + 89f4c88 commit 25f3161
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 486 deletions.
69 changes: 47 additions & 22 deletions Modules/Test/classes/class.ilAssQuestionPageCommandForwarder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
<?php

/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

/**
* Class ilTestCtrlForwarder
Expand Down Expand Up @@ -28,56 +42,67 @@ public function setTestObj(ilObjTest $testObj) : void

public function forward() : void
{
global $DIC; /* @var ILIAS\DI\Container $DIC */
/* @var ILIAS\DI\Container $DIC */
global $DIC;
$ctrl = $DIC->ctrl();
$main_template = $DIC->ui()->mainTemplate();
$lng = $DIC->language();

$this->testrequest = $DIC->test()->internal()->request();
require_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php";

//echo $_REQUEST['prev_qid'];
if ($this->testrequest->raw('prev_qid')) {
$DIC->ctrl()->setParameter($this, 'prev_qid', $this->testrequest->raw('prev_qid'));
$ctrl->setParameter($this, 'prev_qid', $this->testrequest->raw('prev_qid'));
}

//global $___test_express_mode;
//$___test_express_mode = true;
$_GET['calling_test'] = $this->getTestObj()->getRefId();
include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
$DIC->ui()->mainTemplate()->setCurrentBlock("ContentStyle");
$DIC->ui()->mainTemplate()->setVariable(
$main_template->setCurrentBlock("ContentStyle");
$main_template->setVariable(
"LOCATION_CONTENT_STYLESHEET",
ilObjStyleSheet::getContentStylePath(0)
);
$DIC->ui()->mainTemplate()->parseCurrentBlock();
$main_template->parseCurrentBlock();

// syntax style
$DIC->ui()->mainTemplate()->setCurrentBlock("SyntaxStyle");
$DIC->ui()->mainTemplate()->setVariable(
$main_template->setCurrentBlock("SyntaxStyle");
$main_template->setVariable(
"LOCATION_SYNTAX_STYLESHEET",
ilObjStyleSheet::getSyntaxStylePath()
);
$DIC->ui()->mainTemplate()->parseCurrentBlock();
require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
$main_template->parseCurrentBlock();
$q_gui = assQuestionGUI::_getQuestionGUI("", $this->testrequest->getQuestionId());

$q_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
$q_gui->setQuestionTabs();
$q_gui->outAdditionalOutput();
$q_gui->object->setObjId($this->getTestObj()->getId());
$question = &$q_gui->object;
$DIC->ctrl()->saveParameter($this, "q_id");
$DIC->language()->loadLanguageModule("content");
$DIC->ctrl()->setReturnByClass("ilAssQuestionPageGUI", "view");
$DIC->ctrl()->setReturnByClass("ilObjTestGUI", "questions");

if ($ctrl->getCmd() === 'edit' && $question->isInActiveTest()) {
$main_template->setOnScreenMessage('failure', $lng->txt("question_is_part_of_running_test"));
$ctrl->redirectByClass('ilAssQuestionPreviewGUI', ilAssQuestionPreviewGUI::CMD_SHOW);
}

$ctrl->saveParameter($this, "q_id");
$lng->loadLanguageModule("content");
$ctrl->setReturnByClass("ilAssQuestionPageGUI", "view");
$ctrl->setReturnByClass("ilObjTestGUI", "questions");
$page_gui = new ilAssQuestionPageGUI($this->testrequest->getQuestionId());

$page_gui->setEditPreview(true);
if (strlen($DIC->ctrl()->getCmd()) == 0) {
$DIC->ctrl()->setCmdClass(get_class($page_gui));
$DIC->ctrl()->setCmd("preview");
if (strlen($ctrl->getCmd()) == 0) {
$ctrl->setCmdClass(get_class($page_gui));
$ctrl->setCmd("preview");
}
$page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(true)));
$page_gui->setTemplateTargetVar("ADM_CONTENT");
$page_gui->setOutputMode($this->getTestObj()->evalTotalPersons() == 0 ? "edit" : 'preview');
$page_gui->setHeader($question->getTitle());
$page_gui->setPresentationTitle($question->getTitle() . ' [' . $DIC->language()->txt('question_id_short') . ': ' . $question->getId() . ']');
$page_gui->setPresentationTitle($question->getTitle() . ' [' . $lng->txt('question_id_short') . ': ' . $question->getId() . ']');

$html = $DIC->ctrl()->forwardCommand($page_gui);
$DIC->ui()->mainTemplate()->setContent($html);
$html = $ctrl->forwardCommand($page_gui);
$main_template->setContent($html);
}
}
Loading

0 comments on commit 25f3161

Please sign in to comment.