diff --git a/main/survey/create_new_survey.php b/main/survey/create_new_survey.php index 4e4bb9597a..10615f8c05 100755 --- a/main/survey/create_new_survey.php +++ b/main/survey/create_new_survey.php @@ -1,55 +1,55 @@ , Ghent University: cleanup, refactoring and rewriting large parts (if not all) of the code -* @author Julio Montoya Armas , Dokeos: Personality Test modification and rewriting large parts of the code -* @version $Id: create_new_survey.php 22297 2009-07-22 22:08:30Z cfasanando $ -* -* @todo only the available platform languages should be used => need an api get_languages and and api_get_available_languages (or a parameter) -*/ - -// name of the language file that needs to be included + * @package chamilo.survey + * @author unknown, the initial survey that did not make it in 1.8 because of bad code + * @author Patrick Cool , Ghent University: cleanup, refactoring and rewriting large parts (if not all) of the code + * @author Julio Montoya Armas , Chamilo: Personality Test modification and rewriting large parts of the code + * @version $Id: create_new_survey.php 22297 2009-07-22 22:08:30Z cfasanando $ + * + * @todo only the available platform languages should be used => need an api get_languages and and api_get_available_languages (or a parameter) + */ + +// Language file that needs to be included $language_file = 'survey'; -// including the global dokeos file +// Including the global initialization file require_once '../inc/global.inc.php'; -$this_section=SECTION_COURSES; +$this_section = SECTION_COURSES; -// including additional libraries +// Including additional libraries /** @todo check if these are all needed */ /** @todo check if the starting / is needed. api_get_path probably ends with an / */ -//require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php"); -require_once('survey.lib.php'); -require_once (api_get_path(LIBRARY_PATH).'/fileManage.lib.php'); -require_once (api_get_path(CONFIGURATION_PATH) ."/add_course.conf.php"); -require_once (api_get_path(LIBRARY_PATH)."/add_course.lib.inc.php"); -require_once (api_get_path(LIBRARY_PATH)."/course.lib.php"); -require_once (api_get_path(LIBRARY_PATH)."/groupmanager.lib.php"); -require_once (api_get_path(LIBRARY_PATH)."/usermanager.lib.php"); -require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); +//require_once api_get_path(LIBRARY_PATH).'survey.lib.php'; +require_once 'survey.lib.php'; +require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; +require_once api_get_path(CONFIGURATION_PATH).'add_course.conf.php'; +require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php'; +require_once api_get_path(LIBRARY_PATH).'course.lib.php'; +require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; +require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; +require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; $htmlHeadXtra[] = ''; //jQuery $htmlHeadXtra[] = ''; // Database table definitions @@ -59,11 +59,9 @@ $table_course = Database :: get_main_table(TABLE_MAIN_COURSE); $table_course_survey_rel = Database :: get_main_table(TABLE_MAIN_COURSE_SURVEY); /** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/ -// if user is not teacher or if he's a coach trying to access an element out of his session -if (!api_is_allowed_to_edit()) -{ - if(!api_is_course_coach() || (!empty($_GET['survey_id']) && !api_is_element_in_the_session(TOOL_SURVEY,intval($_GET['survey_id'])))) - { +// If user is not teacher or if he's a coach trying to access an element out of his session +if (!api_is_allowed_to_edit()) { + if (!api_is_course_coach() || (!empty($_GET['survey_id']) && !api_is_element_in_the_session(TOOL_SURVEY, intval($_GET['survey_id'])))) { Display :: display_header(); Display :: display_error_message(get_lang('NotAllowed'), false); Display :: display_footer(); @@ -71,31 +69,29 @@ if (!api_is_allowed_to_edit()) } } -// getting the survey information -$survey_id = Security::remove_XSS($_GET['survey_id']); +// Getting the survey information +$survey_id = Security::remove_XSS($_GET['survey_id']); $survey_data = survey_manager::get_survey($survey_id); -$urlname = strip_tags(api_substr(api_html_entity_decode($survey_data['title'],ENT_QUOTES,$charset), 0, 40)); +$urlname = strip_tags(api_substr(api_html_entity_decode($survey_data['title'], ENT_QUOTES), 0, 40)); if (api_strlen(strip_tags($survey_data['title'])) > 40) { $urlname .= '...'; } -// breadcrumbs -if ($_GET['action'] == 'add') -{ - $interbreadcrumb[] = array ("url" => "survey_list.php", "name" => get_lang('SurveyList')); +// Breadcrumbs +if ($_GET['action'] == 'add') { + $interbreadcrumb[] = array('url' => 'survey_list.php', 'name' => get_lang('SurveyList')); $tool_name = get_lang('CreateNewSurvey'); } if ($_GET['action'] == 'edit' && is_numeric($survey_id)) { - $interbreadcrumb[] = array ("url" => "survey_list.php", "name" => get_lang('SurveyList')); - $interbreadcrumb[] = array ("url" => "survey.php?survey_id=".$survey_id, "name" => strip_tags($urlname)); + $interbreadcrumb[] = array('url' => 'survey_list.php', 'name' => get_lang('SurveyList')); + $interbreadcrumb[] = array('url' => 'survey.php?survey_id='.$survey_id, 'name' => strip_tags($urlname)); $tool_name = get_lang('EditSurvey'); } -// getting the default values -if ($_GET['action'] == 'edit' AND isset($survey_id) AND is_numeric($survey_id)) -{ +// Getting the default values +if ($_GET['action'] == 'edit' && isset($survey_id) && is_numeric($survey_id)) { $defaults = $survey_data; $defaults['survey_id'] = $survey_id; $defaults['anonymous'] = $survey_data['anonymous']; @@ -109,18 +105,17 @@ if ($_GET['action'] == 'edit' AND isset($survey_id) AND is_numeric($survey_id)) $defaults['anonymous'] = 0; } -// initiate the object +// Initialize the object $form = new FormValidator('survey', 'post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&survey_id='.$survey_id); $form->addElement('header', '', $tool_name); -// settting the form elements -if ($_GET['action'] == 'edit' AND isset($survey_id) AND is_numeric($survey_id)) -{ +// Settting the form elements +if ($_GET['action'] == 'edit' && isset($survey_id) && is_numeric($survey_id)) { $form->addElement('hidden', 'survey_id'); } -$survey_code = $form->addElement('text', 'survey_code', get_lang('SurveyCode'), array('size' => '20','maxlength'=>'20', 'id'=>'surveycode_title')); +$survey_code = $form->addElement('text', 'survey_code', get_lang('SurveyCode'), array('size' => '20', 'maxlength' => '20', 'id' => 'surveycode_title')); //$form->applyFilter('survey_code', 'html_filter'); if ($_GET['action'] == 'edit') { @@ -135,33 +130,33 @@ $form->addElement('html_editor', 'survey_subtitle', get_lang('SurveySubTitle'), //Language selection has been disabled. If you want to re-enable, please //disable the following line (hidden language field). $lang_array = api_get_languages(); -foreach ($lang_array['name'] as $key=>$value) { +foreach ($lang_array['name'] as $key => $value) { $languages[$lang_array['folder'][$key]] = $value; } $form->addElement('select', 'survey_language', get_lang('Language'), $languages); */ + // Pass the language of the survey in the form $form->addElement('hidden', 'survey_language'); $form->addElement('datepickerdate', 'start_date', get_lang('StartDate'), array('form_name'=>'survey')); $form->addElement('datepickerdate', 'end_date', get_lang('EndDate'), array('form_name'=>'survey')); -//$group=''; -//$group[] =& HTML_QuickForm::createElement('radio', 'survey_share',null, get_lang('Yes'),$form_share_value); -/** TODO maybe it is better to change this into false instead see line 95 in survey.lib.php */ -//$group[] =& HTML_QuickForm::createElement('radio', 'survey_share',null, get_lang('No'),0); +//$group = ''; +//$group[] =& HTML_QuickForm::createElement('radio', 'survey_share', null, get_lang('Yes'), $form_share_value); +/** TODO Maybe it is better to change this into false instead see line 95 in survey.lib.php */ +//$group[] =& HTML_QuickForm::createElement('radio', 'survey_share', null, get_lang('No'), 0); //$form->addGroup($group, 'survey_share', get_lang('ShareSurvey'), ' '); $form->addElement('checkbox', 'anonymous', get_lang('Anonymous')); $form->addElement('html_editor', 'survey_introduction', get_lang('SurveyIntroduction'), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '130', 'ToolbarStartExpanded' => false)); $form->addElement('html_editor', 'survey_thanks', get_lang('SurveyThanks'), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '130', 'ToolbarStartExpanded' => false)); - /* // Aditional Parameters $form -> addElement('html','');*/ @@ -169,27 +164,25 @@ $form -> addElement('html','
$surveytypes[0] = get_lang('Normal'); $surveytypes[1] = get_lang('Conditional'); - if ($_GET['action'] == 'add') { - $form->addElement('hidden','survey_type',0); - $form -> addElement('html','