forked from jwnisbet/melodiesforus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
endPage.php
executable file
·75 lines (60 loc) · 1.54 KB
/
endPage.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
<?php
include_once('redirector.php');
processSurvey();
include('thankYouPage.php');
die; //not really needed, but just here for safety
function processSurvey() {
$_REQUEST['action'] = 'connect';
unset($_REQUEST['action']);
unset($_REQUEST['prevPage']);
integrityCheck();
//If you are using the scales, then these lines collapse multiple-item questions
//into a single-item score
//collapseScale('rps', 9);
//collapseScale('nfc', 9);
ksort($_REQUEST);
edit_session($_REQUEST, false, 'post');
}
/*
function collapseScale($type, $size) {
if($type == 'rps' || $type == 'nfc') {
if($type == 'rps') {
$rev = array(1, 2, 3, 5);
}
else {
$rev = array(1, 3, 4, 5);
}
$rpstotal = 0;
foreach($_REQUEST as $k => $v) {
if(preg_match('/^'.$type.'(\d)$/', $k, $matches)) {
$rpsnum = intval($matches[1]);
if(in_array($rpsnum, $rev)) {
$v = $size+1-$v;
}
$rpstotal += $v;
unset($_REQUEST[$k]);
}
}
$_REQUEST[$type.'total'] = $rpstotal;
}
}
*/
//Checks the correctness of the integrity questions on the survey.
function integrityCheck() {
foreach($_REQUEST as $k => $v) {
if(preg_match('/^check(\d)$/', $k, $matches)) {
$correct = intval($matches[1]);
$check = $v;
if($check != $correct) {
?>
<script>
alert("You have answered an integrity question incorrectly. Please go back to the survey and read the directions carefully. Then, check your answers and re-submit.");
window.history.back(-1);
</script>
<?php
die;
}
unset($_REQUEST[$k]);
}
}
}