Source for file preview.php
Documentation is available at preview.php
DOKEOS - elearning and course management software
For a full list of contributors, see documentation/credits.html
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See "documentation/licence.html" more details.
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
* @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: survey_list.php 10680 2007-01-11 21:26:23Z pcool $
* @todo use quickforms for the forms
// name of the language file that needs to be included
$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');
// Database table definitions
// We exit here if ther is no valid $_GET parameter
if (!isset ($_GET['survey_id']) OR !is_numeric($_GET['survey_id']))
// getting the survey information
$interbreadcrumb[] = array ("url" => 'survey_list.php', 'name' => get_lang('SurveyList'));
$interbreadcrumb[] = array ("url" => "survey.php?survey_id=". $_GET['survey_id'], "name" => $urlname);
// We exit here is the first or last question is a pagebreak (which causes errors)
// only a course admin is allowed to preview a survey: you are NOT a course admin => error message
// only a course admin is allowed to preview a survey: you are a course admin
echo '<div id="survey_title">'. $survey_data['survey_title']. '</div>';
echo '<div id="survey_subtitle">'. $survey_data['survey_subtitle']. '</div>';
// displaying the survey introduction
if (!isset ($_GET['show']))
echo '<div id="survey_content" class="survey_content">'. $survey_data['survey_introduction']. '</div>';
// displaying the survey thanks message
if ($_POST['finish_survey'])
echo '<div id="survey_content" class="survey_content"><strong>'. get_lang('SurveyFinished'). ' </strong>'. $survey_data['survey_thanks']. '</div>';
if (isset ($_GET['show']))
// Getting all the questions for this page and add them to a multidimensional array where the first index is the page.
// as long as there is no pagebreak fount we keep adding questions to the page
$questions_displayed = array();
$sql = "SELECT * FROM $table_survey_question
if($row['type'] == 'pagebreak')
$paged_questions[$counter][] = $row['question_id'];
$sql = "SELECT survey_question.question_id, survey_question.survey_id, survey_question.survey_question, survey_question.display, survey_question.sort, survey_question.type, survey_question.max_value,
survey_question_option.question_option_id, survey_question_option.option_text, survey_question_option.sort as option_sort
FROM $table_survey_question survey_question
LEFT JOIN $table_survey_question_option survey_question_option
ON survey_question.question_id = survey_question_option.question_id
ORDER BY survey_question.sort, survey_question_option.sort ASC";
// if the type is not a pagebreak we store it in the $questions array
if($row['type'] <> 'pagebreak')
$questions[$row['sort']]['question_id'] = $row['question_id'];
$questions[$row['sort']]['survey_id'] = $row['survey_id'];
$questions[$row['sort']]['survey_question'] = $row['survey_question'];
$questions[$row['sort']]['display'] = $row['display'];
$questions[$row['sort']]['type'] = $row['type'];
$questions[$row['sort']]['options'][intval($row['option_sort'])] = $row['option_text'];
$questions[$row['sort']]['maximum_score'] = $row['max_value'];
// if the type is a pagebreak we are finished loading the questions for this page
// selecting the maximum number of pages
// Displaying the form with the questions
if (isset ($_GET['show']))
$show = (int) $_GET['show'] + 1;
echo '<form id="question" name="question" method="post" action="'. api_get_self(). '?survey_id='. Security::remove_XSS($_GET['survey_id']). '&show='. $show. '">';
foreach ($questions as $key=> $question)
$display = new $question['type'];
$display->render_question($question);
if (($show < $numberofpages) OR !$_GET['show'])
//echo '<a href="'.api_get_self().'?survey_id='.$_GET['survey_id'].'&show='.$limit.'">NEXT</a>';
echo '<br /><input type="submit" name="next_survey_page" value="'. get_lang('Next'). ' >> " />';
if ($show >= $numberofpages AND $_GET['show'])
echo '<input type="submit" name="finish_survey" value="'. get_lang('FinishSurvey'). ' >> " />';
|