Пример #1
0
}
if ($action == 'empty') {
    $mysession = api_get_session_id();
    if ($mysession != 0) {
        if (!((api_is_course_coach() || api_is_platform_admin()) && api_is_element_in_the_session(TOOL_SURVEY, $_GET['survey_id']))) {
            // The coach can't empty a survey not belonging to his session
            api_not_allowed();
            exit;
        }
    } else {
        if (!(api_is_course_admin() || api_is_platform_admin())) {
            api_not_allowed();
            exit;
        }
    }
    $return = SurveyManager::empty_survey(intval($_GET['survey_id']));
    if ($return) {
        Display::display_confirmation_message(get_lang('SurveyEmptied'), false);
    } else {
        Display::display_error_message(get_lang('ErrorOccurred'), false);
    }
}
// Action handling: performing the same action on multiple surveys
if (isset($_POST['action']) && $_POST['action']) {
    if (is_array($_POST['id'])) {
        foreach ($_POST['id'] as $key => &$value) {
            // getting the information of the survey (used for when the survey is shared)
            $survey_data = SurveyManager::get_survey($value);
            // if the survey is shared => also delete the shared content
            if (is_numeric($survey_data['survey_share'])) {
                SurveyManager::delete_survey($survey_data['survey_share'], true);
Пример #2
0
$interbreadcrumb[] = array('url' => '../course_info/maintenance.php?' . api_get_cidreq(), 'name' => get_lang('Maintenance'));
// The section (for the tabs)
$this_section = SECTION_COURSES;
// Display the header
Display::display_header(get_lang('CopySurvey'));
echo Display::page_header(get_lang('CopySurvey'));
/* MAIN CODE */
// If a CourseSelectForm is posted or we should copy all resources, then copy them
if (Security::check_token('post')) {
    // Clear token
    Security::clear_token();
    $surveyId = intval($_POST['surveys']);
    $courseId = Security::remove_XSS($_POST['destination_course']);
    $surveyCopyId = SurveyManager::copy_survey($surveyId, null, $courseId);
    // Copy the survey to the target course
    SurveyManager::empty_survey($surveyCopyId, $courseId);
    // Empty the copied survey
    Display::display_confirmation_message(get_lang('SurveyCopied'));
}
$surveys = SurveyManager::get_surveys(api_get_course_id(), api_get_session_id());
$courses = CourseManager::get_courses_list();
$form = new FormValidator('copy_survey', 'post', 'copy_survey.php?' . api_get_cidreq());
if (!$surveys) {
    Display::display_error_message(get_lang('NoSurveyAvailable'));
}
if (count($courses) <= 1) {
    Display::display_error_message(get_lang('CourseListNotAvailable'));
}
if ($surveys && count($courses) > 1) {
    // Surveys select
    $options = array();