Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Move get session key for the pause reaosn to a common method #2448

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions model/Service/ConcurringSessionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
namespace oat\taoQtiTest\model\Service;

use common_Exception;
use common_exception_NotFound;
use oat\oatbox\service\ServiceManager;
use oat\tao\model\featureFlag\FeatureFlagCheckerInterface;
use oat\taoDelivery\model\execution\DeliveryExecution;
Expand Down Expand Up @@ -113,21 +114,23 @@ public function pauseConcurrentSessions(DeliveryExecution $activeExecution): voi

public function isConcurringSession(DeliveryExecution $execution): bool
{
$key = "pauseReason-{$execution->getOriginalIdentifier()}";
$key = $this->getPauseReasonSessionKey($execution);

return $this->currentSession->hasAttribute($key)
&& $this->currentSession->getAttribute($key) === self::PAUSE_REASON_CONCURRENT_TEST;
}

public function clearConcurringSession(DeliveryExecution $execution): void
{
$this->currentSession->removeAttribute("pauseReason-{$execution->getOriginalIdentifier()}");
$this->currentSession->removeAttribute(
$this->getPauseReasonSessionKey($execution)
);
}

public function setConcurringSession(string $executionId): void
{
$this->currentSession->setAttribute(
"pauseReason-{$executionId}",
$this->getPauseReasonSessionKey($executionId),
self::PAUSE_REASON_CONCURRENT_TEST
);
}
Expand Down Expand Up @@ -253,6 +256,19 @@ private function getContextByDeliveryExecution(DeliveryExecutionInterface $execu
);
}

/**
* @param DeliveryExecution|string $execution
* @throws common_exception_NotFound
*/
private function getPauseReasonSessionKey($execution): string
{
if ($execution instanceof DeliveryExecution) {
return "pauseReason-{$execution->getOriginalIdentifier()}";
}

return "pauseReason-{$execution}";
}

private function getTimerAdjustmentService(): TimerAdjustmentService
{
/** @noinspection PhpIncompatibleReturnTypeInspection */
Expand Down
Loading