Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize dropdown choice template view #54

Open
michael-franke opened this issue Apr 13, 2019 · 11 comments
Open

Generalize dropdown choice template view #54

michael-franke opened this issue Apr 13, 2019 · 11 comments

Comments

@michael-franke
Copy link
Member

As far as I can see the babeViews.dropdownChoice only allows for two alternatives, specified like this:

{
    question: "What's the weather like?",
    option1: 'shiny',
    option2: 'rainbow'
}

This should ideally be generalized to allow for arbitrary options, e.g., to allow input like this:

{
    question: "What's the weather like?",
    options: ['shiny', 'rainbow', 'cloudy', 'typically Amsterdam']
}

We could then add an optional field shuffle_options which defaults to false and which if true randomly shuffles the choice options for display in the dropdown menu.

@JannisBush
Copy link
Contributor

JannisBush commented Apr 13, 2019

This would be possible, but do we want to save the options as option1: 'shiny', option2: 'rainbow', optionN: 'whatever' or do we want to save the options as an array.

The second one could be problematic, and we currently do not "allow" such submissions at the back-end see here.

The first one could be implemented like this

@x-ji
Copy link
Member

x-ji commented Apr 13, 2019

The reasoning for not allowing arrays in submissions is because of CSV formatting, i.e. how should we format an array in the CSV output so that it's easy to comprehend and also easy to analyze by (R) scripts.

One possible way is to output it like entry1||entry2||entry 3, i.e. use || as the separator, and then the script can segment the array by looking for ||. However, if we do this, we'll have to make sure that || doesn't occur in any of the array entries, otherwise errors would ensue.

Another way is to just always require the frontend to not submit arrays and instead submit each option separately, as Jannis mentioned above.

@JannisBush
Copy link
Contributor

I just tested, what actually happens when you use an array at the moment.

For this, I inserted test_array : [1,2,3,"a","b] in the trial data of an experiment.

Result downloaded from the last page of the debug mode:

"trial_type","trial_number","key_pressed","correctness","pause","RT","key1","key2","q","p","target_object","target_position","condition","focalColor","focalShape","focalNumber","elemSize","total","start_with","otherShape","otherColor","sort","test_array","startDate","startTime","age","gender","education","languages","comments","endTime","timeSpent","experiment_id",
"main","1","q","correct","2185","330","q","p","circle","square","circle","right","incongruent","blue","circle","1","100","2","other","square","white","split_grid","1,2,3,a,b","Sun Apr 14 2019 09:59:33 GMT+0200 (Central European Summer Time)","1555228773704","","","","","","1555228786455","0.21251666666666666","INSERT_A_NUMBER",

Important part: "test_array" = "1,2,3,a,b"

Result downloaded from the server app:

submission_id,otherShape,startDate,target_object,correctness,total,experiment_id,trial_type,q,focalShape,key2,target_position,p,test_array,pause,key_pressed,condition,endTime,otherColor,age,comments,sort,key1,education,languages,start_with,RT,gender,trial_number,startTime,elemSize,focalColor,timeSpent,focalNumber
321,circle,Sun Apr 14 2019 10:01:35 GMT+0200 (Central European Summer Time),square,correct,2,63,practice,square,square,p,left,circle,1|2|3|a|b,1535,q,congruent,1555228907222,white,,,split_grid,q,,,focal,330,,1,1555228895329,100,blue,0.19821666666666668,1

Important part: test_array = 1|2|3|a|b

R:
Reading in the debug result with readr::read_csv generates test_array : chr "1,2,3,a,b" and transforming it with strsplit(dat, split=",") gives : chr [1:5] "1" "2" "3" "a" "b".

Reading in the server result with readr::read_csv generates test_array : chr "1|2|3|a|b" and transforming it with strsplit(dat, split="[|]") gives : chr [1:5] "1" "2" "3" "a" "b"


Now, I changed the array to test_array : [1,2,3,"a","b","c|ha,c"].

Debug: "1,2,3,a,b,c|ha,c"

Server: 1|2|3|a|b|c|ha,c

Both will fail to produce the original array.


I guess, we could allow arrays and write a warning somewhere not to use , and | in arrays?

@michael-franke
Copy link
Member Author

michael-franke commented Apr 14, 2019 via email

@x-ji
Copy link
Member

x-ji commented Apr 14, 2019

Yeah I think the problem with having a warning not to use , or | is that, some of the outputs are not generated by the experiment designer, but rather the participant. What if they write several sentences containing ,, for example. The system would then not be foolproof.

The idea of using n + 1 times separator is interesting. I'll try to implement that on the backend.

@JannisBush
Copy link
Contributor

The places where the participant can input sentences, should be handled as Strings and not as Arrays anyways. Therefore, there shouldn't be a problem, because we only touch Arrays or am I mistaken?

@x-ji
Copy link
Member

x-ji commented Apr 14, 2019

There were cases in previous experiments where there are e.g. three sentences to be filled in on the same page, resulting in the response being recorded in three parts. Of course if there's only one sentence there will only be one string. Not sure if such cases are still possible in the new frontend templates.

@x-ji
Copy link
Member

x-ji commented Apr 19, 2019

I think currently what wouldn't work is when an entry is a JS object, i.e. k-v pairs. This is what happened with the error that Jannis encountered a while ago. If an entry is just a plain array, the contents of the array would be output in the CSV file, separated with |. I have clarified it in the README.

@michael-franke
Copy link
Member Author

michael-franke commented Apr 21, 2019 via email

@x-ji
Copy link
Member

x-ji commented Apr 21, 2019

Indeed the submission of the canvas data as an object was what triggered Jannis to encounter the bug in the first place. We discussed the issue here: magpie-ea/magpie-backend#72 (comment) and Jannis flattened the object in the frontend.

Should we allow the user to include objects in their submission but flatten the object? Then should we do it in the frontend, as a check before the submission, or should the backend try to do it?

@michael-franke
Copy link
Member Author

michael-franke commented Apr 22, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants