fixed tab selected and problems with survey is empty - see CT#463

skala
Cristian Fasanando 16 years ago
parent faf3268194
commit 07a1e3e8f1
  1. 1
      main/survey/create_new_survey.php
  2. 24
      main/survey/preview.php
  3. 1
      main/survey/reporting.php
  4. 6
      main/survey/survey.lib.php
  5. 1
      main/survey/survey.php
  6. 3
      main/survey/survey_invite.php
  7. 1
      main/survey/survey_list.php

@ -35,6 +35,7 @@ $language_file = 'survey';
// including the global dokeos file // including the global dokeos file
require_once ('../inc/global.inc.php'); require_once ('../inc/global.inc.php');
$this_section=SECTION_COURSES;
$htmlHeadXtra[] = '<script type="text/javascript" language="javascript"> $htmlHeadXtra[] = '<script type="text/javascript" language="javascript">

@ -34,11 +34,10 @@ $language_file = 'survey';
// including the global dokeos file // including the global dokeos file
require ('../inc/global.inc.php'); require ('../inc/global.inc.php');
// including additional libraries
//require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php");
require_once('survey.lib.php'); require_once('survey.lib.php');
$this_section=SECTION_COURSES;
// Database table definitions // Database table definitions
$table_survey = Database :: get_course_table(TABLE_SURVEY); $table_survey = Database :: get_course_table(TABLE_SURVEY);
$table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION); $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
@ -56,7 +55,7 @@ if (!isset($_GET['survey_id']) OR !is_numeric($_GET['survey_id'])){
// getting the survey information // getting the survey information
$survey_id = Security::remove_XSS($_GET['survey_id']); $survey_id = intval($_GET['survey_id']);
$survey_data = survey_manager::get_survey($survey_id); $survey_data = survey_manager::get_survey($survey_id);
if (empty($survey_data)) { if (empty($survey_data)) {
@ -88,6 +87,8 @@ if (!api_is_allowed_to_edit(false,true))
{ {
Display :: display_error_message(get_lang('NotAllowed'), false); Display :: display_error_message(get_lang('NotAllowed'), false);
}*/ }*/
$counter_question = 0;
// only a course admin is allowed to preview a survey: you are a course admin // only a course admin is allowed to preview a survey: you are a course admin
if (api_is_course_admin() || (api_is_course_admin() && $_GET['isStudentView']=='true') || api_is_allowed_to_session_edit(false,true)) { if (api_is_course_admin() || (api_is_course_admin() && $_GET['isStudentView']=='true') || api_is_allowed_to_session_edit(false,true)) {
// survey information // survey information
@ -143,9 +144,7 @@ if (api_is_course_admin() || (api_is_course_admin() && $_GET['isStudentView']=='
$result = Database::query($sql, __FILE__, __LINE__); $result = Database::query($sql, __FILE__, __LINE__);
$question_counter_max = Database::num_rows($result); $question_counter_max = Database::num_rows($result);
$counter = 0;
$limit=0; $limit=0;
$questions = array();
while ($row = Database::fetch_array($result)) while ($row = Database::fetch_array($result))
{ {
// if the type is not a pagebreak we store it in the $questions array // if the type is not a pagebreak we store it in the $questions array
@ -164,7 +163,7 @@ if (api_is_course_admin() || (api_is_course_admin() && $_GET['isStudentView']=='
{ {
break; break;
} }
$counter++; $counter_question++;
} }
} }
} }
@ -182,6 +181,7 @@ if (api_is_course_admin() || (api_is_course_admin() && $_GET['isStudentView']=='
$show = 0; $show = 0;
} }
echo '<form id="question" name="question" method="post" action="'.api_get_self().'?survey_id='.Security::remove_XSS($survey_id).'&show='.$show.'">'; echo '<form id="question" name="question" method="post" action="'.api_get_self().'?survey_id='.Security::remove_XSS($survey_id).'&show='.$show.'">';
if(is_array($questions) && count($questions)>0) if(is_array($questions) && count($questions)>0)
{ {
foreach ($questions as $key=>$question) foreach ($questions as $key=>$question)
@ -190,13 +190,16 @@ if (api_is_course_admin() || (api_is_course_admin() && $_GET['isStudentView']=='
$display->render_question($question); $display->render_question($question);
} }
} }
if (($show < $numberofpages) OR !$_GET['show'])
if (($show < $numberofpages) || (!$_GET['show'] && count($questions) > 0))
{ {
//echo '<a href="'.api_get_self().'?survey_id='.$survey_id.'&amp;show='.$limit.'">NEXT</a>';
echo '<br /><button type="submit" name="next_survey_page" class="next">'.get_lang('NextQuestion').' </button>'; echo '<br /><button type="submit" name="next_survey_page" class="next">'.get_lang('NextQuestion').' </button>';
} }
if ($show >= $numberofpages AND $_GET['show']) if ($show >= $numberofpages && $_GET['show'] || ( isset($_GET['show']) && count($questions) == 0))
{ {
if (count($questions) == 0) {
echo '<p>'.get_lang('ThereAreNotQuestionsForthisSurvey').'</p>';
}
echo '<button type="submit" name="finish_survey" class="next">'.get_lang('FinishSurvey').' </button>'; echo '<button type="submit" name="finish_survey" class="next">'.get_lang('FinishSurvey').' </button>';
} }
echo '</form>'; echo '</form>';
@ -206,4 +209,3 @@ if (api_is_course_admin() || (api_is_course_admin() && $_GET['isStudentView']=='
// Footer // Footer
Display :: display_footer(); Display :: display_footer();
?>

@ -37,6 +37,7 @@ $language_file = 'survey';
// including the global dokeos file // including the global dokeos file
require ('../inc/global.inc.php'); require ('../inc/global.inc.php');
require_once('survey.lib.php'); require_once('survey.lib.php');
$this_section=SECTION_COURSES;
$survey_id = Security::remove_XSS($_GET['survey_id']); $survey_id = Security::remove_XSS($_GET['survey_id']);

@ -2761,6 +2761,8 @@ class SurveyUtil {
echo '<div class="actions">'; echo '<div class="actions">';
echo '<a href="reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview')).' '.get_lang('BackTo').' '.get_lang('ReportingOverview').'</a>'; echo '<a href="reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview')).' '.get_lang('BackTo').' '.get_lang('ReportingOverview').'</a>';
if ($survey_data['number_of_questions'] > 0) {
echo '<div id="question_report_questionnumbers">'.get_lang('GoToQuestion').': '; echo '<div id="question_report_questionnumbers">'.get_lang('GoToQuestion').': ';
for($i=1; $i<=($survey_data['number_of_questions']); $i++ ) for($i=1; $i<=($survey_data['number_of_questions']); $i++ )
{ {
@ -2802,12 +2804,16 @@ class SurveyUtil {
{ {
echo get_lang('NextQuestion'). ' '.Display::return_icon('next.png',get_lang('NextQuestion'),array('align'=>'middle')); echo get_lang('NextQuestion'). ' '.Display::return_icon('next.png',get_lang('NextQuestion'),array('align'=>'middle'));
} }
}
echo '</div>'; echo '</div>';
echo $question['survey_question']; echo $question['survey_question'];
echo '<br />'; echo '<br />';
if ($question['type'] == 'score') if ($question['type'] == 'score')
{ {
/** @todo this function should return the options as this is needed further in the code */ /** @todo this function should return the options as this is needed further in the code */

@ -14,6 +14,7 @@ $language_file = 'survey';
// including the global dokeos file // including the global dokeos file
require ('../inc/global.inc.php'); require ('../inc/global.inc.php');
$this_section=SECTION_COURSES;
// including additional libraries // including additional libraries
//require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php"); //require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php");

@ -39,12 +39,13 @@ $language_file = 'survey';
require ('../inc/global.inc.php'); require ('../inc/global.inc.php');
// including additional libraries // including additional libraries
//require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php");
require_once('survey.lib.php'); require_once('survey.lib.php');
require_once (api_get_path(LIBRARY_PATH)."course.lib.php"); require_once (api_get_path(LIBRARY_PATH)."course.lib.php");
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
require_once (api_get_path(LIBRARY_PATH)."mail.lib.inc.php"); require_once (api_get_path(LIBRARY_PATH)."mail.lib.inc.php");
$this_section=SECTION_COURSES;
if (!api_is_allowed_to_edit(false,true)) if (!api_is_allowed_to_edit(false,true))
{ {
Display :: display_header(get_lang('Survey')); Display :: display_header(get_lang('Survey'));

@ -40,6 +40,7 @@ if (!isset ($_GET['cidReq'])){
} }
// including the global dokeos file // including the global dokeos file
require ('../inc/global.inc.php'); require ('../inc/global.inc.php');
$this_section=SECTION_COURSES;
// including additional libraries // including additional libraries
//require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php"); //require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php");

Loading…
Cancel
Save