Skip to content

Commit 862985a

Browse files
committed
Fixing detection in changes of exercise-assignment file links for sync indication.
1 parent 427a010 commit 862985a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

app/model/entity/Assignment.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,18 +490,18 @@ public function areExerciseFileLinksInSync(): bool
490490
return false;
491491
}
492492

493-
// build index where keys are exercise file IDs
493+
// build an index where keys are keys (the only unique attribute)
494494
$fileIndex = [];
495495
foreach ($this->getFileLinks() as $link) {
496-
$fileIndex[$link->getExerciseFile()->getId()] = $link;
496+
$fileIndex[$link->getKey()] = $link;
497497
}
498498

499499
// verify that all exercise links are present and has the same data
500500
foreach ($exercise->getFileLinks() as $link) {
501-
$ourLink = $fileIndex[$link->getExerciseFile()->getId()] ?? null;
501+
$ourLink = $fileIndex[$link->getKey()] ?? null;
502502
if (
503503
$ourLink === null
504-
|| $ourLink->getKey() !== $link->getKey()
504+
|| $ourLink->getExerciseFile()->getId() !== $link->getExerciseFile()->getId()
505505
|| $ourLink->getRequiredRole() !== $link->getRequiredRole()
506506
|| $ourLink->getSaveName() !== $link->getSaveName()
507507
) {

0 commit comments

Comments
 (0)