Session: Adjust session-repetition logic and data association - refs BT#22057

pull/5831/head
Christian Beeznest 8 months ago
parent 4bb5dc7a51
commit b21643c713
  1. 6
      public/main/gradebook/index.php
  2. 7
      src/CoreBundle/Command/ReinscriptionCheckCommand.php
  3. 11
      src/CoreBundle/Command/SessionRepetitionCommand.php

@ -827,15 +827,13 @@ $hideCertificateExport = api_get_setting('hide_certificate_export_link');
$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(

@ -226,6 +226,13 @@ class ReinscriptionCheckCommand extends Command
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());

@ -160,19 +160,30 @@ class SessionRepetitionCommand extends Command
}
// 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;

Loading…
Cancel
Save