@@ -25,17 +25,18 @@ class Assignment extends AssignmentBase implements IExercise
2525 use ExerciseData;
2626
2727 /**
28- * @ORM\OneToMany(targetEntity="ExerciseFileLink", mappedBy="assignment", cascade={"persist"})
28+ * @ORM\OneToMany(targetEntity="ExerciseFileLink", mappedBy="assignment", cascade={"persist", "remove"},
29+ * orphanRemoval=true)
2930 * @var Collection<ExerciseFileLink>
3031 */
31- protected $ fileLinks ;
32+ protected $ exerciseFileLinks ;
3233
3334 /**
3435 * @return Collection<ExerciseFileLink>
3536 */
3637 public function getFileLinks (): Collection
3738 {
38- return $ this ->fileLinks ;
39+ return $ this ->exerciseFileLinks ;
3940 }
4041
4142 private function __construct (
@@ -91,7 +92,7 @@ private function __construct(
9192 $ this ->configurationType = $ exercise ->getConfigurationType ();
9293 $ this ->exerciseFiles = $ exercise ->getExerciseFiles ();
9394 $ this ->attachmentFiles = $ exercise ->getAttachmentFiles ();
94- $ this ->fileLinks = new ArrayCollection ();
95+ $ this ->exerciseFileLinks = new ArrayCollection ();
9596 $ this ->solutionFilesLimit = $ exercise ->getSolutionFilesLimit ();
9697 $ this ->solutionSizeLimit = $ exercise ->getSolutionSizeLimit ();
9798 }
@@ -125,7 +126,7 @@ public static function assignToGroup(
125126 // copy file links from exercise
126127 foreach ($ exercise ->getFileLinks () as $ link ) {
127128 $ newLink = ExerciseFileLink::copyForAssignment ($ link , $ assignment );
128- $ assignment ->fileLinks ->add ($ newLink );
129+ $ assignment ->exerciseFileLinks ->add ($ newLink );
129130 }
130131
131132 return $ assignment ;
@@ -599,10 +600,10 @@ public function syncWithExercise(array $options = []): void
599600 }
600601
601602 if ($ syncOptions ->fileLinks ) {
602- $ this ->fileLinks ->clear ();
603+ $ this ->exerciseFileLinks ->clear ();
603604 foreach ($ exercise ->getFileLinks () as $ link ) {
604605 $ newLink = ExerciseFileLink::copyForAssignment ($ link , $ this );
605- $ this ->fileLinks ->add ($ newLink );
606+ $ this ->exerciseFileLinks ->add ($ newLink );
606607 }
607608 }
608609
0 commit comments