[svn r18472] Minor - avoiding warning message

skala
Julio Montoya 16 years ago
parent c755e50d6d
commit f11288b032
  1. 76
      main/survey/question.php
  2. 31
      main/survey/survey.lib.php

@ -23,7 +23,7 @@
* @package dokeos.survey
* @author unknown, the initial survey that did not make it in 1.8 because of bad code
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts of the code
* @version $Id: question.php 18176 2009-02-03 00:06:07Z cfasanando $
* @version $Id: question.php 18472 2009-02-12 18:00:38Z juliomontoya $
*/
// name of the language file that needs to be included
@ -37,8 +37,7 @@ require ('../inc/global.inc.php');
require_once('survey.lib.php');
/** @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))
{
if (!api_is_allowed_to_edit(false,true)) {
Display :: display_header();
Display :: display_error_message(get_lang('NotAllowed'), false);
Display :: display_footer();
@ -52,19 +51,15 @@ $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);
// getting the survey information
$survey_data = survey_manager::get_survey($_GET['survey_id']);
$urlname = substr(html_entity_decode($survey_data['title'],ENT_QUOTES,$charset), 0, 40);
if (strlen(strip_tags($survey_data['title'])) > 40)
{
if (strlen(strip_tags($survey_data['title'])) > 40) {
$urlname .= '...';
}
if($survey_data['survey_type']==1)
{
if($survey_data['survey_type']==1) {
$sql = 'SELECT id FROM '.Database :: get_course_table(TABLE_SURVEY_QUESTION_GROUP).' WHERE survey_id = '.(int)$_GET['survey_id'].' LIMIT 1';
$rs = api_sql_query($sql,__FILE__,__LINE__);
if(Database::num_rows($rs)===0) {
@ -78,12 +73,10 @@ $interbreadcrumb[] = array ("url" => 'survey_list.php', 'name' => get_lang('Surv
$interbreadcrumb[] = array ("url" => 'survey.php?survey_id='.$_GET['survey_id'], 'name' => $urlname);
// Tool name
if ($_GET['action'] == 'add')
{
if ($_GET['action'] == 'add') {
$tool_name = get_lang('AddQuestion');
}
if ($_GET['action'] == 'edit')
{
if ($_GET['action'] == 'edit') {
$tool_name = get_lang('EditQuestion');
}
@ -93,47 +86,41 @@ $possible_types = array('personality','yesno', 'multiplechoice', 'multiplerespon
// checking if it is a valid type
if (!in_array($_GET['type'], $possible_types))
{
Display::display_header($tool_name,'Survey');
Display :: display_header($tool_name,'Survey');
Display :: display_error_message(get_lang('TypeDoesNotExist'), false);
Display :: display_footer();
}
// displaying the form for adding or editing the question
if (empty($_POST['save_question']) && in_array($_GET['type'],$possible_types))
{
// Displaying the header
Display::display_header($tool_name,'Survey');
$error_message='';
// Displys message if exists
if (isset($_SESSION['temp_sys_message']))
{
$error_message=$_SESSION['temp_sys_message'];
unset($_SESSION['temp_sys_message']);
if ($error_message=='PleaseEnterAQuestion' || $error_message=='PleasFillAllAnswer'|| $error_message=='PleaseChooseACondition'|| $error_message=='ChooseDifferentCategories')
{
Display::display_error_message(get_lang($error_message), true);
}
if (empty($_POST['save_question']) && in_array($_GET['type'],$possible_types)) {
if (!isset($_POST['save_question'])) {
// Displaying the header
Display::display_header($tool_name,'Survey');
$error_message='';
// Displys message if exists
if (isset($_SESSION['temp_sys_message'])) {
$error_message=$_SESSION['temp_sys_message'];
unset($_SESSION['temp_sys_message']);
if ($error_message=='PleaseEnterAQuestion' || $error_message=='PleasFillAllAnswer'|| $error_message=='PleaseChooseACondition'|| $error_message=='ChooseDifferentCategories') {
Display::display_error_message(get_lang($error_message), true);
}
}
echo '<img src="../img/'.survey_manager::icon_question($_GET['type']).'" alt="'.get_lang(ucfirst($_GET['type'])).'" title="'.get_lang(ucfirst($_GET['type'])).'" /><br />';
echo get_lang(ucfirst($_GET['type']));
}
echo '<img src="../img/'.survey_manager::icon_question($_GET['type']).'" alt="'.get_lang(ucfirst($_GET['type'])).'" title="'.get_lang(ucfirst($_GET['type'])).'" /><br />';
echo get_lang(ucfirst($_GET['type']));
$form = new $_GET['type'];
// The defaults values for the form
$form_content['horizontalvertical'] = 'vertical2';
$form_content['answers'] = array('', '');
if ($_GET['type'] == 'yesno')
{
if ($_GET['type'] == 'yesno') {
$form_content['answers'][0]=get_lang('Yes');
$form_content['answers'][1]=get_lang('No');
}
if ($_GET['type'] == 'personality')
{
if ($_GET['type'] == 'personality') {
$form_content['answers'][0]=get_lang('1');
$form_content['answers'][1]=get_lang('2');
$form_content['answers'][2]=get_lang('3');
@ -148,20 +135,17 @@ if (empty($_POST['save_question']) && in_array($_GET['type'],$possible_types))
}
// We are editing a question
if (isset($_GET['question_id']) AND !empty($_GET['question_id']))
{
if (isset($_GET['question_id']) AND !empty($_GET['question_id'])) {
$form_content = survey_manager::get_question($_GET['question_id']);
}
// an action has been performed (for instance adding a possible answer, moving an answer, ...)
if ($_POST)
{
if ($_POST) {
$form_content = $_POST;
$form_content = $form->handle_action($form_content);
}
if ($error_message!='')
{
if ($error_message!='') {
$form_content['question']=$_SESSION['temp_user_message'];
$form_content['answers']=$_SESSION['temp_answers'];
$form_content['values']=$_SESSION['temp_values'];
@ -173,9 +157,7 @@ if (empty($_POST['save_question']) && in_array($_GET['type'],$possible_types))
$form->create_form($form_content);
$form->render_form();
}
else
{
} else {
$form_content = $_POST;
$form = new question();
$form->handle_action($form_content);

@ -24,7 +24,7 @@
* @package dokeos.survey
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts (if not all) of the code
@author Julio Montoya Armas <gugli100@gmail.com>, Dokeos: Personality Test modification and rewriting large parts of the code
* @version $Id: survey.lib.php 18382 2009-02-09 21:16:39Z juliomontoya $
* @version $Id: survey.lib.php 18472 2009-02-12 18:00:38Z juliomontoya $
*
* @todo move this file to inc/lib
* @todo use consistent naming for the functions (save vs store for instance)
@ -1465,37 +1465,28 @@ class question
}
// saving a question
if (isset($_POST['save_question']))
{
if (isset($_POST['save_question'])) {
$message = survey_manager::save_question($form_content);
if ($message == 'QuestionAdded' || $message == 'QuestionUpdated' )
{
if ($message == 'QuestionAdded' || $message == 'QuestionUpdated' ) {
$sql='SELECT COUNT(*) FROM '.Database :: get_course_table(TABLE_SURVEY_QUESTION).' WHERE survey_id = '.(int)$_GET['survey_id'];
$res = Database :: fetch_array (api_sql_query($sql, __FILE__, __LINE__));
if ($config['survey']['debug'])
{
if ($config['survey']['debug']) {
Display :: display_header();
Display :: display_confirmation_message($message.'<br />'.get_lang('ReturnTo').' <a href="survey.php?survey_id='.$_GET['survey_id'].'">'.get_lang('Survey').'</a>', false);
} else {
header('Location:survey.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'&message='.$message);
exit();
}
else
{
header('location:survey.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'&message='.$message);
}
}
else
{
if ($message == 'PleaseEnterAQuestion' || $message=='PleasFillAllAnswer'|| $message=='PleaseChooseACondition'|| $message=='ChooseDifferentCategories')
{
} else {
if ($message == 'PleaseEnterAQuestion' || $message=='PleasFillAllAnswer'|| $message=='PleaseChooseACondition'|| $message=='ChooseDifferentCategories') {
$_SESSION['temp_user_message']=$form_content['question'];
$_SESSION['temp_sys_message']=$message;
$_SESSION['temp_answers']=$form_content['answers'];
$_SESSION['temp_values']=$form_content['values'];
header('location:question.php?'.api_get_cidreq().'&question_id='.Security::remove_XSS($_GET['question_id']).'&survey_id='.Security::remove_XSS($_GET['survey_id']).'&action='.Security::remove_XSS($_GET['action']).'&type='.Security::remove_XSS($_GET['type']).'');
}
}
}
}

Loading…
Cancel
Save