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.
162 lines
5.1 KiB
162 lines
5.1 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: survey_list.php 14784 2008-04-08 12:58:45Z 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');
|
|
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)*/
|
|
if (!api_is_allowed_to_edit())
|
|
{
|
|
Display :: display_header(get_lang('SurveyList'));
|
|
SurveyUtil::survey_list_user($_user['user_id']);
|
|
Display :: display_footer();
|
|
exit;
|
|
}
|
|
|
|
// Database table definitions
|
|
$table_survey = Database :: get_course_table(TABLE_SURVEY);
|
|
$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'));
|
|
$tool_name = get_lang('SearchASurvey');
|
|
}
|
|
else
|
|
{
|
|
$tool_name = get_lang('SurveyList');
|
|
}
|
|
|
|
// Header
|
|
Display :: display_header($tool_name);
|
|
//api_display_tool_title($tool_name);
|
|
|
|
// Action handling: searching
|
|
if (isset ($_GET['search']) AND $_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)
|
|
$survey_data = survey_manager::get_survey($_GET['survey_id']);
|
|
// 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)
|
|
{
|
|
Display :: display_confirmation_message(get_lang('SurveyDeleted'), false);
|
|
}
|
|
else
|
|
{
|
|
Display :: display_error_message(get_lang('ErrorOccurred'), false);
|
|
}
|
|
}
|
|
|
|
if(isset($_GET['action']) && $_GET['action'] == 'empty')
|
|
{
|
|
$return = survey_manager::empty_survey(intval($_GET['survey_id']));
|
|
if ($return)
|
|
{
|
|
Display :: display_confirmation_message(get_lang('SurveyEmptied'), false);
|
|
}
|
|
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)
|
|
{
|
|
// 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']))
|
|
{
|
|
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
|
|
{
|
|
Display :: display_error_message(get_lang('NoSurveysSelected'), false);
|
|
}
|
|
}
|
|
|
|
|
|
// Action links
|
|
echo '<a href="create_new_survey.php?'.api_get_cidreq().'&action=add">'.get_lang('CreateNewSurvey').'</a> | ';
|
|
//echo '<a href="survey_all_courses.php">'.get_lang('CreateExistingSurvey').'</a> | ';
|
|
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&search=advanced">'.get_lang('Search').'</a>';
|
|
|
|
// Main content
|
|
SurveyUtil::display_survey_list();
|
|
|
|
// Footer
|
|
Display :: display_footer();
|
|
|
|
/* Bypass functions to make direct use from SortableTable possible */
|
|
function get_number_of_surveys()
|
|
{
|
|
return SurveyUtil::get_number_of_surveys();
|
|
}
|
|
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)
|
|
{
|
|
return SurveyUtil::modify_filter($survey_id);
|
|
}
|
|
function anonymous_filter($anonymous)
|
|
{
|
|
return SurveyUtil::anonymous_filter($anonymous);
|
|
} |