Skip to content

Commit b30eca2

Browse files
committed
Merge branch 'master' into meta-testing
2 parents 685be46 + b58aa5e commit b30eca2

6 files changed

Lines changed: 20 additions & 47 deletions

File tree

app/V1Module/presenters/AssignmentSolutionsPresenter.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,12 @@ public function actionSetBonusPoints(string $id)
390390
$changedSolutions[] = $this->assignmentSolutionViewFactory->getSolutionData($solution);
391391
if ($assignment) {
392392
$best = $this->assignmentSolutions->findBestSolution($assignment, $author);
393-
if ($best->getId() !== $oldBest->getId()) {
393+
if (!$best || !$oldBest || $best->getId() !== $oldBest->getId()) {
394394
// best solution has changed, we need to report this
395-
if ($best->getId() !== $id) {
395+
if ($best && $best->getId() !== $id) {
396396
$changedSolutions[] = $this->assignmentSolutionViewFactory->getSolutionData($best);
397397
}
398-
if ($oldBest->getId() !== $id) {
398+
if ($oldBest && $oldBest->getId() !== $id) {
399399
$changedSolutions[] = $this->assignmentSolutionViewFactory->getSolutionData($oldBest);
400400
}
401401
}
@@ -498,7 +498,9 @@ public function actionSetFlag(string $id, string $flag)
498498

499499
// finally flush all changed to the database
500500
$this->assignmentSolutions->flush();
501-
$this->assignmentSolutions->refresh($oldBestSolution);
501+
if ($oldBestSolution) {
502+
$this->assignmentSolutions->refresh($oldBestSolution);
503+
}
502504

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

514516
// assemble response (all entities and stats that may have changed)
515-
$assignmentId = $solution->getAssignment()->getId();
516517
$groupOfSolution = $solution->getAssignment()->getGroup();
517518
if ($groupOfSolution === null) {
518519
throw new NotFoundException("Group for assignment '$id' was not found");
@@ -528,12 +529,16 @@ public function actionSetFlag(string $id, string $flag)
528529
$solution->getAssignment(),
529530
$solution->getSolution()->getAuthor()
530531
);
531-
if ($oldBestSolution->getId() !== $bestSolution->getId()) {
532+
if (!$oldBestSolution || !$bestSolution || $oldBestSolution->getId() !== $bestSolution->getId()) {
532533
// add old and current best solutions as well (since they have changed)
533-
$resSolutions[$oldBestSolution->getId()] =
534-
$this->assignmentSolutionViewFactory->getSolutionData($oldBestSolution);
535-
$resSolutions[$bestSolution->getId()] =
536-
$this->assignmentSolutionViewFactory->getSolutionData($bestSolution);
534+
if ($oldBestSolution) {
535+
$resSolutions[$oldBestSolution->getId()] =
536+
$this->assignmentSolutionViewFactory->getSolutionData($oldBestSolution);
537+
}
538+
if ($bestSolution) {
539+
$resSolutions[$bestSolution->getId()] =
540+
$this->assignmentSolutionViewFactory->getSolutionData($bestSolution);
541+
}
537542
}
538543

539544
$this->sendSuccessResponse([

app/V1Module/presenters/UploadedFilesPresenter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ public function actionContent(string $id, ?string $entry = null)
264264
// Remove UTF BOM prefix...
265265
$utf8bom = "\xef\xbb\xbf";
266266
$contents = Strings::replace($contents, "~^$utf8bom~");
267+
$contents = str_replace("\r\n", "\n", $contents); // normalize line endings
267268

268269
$fixedContents = @mb_convert_encoding($contents, 'UTF-8', 'UTF-8');
269270

app/config/permissions.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ permissions:
309309

310310
- allow: true
311311
resource: group
312-
role: empowered-supervisor
312+
role: supervisor
313313
actions:
314314
- viewExamLocksIPs
315315
conditions:

app/model/view/UserViewFactory.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private function getUserData(User $user, bool $canViewPrivate, bool $reallyShowE
8686
"isExternal" => $user->hasExternalAccounts(),
8787
"isAllowed" => $user->isAllowed(),
8888
"externalIds" => $this->getExternalIds($user, $reallyShowEverything),
89-
"ipLock" => $user->isIpLocked(),
89+
"ipLock" => $user->isIpLocked() ? $user->getIpLockRaw() : null,
9090
"groupLock" => $user->getGroupLock()?->getId(),
9191
"isGroupLockStrict" => $user->isGroupLockStrict(),
9292
];
@@ -96,8 +96,6 @@ private function getUserData(User $user, bool $canViewPrivate, bool $reallyShowE
9696
$uiData = $user->getUiData();
9797
$privateData["uiData"] = $uiData ? $uiData->getData() : null;
9898
$privateData["settings"] = $user->getSettings();
99-
// ipLock is replaced with actual IP address
100-
$privateData["ipLock"] = $user->isIpLocked() ? $user->getIpLockRaw() : null;
10199
$privateData["ipLockExpiration"] = $user->isIpLocked()
102100
? $user->getIpLockExpiration()?->getTimestamp() : null;
103101
$privateData["groupLockExpiration"] = $user->isGroupLocked()

recodex-api.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
%define name recodex-core
22
%define short_name api
33
%define install_dir /opt/%{name}
4-
%define version 2.16.1
5-
%define unmangled_version 9f2e984f03086c228016bc7e420bfa23d8c7e8b9
4+
%define version 2.17.0
5+
%define unmangled_version 8886b04634ad87c2657f7efed1211c2e4d2bbb65
66
%define release 1
77

88
Summary: ReCodEx core API component

tests/Presenters/GroupsPresenter.phpt

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,40 +1788,9 @@ class TestGroupsPresenter extends Tester\TestCase
17881788
);
17891789
}
17901790

1791-
public function testGetExamLocks()
1792-
{
1793-
$group = $this->prepExamGroup(); // logged in as supervisor
1794-
$student = $this->presenter->users->getByEmail("demoGroupMember1@example.com");
1795-
1796-
$now = (new DateTime())->getTimestamp();
1797-
$begin = $now - 7200;
1798-
$end = $now - 3600;
1799-
$group->setExamPeriod(DateTime::createFromFormat('U', $begin), DateTime::createFromFormat('U', $end));
1800-
$this->presenter->groups->persist($group);
1801-
1802-
$exam = new GroupExam($group, DateTime::createFromFormat('U', $begin), DateTime::createFromFormat('U', $end), false);
1803-
$this->presenter->groupExams->persist($exam);
1804-
1805-
$lock = new GroupExamLock($exam, $student, '1.2.3.4');
1806-
$this->presenter->groupExamLocks->persist($lock);
1807-
1808-
$payload = PresenterTestHelper::performPresenterRequest(
1809-
$this->presenter,
1810-
'V1:Groups',
1811-
'GET',
1812-
['action' => 'getExamLocks', 'id' => $group->getId(), 'examId' => $exam->getId()],
1813-
);
1814-
1815-
Assert::count(1, $payload);
1816-
Assert::equal($exam->getId(), $payload[0]['groupExamId']);
1817-
Assert::equal($student->getId(), $payload[0]['studentId']);
1818-
Assert::false(array_key_exists('remoteAddr', $payload[0])); // supervisor cannot se IPs
1819-
}
1820-
18211791
public function testGetExamLocksWithIPs()
18221792
{
18231793
$group = $this->prepExamGroup();
1824-
PresenterTestHelper::loginDefaultAdmin($this->container); // admin can see IPs
18251794
$student = $this->presenter->users->getByEmail("demoGroupMember1@example.com");
18261795

18271796
$now = (new DateTime())->getTimestamp();

0 commit comments

Comments
 (0)