Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 15 additions & 10 deletions app/V1Module/presenters/AssignmentSolutionsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,12 @@ public function actionSetBonusPoints(string $id)
$changedSolutions[] = $this->assignmentSolutionViewFactory->getSolutionData($solution);
if ($assignment) {
$best = $this->assignmentSolutions->findBestSolution($assignment, $author);
if ($best->getId() !== $oldBest->getId()) {
if (!$best || !$oldBest || $best->getId() !== $oldBest->getId()) {
// best solution has changed, we need to report this
if ($best->getId() !== $id) {
if ($best && $best->getId() !== $id) {
$changedSolutions[] = $this->assignmentSolutionViewFactory->getSolutionData($best);
}
if ($oldBest->getId() !== $id) {
if ($oldBest && $oldBest->getId() !== $id) {
$changedSolutions[] = $this->assignmentSolutionViewFactory->getSolutionData($oldBest);
}
}
Expand Down Expand Up @@ -498,7 +498,9 @@ public function actionSetFlag(string $id, string $flag)

// finally flush all changed to the database
$this->assignmentSolutions->flush();
$this->assignmentSolutions->refresh($oldBestSolution);
if ($oldBestSolution) {
$this->assignmentSolutions->refresh($oldBestSolution);
}

// send notification email
$notificationMethod = $flag . 'FlagChanged';
Expand All @@ -512,7 +514,6 @@ public function actionSetFlag(string $id, string $flag)
}

// assemble response (all entities and stats that may have changed)
$assignmentId = $solution->getAssignment()->getId();
$groupOfSolution = $solution->getAssignment()->getGroup();
if ($groupOfSolution === null) {
throw new NotFoundException("Group for assignment '$id' was not found");
Expand All @@ -528,12 +529,16 @@ public function actionSetFlag(string $id, string $flag)
$solution->getAssignment(),
$solution->getSolution()->getAuthor()
);
if ($oldBestSolution->getId() !== $bestSolution->getId()) {
if (!$oldBestSolution || !$bestSolution || $oldBestSolution->getId() !== $bestSolution->getId()) {
// add old and current best solutions as well (since they have changed)
$resSolutions[$oldBestSolution->getId()] =
$this->assignmentSolutionViewFactory->getSolutionData($oldBestSolution);
$resSolutions[$bestSolution->getId()] =
$this->assignmentSolutionViewFactory->getSolutionData($bestSolution);
if ($oldBestSolution) {
$resSolutions[$oldBestSolution->getId()] =
$this->assignmentSolutionViewFactory->getSolutionData($oldBestSolution);
}
if ($bestSolution) {
$resSolutions[$bestSolution->getId()] =
$this->assignmentSolutionViewFactory->getSolutionData($bestSolution);
}
}

$this->sendSuccessResponse([
Expand Down
4 changes: 1 addition & 3 deletions app/model/view/UserViewFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private function getUserData(User $user, bool $canViewPrivate, bool $reallyShowE
"isExternal" => $user->hasExternalAccounts(),
"isAllowed" => $user->isAllowed(),
"externalIds" => $this->getExternalIds($user, $reallyShowEverything),
"ipLock" => $user->isIpLocked(),
"ipLock" => $user->isIpLocked() ? $user->getIpLockRaw() : null,
"groupLock" => $user->getGroupLock()?->getId(),
"isGroupLockStrict" => $user->isGroupLockStrict(),
];
Expand All @@ -96,8 +96,6 @@ private function getUserData(User $user, bool $canViewPrivate, bool $reallyShowE
$uiData = $user->getUiData();
$privateData["uiData"] = $uiData ? $uiData->getData() : null;
$privateData["settings"] = $user->getSettings();
// ipLock is replaced with actual IP address
$privateData["ipLock"] = $user->isIpLocked() ? $user->getIpLockRaw() : null;
$privateData["ipLockExpiration"] = $user->isIpLocked()
? $user->getIpLockExpiration()?->getTimestamp() : null;
$privateData["groupLockExpiration"] = $user->isGroupLocked()
Expand Down
4 changes: 2 additions & 2 deletions recodex-api.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
%define short_name api
%define install_dir /opt/%{name}
%define version 2.16.1
%define unmangled_version 9f2e984f03086c228016bc7e420bfa23d8c7e8b9
%define release 1
%define unmangled_version 1e145d5253dacbe64a8ed1050883834b05a8deeb
%define release 2

Summary: ReCodEx core API component
Name: %{name}
Expand Down