forked from jspsych/jsPsych
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjspsych-form.html
57 lines (47 loc) · 2 KB
/
jspsych-form.html
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
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.2.1/material.indigo-pink.min.css">
<script defer src="https://code.getmdl.io/1.2.1/material.min.js"></script>
<script src="../jspsych.js"></script>
<script src="../plugins/jspsych-form.js"></script>
<script src="../plugins/jspsych-text.js"></script>
<link rel="stylesheet" href="../css/jspsych.css"></script>
<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>-->
<head>
<title></title>
</head>
<body>
</body>
<script type="text/javascript">
function clickToSubmit() {
alert("This is a test. Check Question #7 to see the effect.");
document.getElementById("custom_id_1").value += "Customize actions when submit buttons is pressed.";
return {"Customized output": "Customize actions when submit buttons is pressed."};
}
var schema = {
form: {form_title: 'Test #1'}, // , ribbon_bg: "img/ribbon.jpg", layout_color: "grey-300", content_bg_color: "grey-100"},
"Question #1": {type: "short answer", correct: "Answer #1", required: true},
"Question #2": {type: "password"},
"Question #3": {type: "checkbox", labels: ["option1", "option2"], correctAnswers: ["value1", "value2"], values:["value1", "value2"]},
"Question #4": {type: "radio", labels: ["option1", "option2"], correctAnswers: ["option1"]},
"Question #5": {type: "range"},
"Question #6": {type: "dropdown"},
"Question #7": {type: "long answer", question_description: "Some random contents", id: "custom_id_1"},
"Question #8<p>Some random contents</p>": {type: "long answer", question_description: ""},
onSubmit: {label: "Submit", onclick: clickToSubmit}
}
var text_trial = {
type: 'html-keyboard-response',
stimulus: 'Press any key to view form.'
}
var form_trial = {
type: 'form',
schema: schema
}
jsPsych.init({
timeline: [text_trial, form_trial],
on_finish: function(){ jsPsych.data.displayData(); }
});
</script>
</html>