Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chamilo-lms/main/survey/question.php

120 lines
3.7 KiB

<?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.
Contact:
Dokeos
Rue des Palais 44 Paleizenstraat
B-1030 Brussels - Belgium
Tel. +32 (2) 211 34 56
*/
/**
* @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 11134 2007-02-16 14:39:59Z pcool $
*/
// 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');
/** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
if (!api_is_allowed_to_edit())
{
Display :: display_header();
Display :: display_error_message(get_lang('NotAllowedHere'));
Display :: display_footer();
exit;
}
// Database table definitions
/** @todo use database constants for the survey tables */
$table_survey = Database :: get_course_table(TABLE_SURVEY);
$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);
// breadcrumbs
$interbreadcrumb[] = array ("url" => 'survey_list.php', 'name' => get_lang('SurveyList'));
$interbreadcrumb[] = array ("url" => 'survey.php?survey_id='.$_GET['survey_id'], 'name' => get_lang('Survey'));
// Tool name
if ($_GET['action'] == 'add')
{
$tool_name = get_lang('AddQuestion');
}
if ($_GET['action'] == 'edit')
{
$tool_name = get_lang('EditQuestion');
}
// Displaying the header
Display::display_header($tool_name);
// the possible question types
$possible_types = array('yesno', 'multiplechoice', 'multipleresponse', 'open', 'dropdown', 'comment', 'pagebreak');
// checking if it is a valid type
if (!in_array($_GET['type'], $possible_types))
{
Display :: display_error_message(get_lang('TypeDoesNotExist'));
Display :: display_footer();
}
// Displaying the survey information
$survey_data = survey_manager::get_survey($_GET['survey_id']);
echo '<a href="survey.php?survey_id='.$survey_data['survey_id'].'">'.$survey_data['title'].'</a><br />';
echo $survey_data['subtitle'];
// displaying the form for adding or editing the question
if (!$_POST['save_question'])
{
$form = new $_GET['type'];
// The defaults values for the form
$form_content['horizontalvertical'] = 'vertical';
$form_content['answers'] = array('', '');
// We are editing a question
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)
{
$form_content = $_POST;
$form_content = $form->handle_action($form_content);
}
$form->create_form($form_content);
$form->render_form();
}
else
{
$form_content = $_POST;
$form = new question();
$form->handle_action($form_content);
}
// Footer
Display :: display_footer();
?>