Exemplo n.º 1
0
                } else {
                    // Update
                    $sequenceResource->getSequence()->setGraphAndSerialize($graph);
                }
                $em->persist($sequenceResource);
                $em->flush();
                echo Display::return_message(get_lang('Saved'), 'success');
                break;
        }
        break;
    case 'get_requirements':
        $userId = api_get_user_id();
        switch ($type) {
            case SequenceResource::SESSION_TYPE:
                $session = api_get_session_info($id);
                $sequences = $repository->getRequirements($session['id'], $type);
                if (count($sequences) === 0) {
                    break;
                }
                $sequenceList = SequenceResourceManager::checkRequirementsForUser($sequences, $type, $userId);
                $allowSubscription = SequenceResourceManager::checkSequenceAreCompleted($sequenceList);
                $courseController = new CoursesController();
                $subscribeButton = '';
                if ($allowSubscription) {
                    $subscribeButton = $courseController->getRegisteredInSessionButton($session['id'], $session['name'], false);
                }
                echo Container::getTemplating()->render('@template_style/sequence_resource/session_requirements.html.twig', ['sequences' => $sequenceList, 'allow_subscription' => $allowSubscription, 'subscribe_button' => $subscribeButton]);
                break;
        }
        break;
}
Exemplo n.º 2
0
        }
    }
    $courses[] = ['course' => $sessionCourse, 'description' => $courseDescription, 'tags' => $courseTags, 'objectives' => $courseObjectives, 'topics' => $courseTopics, 'coaches' => $coachesData, 'extra_fields' => $courseValues->getAllValuesForAnItem($sessionCourse->getId())];
}
$sessionDates = SessionManager::parseSessionDates(['display_start_date' => $session->getDisplayStartDate(), 'display_end_date' => $session->getDisplayEndDate(), 'access_start_date' => $session->getAccessStartDate(), 'access_end_date' => $session->getAccessEndDate(), 'coach_access_start_date' => $session->getCoachAccessStartDate(), 'coach_access_end_date' => $session->getCoachAccessEndDate()]);
$sessionRequirements = $sequenceResourceRepo->getRequirements($session->getId(), SequenceResource::SESSION_TYPE);
$hasRequirements = false;
foreach ($sessionRequirements as $sequence) {
    if (!empty($sequence['requirements'])) {
        $hasRequirements = true;
        break;
    }
}
$courseController = new CoursesController();
/* View */
//$template = new Template($session->getName(), true, true, false, true, false);
$template = \Chamilo\CoreBundle\Framework\Container::getTwig();
$template->addGlobal('show_tutor', api_get_setting('session.show_session_coach') === 'true' ? true : false);
$template->addGlobal('pageUrl', api_get_path(WEB_PATH) . "session/{$session->getId()}/about/");
$template->addGlobal('session', $session);
$template->addGlobal('session_date', $sessionDates);
$template->addGlobal('is_subscribed', SessionManager::isUserSubscribedAsStudent($session->getId(), api_get_user_id()));
$template->addGlobal('subscribe_button', $courseController->getRegisteredInSessionButton($session->getId(), $session->getName(), $hasRequirements));
$template->addGlobal('courses', $courses);
$template->addGlobal('essence', \Essence\Essence::instance());
$template->addGlobal('session_extra_fields', $sessionValues->getAllValuesForAnItem($session->getId(), true));
$template->addGlobal('has_requirements', $hasRequirements);
$template->addGlobal('sequences', $sessionRequirements);
//$templateFolder = api_get_configuration_value('default_template');
echo $template->render('@template_style/session/about.html.twig');
//$template->assign('header', $session->getName());
Exemplo n.º 3
0
                }
                $em->persist($sequenceResource);
                $em->flush();
                echo Display::return_message(get_lang('Saved'), 'success');
                break;
        }
        break;
    case 'get_requirements':
        $userId = api_get_user_id();
        switch ($type) {
            case SequenceResource::SESSION_TYPE:
                $session = api_get_session_info($id);
                $sequences = $repository->getRequirements($session['id'], $type);
                if (count($sequences) === 0) {
                    break;
                }
                $sequenceList = SequenceResourceManager::checkRequirementsForUser($sequences, $type, $userId);
                $allowSubscription = SequenceResourceManager::checkSequenceAreCompleted($sequenceList);
                $courseController = new CoursesController();
                $view = new Template(null, false, false, false, false, false);
                $view->assign('sequences', $sequenceList);
                $view->assign('allow_subscription', $allowSubscription);
                if ($allowSubscription) {
                    $view->assign('subscribe_button', $courseController->getRegisteredInSessionButton($session['id'], $session['name'], false));
                }
                $template = $view->get_template('sequence_resource/session_requirements.tpl');
                $view->display($template);
                break;
        }
        break;
}