Skip to content
Permalink
Browse files

WIP: Add multiplicate questions in survey based in classes BT#15033

  • Loading branch information...
jmontoyaa committed Nov 13, 2018
1 parent 13b5fcf commit 373427b5abf01a7b7ffe8357bfef63475c4dd3f0
@@ -97,7 +97,7 @@
// Survey_code of the survey
$surveyCode = $_GET['scode'];
if ($isAnonymous) {
$autoInvitationcode = "auto-ANONY_".md5(time())."-$surveyCode";
$autoInvitationcode = 'auto-ANONY_'.md5(time())."-$surveyCode";
} else {
// New invitation code from userid
$autoInvitationcode = "auto-$userid-$surveyCode";
@@ -742,7 +742,8 @@
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
WHERE
survey_question NOT LIKE '%{{%' AND
survey_question.survey_id = '".intval($survey_invitation['survey_id'])."' AND
survey_question.question_id IN (".implode(',', $paged_questions[$_GET['show']]).") AND
survey_question.c_id = $course_id
@@ -774,7 +775,7 @@
}
}
} elseif ($survey_data['survey_type'] === '1') {
$my_survey_id = intval($survey_invitation['survey_id']);
$my_survey_id = (int) $survey_invitation['survey_id'];
$current_user = Database::escape_string($survey_invitation['user']);
if (isset($_POST['personality'])) {
@@ -787,7 +788,10 @@
$answer_list = [];
// Get current user results
$results = [];
$sql = "SELECT survey_group_pri, user, SUM(value) as value
$sql = "SELECT
survey_group_pri,
user,
SUM(value) as value
FROM $table_survey_answer as survey_answer
INNER JOIN $table_survey_question as survey_question
ON (survey_question.question_id = survey_answer.question_id)
@@ -807,7 +811,6 @@
$results[] = $answer_list;
}
//echo '<br />'; print_r($results); echo '<br />';
// Get the total score for each group of questions
$totals = [];
$sql = "SELECT SUM(temp.value) as value, temp.survey_group_pri FROM
@@ -1178,7 +1181,7 @@
// Selecting the maximum number of pages
$sql = "SELECT * FROM $table_survey_question
WHERE
WHERE
c_id = $course_id AND
type = '".Database::escape_string('pagebreak')."' AND
survey_id='".intval($survey_invitation['survey_id'])."'";
@@ -112,7 +112,7 @@
if (isset($_POST['finish_survey'])) {
echo Display::return_message(get_lang('SurveyFinished'), 'confirm');
echo $survey_data['survey_thanks'];
Display :: display_footer();
Display::display_footer();
exit;
}
@@ -125,7 +125,10 @@
$paged_questions = [];
$counter = 0;
$sql = "SELECT * FROM $table_survey_question
WHERE c_id = $course_id AND survey_id = '".$surveyId."'
WHERE
survey_question NOT LIKE '%{{%' AND
c_id = $course_id AND
survey_id = '".$surveyId."'
ORDER BY sort ASC";
$result = Database::query($sql);
$questions_exists = true;
@@ -161,7 +164,9 @@
WHERE
survey_question.survey_id = '".$surveyId."' AND
survey_question.question_id IN (".Database::escape_string(implode(',', $paged_questions[$_GET['show']]), null, false).") AND
survey_question.c_id = $course_id
survey_question.c_id = $course_id AND
survey_question NOT LIKE '%{{%'
ORDER BY survey_question.sort, survey_question_option.sort ASC";
$result = Database::query($sql);
@@ -189,6 +194,7 @@
// Selecting the maximum number of pages
$sql = "SELECT * FROM $table_survey_question
WHERE
survey_question NOT LIKE '%{{%' AND
c_id = $course_id AND
type = '".Database::escape_string('pagebreak')."' AND
survey_id = '".$surveyId."'";
@@ -202,7 +208,7 @@
$show = 0;
}
$url = api_get_self().'?survey_id='.$surveyId.'&show='.$show;
$url = api_get_self().'?survey_id='.$surveyId.'&show='.$show.'&'.api_get_cidreq();
$form = new FormValidator(
'question-survey',
'post',
@@ -100,7 +100,7 @@
Display :: display_header($tool_name, 'Survey');
echo $actions;
echo Display::return_message(get_lang('TypeDoesNotExist'), 'error', false);
Display :: display_footer();
Display::display_footer();
}
$error_message = '';
@@ -115,24 +115,29 @@
$formData = [];
$formData['answers'] = ['', ''];
if ($_GET['type'] == 'yesno') {
$formData['answers'][0] = get_lang('Yes');
$formData['answers'][1] = get_lang('No');
switch ($_GET['type']) {
case 'yesno':
$formData['answers'][0] = get_lang('Yes');
$formData['answers'][1] = get_lang('No');
break;
case '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;
break;
case 'open':
Display::addFlash(Display::return_message(get_lang('QuestionTags')));
break;
}
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;
}
// We are editing a question
if (isset($_GET['question_id']) && !empty($_GET['question_id'])) {
@@ -150,7 +155,5 @@
}
Display::display_header($tool_name, 'Survey');
echo $surveyQuestion->getForm()->returnForm();
Display :: display_footer();
Display::display_footer();

0 comments on commit 373427b

Please sign in to comment.
You can’t perform that action at this time.