Minor - format code

pull/2487/head
jmontoyaa 9 years ago
parent d573043c30
commit 613a560bb3
  1. 10
      main/survey/create_new_survey.php
  2. 29
      main/survey/fillsurvey.php
  3. 256
      main/survey/preview.php
  4. 52
      main/survey/question.php
  5. 10
      main/survey/reporting.php
  6. 14
      main/survey/survey.download.inc.php
  7. 259
      main/survey/survey.php
  8. 45
      main/survey/survey_invitation.php
  9. 207
      main/survey/survey_invite.php
  10. 12
      main/survey/survey_list.php

@ -2,14 +2,14 @@
/* For licensing terms, see /license.txt */
/**
* @package chamilo.survey
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup,
* @package chamilo.survey
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup,
* refactoring and rewriting large parts (if not all) of the code
* @author Julio Montoya Armas <gugli100@gmail.com>, Chamilo: Personality
* @author Julio Montoya Armas <gugli100@gmail.com>, Chamilo: Personality
* Test modification and rewriting large parts of the code
* @version $Id: create_new_survey.php 22297 2009-07-22 22:08:30Z cfasanando $
* @version $Id: create_new_survey.php 22297 2009-07-22 22:08:30Z cfasanando $
*
* @todo only the available platform languages should be used => need an
* @todo only the available platform languages should be used => need an
* api get_languages and and api_get_available_languages (or a parameter)
*/

