public function session($name, Course $course, $status = 0) { $now = new \DateTime(); $session = new CourseSession(); $session->setName($name); $session->setCourse($course); $session->setCreationDate($now); $session->setSessionStatus($status); $this->om->persist($session); return $session; }
public function createCourseSession(Course $course, User $user, $sessionName = null, Cursus $cursus = null, $registrationDate = null, $startDate = null, $endDate = null) { if (is_null($registrationDate)) { $registrationDate = new \DateTime(); } $session = new CourseSession(); $session->setName($sessionName); $session->setCourse($course); $session->addCursu($cursus); $session->setCreationDate($registrationDate); $session->setPublicRegistration($course->getPublicRegistration()); $session->setPublicUnregistration($course->getPublicUnregistration()); $session->setRegistrationValidation($course->getRegistrationValidation()); $session->setStartDate($startDate); $session->setEndDate($endDate); $workspace = $this->generateWorkspace($course, $session, $user); $session->setWorkspace($workspace); $learnerRole = $this->generateRoleForSession($workspace, $course->getLearnerRoleName(), 0); $tutorRole = $this->generateRoleForSession($workspace, $course->getTutorRoleName(), 1); $session->setLearnerRole($learnerRole); $session->setTutorRole($tutorRole); $this->persistCourseSession($session); return $session; }
public function createCourseSession(Course $course, $name = null, $description = null, array $cursus = [], $creationDate = null, $startDate = null, $endDate = null, $defaultSession = false, $publicRegistration = false, $publicUnregistration = false, $registrationValidation = false, $userValidation = false, $organizationValidation = false, $maxUsers = null, $type = 0, array $validators = [], $eventRegistrationType = CourseSession::REGISTRATION_AUTO, $displayOrder = 500, $color = null) { if (is_null($creationDate)) { $creationDate = new \DateTime(); } $session = new CourseSession(); if ($name) { $session->setName($name); } foreach ($cursus as $c) { $session->addCursus($c); } $session->setDescription($description); $session->setCreationDate($creationDate); $session->setDefaultSession((bool) $defaultSession); $session->setPublicRegistration((bool) $publicRegistration); $session->setPublicUnregistration((bool) $publicUnregistration); $session->setRegistrationValidation((bool) $registrationValidation); $session->setUserValidation((bool) $userValidation); $session->setOrganizationValidation((bool) $organizationValidation); $session->setMaxUsers($maxUsers); $session->setType($type); $session->setEventRegistrationType($eventRegistrationType); $session->setDisplayOrder($displayOrder); $details = []; $details['color'] = $color; $total = $this->platformConfigHandler->hasParameter('cursus_session_default_total') ? $this->platformConfigHandler->getParameter('cursus_session_default_total') : null; $details['total'] = $total; $session->setDetails($details); if ($defaultSession) { $this->resetDefaultSessionByCourse($course); } if (is_null($startDate)) { $startDate = $creationDate; } $session->setStartDate($startDate); if (is_null($endDate)) { $endDate = clone $startDate; $endDate->add(new \DateInterval('P' . $course->getDefaultSessionDuration() . 'D')); } $session->setEndDate($endDate); foreach ($validators as $validator) { $session->addValidator($validator); } $this->createCourseSessionFromSession($session, $course); if ($course->getWithSessionEvent()) { $this->createSessionEvent($session); } return $session; }