Watts-Lab / surveys

Library of surveys for deliberation experiments
MIT License
3 stars 4 forks source link

Send survey results to empirica on survey completion #4

Closed JamesPHoughton closed 2 years ago

JamesPHoughton commented 2 years ago

We need to be able to get the data out of the survey object and send it to empirica to be combined with the other data from the player's experience. SurveyJS lets us do this with a handler supplied by empirica. The SurveyWrapper component needs to be able to accept a handler from empirica and use it.

This issue can be merged when

Alan-Qiao commented 2 years ago

Where does the export data go and in what form? Export to JSON along with playerId? Add to Admin Console Player Tab (which is under construction)?

Alan-Qiao commented 2 years ago

WIP in https://github.com/Watts-Lab/deliberation-empirica/tree/alan-sendSurveyResults Implemented Callback, and data successfully prints to console. Waiting on clarification before completing full pipeline.

JamesPHoughton commented 2 years ago

Where does the export data go and in what form?

Data should be saved to the player object, as in the handleSubmit in the other ExitSurvey: https://github.com/Watts-Lab/deliberation-empirica/blob/main/client/src/intro-exit/ExitSurvey.jsx#L19-L29. When we export the data after all games are finished, there will be a players.json file, and the key/value pair will be added to players.data in this export.

player.set takes a key and a value. For us, the key should probably be the name of the survey that we are returning results for. I'm not sure what surveyjs gives you as a result object. Can you find out it it is some sort of dictionary that we can pass through without making changes, or if we'll want to format the result before we add it to the player data?

Alan-Qiao commented 2 years ago

The data is already formatted in a JSON Object/Dictionary so I can pass it straight as the value. For now I am just hardcoding the name of the survey as currently the import step for specific survey json is also hardcoded.

JamesPHoughton commented 2 years ago

Thats fine. At some point we'll set up an infrastructure for selecting between post-discussion surveys based on a treatment variable set in the admin console. We can update the hard-coding then.

Alan-Qiao commented 2 years ago

At the moment, I have confirmed through manual testing that the survey results are correctly being associated with the player object in tajriba.json Should I write Cypress to check for correctness in tajriba.json on game end or wait for a more elegent player.json output?

JamesPHoughton commented 2 years ago

Lets do something very simple with the tajriba.json - lets just enter a long randomized string in the survey somewhere, and check that the tajriba.json file contains that string somewhere. I think down the road we might be more explicit, but this should get us 80% of the way there for reasonably little effort.

JamesPHoughton commented 2 years ago

Well done! =)