forked from debruine/experimentum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslideshow.php
105 lines (79 loc) · 2.55 KB
/
slideshow.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
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/include/main_func.php';
auth(1);
// set up experiment
require_once $_SERVER['DOCUMENT_ROOT'] . '/include/classes/exp.php';
$exp_id=$_GET['id'];
$version=$_GET['v'];
$exp = new experiment($exp_id, $version);
if (!$exp->check_exists()) { header('Location: /'); exit; }
$query = new myQuery("SELECT trial_n, exposure,
lefti.path as left_img,
centeri.path as center_img,
righti.path as right_img
FROM adapt_trial
LEFT JOIN stimuli AS lefti ON adapt_trial.left_img=lefti.id
LEFT JOIN stimuli AS centeri ON adapt_trial.center_img=centeri.id
LEFT JOIN stimuli AS righti ON adapt_trial.right_img=righti.id
WHERE exp_id=$exp_id AND version='$version' ORDER BY RAND()");
$myimagelist = $query->get_assoc();
$q = new myQuery("SELECT question FROM versions WHERE exp_id=$exp_id AND version=$version");
$version_question = $q->get_one();
/****************************************************/
/* !Display Page */
/***************************************************/
$title = array();
$styles = array(
'#question' => 'text-align: center;'
);
$page = new page($title);
$page->set_menu(false);
$page->displayHead($styles);
$page->displayBody();
?>
<!--*************************************************-->
<!-- !Javascripts for this page -->
<!--*************************************************-->
<script>
$(function() {
<?php
$waittime = 0;
foreach($myimagelist as $myimages) {
if (!empty($myimages['left_img'])) {
echo sprintf(" setTimeout(\"\$('#left_img').attr('src', '%s');\", %d);\n",
$myimages['left_img'], $waittime);
$left_img_count++;
}
if (!empty($myimages['center_img'])) {
echo sprintf(" setTimeout(\"\$('#center_img').attr('src', '%s');\", %d);\n",
$myimages['center_img'], $waittime);
$center_img_count++;
}
if (!empty($myimages['right_img'])) {
echo sprintf(" setTimeout(\"\$('#right_img').attr('src', '%s');\", %d);\n",
$myimages['right_img'], $waittime);
$right_img_count++;
}
$waittime += $myimages['exposure'];
}
$testurl = sprintf("/exp?go&id=%d&v=%d", $exp_id, $version);
echo " setTimeout(\"window.location.href = '{$testurl}';\", $waittime);\n";
?>
});
</script>
<div id='question'><?= loc($version_question) ?></div>
<table class='slideshow'>
<tr>
<?php
if ($left_img_count>0)
echo " <td><img id='left_img' src='' /></td>\n";
if ($center_img_count>0)
echo " <td><img id='center_img' src='' /></td>\n";
if ($right_img_count>0)
echo " <td><img id='right_img' src='' /></td>\n";
?>
</tr>
</table>
<?php
$page->displayFooter();
?>