The working copy of source code is hosted at http://github.com/yiwang/titration
parameter 'lang' is to specify languageIf language not specified, default is lang=en
survey.js for the main logic, it does the heavy lifting to substitute $BASE_VALUE and $VAL_VALUE with correct numbers based on user interaction and the corresponding Transition Matrix.
entry.js for data structure at client side.
survey-header.php for linking *.js libraries and transforming *.yaml question files to JSON format.
survey.php for constructing major viewable elements (<div> etc.) in survey page.
survey-save.php for handling POST data and save user's respond to server
Question files in 'question' foler
Each question file is named as ID.yaml, where ID is integer, i.e. 1, 2, 3 ...
$BASE_VALUE and $VAR_VALUE mark variable locations and will be substituted with actual number at run time.
Refer to file config.yaml
Description of Transition Matrix (tm), the table-like representation of the schema for '$VAR_VALUE' generation based on user's each choice within one question (group) sharing the same textual description.
Suppose we have the above base/var/sub scenario (bvs_array=[0 (for exit and Infinite), base, d, c, c.i, b, b.i, a] in code), one (of possible multiple) Transition Matrix based on user's each choice may be generated as below:
Note var transition to 'exit' denotes exiting the choice question (which is ctype0 in code) and leading to the filling blank question (which is ctype1 in code).
tm.js in code implements Transition Matrixes. "tm-index" field in each YAML question file specify the index of Transition Matrix pertaining to the specific question.
Note the number (0-7) is actually the index of elements in bvs_array.
A template to specify the format of YAML question files.
#line starting with '#' is comment, does not harm the file format, but only for human readability, the above '---' line is needed.
# Section title here, for easier relating to the location in the paper.
# Choose one TYPE from below and DELETE OTHERS, just for easier to identify the type later.
1#Environmental: usage x gain
2#Environmental: usage x loss
3#Environmental: existence x loss
4#Environmental: existence x gain
5#Monetary: luck x gain
6#Monetary: luck x loss
7#Monetary: self-earned/inflicted x gain
8#Monetary: self-earned/inflicted x loss
9#Health: risk x gain
10#Health: risk x loss
11#Health: condition x loss
12#Health: condition x gain
13#Environmental: permanent x loss
14#Environmental: temporary x loss
15#Environmental: permanent x gain
16#Environmental: temporary x gain
17#Monetary: house x gain
18#Monetary: earned x gain
19#Monetary: house x loss
20#Monetary: earned x loss
21#Health: severe x gain
22#Health: severe x loss
23#Health: mild x gain
24#Health: mild x loss
# tm-index specifies the index of Transition Matrix pertaining to this specific question
# pattern for 'var' and 'sub'
# d c b a for 'var'
# c.i b.i for 'sub'
# 22 - 30 - (37) - 44 - (55) - 65
# 'var' has EXACTLY 4 numbers in it, 'sub' has EXACTLY 2 numbers in MONOTONICALLY INCREASING order.
# DO have one WHITE SPACE after ',' between each number
var: [22, 30, 44, 65]
sub: [37, 55]
Start paragraph here with 4 WHITE SPACES padding in the begining, use $BASE_VALUE and $VAR_VALUE to represent numbers
Start paragraph here, use $BASE_VALUE and $VAR_VALUE to represent numbers
- start sentence here with one WHITE SPACE from '-' $BASE_VALUE
# note, only for ctype = 0, the selection question
en: #start sentence here with one WHITE SPACE from ':', if there is no note, leave this blank
when one instance of survey is finished, an entry (entry.js in code) is generated and written to data file in CSV format as one appending line.
en,Z,Mon Jan 11 2010 04:46:47 GMT-0600 (CST),1263206807163,1263206824929,17.8,ID8,23,300,10000,3.166,5.991,,,,ID22,23,150,200,2.185,2.054,1.572,2.798,,SEQ,22,8
as an entry in CSV files means:
language  => en set, which contains ID8 and ID22  => Z survey start time in string  => Mon Jan 11 2010 04:46:47 GMT-0600 (CST) survey start time in ms  => 1263206807163 survey end time in ms  => 1263206824929 duration=- in second  => 17.8
~ are data for ID8 question first question ID  => ID8 user's input for "equally attractive"  => 23
user's preference range: (300,10000)
range LOW value  => 300 range HIGH value  => 10000
~ are intervals in second of user's actions for ID8 question
 => 3.166  => 5.991 12~14 are empty place holders
 =>  =>  => ~ are data for ID22 question
 => ID22  => 23  => 150  => 200  => 2.185  => 2.054  => 1.572  => 2.798  =>
SEQ Separator  => SEQ
the order of randomized ID sequence (the order user answers the questions) is ID22 first, then ID8
 => 22  => 8Note 23-15 = 14-6, thus each ID occupies the same number of tokens.