コード例 #1
0
        void Start()
        {
            // here we can programatically obtain experiment name, ppid, etc
            string experimentName = "example_without_ui";
            string ppid           = "example_ppid";

            // here we make a settings object from a JSON string - this could, for example, be pulled from a web API.
            UXF.Settings sessionSettings = new UXF.Settings(
                (Dictionary <string, object>)MiniJSON.Json.Deserialize(jsonString)
                );

            session.Begin(experimentName, ppid, "example_output", settings: sessionSettings);

            // herein everything is the same
        }
コード例 #2
0
        public void BeginSessionManually()
        {
            //
            // :: We will call this method by pressing the Begin Session button on the UI.
            //

            // here we can programatically obtain ppid from the UI.
            string ppid = ppidField.text;

            // if ppid empty, throw an error
            if (ppid.Trim() == string.Empty)
            {
                throw new System.Exception("Error! PPID is blank!");
            }

            // we take the text from the input boxes and store it in participant details.
            Dictionary <string, object> myParticipantDetails = new Dictionary <string, object>()
            {
                { "favourite_colour", favouriteColourField.text },
                { "favourite_food", favouriteFoodField.text }
            };

            // we take the text from the num trials input and convert to int
            int numTrials = System.Convert.ToInt32(numTrialsField.text);

            // if less than or equal to zero, throw an error
            if (numTrials <= 0)
            {
                throw new System.Exception("Error! Number of trials must be greater than 0!");
            }

            // store the value in a Settings object
            UXF.Settings mySettings = new UXF.Settings();
            mySettings.SetValue("n_trials", numTrials);

            // begin the session with our new values.
            // settings and participant details are optional
            string experimentName = "example_manual_start";

            session.Begin(experimentName, ppid, settings: mySettings, participantDetails: myParticipantDetails);
        }