Exemple #1
0
        public override void Start(HumanSubject current_subject = null)
        {
            if (current_subject != null)
            {
                //Get the list of words to use for this study block
                var hal_config             = HumanAcceleratedLearningConfiguration.GetInstance();
                var available_dictionaries = hal_config.LanguageDictionaries;
                source_language_dictionary = available_dictionaries.Where(x =>
                                                                          x.ForeignLanguageName.Equals(ForeignLanguage) &&
                                                                          x.NativeLanguageName.Equals(NativeLanguage)
                                                                          ).FirstOrDefault();

                //Shuffle the words
                if (source_language_dictionary != null)
                {
                    var word_list = source_language_dictionary.DictionaryWordPairs.ToList();
                    shuffled_word_list     = MathHelperMethods.ShuffleList(word_list);
                    last_word_display_time = DateTime.MinValue;
                    current_wordpair_index = 0;

                    //Create a file for this study session
                    fid = StudyBlock.CreateStudyBlockFile(current_subject.UserName);

                    HasPhaseStarted = true;
                }
            }
        }
        public FormattedString CheckGoalStatus(StudyBlock item)
        {
            var      fs         = new FormattedString();
            DateTime start      = DateTime.Parse(item.StartTime);
            DateTime end        = DateTime.Parse(item.EndTime);
            TimeSpan diff       = end.Subtract(start);
            string   difference = diff.Minutes.ToString();

            if (Int32.Parse(difference) > Int32.Parse(item.Goal) || Int32.Parse(difference) == Int32.Parse(item.Goal))
            {
                fs.Spans.Add(new Span {
                    Text = "Congratulations!", FontSize = 20, FontAttributes = FontAttributes.Bold
                });
                fs.Spans.Add(new Span {
                    Text = " you studied for ", FontSize = 15, FontAttributes = FontAttributes.Italic
                });
                fs.Spans.Add(new Span {
                    Text = difference + " minutes.", FontSize = 15, FontAttributes = FontAttributes.Bold
                });
                return(fs);///"Congratulations you studied for " + difference + " minutes";
            }
            else
            {
                fs.Spans.Add(new Span {
                    Text = "Sucks!", FontSize = 20, FontAttributes = FontAttributes.Bold
                });
                fs.Spans.Add(new Span {
                    Text = " you studied for ", FontSize = 15, FontAttributes = FontAttributes.Italic
                });
                fs.Spans.Add(new Span {
                    Text = difference + " minutes.", FontSize = 15, FontAttributes = FontAttributes.Bold
                });
                return(fs);///"Sucks! you only studied for " + difference + " minutes";
            }
        }
Exemple #3
0
        public override void Update()
        {
            //If the shuffled word list is null or has 0 words, immediately exit
            if (shuffled_word_list == null || (shuffled_word_list != null && shuffled_word_list.Count == 0))
            {
                IsPhaseFinished = true;
                return;
            }

            //If it is not yet time to display a new word pair...
            //Check to see if it is time to make the current word pair disappear...
            if (DateTime.Now >= (last_word_display_time + TimeSpan.FromMilliseconds(this.Duration)))
            {
                CurrentForeignLanguageWord = string.Empty;
                CurrentNativeLanguageWord  = string.Empty;
            }

            if (DateTime.Now >= (last_word_display_time + TimeSpan.FromMilliseconds(this.Duration + this.Spacing)))
            {
                //Check to see if we are done
                if (current_wordpair_index >= shuffled_word_list.Count)
                {
                    //Set the flag indicating this phase is finished
                    IsPhaseFinished = true;

                    //Close the save file for this study block
                    if (fid != null)
                    {
                        fid.Close();
                    }

                    //Return from this function immediately
                    return;
                }
                else
                {
                    //If we are not done yet...
                    //Grab the next word pair
                    CurrentForeignLanguageWord = shuffled_word_list[current_wordpair_index].Item1;
                    CurrentNativeLanguageWord  = shuffled_word_list[current_wordpair_index].Item2;

                    //Set the time for when this word pair was displayed
                    last_word_display_time = DateTime.Now;

                    //Increment the word pair index
                    current_wordpair_index++;

                    //Save this trial
                    if (fid != null)
                    {
                        StudyBlock.WriteStudyTrial(fid, CurrentForeignLanguageWord, CurrentNativeLanguageWord, last_word_display_time);
                    }
                }
            }
        }
        public BlockSetup()
        {
            InitializeComponent();

            Padding = new Thickness(10, 20, 10, 10);



            StudyBlock blockItem = new StudyBlock();

            Begin.Clicked += async(sender, args) =>
            {
                blockItem.Topic     += Topic.Text;
                blockItem.Location  += Location.Text;
                blockItem.Goal      += Goal.Text;
                blockItem.StartTime += DateTime.Now.ToString("T");
                await Navigation.PushAsync(new Distracted(blockItem));
            };
        }
        public Distracted(StudyBlock studyBlockItem)
        {
            InitializeComponent();

            bingSpeechService = new BingSpeechService(new AuthenticationService(Constants.BingSpeechApiKey));

            Padding = new Thickness(10, 0, 10, 0);

            Reason.FontSize = 12;

            StudyBlock model = new StudyBlock
            {
                StartTime = studyBlockItem.StartTime,
                EndTime   = studyBlockItem.EndTime,
                Topic     = studyBlockItem.Topic,
                Location  = studyBlockItem.Location,
                Goal      = studyBlockItem.Goal,
            };

            NavigationPage.SetHasBackButton(this, false);


            Boom.Clicked += async(sender, args) =>
            {
                Boom.IsVisible        = false;
                model.EndTime        += DateTime.Now.ToString("T");
                Results.IsVisible     = true;
                Results.FormattedText = CheckGoalStatus(model);
                SpeechArea.IsVisible  = true;
                await AzureManager.AzureManagerInstance.PostStudyBlockInformation(model);
            };


            Home.Clicked += async(sender, args) =>
            {
                await Navigation.PopToRootAsync();
            };
        }
