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. 30
      main/survey/preview.php
  3. 1
      main/survey/reporting.php
  4. 72
      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
require_once ('../inc/global.inc.php');
$this_section=SECTION_COURSES;
$htmlHeadXtra[] = '<script type="text/javascript" language="javascript">

@ -34,11 +34,10 @@ $language_file = 'survey';
// including the global dokeos file
require ('../inc/global.inc.php');
// including additional libraries
//require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php");
require_once('survey.lib.php');
$this_section=SECTION_COURSES;
// Database table definitions
$table_survey = Database :: get_course_table(TABLE_SURVEY);
$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
$survey_id = Security::remove_XSS($_GET['survey_id']);
$survey_id = intval($_GET['survey_id']);
$survey_data = survey_manager::get_survey($survey_id);
if (empty($survey_data)) {
@ -88,6 +87,8 @@ if (!api_is_allowed_to_edit(false,true))
{
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
if (api_is_course_admin() || (api_is_course_admin() && $_GET['isStudentView']=='true') || api_is_allowed_to_session_edit(false,true)) {
// survey information
@ -142,10 +143,8 @@ if (api_is_course_admin() || (api_is_course_admin() && $_GET['isStudentView']=='
ORDER BY survey_question.sort, survey_question_option.sort ASC";
$result = Database::query($sql, __FILE__, __LINE__);
$question_counter_max = Database::num_rows($result);
$counter = 0;
$limit=0;
$questions = array();
$question_counter_max = Database::num_rows($result);
$limit=0;
while ($row = Database::fetch_array($result))
{
// 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;
}
$counter++;
$counter_question++;
}
}
}
@ -182,6 +181,7 @@ if (api_is_course_admin() || (api_is_course_admin() && $_GET['isStudentView']=='
$show = 0;
}
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)
{
foreach ($questions as $key=>$question)
@ -190,13 +190,16 @@ if (api_is_course_admin() || (api_is_course_admin() && $_GET['isStudentView']=='
$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>';
}
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 '</form>';
@ -205,5 +208,4 @@ if (api_is_course_admin() || (api_is_course_admin() && $_GET['isStudentView']=='
}
// Footer
Display :: display_footer();
?>
Display :: display_footer();

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

@ -2761,46 +2761,49 @@ class SurveyUtil {
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 '<div id="question_report_questionnumbers">'.get_lang('GoToQuestion').': ';
for($i=1; $i<=($survey_data['number_of_questions']); $i++ )
{
if ($offset <> $i-1)
if ($survey_data['number_of_questions'] > 0) {
echo '<div id="question_report_questionnumbers">'.get_lang('GoToQuestion').': ';
for($i=1; $i<=($survey_data['number_of_questions']); $i++ )
{
echo '<a href="reporting.php?action=questionreport&amp;survey_id='.Security::remove_XSS($_GET['survey_id']).'&amp;question='.($i-1).'">'.$i.'</a>';
if ($offset <> $i-1)
{
echo '<a href="reporting.php?action=questionreport&amp;survey_id='.Security::remove_XSS($_GET['survey_id']).'&amp;question='.($i-1).'">'.$i.'</a>';
}
else
{
echo $i;
}
if ($i < $survey_data['number_of_questions'])
{
echo ' | ';
}
}
echo '</div>';
// getting the question information
$sql = "SELECT * FROM $table_survey_question WHERE survey_id='".Database::escape_string($_GET['survey_id'])."' AND type<>'pagebreak' AND type<>'comment' ORDER BY sort ASC LIMIT ".$offset.",1";
$result = Database::query($sql, __FILE__, __LINE__);
$question = Database::fetch_array($result);
// navigate through the questions (next and previous)
if ($_GET['question'] <> 0)
{
echo '<a href="reporting.php?action='.Security::remove_XSS($_GET['action']).'&amp;survey_id='.$_GET['survey_id'].'&amp;question='.Security::remove_XSS($offset-1).'">'.Display::return_icon('prev.png',get_lang('PreviousQuestion'),array('align'=>'middle')).' '.get_lang('PreviousQuestion').'</a> ';
}
else
{
echo $i;
echo Display::return_icon('prev.png',get_lang('PreviousQuestion'),array('align'=>'middle')).' '.get_lang('PreviousQuestion').' ';
}
if ($i < $survey_data['number_of_questions'])
echo ' | ';
if ($_GET['question'] < ($survey_data['number_of_questions']-1))
{
echo ' | ';
echo '<a href="reporting.php?action='.Security::remove_XSS($_GET['action']).'&amp;survey_id='.Security::remove_XSS($_GET['survey_id']).'&amp;question='.Security::remove_XSS($offset+1).'">'.get_lang('NextQuestion').' '.Display::return_icon('next.png',get_lang('NextQuestion'),array('align'=>'middle')).'</a>';
}
else
{
echo get_lang('NextQuestion'). ' '.Display::return_icon('next.png',get_lang('NextQuestion'),array('align'=>'middle'));
}
}
echo '</div>';
// getting the question information
$sql = "SELECT * FROM $table_survey_question WHERE survey_id='".Database::escape_string($_GET['survey_id'])."' AND type<>'pagebreak' AND type<>'comment' ORDER BY sort ASC LIMIT ".$offset.",1";
$result = Database::query($sql, __FILE__, __LINE__);
$question = Database::fetch_array($result);
// navigate through the questions (next and previous)
if ($_GET['question'] <> 0)
{
echo '<a href="reporting.php?action='.Security::remove_XSS($_GET['action']).'&amp;survey_id='.$_GET['survey_id'].'&amp;question='.Security::remove_XSS($offset-1).'">'.Display::return_icon('prev.png',get_lang('PreviousQuestion'),array('align'=>'middle')).' '.get_lang('PreviousQuestion').'</a> ';
}
else
{
echo Display::return_icon('prev.png',get_lang('PreviousQuestion'),array('align'=>'middle')).' '.get_lang('PreviousQuestion').' ';
}
echo ' | ';
if ($_GET['question'] < ($survey_data['number_of_questions']-1))
{
echo '<a href="reporting.php?action='.Security::remove_XSS($_GET['action']).'&amp;survey_id='.Security::remove_XSS($_GET['survey_id']).'&amp;question='.Security::remove_XSS($offset+1).'">'.get_lang('NextQuestion').' '.Display::return_icon('next.png',get_lang('NextQuestion'),array('align'=>'middle')).'</a>';
}
else
{
echo get_lang('NextQuestion'). ' '.Display::return_icon('next.png',get_lang('NextQuestion'),array('align'=>'middle'));
}
echo '</div>';
@ -2808,6 +2811,9 @@ class SurveyUtil {
echo '<br />';
if ($question['type'] == 'score')
{
/** @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
require ('../inc/global.inc.php');
$this_section=SECTION_COURSES;
// including additional libraries
//require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php");

@ -39,12 +39,13 @@ $language_file = 'survey';
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 (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)."mail.lib.inc.php");
$this_section=SECTION_COURSES;
if (!api_is_allowed_to_edit(false,true))
{
Display :: display_header(get_lang('Survey'));

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

Loading…
Cancel
Save