@ -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.'&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();