forked from tjmonsi/AutoComPasteHTML
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexperiment.php
More file actions
118 lines (99 loc) · 3.85 KB
/
Copy pathexperiment.php
File metadata and controls
118 lines (99 loc) · 3.85 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
113
114
115
116
117
118
<?php
include ("./header.php");
participant_id_check ();
$experiments = get_experiments ();
$participant = $experiments->$_SESSION["participant_id"];
$experiments = $participant->experiments;
if (!isset ($_SESSION["experiment_step"])) {
$_SESSION["experiment_step"] = 0;
} else {
// Check if experiment data is valid.
if (isset ($_POST["experiment_raw"]) &&
isset ($_POST["experiment_time"]) && !empty ($_POST["experiment_time"])) {
// Experiment data is good at this point.
$_SESSION["experiment_results"][$_SESSION["experiment_step"]] = $_POST;
$_SESSION["experiment_step"]++;
}
if (($_SESSION["experiment_step"]) % 9 == 0 &&
($_SESSION["experiment_step"]) < count ($experiments) &&
isset ($_SESSION["experiment_resume_from_rest"]) && !$_SESSION["experiment_resume_from_rest"]) {
// Is it time for a rest?
$_SESSION["experiment_resume_from_rest"] = true;
header ("Location: rest.php");
die ();
} else {
$_SESSION["experiment_resume_from_rest"] = false;
}
}
// At this stage the experiment is over.
if ($_SESSION["experiment_step"] >= count ($experiments)) {
header ("Location: page3.php");
die ();
}
// Set the title.
$experiment_title = "Round " . ($_SESSION["experiment_step"] + 1) . " of " .
count ($participant->experiments);
$experiment = $experiments[$_SESSION["experiment_step"]];
// Set the instructions.
if ($experiment->technique == "autocompaste") {
$experiment_instruction = "Use AutoComPaste to copy and paste the " .
"following text from the windows into the text box.";
}
if ($experiment->technique == "ctrlc_ctrlv") {
$experiment_instruction = " Use Ctrl+C and Ctrl+V to copy and paste the " .
"following text from the windows into the text box.";
}
?>
<script>
var acp_open_windows = <?php echo $experiment->open_windows; ?>;
var acp_round = <?php echo ($_SESSION["experiment_step"] + 1); ?>;
var acp_granularity = "<?php echo $experiment->granularity; ?>";
var acp_stimuli = "<?php echo addcslashes ($experiment->stimuli, "\n"); ?>";
</script>
<div id="autocompaste" class="col-sm-9">
<div id="autocompaste-display">
</div>
</div>
<div id="instructions" class="col-sm-3">
<h4><?php echo $experiment_title; ?></h4>
<p>
<?php echo $experiment_instruction; ?>
</p>
<pre><code><?php echo $experiment->stimuli; ?></code></pre>
<span class="pull-right">
<form method="POST" action="experiment.php?sid=<?php echo $session_id; ?>" id="experiment-form">
<input type="hidden" name="experiment_raw" id="experiment-raw" value="" />
<input type="hidden" name="experiment_time" id="experiment-time" value="0" />
<button type="submit" class="btn btn-primary">Next →</button>
</form>
</span>
</div>
<div id="error-overlay">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Oops! Error loading experiment interface...</h4>
</div>
<div class="modal-body">
<p>
There was an error while loading some of the components required for
the experiment. Please contact your investigator for further assistance.
</p>
<p>
Alternatively, you may try one of the two options below.
</p>
<p>
We apologize for the inconvenience caused.
</p>
</div>
<div class="modal-footer">
<a href="index.php" class="btn btn-default">Start Over</a>
<a href="javascript:location.reload ();" class="btn btn-primary">Try Again</a>
</div>
</div>
</div>
</div>
<?php
//include("testenv.html");
include ("./footer.php");
?>