/** * @param int $sessionAmount Amount of sessions to be created * @param float $recurringSpeakerPercentage Percentage of recurring speakers for all sessions * @param array $recurringSpeakersPerSessionPercentage Percentage of recurring speakers per session * @param bool $isPossibleAtAll Whether a valid result is possible at all, based on the given parameters * * + $recurringSpeakerPercentage * Example: "0.1" would end up in 10% of all speakers doing multiple sessions * + $recurringSpeakersPerSessionPercentage * The key defines the number of speakers per session, the value the percentage on all sessions. * Example: "[2 => 0.2, 3 => 0.1]" would be 20% of all sessions have 2 speakers, 10% have 3 speakers * * @test * @dataProvider scheduledSessionsAreFeasibleDataProvider */ public function scheduledSessionsAreFeasible($sessionAmount, $recurringSpeakerPercentage, array $recurringSpeakersPerSessionPercentage, $isPossibleAtAll) { $recurringSpeakerPercentage = $this->minMax($recurringSpeakerPercentage, 0.0, 1.0); $speakerAmount = $this->minMax((int) $sessionAmount * (1.0 - $recurringSpeakerPercentage), 1); $configuration = $this->createConfiguration(); $roomMaximum = $this->determineRoomMaximum($configuration); $sessionMaximum = $this->determineSessionMaximum($configuration); $rooms = $this->createRooms($roomMaximum); $speakers = $this->createSpeakers($speakerAmount); $sessions = $this->createSessions($sessionAmount, $speakers, $recurringSpeakersPerSessionPercentage); // Execute service to schedule sessions $result = $this->subject->generateTimetable($configuration, $sessions, $rooms); $assignedSessions = $this->subject->getAssignedSessions(); $unassignedSessions = $this->subject->getUnassignedSessions(); $this->assertLessThanOrEqual($sessionMaximum, count($assignedSessions), 'Assigned sessions exceeds possible session amout'); $this->assertEquals($sessionAmount, count($assignedSessions) + count($unassignedSessions), 'Amount of assigned and unassigned sessions does not sum up to total session amount'); $this->assertEquals($isPossibleAtAll && $sessionAmount <= $sessionMaximum, $result, 'Result value seems to be wrong'); }
/** * 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]); }