MartinFk / VRQuestionnaireToolkit

🎓 ---- VRQuestionnaireToolkit ---- 🎓Enables the community to easily collect subjective measures in virtual environments.
MIT License
114 stars 25 forks source link

Survey panel scale and position #16

Closed volkerku closed 3 years ago

volkerku commented 3 years ago

Great tool, thanks for making this available. I tried to customise a survey in regards to default scale and position in the world. However, I'm unable to set a scale of position in the editor, at play it always reverts to default values. Tried to scale a parent gameobject or the survey, the survey gamebject and also the page & questionnaire prefabs. Also tried commenting out some of the localscale commands in the script, but no luck. Can you help pls.

Another thing, I tried to add a close button to the final page, using the lastPage prefab, but not sure how to go about this. If I change the script, so the footer is displayed for the last page, it is overwritten by the default next/previous buttons.

BTW, it was fairly simple to add the functionality to save the survey result on a server with webrequest.post and a php script.

MartinFk commented 3 years ago

1) For resizing, please see the Manual (https://github.com/MartinFk/VRQuestionnaireToolkit/wiki/%F0%9F%93%96-Manual). Section 5 explains how to do this. It is supported since version 1.1 in case you are still using 1.0. The world-anchoring described in section 4 only works in ConfigurationMode (when running the scene). It is misleading in the documentation -> I will update this. The size/position settings are stored in a separate file and loaded when starting the scene.

2) I am afraid, I do not really understand what you want to do. On the final page there is a submit button, right? Do you want to change the text to "Close"?

3) Awesome! If you don't mind it would be great if you could share this with us (you would get the credit for it). I think many people would benefit from this given the current situation.

volkerku commented 3 years ago

Thanks. I'll try the resizing this way. At present, the last page of a survey ( after submit ) is just acknowleding and thanking the participant. This page does not, by default, have a button. However, I mananged to add a footer with close button to the last page prefab. So this works now.

For the server side data upload, here is what i did:

c# code, added to existing Export.cs

IEnumerator UploadPost(string data)
    {
        WWWForm form = new WWWForm();
        form.AddField("unitypost", data);
        using (UnityWebRequest www = UnityWebRequest.Post("https://domain.com/surveyData.php", form))
        {
            www.downloadHandler = new DownloadHandlerBuffer();
            yield return www.SendWebRequest();

            if (www.isNetworkError)
            {
                Debug.Log(www.error);
            }
            else
            {
                string responseText = www.downloadHandler.text;
                Debug.Log("Response Text from the server = " + responseText);
            }
        }
    }

call: StartCoroutine(UploadPost(string));

I re-formatted the survey result in export.cs, so each participant is a row in the server csv file. Easier to analyze the data in this way: dateTime;Q1;Q2;Q3;Q4;Q5 22-02-2021-08-28-11;1;2;3;4;5 22-02-2021-08-28-41;5;4;3;2;1 22-02-2021-11-53-05;1;1;1;1;1 22-02-2021-12-05-55;1;2;3;4;5

server side: empty text file: surveyData.txt Php script: surveyData.php :

<?php
if(isset($_POST["unitypost"])){
    echo "This is Unity POST Response. Entered value is: " . $_POST["unitypost"];
    file_put_contents("surveyData.txt", $_POST['unitypost'], FILE_APPEND);
}
?>
MartinFk commented 3 years ago

Thanks you very much for your input!

Let me know if you need anything else.