Esempio n. 1
0
        public IEnumerable <View> RunTrial(int index, bool isStudy, StudyTestPair stp, StreamWriter logWriter,
                                           StreamWriter logWriterV, //List<EEGDataEntry> currentTrialEntries,
                                           RandomizedQueue <StudyTestPair> studySoon,
                                           RandomizedQueue <StudyTestPair> testSoon, RandomizedQueue <StudyTestPair> testLate)
        {
            //yield return new RestView(this.settings.BlinkTime);
            int trialnumber = index + 1;

            yield return(new TextView("Trial number: " + trialnumber, this.settings.BlinkTime, GUIUtils.Constants.DISPLAY_FONT_LARGE));

            yield return(new FixationView(this.settings.FixationTime));

            IViewResult result;
            View        vocabView;

            if (isStudy)
            {
                vocabView = new TextView(stp.test + Environment.NewLine + stp.answer, settings.DisplayTime, GUIUtils.Constants.DISPLAY_FONT_LARGE);
            }
            else
            {
                vocabView = new VocabView(stp.test, stp.answer, settings.DisplayTime, settings.DelayTime, false, out result);
            }

            yield return(vocabView);

            //The user controls which group the stimulus goes into after the trial
            StudyTestPair toAdd = stp; //new StudyTestPair(stp.test, stp.answer, stp.number);

            if (!isStudy)
            {
                yield return(new TextView((bool)vocabView.Result.Value ? "Correct" : "Incorrect", settings.FeedbackTime, GUIUtils.Constants.DISPLAY_FONT_LARGE));

                int toWrite = (bool)vocabView.Result.Value ? 1 : 0;
                logWriter.WriteLine(toAdd.number + ", " + toWrite);
                string[]   options = { "Study Soon", "Test Soon", "Test Later" };
                ChoiceView choice  = new ChoiceView(options);
                yield return(choice);

                if ((string)choice.Result.Value == options[0])
                {
                    studySoon.Add(toAdd);
                }
                else if ((string)choice.Result.Value == options[1])
                {
                    testSoon.Add(toAdd);
                }
                else
                {
                    testLate.Add(toAdd);
                }
                logWriterV.WriteLine("User Answer: " + vocabView.Result.Value);
                logWriterV.WriteLine("User Choice: " + choice.Result.Value);
            }
            else
            {
                testSoon.Add(toAdd);
                logWriterV.WriteLine("Study Trial");
            }
        }
Esempio n. 2
0
        private IEnumerable <View> GetViews(ISynchronizeInvoke invoker, StreamWriter logWriterV, StreamWriter logWriter,
                                            RandomizedQueue <StudyTestPair> studySoon, RandomizedQueue <StudyTestPair> testSoon, RandomizedQueue <StudyTestPair> testLate)
        {
            //Presents stimuli from the three categories randomly with set probabilities
            Random numgen = new Random();

            for (int index = 0; index < settings.NumTrials; index++)
            {
                double choice = numgen.NextDouble();
                if (choice < 0.01)
                {
                    if (!testLate.IsEmpty())
                    {
                        StudyTestPair currstp = testLate.RemoveRandom();
                        logWriterV.WriteLine("Question: " + currstp.test);
                        logWriterV.WriteLine("Correct Answer: " + currstp.answer);
                        foreach (var view in RunTrial(index, false, currstp, logWriter,
                                                      logWriterV,
                                                      studySoon, testSoon, testLate))
                        {
                            yield return(view);
                        }
                    }
                    else if (!studySoon.IsEmpty())
                    {
                        StudyTestPair study = studySoon.RemoveRandom();
                        logWriterV.WriteLine("Study Trial");
                        logWriterV.WriteLine(study.test);
                        logWriterV.WriteLine(study.answer);
                        foreach (var view in RunTrial(index, true, study, logWriter,
                                                      logWriterV,
                                                      studySoon, testSoon, testLate))
                        {
                            yield return(view);
                        }
                    }
                    else
                    {
                        StudyTestPair currstp = testSoon.RemoveRandom();
                        logWriterV.WriteLine("Question: " + currstp.test);
                        logWriterV.WriteLine("Correct Answer: " + currstp.answer);
                        foreach (var view in RunTrial(index, false, currstp, logWriter,
                                                      logWriterV,
                                                      studySoon, testSoon, testLate))
                        {
                            yield return(view);
                        }
                    }
                }
                else if (choice < 0.4)
                {
                    if (!studySoon.IsEmpty())
                    {
                        StudyTestPair study = studySoon.RemoveRandom();
                        logWriterV.WriteLine("Study Trial");
                        logWriterV.WriteLine(study.test);
                        logWriterV.WriteLine(study.answer);
                        foreach (var view in RunTrial(index, true, study, logWriter,
                                                      logWriterV,
                                                      studySoon, testSoon, testLate))
                        {
                            yield return(view);
                        }
                    }
                    else if (!testSoon.IsEmpty())
                    {
                        StudyTestPair currstp = testSoon.RemoveRandom();
                        logWriterV.WriteLine("Question: " + currstp.test);
                        logWriterV.WriteLine("Correct Answer: " + currstp.answer);
                        foreach (var view in RunTrial(index, false, currstp, logWriter,
                                                      logWriterV,
                                                      studySoon, testSoon, testLate))
                        {
                            yield return(view);
                        }
                    }
                    else
                    {
                        StudyTestPair currstp = testLate.RemoveRandom();
                        logWriterV.WriteLine("Question: " + currstp.test);
                        logWriterV.WriteLine("Correct Answer: " + currstp.answer);
                        foreach (var view in RunTrial(index, false, currstp, logWriter,
                                                      logWriterV,
                                                      studySoon, testSoon, testLate))
                        {
                            yield return(view);
                        }
                    }
                }
                else
                {
                    if (!testSoon.IsEmpty())
                    {
                        StudyTestPair currstp = testSoon.RemoveRandom();
                        logWriterV.WriteLine("Question: " + currstp.test);
                        logWriterV.WriteLine("Correct Answer: " + currstp.answer);
                        foreach (var view in RunTrial(index, false, currstp, logWriter,
                                                      logWriterV,
                                                      studySoon, testSoon, testLate))
                        {
                            yield return(view);
                        }
                    }
                    else if (!studySoon.IsEmpty())
                    {
                        StudyTestPair study = studySoon.RemoveRandom();
                        logWriterV.WriteLine("Study Trial");
                        logWriterV.WriteLine(study.test);
                        logWriterV.WriteLine(study.answer);
                        foreach (var view in RunTrial(index, true, study, logWriter,
                                                      logWriterV,
                                                      studySoon, testSoon, testLate))
                        {
                            yield return(view);
                        }
                    }
                    else
                    {
                        StudyTestPair currstp = testLate.RemoveRandom();
                        logWriterV.WriteLine("Question: " + currstp.test);
                        logWriterV.WriteLine("Correct Answer: " + currstp.answer);
                        foreach (var view in RunTrial(index, false, currstp, logWriter,
                                                      logWriterV,
                                                      studySoon, testSoon, testLate))
                        {
                            yield return(view);
                        }
                    }
                }
            }
        }