forked from rbwatson/wlux_test_server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask-start.php
More file actions
112 lines (102 loc) · 3.93 KB
/
Copy pathtask-start.php
File metadata and controls
112 lines (102 loc) · 3.93 KB
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
// get session ID from query string
// get the request data
if (!empty($HTTP_RAW_POST_DATA)) {
$postData = json_decode($HTTP_RAW_POST_DATA,true);
}
// if the data is not in the raw post data, try the post form
if (empty($postData)) {
$postData = $_POST;
}
// if the data is not in the the post form, try the query string
if (empty($postData)) {
$postData = $_GET;
}
$sessionId = 0;
if (!empty($postData['wlux_session'])) {
$sessionId = $postData['wlux_session'];
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Task Start</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
h2 { margin-top: 1em; }
div.container { width: 500px; margin: auto; }
</style>
<title>WebLabUX Study Task Start</title>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$j = jQuery.noConflict();
var sessionInfo = null;
var host = window.location.host;
var LOCAL = (host.indexOf("localhost") != -1) ||
(host.indexOf("127.0.0.1") != -1);
var taskURL = "http://wlux.uw.edu/rbwatson/task.php";
if (LOCAL) {
taskURL = "/rbwatson/task.php";
}
function getTask () {
// get session info
$j.ajaxSetup({async: false}); //
// if undefined, use ""
if (<?php echo $sessionId ?> > 0) {
// start the task and get the configuration info
var postResult = $j.post (taskURL, {"start": {"sessionId" : <?php echo $sessionId ?>}},"json");
postResult.done (function (response) {
if (response.data !== undefined) {
sessionInfo = response.data;
// alert("Going to: " + nextPage);
$j("#pageHeading").text("Task "+ sessionInfo.taskId);
$j("#taskInstructions").html("<p>SessionId: "+
sessionInfo.sessionId + "<br/>StartTime: " +
sessionInfo.startTime + "</p><h2>Task Instructions:</h2>" +
sessionInfo.startPageHtml);
$j("#sessionField").attr("value", sessionInfo.sessionId.toString());
// $j("#taskField").attr("value", response.data.taskId.toString());
if ("external" == sessionInfo.taskType) {
if (sessionInfo.startPageNextUrl.length > 0) {
$j("#continueForm").attr("action", sessionInfo.startPageNextUrl);
$j("#continueForm").attr("method", "GET");
}
} else if ("single" == sessionInfo.taskType) {
if (sessionInfo.finishPageNextUrl.length > 0) {
$j("#continueForm").attr("action", sessionInfo.finishPageNextUrl);
$j("#continueForm").attr("method", "POST");
}
}
$j("#continueBtn").attr("disabled",false);
} else {
if (response.error.lastTask !== undefined) {
//display last task message
$j("#pageHeading").text("Finished");
$j("#taskInstructions").html("<p>" + response.error.lastTask + "<br/>Press <strong>Continue</strong> to finish.</p>");
$j("#continueBtn").attr("disabled",false);
$j("#continueForm").attr("action","study-end.php");
}
}
});
} else {
$j("#textDiv").html("<p>No session was specified</p>");
}
}
</script>
</head>
<body onload="getTask()">
<div id="pageContent" style="margin-left:auto; margin-right:auto; width:800px;">
<h1 id="pageHeading">Task x begin</h1>
<div id="taskInstructions">
<p>These are the instructions for task 1. Press <strong>Continue</strong> to begin.</p>
</div>
<div id="continueFormDiv">
<form id="continueForm" name="form1" method="POST" action="task-finish.php">
<input id="sessionField" type="hidden" name="wlux_session" value="<?php echo $sessionId ?>" />
<input id="continueBtn" type="submit" value="Continue" disabled />
</form>
</div>
</div>
</body>
</html>