-
Notifications
You must be signed in to change notification settings - Fork 988
/
preview.php
150 lines (124 loc) · 4.41 KB
/
preview.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id$
*/
//Ensure script is not run directly, avoid path disclosure
$LEMdebugLevel=0;
include_once("login_check.php");
require_once(dirname(__FILE__).'/sessioncontrol.php');
require_once(dirname(__FILE__).'/../qanda.php');
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
if (!isset($qid)) {$qid=returnglobal('qid');}
if (empty($surveyid)) {die("No SID provided.");}
if (empty($qid)) {die("No QID provided.");}
if (!isset($_GET['lang']) || $_GET['lang'] == "")
{
$language = GetBaseLanguageFromSurveyID($surveyid);
} else {
$language = $_GET['lang'];
}
$_SESSION['s_lang'] = $language;
$_SESSION['fieldmap']=createFieldMap($surveyid,'full',false,$qid);
// Prefill question/answer from defaultvalues
foreach ($_SESSION['fieldmap'] as $field)
{
if (isset($field['defaultvalue']))
{
$_SESSION[$field['fieldname']]=$field['defaultvalue'];
}
}
$clang = new limesurvey_lang($language);
$thissurvey=getSurveyInfo($surveyid);
$_SESSION['dateformats'] = getDateFormatData($thissurvey['surveyls_dateformat']);
$qquery = 'SELECT * FROM '.db_table_name('questions')." WHERE sid='$surveyid' AND qid='$qid' AND language='{$language}'";
$qresult = db_execute_assoc($qquery);
$qrows = $qresult->FetchRow();
$ia = array(0 => $qid,
1 => $surveyid.'X'.$qrows['gid'].'X'.$qid,
2 => $qrows['title'],
3 => $qrows['question'],
4 => $qrows['type'],
5 => $qrows['gid'],
6 => $qrows['mandatory'],
//7 => $qrows['other']); // ia[7] is conditionsexist not other
7 => 'N',
8 => 'N' ); // ia[8] is usedinconditions
LimeExpressionManager::StartSurvey($thissurvey['sid'], 'question', ($thissurvey['anonymized']!="N"), false,$LEMdebugLevel);
$qseq = LimeExpressionManager::GetQuestionSeq($qid);
$moveResult = LimeExpressionManager::JumpTo($qseq+1,false,true);
$answers = retrieveAnswers($ia);
if (!$thissurvey['template'])
{
$thistpl=sGetTemplatePath($defaulttemplate);
}
else
{
$thistpl=sGetTemplatePath(validate_templatedir($thissurvey['template']));
}
doHeader();
$dummy_js = '
<!-- JAVASCRIPT FOR CONDITIONAL QUESTIONS -->
<script type="text/javascript">
/* <![CDATA[ */
function checkconditions(value, name, type)
{
}
function noop_checkconditions(value, name, type)
{
}
/* ]]> */
</script>
';
$answer=$answers[0][1];
$help=$answers[0][2];
$question = $answers[0][0];
$question['code']=$answers[0][5];
$question['class'] = question_class($qrows['type']);
$question['essentials'] = 'id="question'.$qrows['qid'].'"';
$question['sgq']=$ia[1];
if ($qrows['mandatory'] == 'Y')
{
$question['man_class'] = ' mandatory';
}
else
{
$question['man_class'] = '';
};
$content = templatereplace(file_get_contents("$thistpl/startpage.pstpl"));
$content .='<form method="post" action="index.php" id="limesurvey" name="limesurvey" autocomplete="off">';
$content .= templatereplace(file_get_contents("$thistpl/startgroup.pstpl"));
$question_template = file_get_contents("$thistpl/question.pstpl");
if(substr_count($question_template , '{QUESTION_ESSENTIALS}') > 0 ) // the following has been added for backwards compatiblity.
{// LS 1.87 and newer templates
$content .= "\n".templatereplace($question_template,NULL,false,$qid)."\n";
}
else
{// LS 1.86 and older templates
$content .= '<div '.$question['essentials'].' class="'.$question['class'].$question['man_class'].'">';
$content .= "\n".templatereplace($question_template,NULL,false,$qid)."\n";
$content .= "\n\t</div>\n";
};
$content .= templatereplace(file_get_contents("$thistpl/endgroup.pstpl")).$dummy_js;
$content .= '<p> </form>';
LimeExpressionManager::FinishProcessingPage();
echo $content;
if ($LEMdebugLevel >= 1) {
echo LimeExpressionManager::GetDebugTimingMessage();
}
if ($LEMdebugLevel >= 2) {
echo "<table><tr><td align='left'><b>Group/Question Validation Results:</b>".$moveResult['message']."</td></tr></table>\n";
}
$content .= templatereplace(file_get_contents("$thistpl/endpage.pstpl"));
echo "</html>\n";
exit;
?>