Ejemplo n.º 1
0
 /**
  * @param \TYPO3\Sessions\Domain\Model\AcceptedSession $session
  * @validate $session \TYPO3\Sessions\Domain\Validator\SpeakerCollisionValidator
  * @return string
  */
 public function scheduleSessionAction(\TYPO3\Sessions\Domain\Model\AcceptedSession $session)
 {
     // update properties
     $this->acceptedSessionRepository->update($session);
     /** @var PersistenceManager $persistenceManager */
     $persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class);
     $persistenceManager->persistAll();
     // change type manually after extbase updated the object
     /** @var \TYPO3\CMS\Core\Database\DatabaseConnection $db */
     $db = $GLOBALS['TYPO3_DB'];
     $res = $db->exec_UPDATEquery('tx_sessions_domain_model_session', 'uid = ' . $session->getUid(), ['type' => ScheduledSession::class]);
     return 'success';
 }
 /**
  * Generate first timetable for sessions
  *
  * @param boolean $considerTopics
  * @param integer $iterations
  *
  * @validate $iterations NumberRangeValidator(minimum = 1, maximum = 20)
  */
 public function createTimeTableAction($considerTopics, $iterations)
 {
     // Generate Config Array
     // TODO: Extract to options or something else
     // Room and time slots
     $config['roomAndTimeData'][0]['timeSlots'] = 2;
     $config['roomAndTimeData'][0]['rooms'] = 6;
     $config['roomAndTimeData'][1]['timeSlots'] = 3;
     $config['roomAndTimeData'][1]['rooms'] = 6;
     $config['roomAndTimeData'][2]['timeSlots'] = 3;
     $config['roomAndTimeData'][2]['rooms'] = 6;
     $config['roomAndTimeData'][3]['timeSlots'] = 1;
     $config['roomAndTimeData'][3]['rooms'] = 6;
     // Begin and end of time slots
     $config['timeSlots'][0]['begin'] = "09:30";
     $config['timeSlots'][0]['end'] = "11:00";
     $config['timeSlots'][1]['begin'] = "14:00";
     $config['timeSlots'][1]['end'] = "15:30";
     $config['timeSlots'][2]['begin'] = "16:30";
     $config['timeSlots'][2]['end'] = "18:00";
     // Dates of the event
     $config['dates'][] = "01.09.2016";
     $config['dates'][] = "02.09.2016";
     $config['dates'][] = "03.09.2016";
     $config['dates'][] = "04.09.2016";
     // TODO: Alle ScheduledSessions umwandeln in AcceptedSessions
     // Get all sessions
     $sessions = $this->acceptedSessionRepository->getAllOrderByVoteCount()->toArray();
     // Get all rooms
     $rooms = $this->roomRepository->findAllLimited(6)->toArray();
     // Generate timetable with service
     $success = $this->createTimetableService->generateTimetable($config, $sessions, $rooms, $iterations, $considerTopics);
     $incompleteSessions = array();
     if (!$success) {
         $incompleteSessions = $this->createTimetableService->getUnassignedSessions();
     }
     // Save changes on sessions
     foreach ($this->createTimetableService->getAssignedSessions() as $assignedSession) {
         // TODO: Umwandeln aller zugewiesenen Sessions in ScheduledSessions
         /**
          * @var AcceptedSession $assignedSession
          */
         $assignedSession->_setProperty('type', \TYPO3\Sessions\Domain\Model\ScheduledSession::class);
         $this->anySessionRepository->update($assignedSession);
     }
     $this->redirect('index', 'SessionModule', 'sessions', array('incompleteSessions' => $incompleteSessions, 'creationDone' => true));
 }
 /**
  * Generate first timetable for sessions
  *
  * @param boolean $considerTopics
  * @param integer $iterations
  *
  * @validate $iterations NumberRangeValidator(minimum = 1, maximum = 20)
  */
 public function createTimeTableAction($considerTopics, $iterations)
 {
     // Generate Config Array
     // TODO: Extract to options or something else
     // Room and time slots
     $config['roomAndTimeData'][0]['timeSlots'] = 2;
     $config['roomAndTimeData'][0]['rooms'] = 6;
     $config['roomAndTimeData'][1]['timeSlots'] = 3;
     $config['roomAndTimeData'][1]['rooms'] = 6;
     $config['roomAndTimeData'][2]['timeSlots'] = 3;
     $config['roomAndTimeData'][2]['rooms'] = 6;
     $config['roomAndTimeData'][3]['timeSlots'] = 1;
     $config['roomAndTimeData'][3]['rooms'] = 6;
     // Begin and end of time slots
     $config['timeSlots'][0]['begin'] = "09:30";
     $config['timeSlots'][0]['end'] = "11:00";
     $config['timeSlots'][1]['begin'] = "14:00";
     $config['timeSlots'][1]['end'] = "15:30";
     $config['timeSlots'][2]['begin'] = "16:30";
     $config['timeSlots'][2]['end'] = "18:00";
     // Dates of the event
     $config['dates'][] = "01.09.2016";
     $config['dates'][] = "02.09.2016";
     $config['dates'][] = "03.09.2016";
     $config['dates'][] = "04.09.2016";
     // TODO: Alle ScheduledSessions umwandeln in AcceptedSessions
     // Get all sessions
     $sessions = $this->acceptedSessionRepository->getAllOrderByVoteCount()->toArray();
     // Get all rooms
     $rooms = $this->roomRepository->findAllLimited(6)->toArray();
     // Generate timetable with service
     $success = $this->createTimetableService->generateTimetable($config, $sessions, $rooms, $iterations, $considerTopics);
     $incompleteSessions = array();
     if (!$success) {
         $incompleteSessions = $this->createTimetableService->getUnassignedSessions();
     }
     /** @var \TYPO3\CMS\Core\Database\DatabaseConnection $db */
     $db = $GLOBALS['TYPO3_DB'];
     // Save changes on sessions
     /** @var AcceptedSession $assignedSession*/
     foreach ($this->createTimetableService->getAssignedSessions() as $assignedSession) {
         $this->anySessionRepository->update($assignedSession, true);
         $db->exec_UPDATEquery('tx_sessions_domain_model_session', 'uid = ' . $assignedSession->getUid(), ['type' => ScheduledSession::class]);
     }
     $this->redirect('index', 'SessionModule', 'sessions', ['incompleteSessions' => $incompleteSessions, 'creationDone' => true]);
 }