Exercise: Add Help Link to Audio Question Types - refs BT#21319

pull/5099/head
christianbeeznst 10 months ago
parent 18d135dd2b
commit c3f67f73f6
  1. 6
      src/CoreBundle/Entity/CourseRelUser.php
  2. 2
      src/CoreBundle/Entity/TrackEAttemptQualify.php
  3. 30
      src/CoreBundle/EventSubscriber/AnonymousUserSubscriber.php

@ -60,12 +60,12 @@ class CourseRelUser implements Stringable
protected ?int $id = null;
#[Groups(['course:read', 'user:read', 'course_rel_user:read'])]
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'courses', cascade: ['persist'])]
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: User::class, cascade: ['persist'], inversedBy: 'courses')]
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
protected User $user;
#[Groups(['course_rel_user:read'])]
#[ORM\ManyToOne(targetEntity: Course::class, inversedBy: 'users', cascade: ['persist'])]
#[ORM\ManyToOne(targetEntity: Course::class, cascade: ['persist'], inversedBy: 'users')]
#[ORM\JoinColumn(name: 'c_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
protected Course $course;

@ -53,7 +53,7 @@ class TrackEAttemptQualify
protected ?string $answer;
#[ORM\ManyToOne(inversedBy: 'revisedAttempts')]
#[ORM\JoinColumn(name: 'exe_id', referencedColumnName: 'exe_id', nullable: false)]
#[ORM\JoinColumn(name: 'exe_id', referencedColumnName: 'exe_id', nullable: false, onDelete: 'CASCADE')]
private ?TrackEExercise $trackExercise = null;
public function __construct()

@ -6,8 +6,6 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\EventSubscriber;
use Chamilo\CoreBundle\Entity\TrackEAttemptQualify;
use Chamilo\CoreBundle\Entity\TrackEExercise;
use Chamilo\CoreBundle\Entity\TrackELogin;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Settings\SettingsManager;
@ -125,8 +123,6 @@ class AnonymousUserSubscriber implements EventSubscriberInterface
if ($oldestAnonymousUser) {
error_log('Deleting oldest anonymous user: '.$oldestAnonymousUser->getId());
$this->handleRelatedEntities($oldestAnonymousUser);
$this->entityManager->remove($oldestAnonymousUser);
$this->entityManager->flush();
}
@ -158,30 +154,4 @@ class AnonymousUserSubscriber implements EventSubscriberInterface
return $anonymousUser->getId();
}
private function handleRelatedEntities(User $user): void
{
$trackEExercisesRepository = $this->entityManager->getRepository(TrackEExercise::class);
$exercises = $trackEExercisesRepository->findBy(['user' => $user->getId()]);
foreach ($exercises as $exercise) {
$this->handleAttemptRecordings($exercise);
$this->entityManager->remove($exercise);
}
$this->entityManager->flush();
}
private function handleAttemptRecordings(TrackEExercise $exercise): void
{
$trackEAttemptRecordingRepository = $this->entityManager->getRepository(TrackEAttemptQualify::class);
$attemptRecordings = $trackEAttemptRecordingRepository->findBy(['trackExercise' => $exercise->getExeId()]);
foreach ($attemptRecordings as $attemptRecording) {
$this->entityManager->remove($attemptRecording);
}
}
}

Loading…
Cancel
Save