@ -2,12 +2,12 @@
/* For licensing terms, see /license.txt */
/**
* @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 as well
* @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 as well
* @todo check if the user already filled the survey and if this is the case then the answers have to be updated and not stored again.
* @todo performance could be improved if not the survey_id was stored with the invitation but the survey_code
* @todo performance could be improved if not the survey_id was stored with the invitation but the survey_code
*/
// Unsetting the course id (because it is in the URL)
if (!isset($_GET['cidReq'])) {
@ -138,8 +138,7 @@ if (Database::num_rows($result) < 1) {
$survey_invitation = Database::fetch_array($result, 'ASSOC');
// Now we check if the user already filled the survey
if (
!isset($_POST['finish_survey']) &&
if (!isset($_POST['finish_survey']) &&
(
$isAnonymous &&
isset($_SESSION['surveyuser']) &&
@ -216,7 +215,6 @@ if (count($_POST) > 0) {
when it is a scoring question then the key of the array is the option_id and the value is the value
*/
if (is_array($value)) {
SurveyUtil::remove_answer(
$survey_invitation['user'],
$survey_invitation['survey_id'],
@ -341,7 +339,6 @@ if (count($_POST) > 0) {
}
} else {
// In case it's another type than 0 or 1
die(get_lang('ErrorSurveyTypeUnknown'));
}
}
@ -477,10 +474,9 @@ if ($survey_data['form_fields'] != '' &&
// EXTRA FIELDS
$extraField = new ExtraField('user');
$returnParams = $extraField->addElements($form, api_get_user_id());
$jquery_ready_content = $returnParams['jquery_ready_content'];
// the $jquery_ready_content variable collects all functions that will be load in the $(document).ready javascript function
// the $jquery_ready_content variable collects all functions that will be load in the $(document).ready javascript function
$htmlHeadXtra[] = '<script>
$(document).ready(function(){
'.$jquery_ready_content.'
@ -642,7 +638,6 @@ if (isset($_GET['show']) || isset($_POST['personality'])) {
if (array_key_exists($_GET['show'], $paged_questions)) {
if (isset($_GET['user_id'])) {
// Get the user into survey answer table (user or anonymus)
$my_user_id = ($survey_data['anonymous'] == 1) ? $_SESSION['surveyuser'] : api_get_user_id();
@ -704,9 +699,7 @@ if (isset($_GET['show']) || isset($_POST['personality'])) {
$counter = 0;
$limit = 0;
$questions = array();
while ($row = Database :: fetch_array($result, 'ASSOC')) {
// 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'];
@ -867,7 +860,9 @@ if (isset($_GET['show']) || isset($_POST['personality'])) {
// If there is one or less score equalities
if ($equal_count === 0 || $equal_count === 1) {
// i.e 70% - 70% -60% - 60% $equal_count = 1 we only get the first 2 options
if (($result[0]['value'] == $result[1]['value']) && ($result[2]['value'] == $result[3]['value'])) {
if (($result[0]['value'] == $result[1]['value']) &&
($result[2]['value'] == $result[3]['value'])
) {
$group_cant = 1;
}
// i.e 70% - 70% -0% - 0% - $equal_count = 0 we only get the first 2 options
@ -938,7 +933,6 @@ if (isset($_GET['show']) || isset($_POST['personality'])) {
!is_array($_SESSION['page_questions_sec']) &&
count($_SESSION['page_questions_sec'] == 0)
) {
$sql = "SELECT * FROM $table_survey_question
WHERE
c_id = $course_id AND
@ -962,8 +956,6 @@ if (isset($_GET['show']) || isset($_POST['personality'])) {
} else {
$paged_questions_sec = $_SESSION['paged_questions_sec'];
}
//print_r($paged_questions_sec);
$paged_questions = $_SESSION['paged_questions']; // For the sake of pages counting
//$paged_questions = $paged_questions_sec; // For the sake of pages counting coming up at display time...
@ -977,7 +969,6 @@ if (isset($_GET['show']) || isset($_POST['personality'])) {
//}
//echo '<pre>'; print_r($paged_questions_sec); echo '</pre>';
if (is_array($paged_questions_sec)) {
$sql = "SELECT
survey_question.survey_group_sec1,
survey_question.survey_group_sec2,

@ -2,11 +2,11 @@
/* For licensing terms, see /license.txt */
/**
* @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 $
* @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 $
*/
require_once __DIR__.'/../inc/global.inc.php';
@ -43,8 +43,11 @@ if (Database::num_rows($result) > 0) {
// We exit here if there is no valid $_GET parameter
if (!isset($_GET['survey_id']) || !is_numeric($_GET['survey_id'])) {
api_not_allowed(true, Display::return_message(get_lang('InvallidSurvey'), 'error', false));
exit;
api_not_allowed(
true,
Display::return_message(get_lang('InvallidSurvey'), 'error', false)
);
exit;
}
// Getting the survey information
@ -52,14 +55,17 @@ $survey_id = intval($_GET['survey_id']);
$survey_data = SurveyManager::get_survey($survey_id);
if (empty($survey_data)) {
api_not_allowed(true, Display::return_message(get_lang('InvallidSurvey'), 'error', false));
exit;
api_not_allowed(
true,
Display::return_message(get_lang('InvallidSurvey'), 'error', false)
);
exit;
}
$urlname = strip_tags($survey_data['title']);
if (api_is_allowed_to_edit()) {
// Breadcrumbs
$interbreadcrumb[] = array(
// Breadcrumbs
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq(),
'name' => get_lang('SurveyList')
);
@ -86,57 +92,57 @@ SurveyUtil::check_first_last_question($survey_id, 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)
(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>';
// 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'])) {
if (!empty($survey_data['survey_introduction'])) {
echo '<div id="survey_content" class="survey_content">'.$survey_data['survey_introduction'].'</div>';
}
$limit = 0;
}
$limit = 0;
}
// Displaying the survey thanks message
if (isset($_POST['finish_survey'])) {
Display::display_confirmation_message(get_lang('SurveyFinished'));
// Displaying the survey thanks message
if (isset($_POST['finish_survey'])) {
Display::display_confirmation_message(get_lang('SurveyFinished'));
echo $survey_data['survey_thanks'];
Display :: display_footer();
exit;
}
Display :: display_footer();
exit;
}
$questions = array();
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();
$paged_questions = array();
$counter = 0;
$sql = "SELECT * FROM $table_survey_question
WHERE c_id = $course_id AND survey_id = '".intval($survey_id)."'
ORDER BY sort ASC";
$result = Database::query($sql);
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();
$paged_questions = array();
$counter = 0;
$sql = "SELECT * FROM $table_survey_question
WHERE c_id = $course_id AND survey_id = '".intval($survey_id)."'
ORDER BY sort ASC";
$result = Database::query($sql);
$questions_exists = true;
if (Database::num_rows($result)) {
while ($row = Database::fetch_array($result)) {
if ($row['type'] == 'pagebreak') {
$counter++;
} else {
$paged_questions[$counter][] = $row['question_id'];
}
}
while ($row = Database::fetch_array($result)) {
if ($row['type'] == 'pagebreak') {
$counter++;
} else {
$paged_questions[$counter][] = $row['question_id'];
}
}
} else {
$questions_exists = false;
}
if (array_key_exists($_GET['show'], $paged_questions)) {
$sql = "SELECT
if (array_key_exists($_GET['show'], $paged_questions)) {
$sql = "SELECT
survey_question.question_id,
survey_question.survey_id,
survey_question.survey_question,
@ -144,89 +150,89 @@ if (api_is_course_admin() ||
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 AND
survey_question_option.c_id = $course_id
WHERE
survey_question.survey_id = '".intval($survey_id)."' AND
survey_question.question_id IN (".Database::escape_string(implode(',', $paged_questions[$_GET['show']]), null, false).") AND
survey_question.c_id = $course_id
ORDER BY survey_question.sort, survey_question_option.sort ASC";
$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') {
$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'];
} else {
// If the type is a pagebreak we are finished loading the questions for this page
break;
}
$counter_question++;
}
}
}
// Selecting the maximum number of pages
$sql = "SELECT * FROM $table_survey_question
WHERE
c_id = $course_id AND
type='".Database::escape_string('pagebreak')."' AND
survey_id='".intval($survey_id)."'";
$result = Database::query($sql);
$numberofpages = Database::num_rows($result) + 1;
// Displaying the form with the questions
if (isset($_GET['show'])) {
$show = (int) $_GET['show'] + 1;
} else {
$show = 0;
}
$url = api_get_self().'?survey_id='.Security::remove_XSS($survey_id).'&show='.$show;
$form = new FormValidator('question', 'post', $url);
if (is_array($questions) && count($questions) > 0) {
foreach ($questions as $key => & $question) {
$ch_type = 'ch_'.$question['type'];
/** @var survey_question $display */
$display = new $ch_type;
$form->addHtml('<div class="survey_question_wrapper"><div class="survey_question">');
$form->addHtml($question['survey_question']);
$display->render($form, $question);
$form->addHtml('</div></div>');
}
}
if (($show < $numberofpages) || (!$_GET['show'] && count($questions) > 0)) {
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 AND
survey_question_option.c_id = $course_id
WHERE
survey_question.survey_id = '".intval($survey_id)."' AND
survey_question.question_id IN (".Database::escape_string(implode(',', $paged_questions[$_GET['show']]), null, false).") AND
survey_question.c_id = $course_id
ORDER BY survey_question.sort, survey_question_option.sort ASC";
$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') {
$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'];
} else {
// If the type is a pagebreak we are finished loading the questions for this page
break;
}
$counter_question++;
}
}
}
// Selecting the maximum number of pages
$sql = "SELECT * FROM $table_survey_question
WHERE
c_id = $course_id AND
type='".Database::escape_string('pagebreak')."' AND
survey_id='".intval($survey_id)."'";
$result = Database::query($sql);
$numberofpages = Database::num_rows($result) + 1;
// Displaying the form with the questions
if (isset($_GET['show'])) {
$show = (int) $_GET['show'] + 1;
} else {
$show = 0;
}
$url = api_get_self().'?survey_id='.Security::remove_XSS($survey_id).'&show='.$show;
$form = new FormValidator('question', 'post', $url);
if (is_array($questions) && count($questions) > 0) {
foreach ($questions as $key => & $question) {
$ch_type = 'ch_'.$question['type'];
/** @var survey_question $display */
$display = new $ch_type;
$form->addHtml('<div class="survey_question_wrapper"><div class="survey_question">');
$form->addHtml($question['survey_question']);
$display->render($form, $question);
$form->addHtml('</div></div>');
}
}
if (($show < $numberofpages) || (!$_GET['show'] && count($questions) > 0)) {
if ($show == 0) {
$form->addButton('next_survey_page', get_lang('StartSurvey'), 'arrow-right', 'success', 'large');
$form->addButton('next_survey_page', get_lang('StartSurvey'), 'arrow-right', 'success', 'large');
} else {
$form->addButton('next_survey_page', get_lang('NextQuestion'), 'arrow-right');
$form->addButton('next_survey_page', get_lang('NextQuestion'), 'arrow-right');
}
}
if ($show >= $numberofpages && $_GET['show'] || (isset($_GET['show']) && count($questions) == 0)) {
if ($questions_exists == false) {
echo '<p>'.get_lang('ThereAreNotQuestionsForthisSurvey').'</p>';
}
}
if ($show >= $numberofpages && $_GET['show'] || (isset($_GET['show']) && count($questions) == 0)) {
if ($questions_exists == false) {
echo '<p>'.get_lang('ThereAreNotQuestionsForthisSurvey').'</p>';
}
$form->addButton('finish_survey', get_lang('FinishSurvey'), 'arrow-right');
}
$form->display();
$form->addButton('finish_survey', get_lang('FinishSurvey'), 'arrow-right');
}
$form->display();
} else {
Display :: display_error_message(get_lang('NotAllowed'), false);
Display :: display_error_message(get_lang('NotAllowed'), false);
}
Display :: display_footer();

@ -2,11 +2,11 @@
/* For licensing terms, see /license.txt */
/**
* @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 $
*/
* @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 $
*/
require_once __DIR__.'/../inc/global.inc.php';
@ -70,10 +70,10 @@ $interbreadcrumb[] = array(
// Tool name
if ($_GET['action'] == 'add') {
$tool_name = get_lang('AddQuestion');
$tool_name = get_lang('AddQuestion');
}
if ($_GET['action'] == 'edit') {
$tool_name = get_lang('EditQuestion');
$tool_name = get_lang('EditQuestion');
}
// The possible question types
@ -93,14 +93,14 @@ $possible_types = array(
// Actions
$actions = '<div class="actions">';
$actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.intval($_GET['survey_id']).'">'.
Display::return_icon('back.png', get_lang('BackToSurvey'), '', ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('back.png', get_lang('BackToSurvey'), '', ICON_SIZE_MEDIUM).'</a>';
$actions .= '</div>';
// 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();
Display :: display_header($tool_name, 'Survey');
echo $actions;
Display :: display_error_message(get_lang('TypeDoesNotExist'), false);
Display :: display_footer();
}
$error_message = '';
@ -116,27 +116,27 @@ $formData = array();
$formData['answers'] = array('', '');
if ($_GET['type'] == 'yesno') {
$formData['answers'][0] = get_lang('Yes');
$formData['answers'][1] = get_lang('No');
$formData['answers'][0] = get_lang('Yes');
$formData['answers'][1] = get_lang('No');
}
if ($_GET['type'] == 'personality') {
$formData['answers'][0] = 1;
$formData['answers'][1] = 2;
$formData['answers'][2] = 3;
$formData['answers'][3] = 4;
$formData['answers'][4] = 5;
$formData['values'][0] = 0;
$formData['values'][1] = 0;
$formData['values'][2] = 1;
$formData['values'][3] = 2;
$formData['values'][4] = 3;
$formData['answers'][0] = 1;
$formData['answers'][1] = 2;
$formData['answers'][2] = 3;
$formData['answers'][3] = 4;
$formData['answers'][4] = 5;
$formData['values'][0] = 0;
$formData['values'][1] = 0;
$formData['values'][2] = 1;
$formData['values'][3] = 2;
$formData['values'][4] = 3;
}
// We are editing a question
if (isset($_GET['question_id']) && !empty($_GET['question_id'])) {
$formData = SurveyManager::get_question($_GET['question_id']);
$formData = SurveyManager::get_question($_GET['question_id']);
}
$formData = $surveyQuestion->preSave($formData);

@ -2,12 +2,12 @@
/* For licensing terms, see /license.txt */
/**
* @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 $
* @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)
* @todo The question has to be more clearly indicated (same style as when filling the survey)
*/
require_once __DIR__.'/../inc/global.inc.php';

@ -2,13 +2,13 @@
/* For licensing terms, see /license.txt */
/**
* @package chamilo.survey
* @author Arnaud Ligot <arnaud@cblue.be>
* @version $Id: $
* @package chamilo.survey
* @author Arnaud Ligot <arnaud@cblue.be>
* @version $Id: $
*
* 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
* 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)
@ -44,9 +44,7 @@ function check_download_survey($course, $invitation, $doc_url)
}
// Very basic security check: check if a text field from a survey/answer/option contains the name of the document requested
// Fetch survey ID
// If this is the case there will be a language choice
$sql = "SELECT * FROM $table_survey
WHERE

@ -1,14 +1,15 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* @package chamilo.survey
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts of the code
* @author Julio Montoya
* @package chamilo.survey
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University:
* cleanup, refactoring and rewriting large parts of the code
* @author Julio Montoya
*/
use ChamiloSession as Session;
// Including the global initialization file
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
@ -20,8 +21,8 @@ api_protect_course_script(true);
// Coach can't view this page
$extend_rights_for_coachs = api_get_setting('extend_rights_for_coach_on_survey');
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(),
api_get_course_info()
api_get_user_id(),
api_get_course_info()
);
if ($isDrhOfCourse) {
@ -32,7 +33,7 @@ if (!api_is_allowed_to_edit(false, true) ||
(api_is_course_coach() && $extend_rights_for_coachs == 'false')
) {
api_not_allowed(true);
exit;
exit;
}
// Database table definitions
@ -49,8 +50,8 @@ $action = isset($_GET['action']) ? $_GET['action'] : null;
// Breadcrumbs
$interbreadcrumb[] = array(
'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php',
'name' => get_lang('SurveyList'),
'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php',
'name' => get_lang('SurveyList'),
);
// Getting the survey information
@ -79,7 +80,7 @@ if ($is_survey_type_1 && ($action == 'addgroup' || $action == 'deletegroup')) {
Database::query('UPDATE '.$table_survey_question_group.' SET description = \''.Database::escape_string($_POST['description']).'\'
WHERE c_id = '.$course_id.' AND 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.' (c_id, name,description,survey_id) values ('.$course_id.', \''.Database::escape_string($_POST['name']).'\',\''.Database::escape_string($_POST['description']).'\',\''.Database::escape_string($survey_id).'\') ');
$sendmsg = 'GroupCreatedSuccessfully';
} else {
@ -106,16 +107,26 @@ $my_survey_id_survey = Security::remove_XSS($_GET['survey_id']);
$message_information = isset($_GET['message']) ? Security::remove_XSS($_GET['message']) : null;
if (isset($action)) {
if (($action == 'moveup' || $action == 'movedown') && isset($_GET['question_id'])) {
SurveyManager::move_survey_question($my_action_survey,$my_question_id_survey,$my_survey_id_survey);
echo Display::return_message(get_lang('SurveyQuestionMoved'), 'confirmation');
}
if ($action == 'delete' && is_numeric($_GET['question_id'])) {
SurveyManager::delete_survey_question($my_survey_id_survey, $my_question_id_survey, $survey_data['is_shared']);
}
if (($action == 'moveup' || $action == 'movedown') && isset($_GET['question_id'])) {
SurveyManager::move_survey_question(
$my_action_survey,
$my_question_id_survey,
$my_survey_id_survey
);
echo Display::return_message(get_lang('SurveyQuestionMoved'), 'confirmation');
}
if ($action == 'delete' && is_numeric($_GET['question_id'])) {
SurveyManager::delete_survey_question(
$my_survey_id_survey,
$my_question_id_survey,
$survey_data['is_shared']
);
}
}
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']);
@ -130,26 +141,26 @@ $survey_actions .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php
echo '<div class="actions">'.$survey_actions.'</div>';
if ($survey_data['survey_type'] == 0) {
echo '<div class="panel panel-default">';
echo '<div class="panel-body">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=yesno&amp;survey_id='.$survey_id.'">'.Display::return_icon('yesno.png', get_lang('YesNo'), null, ICON_SIZE_BIG).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=multiplechoice&amp;survey_id='.$survey_id.'">'.Display::return_icon('mcua.png', get_lang('UniqueSelect'), null, ICON_SIZE_BIG).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=multipleresponse&amp;survey_id='.$survey_id.'">'.Display::return_icon('mcma.png', get_lang('MultipleResponse'), null, ICON_SIZE_BIG).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=open&amp;survey_id='.$survey_id.'">'.Display::return_icon('open_answer.png', get_lang('Open'), null, ICON_SIZE_BIG).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=dropdown&amp;survey_id='.$survey_id.'">'.Display::return_icon('dropdown.png', get_lang('Dropdown'), null, ICON_SIZE_BIG).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=percentage&amp;survey_id='.$survey_id.'">'.Display::return_icon('percentagequestion.png', get_lang('Percentage'), null, ICON_SIZE_BIG).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=score&amp;survey_id='.$survey_id.'">'.Display::return_icon('scorequestion.png', get_lang('Score'), null, ICON_SIZE_BIG).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=comment&amp;survey_id='.$survey_id.'">'.Display::return_icon('commentquestion.png', get_lang('Comment'), null, ICON_SIZE_BIG).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=pagebreak&amp;survey_id='.$survey_id.'">'.Display::return_icon('page_end.png', get_lang('Pagebreak'), null, ICON_SIZE_BIG).'</a>';
echo '</div>';
echo '<div class="panel panel-default">';
echo '<div class="panel-body">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=yesno&survey_id='.$survey_id.'">'.Display::return_icon('yesno.png', get_lang('YesNo'), null, ICON_SIZE_BIG).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=multiplechoice&survey_id='.$survey_id.'">'.Display::return_icon('mcua.png', get_lang('UniqueSelect'), null, ICON_SIZE_BIG).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=multipleresponse&survey_id='.$survey_id.'">'.Display::return_icon('mcma.png', get_lang('MultipleResponse'), null, ICON_SIZE_BIG).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=open&survey_id='.$survey_id.'">'.Display::return_icon('open_answer.png', get_lang('Open'), null, ICON_SIZE_BIG).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=dropdown&survey_id='.$survey_id.'">'.Display::return_icon('dropdown.png', get_lang('Dropdown'), null, ICON_SIZE_BIG).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=percentage&survey_id='.$survey_id.'">'.Display::return_icon('percentagequestion.png', get_lang('Percentage'), null, ICON_SIZE_BIG).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=score&survey_id='.$survey_id.'">'.Display::return_icon('scorequestion.png', get_lang('Score'), null, ICON_SIZE_BIG).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=comment&survey_id='.$survey_id.'">'.Display::return_icon('commentquestion.png', get_lang('Comment'), null, ICON_SIZE_BIG).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=pagebreak&survey_id='.$survey_id.'">'.Display::return_icon('page_end.png', get_lang('Pagebreak'), null, ICON_SIZE_BIG).'</a>';
echo '</div>';
echo '</div>';
} else {
echo '<div class="panel panel-default">';
echo '<div class="panel panel-default">';
echo '<div class="panel-body">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&amp;action=add&type=personality&amp;survey_id='.$survey_id.'">';
echo Display::return_icon("yesno.png");
echo '</a></div>';
echo '</div>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=add&type=personality&survey_id='.$survey_id.'">';
echo Display::return_icon("yesno.png");
echo '</a></div>';
echo '</div>';
echo '</div>';
}
@ -162,7 +173,7 @@ 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) {
echo '<th width="100">'.get_lang('Condition').'</th>';
echo '<th width="100">'.get_lang('Condition').'</th>';
echo '<th width="40">'.get_lang('Group').'</th>';
}
echo ' </tr>';
@ -189,97 +200,103 @@ $sql = "SELECT survey_question.*, count(survey_question_option.question_option_i
$result = Database::query($sql);
$question_counter_max = Database::num_rows($result);
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).' ... ';
} else {
echo $row['survey_question'];
}
if ($row['type'] == 'yesno') {
$tool_name = get_lang('YesNo');
} else if ($row['type'] == 'multiplechoice') {
$tool_name = get_lang('UniqueSelect');
} else {
$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="'.api_get_path(WEB_CODE_PATH).'survey/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.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/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.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
if ($question_counter > 1) {
echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&amp;action=moveup&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('up.png', get_lang('MoveUp'),'',ICON_SIZE_SMALL).'</a>';
} else {
Display::display_icon('up_na.png','&nbsp;','',ICON_SIZE_SMALL);
}
if ($question_counter < $question_counter_max) {
echo ' <a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&amp;action=movedown&amp;survey_id='.$survey_id.'&amp;question_id='.$row['question_id'].'">'.Display::return_icon('down.png', get_lang('MoveDown'),'',ICON_SIZE_SMALL).'</a>';
} else {
Display::display_icon('down_na.png','&nbsp;','',ICON_SIZE_SMALL);
}
echo ' </td>';
$question_counter++;
if ($is_survey_type_1) {
echo '<td>'.(($row['survey_group_pri']==0)?get_lang('Secondary'):get_lang('Primary')).'</td>';
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).' ... ';
} else {
echo $row['survey_question'];
}
if ($row['type'] == 'yesno') {
$tool_name = get_lang('YesNo');
} else if ($row['type'] == 'multiplechoice') {
$tool_name = get_lang('UniqueSelect');
} else {
$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="'.api_get_path(WEB_CODE_PATH).'survey/question.php?'.api_get_cidreq().'&action=edit&type='.$row['type'].'&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'&question_id='.$row['question_id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurveyQuestion").'?',ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
if ($question_counter > 1) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=moveup&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('up.png', get_lang('MoveUp'),'',ICON_SIZE_SMALL).'</a>';
} else {
Display::display_icon('up_na.png','&nbsp;','',ICON_SIZE_SMALL);
}
if ($question_counter < $question_counter_max) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=movedown&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.Display::return_icon('down.png', get_lang('MoveDown'),'',ICON_SIZE_SMALL).'</a>';
} else {
Display::display_icon('down_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
}
echo ' </td>';
$question_counter++;
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>';
}
echo '</tr>';
echo '</tr>';
}
echo '</table>';
if ($is_survey_type_1) {
echo '<br /><br /><b>'.get_lang('ManageGroups').'</b><br /><br />';
if (in_array($_GET['sendmsg'], array('GroupUpdatedSuccessfully', 'GroupDeletedSuccessfully', 'GroupCreatedSuccessfully'))) {
echo Display::return_message(get_lang($_GET['sendmsg']), 'confirmation', false);
}
if (in_array($_GET['sendmsg'], array('GroupNeedName'))){
echo Display::return_message(get_lang($_GET['sendmsg']), 'warning', false);
}
echo '<table border="0"><tr><td width="100">'.get_lang('Name').'</td><td>'.get_lang('Description').'</td></tr></table>';
echo '<form action="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?action=addgroup&survey_id='.$survey_id.'" method="post">';
if ($_GET['action'] == 'editgroup') {
$sql = 'SELECT name,description FROM '.$table_survey_question_group.' WHERE id = '.intval($_GET['gid']).' AND survey_id = '.intval($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']).'">';
echo '<input type="submit" value="'.get_lang('Save').'"'.'<input type="button" value="'.get_lang('Cancel').'" onclick="window.location.href = \'survey.php?survey_id='.Security::remove_XSS($survey_id).'\';" />';
} else {
echo '<input type="text" maxlength="20" name="name" value="" size="10">';
echo '<input type="text" maxlength="250" name="description" value="" size="80">';
echo '<input type="submit" value="'.get_lang('Create').'"';
}
echo '</form><br />';
echo '<table class="data_table">';
echo ' <tr class="row_odd">';
echo ' <th width="200">'.get_lang('Name').'</th>';
echo ' <th>'.get_lang('Description').'</th>';
echo ' <th width="100">'.get_lang('Modify').'</th>';
echo ' </tr>';
$sql = 'SELECT id,name,description FROM '.$table_survey_question_group.' WHERE c_id = '.$course_id.' AND survey_id = '.intval($survey_id).' ORDER BY name';
$rs = Database::query($sql);
while($row = Database::fetch_array($rs,ASSOC)){
$grouplist .= '<tr><td>'.$row['name'].'</td><td>'.$row['description'].'</td><td>'.
'<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=editgroup">'.
Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> '.
'<a href="'.api_get_path(WEB_CODE_PATH).'survey/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.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
'</td></tr>';
}
echo $grouplist.'</table>';
echo '<br /><br /><b>'.get_lang('ManageGroups').'</b><br /><br />';
if (in_array($_GET['sendmsg'], array('GroupUpdatedSuccessfully', 'GroupDeletedSuccessfully', 'GroupCreatedSuccessfully'))) {
echo Display::return_message(get_lang($_GET['sendmsg']), 'confirmation', false);
}
if (in_array($_GET['sendmsg'], array('GroupNeedName'))) {
echo Display::return_message(get_lang($_GET['sendmsg']), 'warning', false);
}
echo '<table border="0"><tr><td width="100">'.get_lang('Name').'</td><td>'.get_lang('Description').'</td></tr></table>';
echo '<form action="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?action=addgroup&survey_id='.$survey_id.'" method="post">';
if ($_GET['action'] == 'editgroup') {
$sql = 'SELECT name,description FROM '.$table_survey_question_group.'
WHERE id = '.intval($_GET['gid']).' AND survey_id = '.intval($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']).'">';
echo '<input type="submit" value="'.get_lang('Save').'"'.'<input type="button" value="'.get_lang('Cancel').'" onclick="window.location.href = \'survey.php?survey_id='.Security::remove_XSS($survey_id).'\';" />';
} else {
echo '<input type="text" maxlength="20" name="name" value="" size="10">';
echo '<input type="text" maxlength="250" name="description" value="" size="80">';
echo '<input type="submit" value="'.get_lang('Create').'"';
}
echo '</form><br />';
echo '<table class="data_table">';
echo ' <tr class="row_odd">';
echo ' <th width="200">'.get_lang('Name').'</th>';
echo ' <th>'.get_lang('Description').'</th>';
echo ' <th width="100">'.get_lang('Modify').'</th>';
echo ' </tr>';
$sql = 'SELECT id,name,description
FROM '.$table_survey_question_group.'
WHERE
c_id = '.$course_id.' AND
survey_id = '.intval($survey_id).'
ORDER BY name';
$rs = Database::query($sql);
while ($row = Database::fetch_array($rs, 'ASSOC')) {
$grouplist .= '<tr><td>'.$row['name'].'</td><td>'.$row['description'].'</td><td>'.
'<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&gid='.$row['id'].'&action=editgroup">'.
Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'</a> '.
'<a href="'.api_get_path(WEB_CODE_PATH).'survey/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.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
'</td></tr>';
}
echo $grouplist.'</table>';
}
Session::erase('answer_count');

@ -2,11 +2,11 @@
/* For licensing terms, see /license.txt */
/**
* @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 $
* @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
* @todo the answered column
*/
require_once __DIR__.'/../inc/global.inc.php';
@ -86,32 +86,31 @@ $sql = "SELECT survey_invitation.*, user.firstname, user.lastname, user.email
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) {
if (!$_GET['view'] ||
$_GET['view'] == 'invited' ||
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'])) {
echo '<tr>';
if (is_numeric($row['user'])) {
$userInfo = api_get_user_info($row['user']);
echo '<td>';
echo '<td>';
echo UserManager::getUserProfileLink($userInfo);
echo '</td>';
} else {
} else {
echo '<td>'.$row['user'].'</td>';
}
echo ' <td>'.$row['invitation_date'].'</td>';
echo ' <td>';
if (in_array($row['user'], $answered_data)) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&amp;survey_id='.$survey_id.'&amp;user='.$row['user'].'">'.get_lang('ViewAnswers').'</a>';
} else {
echo '-';
}
echo ' </td>';
echo '</tr>';
}
}
echo ' <td>'.$row['invitation_date'].'</td>';
echo ' <td>';
if (in_array($row['user'], $answered_data)) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&amp;survey_id='.$survey_id.'&amp;user='.$row['user'].'">'.get_lang('ViewAnswers').'</a>';
} else {
echo '-';
}
echo ' </td>';
echo '</tr>';
}
}
// Closing the table

@ -2,15 +2,15 @@
/* For licensing terms, see /license.txt */
/**
* @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 $
* @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
* @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
*/
require_once __DIR__.'/../inc/global.inc.php';
@ -71,26 +71,26 @@ $(function() {
// 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 c_id = $course_id AND code='".Database::escape_string($survey_data['code'])."'";
WHERE c_id = $course_id AND code='".Database::escape_string($survey_data['code'])."'";
$result = Database::query($sql);
if (Database::num_rows($result) > 1) {
Display::display_warning_message(get_lang('IdenticalSurveycodeWarning'));
Display::display_warning_message(get_lang('IdenticalSurveycodeWarning'));
}
// Invited / answered message
if ($survey_data['invited'] > 0 && !isset($_POST['submit'])) {
$message = '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invitation.php?view=answered&survey_id='.$survey_data['survey_id'].'">'.$survey_data['answered'].'</a> ';
$message .= get_lang('HaveAnswered').' ';
$message .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invitation.php?view=invited&survey_id='.$survey_data['survey_id'].'">'.$survey_data['invited'].'</a> ';
$message .= get_lang('WereInvited');
echo Display::return_message($message, 'normal', false);
$message = '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invitation.php?view=answered&survey_id='.$survey_data['survey_id'].'">'.$survey_data['answered'].'</a> ';
$message .= get_lang('HaveAnswered').' ';
$message .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invitation.php?view=invited&survey_id='.$survey_data['survey_id'].'">'.$survey_data['invited'].'</a> ';
$message .= get_lang('WereInvited');
echo Display::return_message($message, 'normal', false);
}
// Building the form for publishing the survey
$form = new FormValidator(
'publish_form',
'post',
api_get_self().'?survey_id='.$survey_id.'&'.api_get_cidreq()
'publish_form',
'post',
api_get_self().'?survey_id='.$survey_id.'&'.api_get_cidreq()
);
$form->addElement('header', '', $tool_name);
@ -109,19 +109,19 @@ foreach ($complete_user_list as & $user) {
CourseManager::addUserGroupMultiSelect($form, array());
/*$form->addElement(
'advmultiselect',
'course_users',
get_lang('CourseUsers'),
$possible_users,
'style="width: 250px; height: 200px;"'
'advmultiselect',
'course_users',
get_lang('CourseUsers'),
$possible_users,
'style="width: 250px; height: 200px;"'
);*/
// Additional users
$form->addElement(
'textarea',
'additional_users',
array(get_lang('AdditonalUsers'), get_lang('AdditonalUsersComment')),
array('rows' => 5)
'textarea',
'additional_users',
array(get_lang('AdditonalUsers'), get_lang('AdditonalUsersComment')),
array('rows' => 5)
);
$form->addElement('html', '<div id="check_mail">');
@ -134,15 +134,15 @@ $form->addElement('html', '<div id="mail_text_wrapper">');
$form->addText('mail_title', get_lang('MailTitle'), false);
// The text of the mail
$form->addHtmlEditor(
'mail_text',
array(get_lang('MailText'), get_lang('UseLinkSyntax')),
false,
array('ToolbarSet' => 'Survey', 'Height' => '150')
'mail_text',
array(get_lang('MailText'), get_lang('UseLinkSyntax')),
false,
array('ToolbarSet' => 'Survey', 'Height' => '150')
);
$form->addElement('html', '</div>');
// 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
$form->addElement('checkbox', 'resend_to_all', '', get_lang('ReminderResendToAllUsers'));
@ -156,11 +156,11 @@ $form->addButtonSave(get_lang('PublishSurvey'));
}*/
$portal_url = api_get_path(WEB_PATH);
if (api_is_multiple_url_enabled()) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$url = api_get_access_url($access_url_id);
$portal_url = $url['url'];
}
$access_url_id = api_get_current_access_url_id();
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
@ -170,7 +170,7 @@ $form->addElement('label', null, get_lang('AutoInviteLink'));
$form->addElement('label', null, $auto_survey_link);
if ($form->validate()) {
$values = $form->exportValues();
$values = $form->exportValues();
$resendAll = isset($values['resend_to_all']) ? $values['resend_to_all'] : '';
$sendMail = isset($values['send_mail']) ? $values['send_mail'] : '';
@ -180,47 +180,47 @@ if ($form->validate()) {
if (empty($values['mail_title']) || empty($values['mail_text'])) {
echo Display::return_message(get_lang('FormHasErrorsPleaseComplete'), 'error');
// Getting the invited users
$defaults = SurveyUtil::get_invited_users($survey_data['code']);
// Getting the survey mail text
if (!empty($survey_data['reminder_mail'])) {
$defaults['mail_text'] = $survey_data['reminder_mail'];
} else {
$defaults['mail_text'] = $survey_data['invite_mail'];
}
$defaults['mail_title'] = $survey_data['mail_subject'];
$defaults['send_mail'] = 1;
$form->setDefaults($defaults);
$defaults = SurveyUtil::get_invited_users($survey_data['code']);
// Getting the survey mail text
if (!empty($survey_data['reminder_mail'])) {
$defaults['mail_text'] = $survey_data['reminder_mail'];
} else {
$defaults['mail_text'] = $survey_data['invite_mail'];
}
$defaults['mail_title'] = $survey_data['mail_subject'];
$defaults['send_mail'] = 1;
$form->setDefaults($defaults);
$form->display();
return;
}
}
// 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
$count_course_users = SurveyUtil::saveInvitations(
$values['users'],
$values['mail_title'],
$values['mail_text'],
SurveyUtil::save_invite_mail(
$values['mail_text'],
$values['mail_title'],
!empty($survey_data['invite_mail'])
);
// Saving the invitations for the course users
$count_course_users = SurveyUtil::saveInvitations(
$values['users'],
$values['mail_title'],
$values['mail_text'],
$resendAll,
$sendMail,
$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]);
}
// 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::saveInvitations(
$counter_additional_users = SurveyUtil::saveInvitations(
$additional_users,
$values['mail_title'],
$values['mail_text'],
@ -229,47 +229,44 @@ if ($form->validate()) {
$remindUnAnswered
);
// Updating the invited field in the survey table
SurveyUtil::update_count_invited($survey_data['code']);
$total_count = $count_course_users + $counter_additional_users;
// Updating the invited field in the survey table
SurveyUtil::update_count_invited($survey_data['code']);
$total_count = $count_course_users + $counter_additional_users;
$table_survey = Database::get_course_table(TABLE_SURVEY);
// Counting the number of people that are invited
$sql = "SELECT * FROM $table_survey
WHERE
c_id = $course_id AND
code = '".Database::escape_string($survey_data['code'])."'
";
$result = Database::query($sql);
$row = Database::fetch_array($result);
$total_invited = $row['invited'];
// Counting the number of people that are invited
$sql = "SELECT * FROM $table_survey
WHERE
c_id = $course_id AND
code = '".Database::escape_string($survey_data['code'])."'
";
$result = Database::query($sql);
$row = Database::fetch_array($result);
$total_invited = $row['invited'];
if ($total_invited > 0) {
$message = '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invitation.php?view=answered&survey_id='.$survey_data['survey_id'].'">'.
$survey_data['answered'].'</a> ';
$message .= get_lang('HaveAnswered').' ';
$message .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invitation.php?view=invited&survey_id='.$survey_data['survey_id'].'">'.
$total_invited.'</a> ';
$message .= get_lang('WereInvited');
echo Display::return_message($message, 'normal', false);
if ($sendMail) {
echo Display::return_message($total_count.' '.get_lang('InvitationsSend'), 'success', false);
$message = '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invitation.php?view=answered&survey_id='.$survey_data['survey_id'].'">'.
$survey_data['answered'].'</a> ';
$message .= get_lang('HaveAnswered').' ';
$message .= '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey_invitation.php?view=invited&survey_id='.$survey_data['survey_id'].'">'.
$total_invited.'</a> ';
$message .= get_lang('WereInvited');
echo Display::return_message($message, 'normal', false);
if ($sendMail) {
echo Display::return_message($total_count.' '.get_lang('InvitationsSend'), 'success', false);
}
}
} else {
// Getting the invited users
$defaults = SurveyUtil::get_invited_users($survey_data['code']);
// Getting the survey mail text
if (!empty($survey_data['reminder_mail'])) {
$defaults['mail_text'] = $survey_data['reminder_mail'];
} else {
$defaults['mail_text'] = $survey_data['invite_mail'];
}
$defaults['mail_title'] = $survey_data['mail_subject'];
$defaults['send_mail'] = 1;
$form->setDefaults($defaults);
// Getting the invited users
$defaults = SurveyUtil::get_invited_users($survey_data['code']);
// Getting the survey mail text
if (!empty($survey_data['reminder_mail'])) {
$defaults['mail_text'] = $survey_data['reminder_mail'];
} else {
$defaults['mail_text'] = $survey_data['invite_mail'];
}
$defaults['mail_title'] = $survey_data['mail_subject'];
$defaults['send_mail'] = 1;
$form->setDefaults($defaults);
$form->display();
}
Display :: display_footer();

@ -2,13 +2,13 @@
/* For licensing terms, see /license.txt */
/**
* @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 $
* @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
* @todo use quickforms for the forms
*/
if (!isset($_GET['cidReq'])) {
$_GET['cidReq'] = 'none'; // Prevent sql errors

Loading…
Cancel
Save