Skip to content

Commit

Permalink
Session: Adjust session-repetition logic and data association - refs …
Browse files Browse the repository at this point in the history
…BT#22057
  • Loading branch information
christianbeeznest committed Jan 6, 2025
1 parent 4bb5dc7 commit b21643c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
6 changes: 2 additions & 4 deletions public/main/gradebook/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -827,15 +827,13 @@ function confirmation() {
$category = null;
if (!empty($selectCat)) {
$repo = Container::getGradeBookCategoryRepository();
if (!empty($categoryId)) {
$category = $repo->find($selectCat);
}
$category = $repo->find($selectCat);
$course_id = CourseManager::get_course_by_category($selectCat);
$show_message = Category::show_message_resource_delete($course_id);
if (empty($show_message)) {
// Student
if (!api_is_allowed_to_edit() && !api_is_excluded_user_type()) {
if ($category) {
if (null !== $category) {
$certificate = Category::generateUserCertificate($category, $stud_id);
if ('true' !== $hideCertificateExport && isset($certificate['pdf_url'])) {
$actionsLeft .= Display::url(
Expand Down
7 changes: 7 additions & 0 deletions src/CoreBundle/Command/ReinscriptionCheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ private function enrollUserInSession($user, $newSession, $oldSession): void
if (!$existingSubscription) {
$newSession->addUserInSession(Session::STUDENT, $user);

foreach ($newSession->getCourses() as $sessionRelCourse) {
$course = $sessionRelCourse->getCourse();
if ($course) {
$newSession->addUserInCourse(Session::STUDENT, $user, $course);
}
}

$subscription = $this->findUserSubscriptionInSession($user, $oldSession);
if ($subscription) {
$subscription->setNewSubscriptionSessionId($newSession->getId());
Expand Down
11 changes: 11 additions & 0 deletions src/CoreBundle/Command/SessionRepetitionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,30 @@ private function duplicateSession(Session $session, bool $debug, OutputInterface
}

// Add courses to the new session
$courseCount = 0;
foreach ($courses as $sessionRelCourse) {
$course = $sessionRelCourse->getCourse();
if ($course) {
$newSession->addCourse($course);
$this->entityManager->persist($newSession);

if ($debug) {
$output->writeln(sprintf('Added course ID %d to session ID %d.', $course->getId(), $newSession->getId()));
}

$this->copyEvaluationsAndCategories($course->getId(), $session->getId(), $newSession->getId(), $debug, $output);

$courseCount++;
}
}

foreach ($session->getGeneralCoaches() as $coach) {
$newSession->addGeneralCoach($coach);
}

$newSession->setNbrCourses($courseCount);
$this->entityManager->persist($newSession);

$this->entityManager->flush();

return $newSession;
Expand Down

0 comments on commit b21643c

Please sign in to comment.