-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuesProcess.php
218 lines (213 loc) · 8.48 KB
/
QuesProcess.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<?php
/**
* Retrieve information from survey of Applicant Form for Faculty Member
*
* @author Navdeep Bagga
* @authorEmail admin@navdeepbagga.com
* @category Retrieve Information
* @copyright Copyright (c) June-July Testing and Consultancy Cell
* @license General Public License
* @version $Id:QuesProcess.php 2012-01-08 $
*/
require_once 'Db.php';
require_once 'UserDetail.php';
/**
* Get all information of questions form question table
* Concatenate all retrieve Information and make column names
* Retrieve answers from column names of given email value from answer table
*
* @category Retrieve Information
* @copyright Copyright (c) June-July Testing and Consultancy Cell
* @license General Public License
* @version Release: @package_version@
* @since Class available since Release 1
* @deprecated Class deprecated in Release 2
*/
class Ques_Processor
{
/**
* This function retrieves specific column value from question table
*
* @arguments column_name,question_table,where_column,selected_value
*
* @return columnvalue_of_question
*/
function createColumn($select, $table, $column, $title)
{
if (is_array($select))
{
foreach($select as $select1)
{
$selectArray = mysql_fetch_array(mysql_query("SELECT `$select1` from `$table` "
. "WHERE `$column` = '$title'"));
$fetchArray[] = $selectArray[$select1];
}
return $fetchArray;
}
$selectCol = mysql_fetch_array(mysql_query("SELECT `$select` from `$table` "
. "WHERE `$column` = '$title' "
. "ORDER BY `$select` DESC LIMIT 1;"));
$fetchCol = $selectCol[$select];
return $fetchCol;
}
/**
* This function retrieves all information like question id, type
* and group id of given question
*
* @arguments last_question_id, question_table
*
* @return array of gid,qid,type of question
*/
function getQuestionInfo($lastQid, $table)
{
for($ques = 1; $ques <= $lastQid; $ques++)
{
$questionQid[] = $ques;
}
$counterA = 0;
foreach($questionQid as $singleQid)
{
$selectQuesInfo = mysql_query("SELECT `qid`, `gid`, `type`,"
. "`other` from `$table` "
. "WHERE `qid` = '$singleQid'");
$fetchQuesInfo = mysql_fetch_array($selectQuesInfo);
$infoQues[$counterA][qid] = $fetchQuesInfo['qid'];
$infoQues[$counterA][gid] = $fetchQuesInfo['gid'];
$infoQues[$counterA][type] = $fetchQuesInfo['type'];
$infoQues[$counterA][other] = $fetchQuesInfo['other'];
$counterA++;
}
return $infoQues;
}
/**
* This function check the type of question, according to that make column names
*
* @arguments survey id, question information, question table
*
* @return array_of_columnnames_of_question
*/
function questionColumnCreator($constSid, $quesInfo, $table)
{
foreach($quesInfo as $singleInfo)
{
if (($singleInfo['type'] == ";")
|| ($singleInfo['type'] == ":")
) {
$selectUnderColm = mysql_query("SELECT `title`, `scale_id` from `$table` "
. "WHERE `parent_qid` = '$singleInfo[qid]' "
. "AND `scale_id` = '0'");
while($fetchUnderColm = mysql_fetch_array($selectUnderColm))
{
$selectRepeatColm = mysql_query("SELECT `title` from `$table` "
. "WHERE `parent_qid` = '$singleInfo[qid]' "
. "AND `scale_id` = '1'");
while($fetchRepeatColm = mysql_fetch_array($selectRepeatColm))
{
$compoundValue[] = $constSid."X".$singleInfo['gid']."X"
. $singleInfo['qid'].$fetchUnderColm['title']
. "_".$fetchRepeatColm['title'];
}
}
}
elseif (($singleInfo['type'] == "M")
|| ($singleInfo['type'] == "Q")
) {
$selectSqColm = mysql_query("SELECT `title` from `$table` "
. "WHERE `parent_qid` = '$singleInfo[qid]'");
while($fetchSqColm = mysql_fetch_array($selectSqColm))
{
$compoundValue[] = $constSid."X".$singleInfo['gid']."X"
. $singleInfo['qid'].$fetchSqColm['title'];
}
if ($singleInfo['other'] == "Y")
{
$compoundValue[] = $constSid."X".$singleInfo['gid']
. "X".$singleInfo['qid']."other";
}
}
elseif ($singleInfo['type'] == "|")
{
$compoundValue[] = $constSid."X".$singleInfo['gid']."X"
. $singleInfo['qid'];
$compoundValue[] = $constSid."X".$singleInfo['gid']."X"
. $singleInfo['qid']."_"."filecount";
}
else {
$compoundValue[] = $constSid."X".$singleInfo['gid']."X"
. $singleInfo['qid'] ;
if ($singleInfo['other'] == "Y")
{
$compoundValue[] = $constSid."X".$singleInfo['gid']."X"
. $singleInfo['qid']."other";
}
}
}
return $compoundValue;
}
/**
* This function retrieve answer of passing question column names.
*
* @arguments column_names,answer_table,where_column,selected_value
*
* @return answer_of_columnvalue
*/
function displayAnswer($columnName, $table, $column)
{
global $quesTable;
global $ansTable;
foreach($columnName as $singleColumn)
{
$selectRow = mysql_query("SELECT `$singleColumn` from `$table` "
. "WHERE `$column` = 'gottarocknow@gmail.com'");
while($fetchRow = mysql_fetch_array($selectRow))
{
if (($fetchRow[$singleColumn] == "A1")
|| ($fetchRow[$singleColumn] == "A2")
) {
$aDivColm = explode("X", $singleColumn);
$selectARows = mysql_query("SELECT answer from `$ansTable` "
. "WHERE `qid` = '$aDivColm[2]' "
. "AND `code` = '$fetchRow[$singleColumn]'");
while($fetchARows = mysql_fetch_array($selectARows))
{
$collectInfo[] = $fetchARows['answer'];
}
}
elseif ($fetchRow[$singleColumn] == "Y")
{
$yDivColm = explode("X", $singleColumn);
$selectY = mysql_query("SELECT `type` from `$quesTable` "
. "WHERE `gid` = '$yDivColm[1]' "
. "AND `qid` = '$yDivColm[2]'");
while ($fetchY = mysql_fetch_array($selectY))
{
$yAnswer = $fetchY['type'];
}
if ($yAnswer == "M")
{
$count = $singleColumn[8];
$explodeTitle = explode("S", $yDivColm[2]);
$RowTitle = "S".$explodeTitle[1];
$selectYRows = mysql_query("SELECT `question` from `$quesTable` "
. "WHERE `parent_qid` = '$count' "
. "AND `gid` = '$yDivColm[1]' "
. "AND `title` = '$RowTitle'");
while($fetchYRows = mysql_fetch_array($selectYRows))
{
$collectInfo[] = $fetchYRows['question'];
}
}
else
{
$collectInfo[] = $fetchRow[$singleColumn];
}
}
else {
$collectInfo[] = $fetchRow[$singleColumn];
}
}
}
return $collectInfo;
}
}
?>