From 11ce9efdf4c528654d36e8ee0b1faa34e65d086c Mon Sep 17 00:00:00 2001 From: Nils Haagen Date: Thu, 13 Jul 2023 15:40:59 +0200 Subject: [PATCH] TA, Question List: translate 'Dashboard', remove SideListGUI --- Modules/Test/classes/class.ilObjTest.php | 2 +- .../classes/class.ilTestPlayerAbstractGUI.php | 2 +- .../class.ilTestQuestionSideListGUI.php | 269 ------------------ .../test/ilTestQuestionSideListGUITest.php | 80 ------ Modules/Test/test/ilTestServiceGUITest.php | 14 +- lang/ilias_en.lang | 4 +- 6 files changed, 14 insertions(+), 357 deletions(-) delete mode 100644 Modules/Test/classes/class.ilTestQuestionSideListGUI.php delete mode 100644 Modules/Test/test/ilTestQuestionSideListGUITest.php diff --git a/Modules/Test/classes/class.ilObjTest.php b/Modules/Test/classes/class.ilObjTest.php index dc38466cb7ac..f817fbed313a 100755 --- a/Modules/Test/classes/class.ilObjTest.php +++ b/Modules/Test/classes/class.ilObjTest.php @@ -2244,7 +2244,7 @@ public function getProcessingTimeAsMinutes() */ public function getProcessingTimeInSeconds($active_id = ""): int { - if (preg_match("/(\d{2}):(\d{2}):(\d{2})/", $this->getProcessingTime(), $matches)) { + if ($this->getProcessingTime() && preg_match("/(\d{2}):(\d{2}):(\d{2})/", $this->getProcessingTime(), $matches)) { $extratime = $this->getExtraTime($active_id) * 60; return ($matches[1] * 3600) + ($matches[2] * 60) + $matches[3] + $extratime; } else { diff --git a/Modules/Test/classes/class.ilTestPlayerAbstractGUI.php b/Modules/Test/classes/class.ilTestPlayerAbstractGUI.php index 749d2c885ced..9db79f00a4cf 100755 --- a/Modules/Test/classes/class.ilTestPlayerAbstractGUI.php +++ b/Modules/Test/classes/class.ilTestPlayerAbstractGUI.php @@ -1453,7 +1453,7 @@ protected function showSideList($presentationMode, $currentSequenceElement) if ($row['worked_through'] || $row['isAnswered'] - || $row['sequence'] == $currentSequenceElement + //|| $row['sequence'] == $currentSequenceElement ) { $status = ILIAS\UI\Component\Listing\Workflow\Step::IN_PROGRESS; diff --git a/Modules/Test/classes/class.ilTestQuestionSideListGUI.php b/Modules/Test/classes/class.ilTestQuestionSideListGUI.php deleted file mode 100644 index 6961adccd3e8..000000000000 --- a/Modules/Test/classes/class.ilTestQuestionSideListGUI.php +++ /dev/null @@ -1,269 +0,0 @@ - - * @version $Id$ - * - * @package Modules/Test - */ -class ilTestQuestionSideListGUI -{ - /** - * @var ilCtrl - */ - protected $ctrl; - - /** - * @var ilLanguage - */ - protected $lng; - - /** - * @var ilTestPlayerAbstractGUI - */ - private $targetGUI; - - /** - * @var array - */ - private $questionSummaryData; - - /** - * @var integer - */ - private $currentSequenceElement; - - /** - * @var string - */ - private $currentPresentationMode; - - /** - * @var bool - */ - private $disabled; - - /** - * @param ilCtrl $ctrl - * @param ilLanguage $lng - */ - public function __construct(ilCtrl $ctrl, ilLanguage $lng) - { - $this->ctrl = $ctrl; - $this->lng = $lng; - - $this->questionSummaryData = array(); - $this->currentSequenceElement = null; - $this->disabled = false; - } - - /** - * @return ilTestPlayerAbstractGUI - */ - public function getTargetGUI(): ilTestPlayerAbstractGUI - { - return $this->targetGUI; - } - - /** - * @param ilTestPlayerAbstractGUI $targetGUI - */ - public function setTargetGUI($targetGUI) - { - $this->targetGUI = $targetGUI; - } - - /** - * @return array - */ - public function getQuestionSummaryData(): array - { - return $this->questionSummaryData; - } - - /** - * @param array $questionSummaryData - */ - public function setQuestionSummaryData($questionSummaryData) - { - $this->questionSummaryData = $questionSummaryData; - } - - /** - * @return int - */ - public function getCurrentSequenceElement(): ?int - { - return $this->currentSequenceElement; - } - - /** - * @param int $currentSequenceElement - */ - public function setCurrentSequenceElement($currentSequenceElement) - { - $this->currentSequenceElement = $currentSequenceElement; - } - - /** - * @return string - */ - public function getCurrentPresentationMode(): string - { - return $this->currentPresentationMode; - } - - /** - * @param string $currentPresentationMode - */ - public function setCurrentPresentationMode($currentPresentationMode) - { - $this->currentPresentationMode = $currentPresentationMode; - } - - /** - * @return boolean - */ - public function isDisabled(): bool - { - return $this->disabled; - } - - /** - * @param boolean $disabled - */ - public function setDisabled($disabled) - { - $this->disabled = $disabled; - } - - /** - * @return ilPanelGUI - */ - private function buildPanel(): ilPanelGUI - { - $panel = ilPanelGUI::getInstance(); - $panel->setHeadingStyle(ilPanelGUI::HEADING_STYLE_SUBHEADING); - $panel->setPanelStyle(ilPanelGUI::PANEL_STYLE_SECONDARY); - $panel->setHeading($this->lng->txt('list_of_questions')); - return $panel; - } - - /** - * @return string - */ - private function renderList(): string - { - $tpl = new ilTemplate('tpl.il_as_tst_list_of_questions_short.html', true, true, 'Modules/Test'); - - foreach ($this->getQuestionSummaryData() as $row) { - $title = ilLegacyFormElementsUtil::prepareFormOutput($row['title']); - - if (strlen($row['description'])) { - $description = " title=\"" . htmlspecialchars($row['description']) . "\" "; - } else { - $description = ""; - } - - $active = ($row['sequence'] == $this->getCurrentSequenceElement()) ? ' active' : ''; - - $class = ( - $row['worked_through'] ? 'answered' . $active : 'unanswered' . $active - ); - - $headerclass = ($row['sequence'] == $this->getCurrentSequenceElement()) ? 'bold' : ''; - - if ($row['marked']) { - $tpl->setCurrentBlock("mark_icon"); - $tpl->setVariable("ICON_SRC", ilUtil::getImagePath('marked.svg')); - $tpl->setVariable("ICON_TEXT", $this->lng->txt('tst_question_marked')); - $tpl->setVariable("ICON_CLASS", 'ilTestMarkQuestionIcon'); - $tpl->parseCurrentBlock(); - } - - if ($this->isDisabled() || $row['disabled']) { - $tpl->setCurrentBlock('disabled_entry'); - $tpl->setVariable('CLASS', $class); - $tpl->setVariable('HEADERCLASS', $headerclass); - $tpl->setVariable('ITEM', $title); - $tpl->setVariable('DESCRIPTION', $description); - $tpl->parseCurrentBlock(); - } else { - // fau: testNav - show mark icon in side list - // fau. - $tpl->setCurrentBlock('linked_entry'); - $tpl->setVariable('HREF', $this->buildLink($row['sequence'])); - $tpl->setVariable('NEXTCMD', ilTestPlayerCommands::SHOW_QUESTION); - $tpl->setVariable('NEXTSEQ', $row['sequence']); - $tpl->setVariable('HEADERCLASS', $headerclass); - $tpl->setVariable('CLASS', $class); - $tpl->setVariable('ITEM', $title); - $tpl->setVariable("DESCRIPTION", $description); - $tpl->parseCurrentBlock(); - } - - $tpl->setCurrentBlock('item'); - } - - return $tpl->get(); - } - - /** - * @return string - */ - public function getHTML(): string - { - $panel = $this->buildPanel(); - $panel->setBody($this->renderList()); - return $panel->getHTML(); - } - - /** - * @param $row - * @return string - */ - private function buildLink($sequenceElement): string - { - $this->ctrl->setParameter( - $this->getTargetGUI(), - 'pmode', - '' - ); - - $this->ctrl->setParameter( - $this->getTargetGUI(), - 'sequence', - $sequenceElement - ); - - $href = $this->ctrl->getLinkTarget($this->getTargetGUI(), ilTestPlayerCommands::SHOW_QUESTION); - - $this->ctrl->setParameter( - $this->getTargetGUI(), - 'pmode', - $this->getCurrentPresentationMode() - ); - $this->ctrl->setParameter( - $this->getTargetGUI(), - 'sequence', - $this->getCurrentSequenceElement() - ); - return $href; - } -} diff --git a/Modules/Test/test/ilTestQuestionSideListGUITest.php b/Modules/Test/test/ilTestQuestionSideListGUITest.php deleted file mode 100644 index ea29a12f4e60..000000000000 --- a/Modules/Test/test/ilTestQuestionSideListGUITest.php +++ /dev/null @@ -1,80 +0,0 @@ - - */ -class ilTestQuestionSideListGUITest extends ilTestBaseTestCase -{ - private ilTestQuestionSideListGUI $testObj; - - protected function setUp(): void - { - parent::setUp(); - - $this->testObj = new ilTestQuestionSideListGUI( - $this->createMock(ilCtrl::class), - $this->createMock(ilLanguage::class) - ); - } - - public function test_instantiateObject_shouldReturnInstance(): void - { - $this->assertInstanceOf(ilTestQuestionSideListGUI::class, $this->testObj); - } - - public function testTargetGUI(): void - { - $targetGui_mock = $this->createMock(ilTestPlayerAbstractGUI::class); - $this->testObj->setTargetGUI($targetGui_mock); - $this->assertEquals($targetGui_mock, $this->testObj->getTargetGUI()); - } - - public function testQuestionSummaryData(): void - { - $expected = [ - "test" => "Hello", - ]; - $this->testObj->setQuestionSummaryData($expected); - $this->assertEquals($expected, $this->testObj->getQuestionSummaryData()); - } - - public function testCurrentSequenceElement(): void - { - $this->testObj->setCurrentSequenceElement(125); - $this->assertEquals(125, $this->testObj->getCurrentSequenceElement()); - } - - public function testCurrentPresentationMode(): void - { - $this->testObj->setCurrentPresentationMode("test"); - $this->assertEquals("test", $this->testObj->getCurrentPresentationMode()); - } - - public function testDisabled(): void - { - $this->testObj->setDisabled(false); - $this->assertFalse($this->testObj->isDisabled()); - - $this->testObj->setDisabled(true); - $this->assertTrue($this->testObj->isDisabled()); - } -} diff --git a/Modules/Test/test/ilTestServiceGUITest.php b/Modules/Test/test/ilTestServiceGUITest.php index 08bf93213469..d6a9a00c6802 100644 --- a/Modules/Test/test/ilTestServiceGUITest.php +++ b/Modules/Test/test/ilTestServiceGUITest.php @@ -1,7 +1,5 @@ @@ -106,12 +106,18 @@ public function testBuildFixedShufflerSeedReturnsValidSeed(): void ] ]; - $reflection = new \ReflectionClass(ilTestServiceGUI::class); + $reflection = new \ReflectionClass(ilTestShuffler::class); $method = $reflection->getMethod('buildFixedShufflerSeed'); $method->setAccessible(true); + $refinery = new \ILIAS\Refinery\Factory( + new \ILIAS\Data\Factory(), + $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock() + ); + $shuffler = new ilTestShuffler($refinery); + foreach ($seeds as $seed) { - $fixed_seed = $method->invoke($this->testObj, $seed['question_id'], $seed['pass_id'], $seed['active_id']); + $fixed_seed = $method->invoke($shuffler, $seed['question_id'], $seed['pass_id'], $seed['active_id']); $this->assertEquals($seed['return'], $fixed_seed); } } diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index a0d052139892..12fafd4b6e07 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -1078,8 +1078,8 @@ assessment#:#question_marking#:#Flagging Questions assessment#:#question_marking_description#:#Participants are given the option to flag test questions for themselves. The flags are shown in the ‘List of Questions’, if that feature it has been activated. assessment#:#question_not_answered#:#The question was not answered assessment#:#question_saved_for_upload#:#The question was saved automatically in order to reserve hard disk space to store the uploaded file. If you cancel this form now, be aware that you must delete the question in the question pool if you do not want to keep it! -assessment#:#question_summary#:#Dashboard -assessment#:#question_summary_btn#:#Dashboard +assessment#:#question_summary#:#Test Pass Overview +assessment#:#question_summary_btn#:#Test Pass Overview assessment#:#question_title#:#Question Title assessment#:#question_type#:#Question Type assessment#:#questionpool_not_entered#:#Please enter a name for a question pool!