示例#1
0
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
// Language variables
if (isset($_GET['search']) && $_GET['search'] == 'advanced') {
    $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'survey/survey_list.php', 'name' => get_lang('SurveyList'));
    $tool_name = get_lang('SearchASurvey');
} else {
    $tool_name = get_lang('SurveyList');
}
// Header
Display::display_header($tool_name, 'Survey');
// Tool introduction
Display::display_introduction_section('survey', 'left');
// Action handling: searching
if (isset($_GET['search']) && $_GET['search'] == 'advanced') {
    SurveyUtil::display_survey_search_form();
}
// Action handling: deleting a survey
if (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['survey_id'])) {
    // Getting the information of the survey (used for when the survey is shared)
    $survey_data = survey_manager::get_survey($_GET['survey_id']);
    if (api_is_course_coach() && intval($_SESSION['id_session']) != $survey_data['session_id']) {
        // The coach can't delete a survey not belonging to his session
        api_not_allowed();
        exit;
    }
    // If the survey is shared => also delete the shared content
    if (is_numeric($survey_data['survey_share'])) {
        survey_manager::delete_survey($survey_data['survey_share'], true);
    }
    $return = survey_manager::delete_survey($_GET['survey_id']);