Feature #272 - "Surveys" tool: Revision and cleaning, part 2.

skala
Ivan Tcholakov 15 years ago
parent f2f70636ca
commit 8dd0f882dc
  1. 1002
      main/survey/fillsurvey.php
  2. 131
      main/survey/preview.php
  3. 124
      main/survey/question.php
  4. 114
      main/survey/reporting.php
  5. 72
      main/survey/survey.download.inc.php
  6. 3092
      main/survey/survey.lib.php
  7. 144
      main/survey/survey.php
  8. 106
      main/survey/survey_invitation.php
  9. 174
      main/survey/survey_invite.php
  10. 166
      main/survey/survey_list.php

File diff suppressed because it is too large Load Diff

@ -1,42 +1,24 @@
<?php
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
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 the GNU General Public License for more details.
Contact: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium, info@dokeos.com
==============================================================================
*/
/* For licensing terms, see /license.txt */
/**
* @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
* @author Julio Montoya Armas <gugli100@gmail.com>, Dokeos: Personality Test modifications
* @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
* @package chamilo.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
* @author Julio Montoya Armas <gugli100@gmail.com>, Chamilo: Personality Test modifications
* @version $Id: survey_list.php 10680 2007-01-11 21:26:23Z pcool $
*
* @todo use quickforms for the forms
*/
// Language file that needs to be included
$language_file = 'survey';
// including the global dokeos file
require ('../inc/global.inc.php');
require_once('survey.lib.php');
// Including the global initialization file
require '../inc/global.inc.php';
require_once 'survey.lib.php';
$this_section=SECTION_COURSES;
$this_section = SECTION_COURSES;
// Database table definitions
$table_survey = Database :: get_course_table(TABLE_SURVEY);
@ -46,15 +28,14 @@ $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
// We exit here if ther is no valid $_GET parameter
if (!isset($_GET['survey_id']) OR !is_numeric($_GET['survey_id'])){
if (!isset($_GET['survey_id']) || !is_numeric($_GET['survey_id'])){
Display :: display_header(get_lang('SurveyPreview'));
Display :: display_error_message(get_lang('InvallidSurvey'), false);
Display :: display_footer();
exit;
}
// getting the survey information
// Getting the survey information
$survey_id = intval($_GET['survey_id']);
$survey_data = survey_manager::get_survey($survey_id);
@ -65,14 +46,14 @@ if (empty($survey_data)) {
exit;
}
$urlname = strip_tags(api_substr(api_html_entity_decode($survey_data['title'],ENT_QUOTES,$charset), 0, 40));
$urlname = strip_tags(api_substr(api_html_entity_decode($survey_data['title'], ENT_QUOTES), 0, 40));
if (api_strlen(strip_tags($survey_data['title'])) > 40) {
$urlname .= '...';
}
// breadcrumbs
$interbreadcrumb[] = array ("url" => 'survey_list.php', 'name' => get_lang('SurveyList'));
$interbreadcrumb[] = array ("url" => "survey.php?survey_id=".$survey_id, "name" => $urlname);
// Breadcrumbs
$interbreadcrumb[] = array('url' => 'survey_list.php', 'name' => get_lang('SurveyList'));
$interbreadcrumb[] = array('url' => 'survey.php?survey_id='.$survey_id, 'name' => $urlname);
// Header
Display :: display_header(get_lang('SurveyPreview'));
@ -80,38 +61,34 @@ Display :: display_header(get_lang('SurveyPreview'));
// We exit here is the first or last question is a pagebreak (which causes errors)
SurveyUtil::check_first_last_question($survey_id, false);
// 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 NOT a course admin => error message
/*
if (!api_is_allowed_to_edit(false,true))
{
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
// 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
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']))
{
// Displaying the survey introduction
if (!isset($_GET['show'])) {
echo '<div id="survey_content" class="survey_content">'.$survey_data['survey_introduction'].'</div>';
$limit = 0;
}
// displaying the survey thanks message
if(isset($_POST['finish_survey']))
{
// Displaying the survey thanks message
if (isset($_POST['finish_survey'])) {
echo '<div id="survey_content" class="survey_content"><strong>'.get_lang('SurveyFinished').' </strong>'.$survey_data['survey_thanks'].'</div>';
Display :: display_footer();
exit;
}
if (isset($_GET['show']))
{
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();
@ -122,17 +99,15 @@ if (api_is_course_admin() || (api_is_course_admin() && $_GET['isStudentView']=='
ORDER BY sort ASC";
$result = Database::query($sql);
while ($row = Database::fetch_array($result))
{
if($row['type'] == 'pagebreak') {
while ($row = Database::fetch_array($result)) {
if ($row['type'] == 'pagebreak') {
$counter++;
} else {
$paged_questions[$counter][] = $row['question_id'];
}
}
}
if (array_key_exists($_GET['show'], $paged_questions))
{
if (array_key_exists($_GET['show'], $paged_questions)) {
$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
@ -144,12 +119,10 @@ if (api_is_course_admin() || (api_is_course_admin() && $_GET['isStudentView']=='
$result = Database::query($sql);
$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
if($row['type'] <> 'pagebreak')
{
$limit = 0;
while ($row = Database::fetch_array($result)) {
// 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'];
@ -158,46 +131,38 @@ if (api_is_course_admin() || (api_is_course_admin() && $_GET['isStudentView']=='
$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
else
{
// If the type is a pagebreak we are finished loading the questions for this page
else {
break;
}
$counter_question++;
}
}
}
// selecting the maximum number of pages
// Selecting the maximum number of pages
$sql = "SELECT * FROM $table_survey_question WHERE type='".Database::escape_string('pagebreak')."' AND survey_id='".Database::escape_string($survey_id)."'";
$result = Database::query($sql);
$numberofpages = Database::num_rows($result) + 1;
// Displaying the form with the questions
if (isset($_GET['show']))
{
if (isset($_GET['show'])) {
$show = (int)$_GET['show'] + 1;
}
else
{
} else {
$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)
{
if (is_array($questions) && count($questions) > 0) {
foreach ($questions as $key => & $question) {
$ch_type = 'ch_'.$question['type'];
$display = new $ch_type;
$display->render_question($question);
}
}
if (($show < $numberofpages) || (!$_GET['show'] && count($questions) > 0))
{
if (($show < $numberofpages) || (!$_GET['show'] && count($questions) > 0)) {
echo '<br /><button type="submit" name="next_survey_page" class="next">'.get_lang('NextQuestion').' </button>';
}
if ($show >= $numberofpages && $_GET['show'] || ( isset($_GET['show']) && count($questions) == 0))
{
if ($show >= $numberofpages && $_GET['show'] || (isset($_GET['show']) && count($questions) == 0)) {
if (count($questions) == 0) {
echo '<p>'.get_lang('ThereAreNotQuestionsForthisSurvey').'</p>';
}

@ -1,66 +1,47 @@
<?php
/*
==============================================================================
Dokeos - elearning and course management software
/* For licensing terms, see /license.txt */
Copyright (c) 2008 Dokeos SPRL
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
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 the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/**
* @package dokeos.survey
* @package chamilo.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 21734 2009-07-02 17:12:41Z cvargas1 $
*/
// name of the language file that needs to be included
// Language file that needs to be included
$language_file = 'survey';
// including the global dokeos file
require ('../inc/global.inc.php');
// Including the global initialization file
require '../inc/global.inc.php';
// including additional libraries
//require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php");
require_once('survey.lib.php');
// Including additional libraries
//require_once api_get_path(LIBRARY_PATH).'survey.lib.php';
require_once 'survey.lib.php';
$htmlHeadXtra[] = '<script src="../inc/lib/javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
$htmlHeadXtra[] = '<script type="text/javascript">
$(document).ready( function() {
//Allow dokeos install in IE
$("button").click(function() {
$("#is_executable").attr("value",$(this).attr("name"));
});
} ); </script>';
/** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
if (!api_is_allowed_to_edit(false,true)) {
if (!api_is_allowed_to_edit(false, true)) {
Display :: display_header();
Display :: display_error_message(get_lang('NotAllowed'), false);
Display :: display_footer();
exit;
}
//Is valid request
$is_valid_request=$_REQUEST['is_executable'];
if ($request_index<>$is_valid_request) {
if ($request_index=='save_question') {
// Is valid request
$is_valid_request = $_REQUEST['is_executable'];
if ($request_index != $is_valid_request) {
if ($request_index == 'save_question') {
unset($_POST[$request_index]);
} elseif ($request_index=='add_answer') {
} elseif ($request_index == 'add_answer') {
unset($_POST[$request_index]);
} elseif($request_index=='remove_answer') {
} elseif($request_index == 'remove_answer') {
unset($_POST[$request_index]);
}
}
@ -72,7 +53,7 @@ $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUEST
$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
// getting the survey information
// Getting the survey information
$survey_data = survey_manager::get_survey($_GET['survey_id']);
if (empty($survey_data)) {
Display :: display_header(get_lang('ToolSurvey'));
@ -82,12 +63,12 @@ if (empty($survey_data)) {
}
$urlname = api_substr(api_html_entity_decode($survey_data['title'],ENT_QUOTES,$charset), 0, 40);
$urlname = api_substr(api_html_entity_decode($survey_data['title'], ENT_QUOTES), 0, 40);
if (api_strlen(strip_tags($survey_data['title'])) > 40) {
$urlname .= '...';
}
if($survey_data['survey_type']==1) {
if ($survey_data['survey_type'] == 1) {
$sql = 'SELECT id FROM '.Database :: get_course_table(TABLE_SURVEY_QUESTION_GROUP).' WHERE survey_id = '.(int)$_GET['survey_id'].' LIMIT 1';
$rs = Database::query($sql);
if(Database::num_rows($rs)===0) {
@ -96,9 +77,9 @@ if($survey_data['survey_type']==1) {
}
}
// breadcrumbs
$interbreadcrumb[] = array ("url" => 'survey_list.php', 'name' => get_lang('SurveyList'));
$interbreadcrumb[] = array ("url" => 'survey.php?survey_id='.Security::remove_XSS($_GET['survey_id']), 'name' => strip_tags($urlname));
// Breadcrumbs
$interbreadcrumb[] = array ('url' => 'survey_list.php', 'name' => get_lang('SurveyList'));
$interbreadcrumb[] = array ('url' => 'survey.php?survey_id='.Security::remove_XSS($_GET['survey_id']), 'name' => strip_tags($urlname));
// Tool name
if ($_GET['action'] == 'add') {
@ -108,34 +89,33 @@ if ($_GET['action'] == 'edit') {
$tool_name = get_lang('EditQuestion');
}
// the possible question types
$possible_types = array('personality','yesno', 'multiplechoice', 'multipleresponse', 'open', 'dropdown', 'comment', 'pagebreak', 'percentage', 'score');
// The possible question types
$possible_types = array('personality', 'yesno', 'multiplechoice', 'multipleresponse', 'open', 'dropdown', 'comment', 'pagebreak', 'percentage', 'score');
// actions
// Actions
$actions = '<div class="actions">';
$actions .= '<a href="survey.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'.Display::return_icon('back.png',get_lang('BackToSurvey')).get_lang('BackToSurvey').'</a>';
$actions .= '<a href="survey.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'.Display::return_icon('back.png', get_lang('BackToSurvey')).get_lang('BackToSurvey').'</a>';
$actions .= '</div>';
// checking if it is a valid type
if (!in_array($_GET['type'], $possible_types))
{
// Checking if it is a valid type
if (!in_array($_GET['type'], $possible_types)) {
Display :: display_header($tool_name,'Survey');
echo $actions;
Display :: display_error_message(get_lang('TypeDoesNotExist'), false);
Display :: display_footer();
}
// displaying the form for adding or editing the question
if (empty($_POST['save_question']) && in_array($_GET['type'],$possible_types)) {
// Displaying the form for adding or editing the question
if (empty($_POST['save_question']) && in_array($_GET['type'], $possible_types)) {
if (!isset($_POST['save_question'])) {
// Displaying the header
Display::display_header($tool_name,'Survey');
Display::display_header($tool_name, 'Survey');
echo $actions;
$error_message='';
$error_message = '';
// Displys message if exists
if (isset($_SESSION['temp_sys_message'])) {
$error_message=$_SESSION['temp_sys_message'];
unset($_SESSION['temp_sys_message']);
if ($error_message=='PleaseEnterAQuestion' || $error_message=='PleasFillAllAnswer'|| $error_message=='PleaseChooseACondition'|| $error_message=='ChooseDifferentCategories') {
if ($error_message == 'PleaseEnterAQuestion' || $error_message == 'PleasFillAllAnswer'|| $error_message == 'PleaseChooseACondition'|| $error_message == 'ChooseDifferentCategories') {
Display::display_error_message(get_lang($error_message), true);
}
}
@ -147,42 +127,41 @@ if (empty($_POST['save_question']) && in_array($_GET['type'],$possible_types)) {
$form_content['answers'] = array('', '');
if ($_GET['type'] == 'yesno') {
$form_content['answers'][0]=get_lang('Yes');
$form_content['answers'][1]=get_lang('No');
$form_content['answers'][0] = get_lang('Yes');
$form_content['answers'][1] = get_lang('No');
}
if ($_GET['type'] == 'personality') {
$form_content['answers'][0]=get_lang('1');
$form_content['answers'][1]=get_lang('2');
$form_content['answers'][2]=get_lang('3');
$form_content['answers'][3]=get_lang('4');
$form_content['answers'][4]=get_lang('5');
$form_content['values'][0]=0;
$form_content['values'][1]=0;
$form_content['values'][2]=1;
$form_content['values'][3]=2;
$form_content['values'][4]=3;
$form_content['answers'][0] = get_lang('1');
$form_content['answers'][1] = get_lang('2');
$form_content['answers'][2] = get_lang('3');
$form_content['answers'][3] = get_lang('4');
$form_content['answers'][4] = get_lang('5');
$form_content['values'][0] = 0;
$form_content['values'][1] = 0;
$form_content['values'][2] = 1;
$form_content['values'][3] = 2;
$form_content['values'][4] = 3;
}
// We are editing a question
if (isset($_GET['question_id']) AND !empty($_GET['question_id'])) {
if (isset($_GET['question_id']) && !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, ...)
// 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);
}
if ($error_message!='') {
$form_content['question']=$_SESSION['temp_user_message'];
$form_content['answers']=$_SESSION['temp_answers'];
$form_content['values']=$_SESSION['temp_values'];
if ($error_message != '') {
$form_content['question'] = $_SESSION['temp_user_message'];
$form_content['answers'] = $_SESSION['temp_answers'];
$form_content['values'] = $_SESSION['temp_values'];
$form_content['horizontalvertical'] = $_SESSION['temp_horizontalvertical'];
unset($_SESSION['temp_user_message']);
unset($_SESSION['temp_answers']);
unset($_SESSION['temp_values']);
@ -199,4 +178,3 @@ if (empty($_POST['save_question']) && in_array($_GET['type'],$possible_types)) {
// Footer
Display :: display_footer();
?>

@ -1,55 +1,31 @@
<?php // $Id: reporting.php 21652 2009-06-27 17:07:35Z herodoto $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
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 the GNU General Public License for more details.
Contact: Dokeos, rue Notre Dame, 152, B-1140 Evere, Belgium, info@dokeos.com
==============================================================================
*/
<?php
/* For licensing terms, see /license.txt */
/**
* @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: reporting.php 21652 2009-06-27 17:07:35Z herodoto $
*
* @todo The question has to be more clearly indicated (same style as when filling the survey)
*/
// name of the language file that needs to be included
* @package chamilo.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: reporting.php 21652 2009-06-27 17:07:35Z herodoto $
*
* @todo The question has to be more clearly indicated (same style as when filling the survey)
*/
// Language file that needs to be included
$language_file = 'survey';
// including the global dokeos file
require ('../inc/global.inc.php');
require_once('survey.lib.php');
$this_section=SECTION_COURSES;
// Including the global initialization file
require '../inc/global.inc.php';
require_once 'survey.lib.php';
$this_section = SECTION_COURSES;
$survey_id = Security::remove_XSS($_GET['survey_id']);
// export
// Export
/**
* @todo use export_table_csv($data, $filename = 'export')
*/
if ($_POST['export_report'])
{
switch($_POST['export_format'])
{
if ($_POST['export_report']) {
switch($_POST['export_format']) {
case 'xls':
$survey_data = survey_manager::get_survey($survey_id);
$filename = 'survey_results_'.$survey_id.'.xls';
@ -66,16 +42,12 @@ if ($_POST['export_report'])
header('Content-type: application/octet-stream');
header('Content-Type: application/force-download');
if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT']))
{
if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
header('Content-Disposition: filename= '.$filename);
}
else
{
} else {
header('Content-Disposition: attachment; filename= '.$filename);
}
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
{
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
header('Pragma: ');
header('Cache-Control: ');
header('Cache-Control: public'); // IE cannot download from sessions without a cache
@ -88,16 +60,15 @@ if ($_POST['export_report'])
}
}
// including additional libraries
//require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php");
require_once (api_get_path(LIBRARY_PATH)."/course.lib.php");
// Including additional libraries
//require_once api_get_path(LIBRARY_PATH).'survey.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
// Checking the parameters
SurveyUtil::check_parameters();
/** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
if (!api_is_allowed_to_edit(false,true))
{
if (!api_is_allowed_to_edit(false, true)) {
Display :: display_header(get_lang('ToolSurvey'));
Display :: display_error_message(get_lang('NotAllowed'), false);
Display :: display_footer();
@ -112,7 +83,7 @@ $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$user_info = Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER); // TODO: To be checked. TABLE_MAIN_SURVEY_REMINDER has not been defined.
// getting the survey information
// Getting the survey information
$survey_data = survey_manager::get_survey($survey_id);
if (empty($survey_data)) {
@ -121,24 +92,20 @@ if (empty($survey_data)) {
Display :: display_footer();
exit;
}
$urlname = strip_tags(api_substr(api_html_entity_decode($survey_data['title'],ENT_QUOTES,$charset), 0, 40));
if (api_strlen(strip_tags($survey_data['title'])) > 40)
{
$urlname = strip_tags(api_substr(api_html_entity_decode($survey_data['title'], ENT_QUOTES), 0, 40));
if (api_strlen(strip_tags($survey_data['title'])) > 40) {
$urlname .= '...';
}
// breadcrumbs
$interbreadcrumb[] = array ("url" => "survey_list.php", "name" => get_lang('SurveyList'));
$interbreadcrumb[] = array ('url' => 'survey.php?survey_id='.$survey_id, 'name' => $urlname);
if (!$_GET['action'] OR $_GET['action'] == 'overview')
{
// Breadcrumbs
$interbreadcrumb[] = array('url' => 'survey_list.php', 'name' => get_lang('SurveyList'));
$interbreadcrumb[] = array('url' => 'survey.php?survey_id='.$survey_id, 'name' => $urlname);
if (!$_GET['action'] OR $_GET['action'] == 'overview') {
$tool_name = get_lang('Reporting');
}
else
{
$interbreadcrumb[] = array ("url" => "reporting.php?survey_id=".$survey_id, "name" => get_lang('Reporting'));
switch ($_GET['action'])
{
} else {
$interbreadcrumb[] = array('url' => 'reporting.php?survey_id='.$survey_id, 'name' => get_lang('Reporting'));
switch ($_GET['action']) {
case 'questionreport':
$tool_name = get_lang('DetailedReportByQuestion');
break;
@ -155,18 +122,18 @@ else
}
// Displaying the header
Display::display_header($tool_name,'Survey');
Display::display_header($tool_name, 'Survey');
// Action handling
SurveyUtil::handle_reporting_actions();
// actions bar
// Actions bar
echo '<div class="actions">';
echo '<a href="survey.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'.Display::return_icon('back.png',get_lang('BackTo').' '.strtolower(get_lang('Survey'))).' '.get_lang('BackTo').' '.strtolower(get_lang('Survey')).'</a>';
echo '</div>';
// content
if (!$_GET['action'] OR $_GET['action'] == 'overview') {
// Content
if (!$_GET['action'] || $_GET['action'] == 'overview') {
$myweb_survey_id = $survey_id;
echo '<div class="sectiontitle"><a href="reporting.php?action=questionreport&amp;survey_id='.$myweb_survey_id.'">'.Display::return_icon('survey_reporting_question.gif',get_lang('DetailedReportByQuestion')).' '.get_lang('DetailedReportByQuestion').'</a></div><div class="sectioncomment">'.get_lang('DetailedReportByQuestionDetail').' </div>';
echo '<div class="sectiontitle"><a href="reporting.php?action=userreport&amp;survey_id='.$myweb_survey_id.'">'.Display::return_icon('survey_reporting_user.gif',get_lang('DetailedReportByUser')).' '.get_lang('DetailedReportByUser').'</a></div><div class="sectioncomment">'.get_lang('DetailedReportByUserDetail').'.</div>';
@ -174,6 +141,5 @@ if (!$_GET['action'] OR $_GET['action'] == 'overview') {
echo '<div class="sectiontitle"><a href="reporting.php?action=completereport&amp;survey_id='.$myweb_survey_id.'">'.Display::return_icon('survey_reporting_complete.gif',get_lang('CompleteReport')).' '.get_lang('CompleteReport').'</a></div><div class="sectioncomment">'.get_lang('CompleteReportDetail').'</div>';
}
// Footer
Display :: display_footer();

@ -1,38 +1,22 @@
<?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
*/
/* For licensing terms, see /license.txt */
/**
* @package dokeos.survey
* @package chamilo.survey
* @author Arnaud Ligot <arnaud@cblue.be>
* @version $Id: $
*
* small peace code to enable user to access images included into survey
* A small peace of code to enable user to access images included into survey
* which are accessible by non authenticated users. This file is included
* by document/download.php
*/
function check_download_survey($course, $invitation, $doc_url) {
require_once('survey.lib.php');
require_once (api_get_path(LIBRARY_PATH)."/course.lib.php");
require_once 'survey.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
// getting all the course information
// Getting all the course information
$_course = CourseManager::get_course_information($course);
// Database table definitions
@ -43,48 +27,37 @@ function check_download_survey($course, $invitation, $doc_url) {
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION, $_course['db_name']);
// now we check if the invitationcode is valid
// Now we check if the invitationcode is valid
$sql = "SELECT * FROM $table_survey_invitation WHERE invitation_code = '".Database::escape_string($invitation)."'";
$result = Database::query($sql);
if (Database::num_rows($result) < 1)
{
if (Database::num_rows($result) < 1) {
Display :: display_error_message(get_lang('WrongInvitationCode'), false);
Display :: display_footer();
exit;
}
$survey_invitation = Database::fetch_assoc($result);
// now we check if the user already filled the survey
if ($survey_invitation['answered'] == 1)
{
// Now we check if the user already filled the survey
if ($survey_invitation['answered'] == 1) {
Display :: display_error_message(get_lang('YouAlreadyFilledThisSurvey'), false);
Display :: display_footer();
exit;
}
// very basic security check: check if a text field from a survey/answer/option contains the name of the document requested
// Very basic security check: check if a text field from a survey/answer/option contains the name of the document requested
//////////////
// fetch survey ID
//////////////
// Fetch survey ID
// If this is the case there will be a language choice
$sql = "SELECT * FROM $table_survey WHERE code='".Database::escape_string($survey_invitation['survey_code'])."'";
$result = Database::query($sql);
if (Database::num_rows($result) > 1)
{
if ($_POST['language'])
{
if (Database::num_rows($result) > 1) {
if ($_POST['language']) {
$survey_invitation['survey_id'] = $_POST['language'];
}
else
{
} else {
echo '<form id="language" name="language" method="POST" action="'.api_get_self().'?course='.$_GET['course'].'&invitationcode='.$_GET['invitationcode'].'">';
echo ' <select name="language">';
while ($row = Database::fetch_assoc($result))
{
while ($row = Database::fetch_assoc($result)) {
echo '<option value="'.$row['survey_id'].'">'.$row['lang'].'</option>';
}
echo '</select>';
@ -93,12 +66,11 @@ function check_download_survey($course, $invitation, $doc_url) {
display::display_footer();
exit;
}
}
else
{
} else {
$row = Database::fetch_assoc($result);
$survey_invitation['survey_id'] = $row['survey_id'];
}
$sql = "select count(*) from $table_survey where survey_id = ".$survey_invitation['survey_id']."
and (
title LIKE '%$doc_url%'
@ -117,15 +89,11 @@ function check_download_survey($course, $invitation, $doc_url) {
)";
$result = Database::query($sql);
if (Database::num_rows($result) == 0)
{
if (Database::num_rows($result) == 0) {
Display :: display_error_message(get_lang('WrongInvitationCode'), false);
Display :: display_footer();
exit;
}
return $_course;
}
?>

File diff suppressed because it is too large Load Diff

@ -1,31 +1,32 @@
<?php // $Id: survey.php 22573 2009-08-03 03:38:13Z yannoo $
/* For licensing terms, see /dokeos_license.txt */
<?php
/* For licensing terms, see /license.txt */
/**
* @package dokeos.survey
* @author unknown
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts of the code
* @version $Id: survey.php 22573 2009-08-03 03:38:13Z yannoo $
*
* @todo use quickforms for the forms
*/
// name of the language file that needs to be included
* @package chamilo.survey
* @author unknown
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts of the code
* @version $Id: survey.php 22573 2009-08-03 03:38:13Z yannoo $
*
* @todo use quickforms for the forms
*/
// Language file that needs to be included
$language_file = 'survey';
// including the global dokeos file
require ('../inc/global.inc.php');
$this_section=SECTION_COURSES;
// Including the global initialization file
require '../inc/global.inc.php';
$this_section = SECTION_COURSES;
// 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");
// 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';
/** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
// coach can't view this page
// Coach can't view this page
$extend_rights_for_coachs = api_get_setting('extend_rights_for_coach_on_survey');
if (!api_is_allowed_to_edit(false,true) || (api_is_course_coach() && $extend_rights_for_coachs=='false'))
{
if (!api_is_allowed_to_edit(false, true) || (api_is_course_coach() && $extend_rights_for_coachs == 'false')) {
Display :: display_header(get_lang('ToolSurvey'));
Display :: display_error_message(get_lang('NotAllowed'), false);
Display :: display_footer();
@ -40,12 +41,13 @@ $table_survey_question_group = Database :: get_course_table(TABLE_SURVEY_QUES
$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$user_info = Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER); // TODO: To be checked. TABLE_MAIN_SURVEY_REMINDER has not been defined.
$survey_id = intval($_GET['survey_id']);
// breadcrumbs
$interbreadcrumb[] = array ("url" => "survey_list.php", "name" => get_lang('SurveyList'));
// Breadcrumbs
$interbreadcrumb[] = array ('url' => 'survey_list.php', 'name' => get_lang('SurveyList'));
// getting the survey information
// Getting the survey information
if (isset($_GET['survey_id'])) {
$course_code = api_get_course_id();
if ($course_code!=-1) {
@ -58,30 +60,26 @@ if (isset($_GET['survey_id'])) {
}
}
if (api_substr($survey_data['title'],0,3)!='<p>'){
$tool_name = strip_tags(api_substr(api_html_entity_decode($survey_data['title'],ENT_QUOTES,$charset), 0, 40));
}else{
$tool_name = strip_tags(api_substr(api_html_entity_decode(api_substr($survey_data['title'],3,-4),ENT_QUOTES,$charset), 0, 40));
if (api_substr($survey_data['title'], 0, 3) != '<p>') {
$tool_name = strip_tags(api_substr(api_html_entity_decode($survey_data['title'], ENT_QUOTES), 0, 40));
} else {
$tool_name = strip_tags(api_substr(api_html_entity_decode(api_substr($survey_data['title'], 3, -4), ENT_QUOTES), 0, 40));
}
$is_survey_type_1 = ($survey_data['survey_type']==1)?true:false;
if (api_strlen(strip_tags($survey_data['title'])) > 40)
{
$is_survey_type_1 = $survey_data['survey_type'] == 1;
if (api_strlen(strip_tags($survey_data['title'])) > 40) {
$tool_name .= '...';
}
if($is_survey_type_1 && ($_GET['action']=='addgroup')||($_GET['action']=='deletegroup'))
{
if ($is_survey_type_1 && $_GET['action'] == 'addgroup' || $_GET['action'] == 'deletegroup') {
$_POST['name'] = trim($_POST['name']);
if(($_GET['action']=='addgroup'))
{
if(!empty($_POST['group_id']))
{
if (($_GET['action'] == 'addgroup')) {
if (!empty($_POST['group_id'])) {
Database::query('UPDATE '.$table_survey_question_group.' SET description = \''.Database::escape_string($_POST['description']).'\' WHERE id = \''.Database::escape_string($_POST['group_id']).'\'');
$sendmsg = 'GroupUpdatedSuccessfully';
}
elseif(!empty($_POST['name']))
{
} elseif(!empty($_POST['name'])) {
Database::query('INSERT INTO '.$table_survey_question_group.' (name,description,survey_id) values (\''.Database::escape_string($_POST['name']).'\',\''.Database::escape_string($_POST['description']).'\',\''.Database::escape_string($survey_id).'\') ');
$sendmsg = 'GroupCreatedSuccessfully';
} else {
@ -89,7 +87,7 @@ if($is_survey_type_1 && ($_GET['action']=='addgroup')||($_GET['action']=='delete
}
}
if($_GET['action']=='deletegroup'){
if ($_GET['action'] == 'deletegroup'){
Database::query('DELETE FROM '.$table_survey_question_group.' WHERE id = '.Database::escape_string($_GET['gid']).' and survey_id = '.Database::escape_string($survey_id));
$sendmsg = 'GroupDeletedSuccessfully';
}
@ -107,7 +105,7 @@ $my_question_id_survey = Security::remove_XSS($_GET['question_id']);
$my_survey_id_survey = Security::remove_XSS($_GET['survey_id']);
$message_information = Security::remove_XSS($_GET['message']);
if (isset($_GET['action'])) {
if (($_GET['action'] == 'moveup' OR $_GET['action'] == 'movedown') AND isset($_GET['question_id'])) {
if (($_GET['action'] == 'moveup' || $_GET['action'] == 'movedown') && isset($_GET['question_id'])) {
survey_manager::move_survey_question($my_action_survey,$my_question_id_survey,$my_survey_id_survey);
Display::display_confirmation_message(get_lang('SurveyQuestionMoved'));
}
@ -116,12 +114,12 @@ if (isset($_GET['action'])) {
}
}
if (isset($_GET['message'])) {
// we have created the survey or updated the survey
// We have created the survey or updated the survey
if (in_array($_GET['message'], array('SurveyUpdatedSuccesfully','SurveyCreatedSuccesfully'))) {
Display::display_confirmation_message(get_lang($message_information).','.PHP_EOL.api_strtolower(get_lang('YouCanNowAddQuestionToYourSurvey')));
}
// we have added a question
if (in_array($_GET['message'], array('QuestionAdded','QuestionUpdated'))) {
// We have added a question
if (in_array($_GET['message'], array('QuestionAdded', 'QuestionUpdated'))) {
Display::display_confirmation_message(get_lang($message_information));
}
@ -129,30 +127,32 @@ if (isset($_GET['message'])) {
Display::display_warning_message(get_lang($message_information), false);
}
}
if(!empty($survey_data['survey_version'])) echo '<b>'.get_lang('Version').': '.$survey_data['survey_version'].'</b>';
if (!empty($survey_data['survey_version'])) echo '<b>'.get_lang('Version').': '.$survey_data['survey_version'].'</b>';
// We exit here is the first or last question is a pagebreak (which causes errors)
SurveyUtil::check_first_last_question($_GET['survey_id']);
// Action links
$survey_actions = '<a href="create_new_survey.php?'.api_get_cidreq().'&amp;action=edit&amp;survey_id='.$survey_id.'">'.Display::return_icon('edit.gif', get_lang('Edit')).' '.get_lang('EditSurvey').'</a>';
$survey_actions .= '<a href="survey_list.php?'.api_get_cidreq().'&amp;action=delete&amp;survey_id='.$survey_id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurvey").'?',ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.gif', get_lang('Delete')).' '.get_lang('DeleteSurvey').'</a>';
$survey_actions .= '<a href="survey_list.php?'.api_get_cidreq().'&amp;action=delete&amp;survey_id='.$survey_id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('DeleteSurvey').'?', ENT_QUOTES)).'\')) return false;">'.Display::return_icon('delete.gif', get_lang('Delete')).' '.get_lang('DeleteSurvey').'</a>';
//$survey_actions .= '<a href="create_survey_in_another_language.php?id_survey='.$survey_id.'">'.Display::return_icon('copy.gif', get_lang('Copy')).'</a>';
$survey_actions .= '<a href="preview.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.Display::return_icon('preview.gif', get_lang('Preview')).' '.get_lang('Preview').'</a>';
$survey_actions .= '<a href="survey_invite.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.Display::return_icon('survey_publish.gif', get_lang('Publish')).' '.get_lang('Publish').'</a>';
$survey_actions .= '<a href="reporting.php?'.api_get_cidreq().'&amp;survey_id='.$survey_id.'">'.Display::return_icon('statistics.gif', get_lang('Reporting')).' '.get_lang('Reporting').'</a>';
echo '<div class="actions">'.$survey_actions.'</div>';
if ($survey_data['survey_type']==0) {
if ($survey_data['survey_type'] == 0) {
echo '<div class="actionsbig">';
echo '<a style="padding-left:0px;" href="question.php?'.api_get_cidreq().'&amp;action=add&type=yesno&amp;survey_id='.$survey_id.'">'.Display::return_icon('yesno.gif',get_lang('YesNo')).'<br/>'.get_lang('YesNo').'</a>';
echo '<a href="question.php?'.api_get_cidreq().'&amp;action=add&type=multiplechoice&amp;survey_id='.$survey_id.'">'.Display::return_icon('mcua.gif',get_lang('UniqueSelect')).'<br />'.get_lang('UniqueSelect').'</a>';
echo '<a href="question.php?'.api_get_cidreq().'&amp;action=add&type=multipleresponse&amp;survey_id='.$survey_id.'">'.Display::return_icon('mcma.gif',get_lang('MultipleResponse')).'<br />'.get_lang('MultipleResponse').'</a>';
echo '<a href="question.php?'.api_get_cidreq().'&amp;action=add&type=open&amp;survey_id='.$survey_id.'">'.Display::return_icon('open_answer.gif',get_lang('Open')).'<br />'.get_lang('Open').'</a>';
echo '<a href="question.php?'.api_get_cidreq().'&amp;action=add&type=dropdown&amp;survey_id='.$survey_id.'">'.Display::return_icon('dropdown.gif',get_lang('Dropdown')).'<br />'.get_lang('Dropdown').'</a>';
echo '<a href="question.php?'.api_get_cidreq().'&amp;action=add&type=percentage&amp;survey_id='.$survey_id.'">'.Display::return_icon('percentagequestion.gif',get_lang('Percentage')).'<br />'.get_lang('Percentage').'</a>';
echo '<a href="question.php?'.api_get_cidreq().'&amp;action=add&type=score&amp;survey_id='.$survey_id.'">'.Display::return_icon('scorequestion.gif',get_lang('Score')).'<br />'.get_lang('Score').'</a>';
echo '<a href="question.php?'.api_get_cidreq().'&amp;action=add&type=comment&amp;survey_id='.$survey_id.'">'.Display::return_icon('commentquestion.gif',get_lang('Comment')).'<br />'.get_lang('Comment').'</a>';
echo '<a href="question.php?'.api_get_cidreq().'&amp;action=add&type=pagebreak&amp;survey_id='.$survey_id.'">'.Display::return_icon('page_end.gif',get_lang('Pagebreak')).'<br />'.get_lang('Pagebreak').'</a>';
echo '<a style="padding-left:0px;" href="question.php?'.api_get_cidreq().'&amp;action=add&type=yesno&amp;survey_id='.$survey_id.'">'.Display::return_icon('yesno.gif', get_lang('YesNo')).'<br/>'.get_lang('YesNo').'</a>';
echo '<a href="question.php?'.api_get_cidreq().'&amp;action=add&type=multiplechoice&amp;survey_id='.$survey_id.'">'.Display::return_icon('mcua.gif', get_lang('UniqueSelect')).'<br />'.get_lang('UniqueSelect').'</a>';
echo '<a href="question.php?'.api_get_cidreq().'&amp;action=add&type=multipleresponse&amp;survey_id='.$survey_id.'">'.Display::return_icon('mcma.gif', get_lang('MultipleResponse')).'<br />'.get_lang('MultipleResponse').'</a>';
echo '<a href="question.php?'.api_get_cidreq().'&amp;action=add&type=open&amp;survey_id='.$survey_id.'">'.Display::return_icon('open_answer.gif', get_lang('Open')).'<br />'.get_lang('Open').'</a>';
echo '<a href="question.php?'.api_get_cidreq().'&amp;action=add&type=dropdown&amp;survey_id='.$survey_id.'">'.Display::return_icon('dropdown.gif', get_lang('Dropdown')).'<br />'.get_lang('Dropdown').'</a>';
echo '<a href="question.php?'.api_get_cidreq().'&amp;action=add&type=percentage&amp;survey_id='.$survey_id.'">'.Display::return_icon('percentagequestion.gif', get_lang('Percentage')).'<br />'.get_lang('Percentage').'</a>';
echo '<a href="question.php?'.api_get_cidreq().'&amp;action=add&type=score&amp;survey_id='.$survey_id.'">'.Display::return_icon('scorequestion.gif', get_lang('Score')).'<br />'.get_lang('Score').'</a>';
echo '<a href="question.php?'.api_get_cidreq().'&amp;action=add&type=comment&amp;survey_id='.$survey_id.'">'.Display::return_icon('commentquestion.gif', get_lang('Comment')).'<br />'.get_lang('Comment').'</a>';
echo '<a href="question.php?'.api_get_cidreq().'&amp;action=add&type=pagebreak&amp;survey_id='.$survey_id.'">'.Display::return_icon('page_end.gif', get_lang('Pagebreak')).'<br />'.get_lang('Pagebreak').'</a>';
echo '</div>';
} else {
echo '<div class="actionsbig">';
@ -169,17 +169,18 @@ echo ' <th>'.get_lang('Title').'</th>';
echo ' <th>'.get_lang('Type').'</th>';
echo ' <th width="50" >'.get_lang('NumberOfOptions').'</th>';
echo ' <th width="100">'.get_lang('Modify').'</th>';
if($is_survey_type_1) {
if ($is_survey_type_1) {
echo '<th width="100">'.get_lang('Condition').'</th>';
echo '<th width="40">'.get_lang('Group').'</th>';
}
echo ' </tr>';
// Displaying the table contents with all the questions
$question_counter = 1;
$sql = "SELECT * FROM $table_survey_question_group WHERE survey_id = '".Database::escape_string($survey_id)."' ORDER BY id";
$result = Database::query($sql);
$groups = array();
while($row = Database::fetch_array($result)) {
while ($row = Database::fetch_array($result)) {
$groups[$row['id']] = $row['name'];
}
$sql = "SELECT survey_question.*, count(survey_question_option.question_option_id) as number_of_options
@ -191,12 +192,12 @@ $sql = "SELECT survey_question.*, count(survey_question_option.question_option_i
ORDER BY survey_question.sort ASC";
$result = Database::query($sql);
$question_counter_max = Database::num_rows($result);
while ($row = Database::fetch_array($result,'ASSOC')) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
echo '<tr>';
echo ' <td>'.$question_counter.'</td>';
echo ' <td>';
if (api_strlen($row['survey_question']) > 100) {
echo api_substr(strip_tags($row['survey_question']),0, 100).' ... ';
echo api_substr(strip_tags($row['survey_question']), 0, 100).' ... ';
} else {
echo $row['survey_question'];
}
@ -209,21 +210,18 @@ while ($row = Database::fetch_array($result,'ASSOC')) {
$tool_name = get_lang(api_ucfirst(Security::remove_XSS($row['type'])));
}
echo '</td>';
echo ' <td>'.$tool_name.'</td>';
echo ' <td>'.$row['number_of_options'].'</td>';
echo ' <td>';
echo ' <a href="question.php?'.api_get_cidreq().'&amp;action=edit&amp;type='.$row['type'].'&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
echo ' <a href="survey.php?'.api_get_cidreq().'&amp;action=delete&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurveyQuestion").'?',ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.gif', get_lang('Delete')).'</a>';
if ($question_counter > 1)
{
if ($question_counter > 1) {
echo ' <a href="survey.php?'.api_get_cidreq().'&amp;action=moveup&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('up.gif', get_lang('MoveUp')).'</a>';
} else {
Display::display_icon('up_na.gif');
}
if ($question_counter < $question_counter_max)
{
if ($question_counter < $question_counter_max) {
echo ' <a href="survey.php?'.api_get_cidreq().'&amp;action=movedown&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('down.gif', get_lang('MoveDown')).'</a>';
} else {
Display::display_icon('down_na.gif');
@ -231,8 +229,7 @@ while ($row = Database::fetch_array($result,'ASSOC')) {
echo ' </td>';
$question_counter++;
if($is_survey_type_1)
{
if ($is_survey_type_1) {
echo '<td>'.(($row['survey_group_pri']==0)?get_lang('Secondary'):get_lang('Primary')).'</td>';
echo '<td>'.(($row['survey_group_pri']==0)?$groups[$row['survey_group_sec1']].'-'.$groups[$row['survey_group_sec2']]:$groups[$row['survey_group_pri']]).'</td>';
}
@ -240,11 +237,10 @@ while ($row = Database::fetch_array($result,'ASSOC')) {
}
echo '</table>';
if($is_survey_type_1)
{
if ($is_survey_type_1) {
echo '<br /><br /><b>'.get_lang('ManageGroups').'</b><br /><br />';
if (in_array($_GET['sendmsg'], array('GroupUpdatedSuccessfully','GroupDeletedSuccessfully','GroupCreatedSuccessfully'))){
if (in_array($_GET['sendmsg'], array('GroupUpdatedSuccessfully', 'GroupDeletedSuccessfully', 'GroupCreatedSuccessfully'))) {
echo Display::display_confirmation_message(get_lang($_GET['sendmsg']), false);
}
@ -255,11 +251,10 @@ if($is_survey_type_1)
echo '<table border="0"><tr><td width="100">'.get_lang('Name').'</td><td>'.get_lang('Description').'</td></tr></table>';
echo '<form action="survey.php?action=addgroup&survey_id='.$survey_id.'" method="post">';
if($_GET['action']=='editgroup') {
if ($_GET['action'] == 'editgroup') {
$sql = 'SELECT name,description FROM '.$table_survey_question_group.' WHERE id = '.Database::escape_string($_GET['gid']).' AND survey_id = '.Database::escape_string($survey_id).' limit 1';
$rs = Database::query($sql);
$editedrow = Database::fetch_array($rs,'ASSOC');
echo '<input type="text" maxlength="20" name="name" value="'.$editedrow['name'].'" size="10" disabled>';
echo '<input type="text" maxlength="150" name="description" value="'.$editedrow['description'].'" size="40">';
echo '<input type="hidden" name="group_id" value="'.Security::remove_XSS($_GET['gid']).'">';
@ -285,7 +280,7 @@ if($is_survey_type_1)
$grouplist .= '<tr><td>'.$row['name'].'</td><td>'.$row['description'].'</td><td>'.
'<a href="survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=editgroup">'.
Display::return_icon('edit.gif', get_lang('Edit')).'</a> '.
'<a href="survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=deletegroup" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('DeleteSurveyGroup'),$row['name']).'?',ENT_QUOTES,$charset)).'\')) return false;">'.
'<a href="survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=deletegroup" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(sprintf(get_lang('DeleteSurveyGroup'),$row['name']).'?',ENT_QUOTES)).'\')) return false;">'.
Display::return_icon('delete.gif', get_lang('Delete')).'</a>'.
'</td></tr>';
}
@ -294,4 +289,3 @@ if($is_survey_type_1)
// Footer
Display :: display_footer();
?>

@ -1,38 +1,22 @@
<?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
*/
/* For licensing terms, see /license.txt */
/**
* @package dokeos.survey
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts of the code
* @version $Id: survey_invite.php 10680 2007-01-11 21:26:23Z pcool $
*
* @todo the answered column
*/
* @package chamilo.survey
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts of the code
* @version $Id: survey_invite.php 10680 2007-01-11 21:26:23Z pcool $
*
* @todo the answered column
*/
// name of the language file that needs to be included
// Language file that needs to be included
$language_file = 'survey';
// Including the global initialization file
require '../inc/global.inc.php';
// Including additional libraries
//require_once (api_get_path(LIBRARY_PATH).'survey.lib.php');
//require_once api_get_path(LIBRARY_PATH).'survey.lib.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once 'survey.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
@ -40,8 +24,7 @@ require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.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(false,true))
{
if (!api_is_allowed_to_edit(false, true)) {
Display :: display_header(get_lang('ToolSurvey'));
Display :: display_error_message(get_lang('NotAllowed'), false);
Display :: display_footer();
@ -59,15 +42,15 @@ $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATIO
$tool_name = get_lang('SurveyInvitations');
// getting the survey information
// Getting the survey information
// We exit here if ther is no valid $_GET parameter
if (!isset($_GET['survey_id']) OR !is_numeric($_GET['survey_id']))
{
if (!isset($_GET['survey_id']) OR !is_numeric($_GET['survey_id'])) {
Display :: display_header($tool_name);
Display :: display_error_message(get_lang('InvallidSurvey'), false);
Display :: display_footer();
exit;
}
$survey_id = Security::remove_XSS($_GET['survey_id']);
$survey_data = survey_manager::get_survey($survey_id);
if (empty($survey_data)) {
@ -76,22 +59,22 @@ if (empty($survey_data)) {
Display :: display_footer();
exit;
}
$urlname =strip_tags(api_substr(api_html_entity_decode($survey_data['title'],ENT_QUOTES,$charset), 0, 40));
$urlname = strip_tags(api_substr(api_html_entity_decode($survey_data['title'], ENT_QUOTES), 0, 40));
if (api_strlen(strip_tags($survey_data['title'])) > 40) {
$urlname .= '...';
}
//breadcrumbs
$interbreadcrumb[] = array ('url' => 'survey_list.php', 'name' => get_lang('SurveyList'));
$interbreadcrumb[] = array ('url' => 'survey.php?survey_id='.$survey_id, 'name' => $urlname);
// Breadcrumbs
$interbreadcrumb[] = array('url' => 'survey_list.php', 'name' => get_lang('SurveyList'));
$interbreadcrumb[] = array('url' => 'survey.php?survey_id='.$survey_id, 'name' => $urlname);
// Displaying the header
Display::display_header($tool_name);
// Checking the parameters
if (!is_numeric($survey_id))
{
if (!is_numeric($survey_id)) {
Display::display_error_message(get_lang('Error'), false);
Display::display_footer();
exit;
@ -99,39 +82,28 @@ if (!is_numeric($survey_id))
// Getting all the people who have filled this survey
$answered_data = survey_manager::get_people_who_filled_survey($survey_id);
if ($survey_data['anonymous'] == 1)
{
if ($survey_data['anonymous'] == 1) {
Display::display_normal_message(get_lang('AnonymousSurveyCannotKnowWhoAnswered').' '.count($answered_data).' '.get_lang('PeopleAnswered'));
$answered_data = array();
}
//
if (!isset($_GET['view']) OR $_GET['view'] == 'invited')
{
if (!isset($_GET['view']) OR $_GET['view'] == 'invited') {
echo get_lang('ViewInvited'). ' | ';
}
else
{
} else {
echo ' <a href="'.api_get_self().'?survey_id='.$survey_id.'&amp;view=invited">'.get_lang('ViewInvited').'</a> |';
}
if ($_GET['view'] == 'answered')
{
if ($_GET['view'] == 'answered') {
echo get_lang('ViewAnswered').' | ';
}
else
{
} else {
echo ' <a href="'.api_get_self().'?survey_id='.$survey_id.'&amp;view=answered">'.get_lang('ViewAnswered').'</a> |';
}
if ($_GET['view'] == 'unanswered')
{
if ($_GET['view'] == 'unanswered') {
echo get_lang('ViewUnanswered');
}
else
{
} else {
echo ' <a href="'.api_get_self().'?survey_id='.$survey_id.'&amp;view=unanswered">'.get_lang('ViewUnanswered').'</a>';
}
// table header
// Table header
echo '<table class="data_table">';
echo ' <tr>';
echo ' <th>'.get_lang('User').'</th>';
@ -143,38 +115,32 @@ $sql = "SELECT survey_invitation.*, user.firstname, user.lastname, user.email FR
LEFT JOIN $table_user user ON survey_invitation.user = user.user_id
WHERE survey_invitation.survey_code = '".Database::escape_string($survey_data['code'])."'";
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res))
{
if (!$_GET['view'] OR $_GET['view'] == 'invited' OR ($_GET['view'] == 'answered' AND in_array($row['user'], $answered_data)) OR ($_GET['view'] == 'unanswered' AND !in_array($row['user'], $answered_data)))
{
while ($row = Database::fetch_assoc($res)) {
if (!$_GET['view'] || $_GET['view'] == 'invited' || ($_GET['view'] == 'answered' && in_array($row['user'], $answered_data)) || ($_GET['view'] == 'unanswered' && !in_array($row['user'], $answered_data))) {
echo '<tr>';
if (is_numeric($row['user']))
{
if (is_numeric($row['user'])) {
echo ' <td><a href="../user/userInfo.php?editMainUserInfo='.$row['user'].'">'.api_get_person_name($row['firstname'], $row['lastname']).'</a></td>';
}
else
{
} else {
echo ' <td>'.$row['user'].'</td>';
}
echo ' <td>'.$row['invitation_date'].'</td>';
echo ' <td>';
if (in_array($row['user'], $answered_data))
{
if (in_array($row['user'], $answered_data)) {
echo '<a href="reporting.php?action=userreport&amp;survey_id='.$survey_id.'&amp;user='.$row['user'].'">'.get_lang('ViewAnswers').'</a>';
}
else
{
} else {
echo '-';
}
echo ' </td>';
echo '</tr>';
}
}
// closing the table
// Closing the table
echo '</table>';
// Footer
Display :: display_footer();
/**
* @todo add the additional parameters
*/

@ -1,53 +1,33 @@
<?php
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2009 Dokeos SPRL
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
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 the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/* For licensing terms, see /license.txt */
/**
* @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
* @author Julio Montoya Dokeos: cleanup, refactoring, security improvements
* @version $Id: survey_invite.php 10680 2007-01-11 21:26:23Z pcool $
*
* @todo checking if the additional emails are valid (or add a rule for this)
* @todo check if the mailtext contains the **link** part, if not, add the link to the end
* @todo add rules: title and text cannot be empty
*/
// name of the language file that needs to be included
* @package chamilo.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
* @author Julio Montoya Chamilo: cleanup, refactoring, security improvements
* @version $Id: survey_invite.php 10680 2007-01-11 21:26:23Z pcool $
*
* @todo checking if the additional emails are valid (or add a rule for this)
* @todo check if the mailtext contains the **link** part, if not, add the link to the end
* @todo add rules: title and text cannot be empty
*/
// Language file that needs to be included
$language_file = 'survey';
// including the global dokeos file
require ('../inc/global.inc.php');
// Including the global initialization file
require '../inc/global.inc.php';
// including additional libraries
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");
// Including additional libraries
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;
$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('ToolSurvey'));
Display :: display_error_message(get_lang('NotAllowed'), false);
Display :: display_footer();
@ -62,7 +42,7 @@ $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$user_info = Database::get_main_table(TABLE_MAIN_SURVEY_REMINDER); // TODO: To be checked. TABLE_MAIN_SURVEY_REMINDER has not been defined.
// getting the survey information
// Getting the survey information
$survey_id = Security::remove_XSS($_GET['survey_id']);
$survey_data = survey_manager::get_survey($survey_id);
if (empty($survey_data)) {
@ -73,36 +53,33 @@ if (empty($survey_data)) {
}
$urlname = strip_tags(api_substr(api_html_entity_decode($survey_data['title'],ENT_QUOTES,$charset), 0, 40));
if (api_strlen(strip_tags($survey_data['title'])) > 40)
{
$urlname = strip_tags(api_substr(api_html_entity_decode($survey_data['title'], ENT_QUOTES), 0, 40));
if (api_strlen(strip_tags($survey_data['title'])) > 40) {
$urlname .= '...';
}
// breadcrumbs
$interbreadcrumb[] = array ('url' => 'survey_list.php', 'name' => get_lang('SurveyList'));
// Breadcrumbs
$interbreadcrumb[] = array('url' => 'survey_list.php', 'name' => get_lang('SurveyList'));
if (api_is_course_admin()) {
$interbreadcrumb[] = array ('url' => 'survey.php?survey_id='.$survey_id, 'name' => $urlname);
$interbreadcrumb[] = array('url' => 'survey.php?survey_id='.$survey_id, 'name' => $urlname);
} else {
$interbreadcrumb[] = array ('url' => 'survey_invite.php?survey_id='.$survey_id, 'name' => $urlname);
$interbreadcrumb[] = array('url' => 'survey_invite.php?survey_id='.$survey_id, 'name' => $urlname);
}
$tool_name = get_lang('SurveyPublication');
// Displaying the header
Display::display_header($tool_name,'Survey');
// checking if there is another survey with this code.
// Checking if there is another survey with this code.
// If this is the case there will be a language choice
$sql = "SELECT * FROM $table_survey WHERE code='".Database::escape_string($survey_data['code'])."'";
$result = Database::query($sql);
if (Database::num_rows($result) > 1)
{
if (Database::num_rows($result) > 1) {
Display::display_warning_message(get_lang('IdenticalSurveycodeWarning'));
}
// invited / answered message
if ($survey_data['invited'] > 0)
{
// Invited / answered message
if ($survey_data['invited'] > 0) {
$message = '<a href="survey_invitation.php?view=answered&amp;survey_id='.$survey_data['survey_id'].'">'.$survey_data['answered'].'</a> ';
$message .= get_lang('HaveAnswered').' ';
$message .= '<a href="survey_invitation.php?view=invited&amp;survey_id='.$survey_data['survey_id'].'">'.$survey_data['invited'].'</a> ';
@ -110,16 +87,15 @@ if ($survey_data['invited'] > 0)
Display::display_normal_message($message, false);
}
// building the form for publishing the survey
$form = new FormValidator('publish_form','post', api_get_self().'?survey_id='.$survey_id);
// Building the form for publishing the survey
$form = new FormValidator('publish_form', 'post', api_get_self().'?survey_id='.$survey_id);
$form->addElement('header', '', $tool_name);
// Course users
$complete_user_list = CourseManager :: get_user_list_from_course_code($_course['id'], true, $_SESSION['id_session'], '', api_sort_by_first_name() ? 'ORDER BY firstname' : 'ORDER BY lastname');
$possible_users = array ();
foreach ($complete_user_list as $index => $user)
{
$possible_users = array();
foreach ($complete_user_list as $index => & $user) {
$possible_users[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
}
$users = $form->addElement('advmultiselect', 'course_users', get_lang('CourseUsers'), $possible_users, 'style="width: 250px; height: 200px;"');
@ -135,80 +111,73 @@ $users->setElementTemplate('
</tr>
</table>
');
$users->setButtonAttributes('add',array('class'=>'arrowr'));
$users->setButtonAttributes('remove',array('class'=>'arrowl'));
// additional users
$form->addElement('textarea', 'additional_users', get_lang('AdditonalUsers'), array ('cols' => 50, 'rows' => 2));
// additional users comment
$users->setButtonAttributes('add', array('class' => 'arrowr'));
$users->setButtonAttributes('remove', array('class' => 'arrowl'));
// Additional users
$form->addElement('textarea', 'additional_users', get_lang('AdditonalUsers'), array('cols' => 50, 'rows' => 2));
// Additional users comment
$form->addElement('static', null, null, get_lang('AdditonalUsersComment'));
// the title of the mail
$form->addElement('text', 'mail_title', get_lang('MailTitle'),array('size' => '80'));
// the text of the mail
// The title of the mail
$form->addElement('text', 'mail_title', get_lang('MailTitle'), array('size' => '80'));
// The text of the mail
$form->addElement('html_editor', 'mail_text', get_lang('MailText'), null, array('ToolbarSet' => 'Survey', 'Width' => '100%', 'Height' => '150'));
// some explanation of the mail
// Some explanation of the mail
$form->addElement('static', null, null, get_lang('UseLinkSyntax'));
$form->addElement('checkbox', 'send_mail', '', get_lang('SendMail'));
// you cab send a reminder to unanswered people if the survey is not anonymous
// You cab send a reminder to unanswered people if the survey is not anonymous
if ($survey_data['anonymous'] != 1) {
$form->addElement('checkbox', 'remindUnAnswered', '', get_lang('RemindUnanswered'));
$form->addElement('checkbox', 'remindUnAnswered', '', get_lang('RemindUnanswered'));
}
// allow resending to all selected users
// Allow resending to all selected users
$form->addElement('checkbox', 'resend_to_all', '', get_lang('ReminderResendToAllUsers'));
// submit button
// Submit button
$form->addElement('style_submit_button', 'submit', get_lang('PublishSurvey'), 'class="save"');
// The rules (required fields)
$form->addRule('mail_title', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('mail_text', get_lang('ThisFieldIsRequired'), 'required');
$portal_url = $_configuration['root_web'];
if ($_configuration['multiple_access_urls']==true) {
if ($_configuration['multiple_access_urls']) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1 ){
if ($access_url_id != -1) {
$url = api_get_access_url($access_url_id);
$portal_url = $url['url'];
}
}
// show the URL that can be used by users to fill a survey without invitation
// Show the URL that can be used by users to fill a survey without invitation
$auto_survey_link = $portal_url.$_configuration['code_append'].
'survey/'.'fillsurvey.php?course='.$_course['sysCode'].
'&invitationcode=auto&scode='.$survey_data['survey_code'];
'survey/'.'fillsurvey.php?course='.$_course['sysCode'].
'&invitationcode=auto&scode='.$survey_data['survey_code'];
$form->addElement('static',null, null, '<br \><br \>' . get_lang('AutoInviteLink'));
$form->addElement('static',null, null, $auto_survey_link);
if ($form->validate())
{
if ($form->validate()) {
$values = $form->exportValues();
// save the invitation mail
// Save the invitation mail
SurveyUtil::save_invite_mail($values['mail_text'], $values['mail_title'], !empty($survey_data['invite_mail']));
// saving the invitations for the course users
// Saving the invitations for the course users
$count_course_users = SurveyUtil::save_invitations($values['course_users'], $values['mail_title'],
$values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']);
// saving the invitations for the additional users
$values['additional_users'] = $values['additional_users'].';'; // this is for the case when you enter only one email
$temp = str_replace(',',';',$values['additional_users']); // this is to allow , and ; as email separators
$additional_users = explode(';',$temp);
for($i=0; $i<count($additional_users); $i++)
{
$values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']);
// Saving the invitations for the additional users
$values['additional_users'] = $values['additional_users'].';'; // This is for the case when you enter only one email
$temp = str_replace(',', ';', $values['additional_users']); // This is to allow , and ; as email separators
$additional_users = explode(';', $temp);
for ($i = 0; $i < count($additional_users); $i++) {
$additional_users[$i] = trim($additional_users[$i]);
}
$counter_additional_users = SurveyUtil::save_invitations($additional_users, $values['mail_title'],
$values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']);
// updating the invited field in the survey table
$values['mail_text'], $values['resend_to_all'], $values['send_mail'], $values['remindUnAnswered']);
// Updating the invited field in the survey table
SurveyUtil::update_count_invited($survey_data['code']);
$total_count = $count_course_users + $counter_additional_users;
Display :: display_confirmation_message($total_count.' '.get_lang('InvitationsSend'));
}
else
{
// getting the invited users
} else {
// Getting the invited users
$defaults = SurveyUtil::get_invited_users($survey_data['code']);
// getting the survey mail text
if (!empty($survey_data['reminder_mail']))
{
// Getting the survey mail text
if (!empty($survey_data['reminder_mail'])) {
$defaults['mail_text'] = $survey_data['reminder_mail'];
}
else
{
} else {
$defaults['mail_text'] = $survey_data['invite_mail'];
}
$defaults['mail_title'] = $survey_data['mail_subject'];
@ -219,4 +188,3 @@ else
// Footer
Display :: display_footer();
?>

@ -1,59 +1,38 @@
<?php // $Id: survey_list.php 21933 2009-07-09 06:08:22Z ivantcholakov $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
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 the GNU General Public License for more details.
Contact: Dokeos, rue Notre Dame, 152, B-1140 Evere, Belgium, info@dokeos.com
==============================================================================
*/
<?php
/* For licensing terms, see /license.txt */
/**
* @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
* @author Julio Montoya Armas <gugli100@gmail.com>, Dokeos: Personality Test modification and rewriting large parts of the code
* @version $Id: survey_list.php 21933 2009-07-09 06:08:22Z ivantcholakov $
*
* @todo use quickforms for the forms
*/
// name of the language file that needs to be included
* @package chamilo.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
* @author Julio Montoya Armas <gugli100@gmail.com>, Chamilo: Personality Test modification and rewriting large parts of the code
* @version $Id: survey_list.php 21933 2009-07-09 06:08:22Z ivantcholakov $
*
* @todo use quickforms for the forms
*/
// Language file that needs to be included
$language_file = 'survey';
if (!isset ($_GET['cidReq'])){
$_GET['cidReq']='none'; // prevent sql errors
$_GET['cidReq'] = 'none'; // Prevent sql errors
$cidReset = true;
}
// including the global dokeos file
// Including the global initialization file
require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;
// including additional libraries
// Including additional libraries
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
//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';
//Tracking
// Tracking
event_access_tool(TOOL_SURVEY);
/** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
if (!api_is_allowed_to_edit(false,true)) //coach can see this
{
/** @todo This has to be moved to a more appropriate place (after the display_header of the code)*/
if (!api_is_allowed_to_edit(false, true)) { // Coach can see this
Display :: display_header(get_lang('SurveyList'));
SurveyUtil::survey_list_user($_user['user_id']);
Display :: display_footer();
@ -68,62 +47,51 @@ $table_survey_question = Database :: get_course_table(TABLE_SURVEY_QUESTION);
$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
// language variables
if (isset ($_GET['search']) && $_GET['search'] == 'advanced')
{
$interbreadcrumb[] = array ('url' => 'survey_list.php', 'name' => get_lang('SurveyList'));
// Language variables
if (isset($_GET['search']) && $_GET['search'] == 'advanced') {
$interbreadcrumb[] = array('url' => 'survey_list.php', 'name' => get_lang('SurveyList'));
$tool_name = get_lang('SearchASurvey');
}
else
{
} else {
$tool_name = get_lang('SurveyList');
}
// Header
Display :: display_header($tool_name,'Survey');
Display :: display_header($tool_name, 'Survey');
//api_display_tool_title($tool_name);
// Tool introduction
Display::display_introduction_section('survey', 'left');
// Action handling: searching
if (isset ($_GET['search']) AND $_GET['search'] == 'advanced')
{
if (isset ($_GET['search']) && $_GET['search'] == 'advanced') {
SurveyUtil::display_survey_search_form();
}
// Action handling: deleting a survey
if (isset($_GET['action']) AND $_GET['action'] == 'delete' AND isset($_GET['survey_id']) AND is_numeric($_GET['survey_id']))
{
// getting the information of the survey (used for when the survey is shared)
if (isset($_GET['action']) && $_GET['action'] == 'delete' && isset($_GET['survey_id']) && is_numeric($_GET['survey_id'])) {
// Getting the information of the survey (used for when the survey is shared)
$survey_data = survey_manager::get_survey($_GET['survey_id']);
if(api_is_course_coach() && intval($_SESSION['id_session']) != $survey_data['session_id'])
{ // the coach can't delete a survey not belonging to his session
if (api_is_course_coach() && intval($_SESSION['id_session']) != $survey_data['session_id']) {
// The coach can't delete a survey not belonging to his session
api_not_allowed();
exit;
}
// if the survey is shared => also delete the shared content
if (is_numeric($survey_data['survey_share']))
{
// If the survey is shared => also delete the shared content
if (is_numeric($survey_data['survey_share'])) {
survey_manager::delete_survey($survey_data['survey_share'], true);
}
$return = survey_manager :: delete_survey($_GET['survey_id']);
if ($return)
{
if ($return) {
Display :: display_confirmation_message(get_lang('SurveyDeleted'), false);
}
else
{
} else {
Display :: display_error_message(get_lang('ErrorOccurred'), false);
}
}
if(isset($_GET['action']) && $_GET['action'] == 'empty')
{
if (isset($_GET['action']) && $_GET['action'] == 'empty') {
$mysession = api_get_session_id();
if ( $mysession != 0 ) {
if(!((api_is_course_coach() || api_is_platform_admin()) && api_is_element_in_the_session(TOOL_SURVEY,intval($_GET['survey_id'])))) {
// the coach can't empty a survey not belonging to his session
if (!((api_is_course_coach() || api_is_platform_admin()) && api_is_element_in_the_session(TOOL_SURVEY,intval($_GET['survey_id'])))) {
// The coach can't empty a survey not belonging to his session
api_not_allowed();
exit;
}
@ -134,44 +102,36 @@ if(isset($_GET['action']) && $_GET['action'] == 'empty')
}
}
$return = survey_manager::empty_survey(intval($_GET['survey_id']));
if ($return)
{
if ($return) {
Display :: display_confirmation_message(get_lang('SurveyEmptied'), false);
}
else
{
} else {
Display :: display_error_message(get_lang('ErrorOccurred'), false);
}
}
// Action handling: performing the same action on multiple surveys
if ($_POST['action'])
{
if (is_array($_POST['id']))
{
foreach ($_POST['id'] as $key=>$value)
if ($_POST['action']) {
if (is_array($_POST['id'])) {
foreach ($_POST['id'] as $key => & $value)
{
// getting the information of the survey (used for when the survey is shared)
$survey_data = survey_manager::get_survey($value);
// if the survey is shared => also delete the shared content
if (is_numeric($survey_data['survey_share']))
{
if (is_numeric($survey_data['survey_share'])) {
survey_manager::delete_survey($survey_data['survey_share'], true);
}
// delete the actual survey
survey_manager::delete_survey($value);
}
Display :: display_confirmation_message(get_lang('SurveysDeleted'), false);
}
else
{
} else {
Display :: display_error_message(get_lang('NoSurveysSelected'), false);
}
}
echo $extended_rights_for_coachs;
echo '<div class="actions">';
if (!api_is_course_coach() || $extend_rights_for_coachs=='true')
{
if (!api_is_course_coach() || $extend_rights_for_coachs == 'true') {
// Action links
echo Display::return_icon('surveyadd.gif', get_lang('CreateNewSurvey')) . '<a href="create_new_survey.php?'.api_get_cidreq().'&amp;action=add">'.get_lang('CreateNewSurvey').'</a> ';
}
@ -179,49 +139,41 @@ if (!api_is_course_coach() || $extend_rights_for_coachs=='true')
echo Display::return_icon('search.gif', get_lang('Search')) . '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;search=advanced">'.get_lang('Search').'</a>';
echo '</div>';
//Load main content
if (api_is_course_coach() && $extend_rights_for_coachs=='false')
// Load main content
if (api_is_course_coach() && $extend_rights_for_coachs == 'false') {
SurveyUtil::display_survey_list_for_coach();
else
} else {
SurveyUtil::display_survey_list();
}
// Footer
Display :: display_footer();
/* Bypass functions to make direct use from SortableTable possible */
function get_number_of_surveys()
{
function get_number_of_surveys() {
return SurveyUtil::get_number_of_surveys();
}
function get_survey_data($from, $number_of_items, $column, $direction)
{
function get_survey_data($from, $number_of_items, $column, $direction) {
return SurveyUtil::get_survey_data($from, $number_of_items, $column, $direction);
}
function modify_filter($survey_id)
{
function modify_filter($survey_id) {
return SurveyUtil::modify_filter($survey_id);
}
function get_number_of_surveys_for_coach()
{
function get_number_of_surveys_for_coach() {
return SurveyUtil::get_number_of_surveys_for_coach();
}
function get_survey_data_for_coach($from, $number_of_items, $column, $direction)
{
function get_survey_data_for_coach($from, $number_of_items, $column, $direction) {
return SurveyUtil::get_survey_data_for_coach($from, $number_of_items, $column, $direction);
}
function modify_filter_for_coach($survey_id)
{
function modify_filter_for_coach($survey_id) {
return SurveyUtil::modify_filter_for_coach($survey_id);
}
function anonymous_filter($anonymous)
{
function anonymous_filter($anonymous) {
return SurveyUtil::anonymous_filter($anonymous);
}

Loading…
Cancel
Save