Skip to content

Commit

Permalink
Test: Fix Error On No Selected Participant
Browse files Browse the repository at this point in the history
  • Loading branch information
kergomard committed Nov 22, 2023
1 parent a2fe4ad commit e244246
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
3 changes: 2 additions & 1 deletion components/ILIAS/Test/classes/class.ilObjTestGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ public function executeCommand(): void
$this->ctrl,
$this->tabs_gui,
$this->toolbar,
$this->test_question_set_config_factory->getQuestionSetConfig()
$this->test_question_set_config_factory->getQuestionSetConfig(),
$this->testrequest
);

$gui->setTestAccess($this->getTestAccess());
Expand Down
8 changes: 6 additions & 2 deletions components/ILIAS/Test/classes/class.ilTestDashboardGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
use ILIAS\UI\Factory as UIFactory;
use ILiAS\UI\Renderer as UIRenderer;

use ILIAS\Test\InternalRequestService;

/**
* Class ilTestDashboardGUI
*
Expand Down Expand Up @@ -50,7 +52,8 @@ public function __construct(
protected ilCtrl $ctrl,
protected ilTabsGUI $tabs,
protected ilToolbarGUI $toolbar,
protected ilTestQuestionSetConfig $question_set_config
protected ilTestQuestionSetConfig $question_set_config,
protected InternalRequestService $testrequest
) {
}

Expand Down Expand Up @@ -128,7 +131,8 @@ public function executeCommand(): void
$this->ctrl,
$this->db,
$this->tabs,
$this->toolbar
$this->toolbar,
$this->testrequest
);
$gui->setTestAccess($this->getTestAccess());
$gui->setObjectiveParent($this->getObjectiveParent());
Expand Down
18 changes: 11 additions & 7 deletions components/ILIAS/Test/classes/class.ilTestParticipantsGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
use ILIAS\UI\Factory as UIFactory;
use ILiAS\UI\Renderer as UIRenderer;

use ILIAS\Test\InternalRequestService;

/**
* Class ilTestParticipantsGUI
*
Expand Down Expand Up @@ -58,7 +60,8 @@ public function __construct(
protected ilCtrl $ctrl,
protected ilDBInterface $db,
protected ilTabsGUI $tabs,
protected ilToolbarGUI $toolbar
protected ilToolbarGUI $toolbar,
protected InternalRequestService $testrequest
) {
$this->participant_access_filter = new ilTestParticipantAccessFilterFactory($access);
}
Expand Down Expand Up @@ -328,15 +331,16 @@ protected function addFinishAllPassesButton(ilToolbarGUI $toolbar): void
protected function saveClientIpCmd(): void
{
$filter_closure = $this->participant_access_filter->getManageParticipantsUserFilter($this->getTestObj()->getRefId());
$a_user_ids = $filter_closure((array) $_POST["chbUser"]);
$selected_users = $filter_closure($this->testrequest->raw('chbUser') ?? []);

if (is_array($a_user_ids)) {
foreach ($a_user_ids as $user_id) {
$this->getTestObj()->setClientIP($user_id, $_POST["clientip_" . $user_id]);
}
} else {
if ($selected_users === []) {
$this->main_tpl->setOnScreenMessage('info', $this->lng->txt("select_one_user"), true);
}

foreach ($selected_users as $user_id) {
$this->getTestObj()->setClientIP($user_id, $_POST["clientip_" . $user_id]);
}

$this->ctrl->redirect($this, self::CMD_SHOW);
}

Expand Down
3 changes: 2 additions & 1 deletion components/ILIAS/Test/tests/ilTestDashboardGUITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ protected function setUp(): void
$DIC['ilCtrl'],
$DIC['ilTabs'],
$DIC['ilToolbar'],
$this->createMock(ilTestQuestionSetConfig::class)
$this->createMock(ilTestQuestionSetConfig::class),
$this->createMock(\ILIAS\Test\InternalRequestService::class)
);
}

Expand Down
3 changes: 2 additions & 1 deletion components/ILIAS/Test/tests/ilTestParticipantsGUITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ protected function setUp(): void
$DIC['ilCtrl'],
$DIC['ilDB'],
$DIC['ilTabs'],
$DIC['ilToolbar']
$DIC['ilToolbar'],
$this->createMock(\ILIAS\Test\InternalRequestService::class)
);
}

Expand Down

0 comments on commit e244246

Please sign in to comment.