public function __construct(CourseSession $session)
 {
     $course = $session->getCourse();
     $workspace = $session->getWorkspace();
     $learnerRole = $session->getLearnerRole();
     $tutorRole = $session->getTutorRole();
     $details = [];
     $details['id'] = $session->getId();
     $details['name'] = $session->getName();
     $details['defaultSession'] = $session->isDefaultSession();
     $details['creationDate'] = $session->getCreationDate();
     $details['publicRegistration'] = $session->getPublicRegistration();
     $details['publicUnregistration'] = $session->getPublicUnregistration();
     $details['registrationValidation'] = $session->getRegistrationValidation();
     $details['startDate'] = $session->getStartDate();
     $details['endDate'] = $session->getEndDate();
     $details['extra'] = $session->getExtra();
     $details['userValidation'] = $session->getUserValidation();
     $details['organizationValidation'] = $session->getOrganizationValidation();
     $details['maxUsers'] = $session->getMaxUsers();
     $details['type'] = $session->getType();
     $details['courseId'] = $course->getId();
     $details['courseTitle'] = $course->getTitle();
     $details['courseCode'] = $course->getCode();
     if (!is_null($workspace)) {
         $details['workspaceId'] = $workspace->getId();
         $details['workspaceName'] = $workspace->getName();
         $details['workspaceCode'] = $workspace->getCode();
         $details['workspaceGuid'] = $workspace->getGuid();
     }
     if (!is_null($learnerRole)) {
         $details['learnerRoleId'] = $learnerRole->getId();
         $details['learnerRoleName'] = $learnerRole->getName();
         $details['learnerRoleKey'] = $learnerRole->getTranslationKey();
     }
     if (!is_null($tutorRole)) {
         $details['tutorRoleId'] = $tutorRole->getId();
         $details['tutorRoleName'] = $tutorRole->getName();
         $details['tutorRoleKey'] = $tutorRole->getTranslationKey();
     }
     parent::__construct(self::ACTION, $details);
 }
Exemplo n.º 2
0
 /**
  * @EXT\Route(
  *     "/course/session/{session}/self/register",
  *     name="claro_cursus_course_session_self_register",
  *     options={"expose"=true}
  * )
  * @EXT\ParamConverter("authenticatedUser", options={"authenticatedUser" = true})
  * @EXT\Template("ClarolineCursusBundle:Widget:coursesListForRegistrationWidget.html.twig")
  */
 public function courseSessionSelfRegisterAction(CourseSession $session, User $authenticatedUser)
 {
     if ($session->getPublicRegistration()) {
         if ($session->getRegistrationValidation()) {
             $this->cursusManager->addUserToSessionQueue($authenticatedUser, $session);
         } else {
             $this->cursusManager->registerUsersToSession($session, array($authenticatedUser), 0);
         }
     }
     return new JsonResponse('success', 200);
 }
Exemplo n.º 3
0
 /**
  * @EXT\Route(
  *     "/course/session/{session}/self/register",
  *     name="claro_cursus_course_session_self_register",
  *     options={"expose"=true}
  * )
  * @EXT\ParamConverter("authenticatedUser", options={"authenticatedUser" = true})
  */
 public function courseSessionSelfRegisterAction(CourseSession $session, User $authenticatedUser)
 {
     $results = null;
     if ($session->getPublicRegistration()) {
         if ($session->hasValidation()) {
             $this->cursusManager->addUserToSessionQueue($authenticatedUser, $session);
         } else {
             $results = $this->cursusManager->registerUsersToSession($session, [$authenticatedUser], 0);
         }
     }
     return new JsonResponse($results, 200);
 }
Exemplo n.º 4
0
 public function deleteCourseSession(CourseSession $session, $withWorkspace = false)
 {
     $course = $session->getCourse();
     $workspace = $session->getWorkspace();
     $learnerRole = $session->getLearnerRole();
     $tutorRole = $session->getTutorRole();
     $details = [];
     $details['id'] = $session->getId();
     $details['name'] = $session->getName();
     $details['defaultSession'] = $session->isDefaultSession();
     $details['creationDate'] = $session->getCreationDate();
     $details['publicRegistration'] = $session->getPublicRegistration();
     $details['publicUnregistration'] = $session->getPublicUnregistration();
     $details['registrationValidation'] = $session->getRegistrationValidation();
     $details['startDate'] = $session->getStartDate();
     $details['endDate'] = $session->getEndDate();
     $details['extra'] = $session->getExtra();
     $details['userValidation'] = $session->getUserValidation();
     $details['organizationValidation'] = $session->getOrganizationValidation();
     $details['maxUsers'] = $session->getMaxUsers();
     $details['type'] = $session->getType();
     $details['courseId'] = $course->getId();
     $details['courseTitle'] = $course->getTitle();
     $details['courseCode'] = $course->getCode();
     if (!is_null($workspace)) {
         $details['workspaceId'] = $workspace->getId();
         $details['workspaceName'] = $workspace->getName();
         $details['workspaceCode'] = $workspace->getCode();
         $details['workspaceGuid'] = $workspace->getGuid();
     }
     if (!is_null($learnerRole)) {
         $details['learnerRoleId'] = $learnerRole->getId();
         $details['learnerRoleName'] = $learnerRole->getName();
         $details['learnerRoleKey'] = $learnerRole->getTranslationKey();
     }
     if (!is_null($tutorRole)) {
         $details['tutorRoleId'] = $tutorRole->getId();
         $details['tutorRoleName'] = $tutorRole->getName();
         $details['tutorRoleKey'] = $tutorRole->getTranslationKey();
     }
     $this->om->startFlushSuite();
     $workspace = $session->getWorkspace();
     $this->om->remove($session);
     if ($withWorkspace && !is_null($workspace)) {
         $this->om->remove($tutorRole);
         $this->om->remove($learnerRole);
         $this->workspaceManager->deleteWorkspace($workspace);
     }
     $event = new LogCourseSessionDeleteEvent($details);
     $this->eventDispatcher->dispatch('log', $event);
     $this->om->endFlushSuite();
 }