Exemple #6
0
        public override void Start(HumanSubject current_subject = null)
        {
            if (current_subject != null)
            {
                _current_subject = current_subject;

                if (current_subject.AllObjectImages.Count == 0 && current_subject.AllObjectImageLocations.Count == 0)
                {
                    var res_folder = HumanAcceleratedLearningConfiguration.GetInstance().ResourcesFolder;
                    var img_path   = HumanAcceleratedLearningConfiguration.GetInstance().ObjectLocationImagesPath;
                    var all_images = Directory.GetFiles(res_folder + img_path).ToList();

                    current_subject.AllObjectImages = all_images;
                    last_picture_display_time       = DateTime.MinValue;
                    current_image_index             = 0;

                    for (int i = 0; i < all_images.Count; i++)
                    {
                        var loc_x = MathHelperMethods.RandomNumbers.Next(1, Convert.ToInt32(grid_columns) - 1);
                        var loc_y = MathHelperMethods.RandomNumbers.Next(1, Convert.ToInt32(grid_rows) - 1);
                        current_subject.AllObjectImageLocations.Add(new Tuple <int, int>(loc_x, loc_y));
                    }

                    //Save all of the object locations to a file
                    ObjectLocation_FileHandler.WriteAllObjectLocationsToFile(current_subject);
                }

                //Create a shuffled list of image indices for this study session
                var all_indices = Enumerable.Range(0, current_subject.AllObjectImages.Count).ToList();
                shuffled_list_of_image_indices = MathHelperMethods.ShuffleList(all_indices);

                //Create a file for this study session
                fid = StudyBlock.CreateStudyBlockFile(current_subject.UserName);

                HasPhaseStarted = true;
                StartTime       = DateTime.Now;
            }
        }
Exemple #7
0
 public async Task PostStudyBlockInformation(StudyBlock studyblock)
 {
     await this.studyblockTable.InsertAsync(studyblock);
 }
Exemple #8
0
        public override void Update()
        {
            if (_current_subject != null && this.ScreenWidth > 0 && this.ScreenHeight > 0)
            {
                if (_current_subject.AllObjectImages == null || (_current_subject.AllObjectImages != null && _current_subject.AllObjectImages.Count == 0))
                {
                    IsPhaseFinished = true;
                    return;
                }

                if (DateTime.Now >= (last_picture_display_time + TimeSpan.FromMilliseconds(this.Duration)))
                {
                    //Check to see if we are done
                    if (current_image_index >= _current_subject.AllObjectImages.Count)
                    {
                        //Set the flag indicating this phase is finished
                        IsPhaseFinished = true;

                        //Close the save file for this study block
                        if (fid != null)
                        {
                            fid.Close();
                        }

                        //Return from this function immediately
                        return;
                    }
                    else
                    {
                        //If we are not done yet...

                        var selected_image_index_from_shuffled_list = shuffled_list_of_image_indices[current_image_index];

                        //Grab the next image
                        CurrentImagePath = _current_subject.AllObjectImages[selected_image_index_from_shuffled_list];

                        //Calculate the new image location here...
                        CurrentImageLocationX_Column = _current_subject.AllObjectImageLocations[selected_image_index_from_shuffled_list].Item1;
                        CurrentImageLocationY_Row    = _current_subject.AllObjectImageLocations[selected_image_index_from_shuffled_list].Item2;
                        CurrentImageLocationX        = _current_subject.AllObjectImageLocations[selected_image_index_from_shuffled_list].Item1 * ColumnWidth;
                        CurrentImageLocationY        = _current_subject.AllObjectImageLocations[selected_image_index_from_shuffled_list].Item2 * RowHeight;

                        //Set the time for when this image was displayed
                        last_picture_display_time = DateTime.Now;

                        //Increment the image index
                        current_image_index++;

                        //Save this trial
                        if (fid != null)
                        {
                            //double cm_x = (CurrentImageLocationX / dip_per_inch) * cm_per_inch;
                            //double cm_y = (CurrentImageLocationY / dip_per_inch) * cm_per_inch;

                            StudyBlock.WriteObjectLocationStudyTrial(fid, Path.GetFileName(CurrentImagePath),
                                                                     CurrentImageLocationX, CurrentImageLocationY, last_picture_display_time);
                        }
                    }
                }
            }
        }