, Ghent University: cleanup, refactoring and rewriting large parts of the code * @version $Id: question.php 21734 2009-07-02 17:12:41Z cvargas1 $ */ //require_once '../inc/global.inc.php'; $htmlHeadXtra[] = ''; /** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/ if (!api_is_allowed_to_edit(false, true)) { Display :: display_header(); Display :: display_error_message(get_lang('NotAllowed'), false); Display :: display_footer(); exit; } // Is valid request $is_valid_request = isset($_REQUEST['is_executable']) ? $_REQUEST['is_executable'] : null; // Database table definitions $table_survey = Database:: get_course_table(TABLE_SURVEY); $table_survey_question = Database:: get_course_table(TABLE_SURVEY_QUESTION); $table_survey_question_option = Database:: get_course_table(TABLE_SURVEY_QUESTION_OPTION); $table_course = Database:: get_main_table(TABLE_MAIN_COURSE); $table_user = Database:: get_main_table(TABLE_MAIN_USER); $course_id = api_get_course_int_id(); // Getting the survey information $surveyData = SurveyManager::get_survey($_GET['survey_id']); if (empty($surveyData)) { Display :: display_header(get_lang('ToolSurvey')); Display :: display_error_message(get_lang('InvallidSurvey'), false); Display :: display_footer(); exit; } $urlname = api_substr(api_html_entity_decode($surveyData['title'], ENT_QUOTES), 0, 40); if (api_strlen(strip_tags($surveyData['title'])) > 40) { $urlname .= '...'; } if ($surveyData['survey_type'] == 1) { $sql = 'SELECT id FROM '.Database :: get_course_table(TABLE_SURVEY_QUESTION_GROUP).' WHERE c_id = '.$course_id.' AND survey_id = '.(int)$_GET['survey_id'].' LIMIT 1'; $rs = Database::query($sql); if (Database::num_rows($rs)===0) { Display::addFlash( Display::return_message(get_lang('YouNeedToCreateGroups')) ); header('Location: '.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.(int)$_GET['survey_id'].'&'.api_get_cidreq()); exit; } } // Breadcrumbs $interbreadcrumb[] = array( 'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq(), 'name' => get_lang('SurveyList'), ); $interbreadcrumb[] = array( 'url' => api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.intval($_GET['survey_id']).'&'.api_get_cidreq(), 'name' => strip_tags($urlname), ); // Tool name if ($_GET['action'] == 'add') { $tool_name = get_lang('AddQuestion'); } if ($_GET['action'] == 'edit') { $tool_name = get_lang('EditQuestion'); } // The possible question types $possible_types = array( 'personality', 'yesno', 'multiplechoice', 'multipleresponse', 'open', 'dropdown', 'comment', 'pagebreak', 'percentage', 'score' ); // Actions $actions = '