public function courseQueue(Course $course, User $user) { $now = new \DateTime(); $status = 0; $validators = $course->getValidators(); if ($course->getUserValidation()) { $status += CourseRegistrationQueue::WAITING_USER; } if ($course->getOrganizationValidation()) { $status += CourseRegistrationQueue::WAITING_ORGANIZATION; } if (count($validators) > 0) { $status += CourseRegistrationQueue::WAITING_VALIDATOR; } elseif ($course->getRegistrationValidation()) { $status += CourseRegistrationQueue::WAITING; } $courseQueue = new CourseRegistrationQueue(); $courseQueue->setUser($user); $courseQueue->setCourse($course); $courseQueue->setApplicationDate($now); $courseQueue->setStatus($status); $this->om->persist($courseQueue); return $courseQueue; }
public function __construct(Course $course) { $details = []; $details['id'] = $course->getId(); $details['title'] = $course->getTitle(); $details['code'] = $course->getCode(); $details['publicRegistration'] = $course->getPublicRegistration(); $details['publicUnregistration'] = $course->getPublicUnregistration(); $details['registrationValidation'] = $course->getRegistrationValidation(); $details['icon'] = $course->getIcon(); $details['tutorRoleName'] = $course->getTutorRoleName(); $details['learnerRoleName'] = $course->getLearnerRoleName(); $details['userValidation'] = $course->getUserValidation(); $details['organizationValidation'] = $course->getOrganizationValidation(); $details['maxUsers'] = $course->getMaxUsers(); $details['defaultSessionDuration'] = $course->getDefaultSessionDuration(); $details['withSessionEvent'] = $course->getWithSessionEvent(); $workspace = $course->getWorkspace(); $workspaceModel = $course->getWorkspaceModel(); if (!is_null($workspace)) { $details['workspaceId'] = $workspace->getId(); $details['workspaceName'] = $workspace->getName(); $details['workspaceCode'] = $workspace->getCode(); $details['workspaceGuid'] = $workspace->getGuid(); } if (!is_null($workspaceModel)) { $details['workspaceModelId'] = $workspaceModel->getId(); $details['workspaceModelName'] = $workspaceModel->getName(); } parent::__construct(self::ACTION, $details); }
/** * @EXT\Route( * "cursus/course/{course}/session/create/form", * name="claro_cursus_course_session_create_form", * options={"expose"=true} * ) * @EXT\ParamConverter("authenticatedUser", options={"authenticatedUser" = true}) * @EXT\Template("ClarolineCursusBundle:Course:courseSessionCreateModalForm.html.twig") */ public function courseSessionCreateFormAction(Course $course) { $session = new CourseSession(); $session->setPublicRegistration($course->getPublicRegistration()); $session->setPublicUnregistration($course->getPublicUnregistration()); $session->setRegistrationValidation($course->getRegistrationValidation()); $session->setMaxUsers($course->getMaxUsers()); $session->setUserValidation($course->getUserValidation()); $session->setOrganizationValidation($course->getOrganizationValidation()); $validators = $course->getValidators(); foreach ($validators as $validator) { $session->addValidator($validator); } $form = $this->formFactory->create(new CourseSessionType($this->cursusManager, $this->translator), $session); return ['form' => $form->createView(), 'course' => $course]; }
public function importCourses(array $datas) { $courses = array(); $i = 0; $usedCodes = $this->getAllCoursesCodes(); $this->om->startFlushSuite(); foreach ($datas as $data) { $course = new Course(); $code = $this->generateValidCode($data['code'], $usedCodes); $course->setCode($code); $course->setTitle($data['title']); $course->setDescription($data['description']); $course->setPublicRegistration($data['publicRegistration']); $course->setPublicUnregistration($data['publicUnregistration']); $course->setRegistrationValidation($data['registrationValidation']); if (isset($data['icon'])) { $course->setIcon($data['icon']); } $this->om->persist($course); $courses[$data['id']] = $course; $i++; if ($i % 50 === 0) { $this->om->forceFlush(); } } $this->om->endFlushSuite(); return $courses; }
/** * @EXT\Route( * "cursus/course/{course}/session/create/form", * name="claro_cursus_course_session_create_form", * options={"expose"=true} * ) * @EXT\ParamConverter("authenticatedUser", options={"authenticatedUser" = true}) * @EXT\Template("ClarolineCursusBundle:Course:courseSessionCreateModalForm.html.twig") */ public function courseSessionCreateFormAction(Course $course) { $session = new CourseSession(); $session->setPublicRegistration($course->getPublicRegistration()); $session->setPublicUnregistration($course->getPublicUnregistration()); $session->setRegistrationValidation($course->getRegistrationValidation()); $form = $this->formFactory->create(new CourseSessionType(), $session); return array('form' => $form->createView(), 'course' => $course); }
/** * @EXT\Route( * "/api/course/{course}/edit", * name="api_put_course_edition", * options = {"expose"=true} * ) * @EXT\ParamConverter("user", converter="current_user") * * Edits a course * * @return \Symfony\Component\HttpFoundation\JsonResponse */ public function putCourseEditionAction(Course $course) { $courseDatas = $this->request->request->get('courseDatas', false); $course->setTitle($courseDatas['title']); $course->setCode($courseDatas['code']); $description = $courseDatas['description'] ? $courseDatas['description'] : null; $course->setDescription($description); $course->setPublicRegistration((bool) $courseDatas['publicRegistration']); $course->setPublicUnregistration((bool) $courseDatas['publicUnregistration']); $course->setRegistrationValidation((bool) $courseDatas['registrationValidation']); $tutorRoleName = $courseDatas['tutorRoleName'] ? $courseDatas['tutorRoleName'] : null; $course->setTutorRoleName($tutorRoleName); $learnerRoleName = $courseDatas['learnerRoleName'] ? $courseDatas['learnerRoleName'] : null; $course->setLearnerRoleName($learnerRoleName); if ($courseDatas['workspace']) { $worskpace = $this->workspaceManager->getWorkspaceById($courseDatas['workspace']); $course->setWorkspace($worskpace); } else { $course->setWorkspace(null); } if ($courseDatas['workspaceModel']) { $worskpaceModel = $this->workspaceModelManager->getModelById($courseDatas['workspaceModel']); $course->setWorkspaceModel($worskpaceModel); } else { $course->setWorkspaceModel(null); } if ($this->request->files->get('courseDatas')['icon']) { $icon = $this->cursusManager->saveIcon($this->request->files->get('courseDatas')['icon']); $course->setIcon($icon); } $course->setUserValidation((bool) $courseDatas['userValidation']); $course->setOrganizationValidation((bool) $courseDatas['organizationValidation']); $maxUsers = $courseDatas['maxUsers'] ? $courseDatas['maxUsers'] : null; $course->setMaxUsers($maxUsers); $course->setDefaultSessionDuration($courseDatas['defaultSessionDuration']); $course->setWithSessionEvent((bool) $courseDatas['withSessionEvent']); $course->setDisplayOrder($courseDatas['displayOrder']); $course->emptyValidators(); $validators = isset($courseDatas['validators']) && count($courseDatas['validators']) > 0 ? $this->userManager->getUsersByIds($courseDatas['validators']) : []; foreach ($validators as $validator) { $course->addValidator($validator); } $this->cursusManager->persistCourse($course); $event = new LogCourseEditEvent($course); $this->eventDispatcher->dispatch('log', $event); $serializedCourse = $this->serializer->serialize($course, 'json', SerializationContext::create()->setGroups(['api_user_min'])); return new JsonResponse($serializedCourse, 200); }
public function isCourseValidator(User $user, Course $course) { $isValidator = false; $validators = $course->getValidators(); foreach ($validators as $validator) { if ($validator->getId() === $user->getId()) { $isValidator = true; break; } } return $isValidator; }