public async override Task <ResultArgs <StudyItemViewModelArgs> > GetNextStudyItemViewModelAsync() { if (_AbortIsFlagged) { return(await StudyHelper.GetAbortedAsync()); } LineEdit lineToStudy = null; //IF WE KNOW ALL OF OUR GROUPS, RESET AND START OVER if (_KnownGroupNumbers.Count == _LineGroups.Count) { _PrevGroupNumberStudied = -1; _PrevStudyWasHit = false; _KnownGroupNumbers.Clear(); foreach (var completedGroup in _LineGroups) { completedGroup.Reset(); } } //GET THE INITIAL GROUP NUMBER TO TRY TO STUDY int groupNumberToStudy = _PrevGroupNumberStudied; LineGroup group = null; if (_PrevStudyWasHit) { //PREV STUDY WAS HIT, SO TRY TO STAY WITH THE PREV GROUP. group = GetGroupFromGroupNumber(_PrevGroupNumberStudied); if (group == null) { throw new Exception();//SINCE PREV STUDY WAS HIT, THIS SHOULD NEVER HAPPEN. } //IF THE GROUP IS NOT YET COMPLETED, GET ITS NEXT LINE, OTHERWISE WE NEED TO TRY THE NEXT GROUP. if (!group.Completed) { lineToStudy = group.GetLine(); if (lineToStudy == null) { throw new Exception(); } _PrevGroupNumberStudied = group.GroupNumber; } else { //PREVIOUS GROUP WAS A HIT AND THAT COMPLETED THAT GROUP, SO GET NEXT GROUP int nextGroupNumber = GetNextUnknownGroupNumber(); group = GetGroupFromGroupNumber(nextGroupNumber); if (group.Completed) { throw new Exception(); } lineToStudy = group.GetLine(); _PrevGroupNumberStudied = group.GroupNumber; } } else { //PREVIOUS WAS A MISS, SO GET LINE FROM NEXT UNKNOWN GROUP int nextGroupNumber = GetNextUnknownGroupNumber(); group = GetGroupFromGroupNumber(nextGroupNumber); if (group.Completed) { throw new Exception(); } lineToStudy = group.GetLine(); _PrevGroupNumberStudied = group.GroupNumber; } //groupNumberToStudy = _PrevGroupNumberStudied; //if (groupNumberToStudy == _LineGroups.Count) // groupNumberToStudy = 0; ////FIND THE FIRST GROUP NUMBER THAT IS UNKNOWN //for (int i = 0; i < _LineGroups.Count; i++) //{ // if (!_KnownGroupNumbers.Contains(groupNumberToStudy)) // break; // //THAT GROUP NUMBER IS ALREADY KNOWN. UPDATE FOR THE NEXT TRY. // groupNumberToStudy++; // if (groupNumberToStudy == _LineGroups.Count) // groupNumberToStudy = 0; //} ////WE NOW HAVE THE GROUP NUMBER TO STUDY. //var group = _LineGroups[groupNumberToStudy]; //var lineToStudy = group.GetLine(); //WE NOW HAVE THE LINE TO STUDY. PROCURE A LINE ORDER var result = await StudyItemViewModelFactory.Ton.Procure(lineToStudy, group.MultiLineText); var viewModel = result.Object; StudyItemViewModelArgs args = new StudyItemViewModelArgs(viewModel); var resultArgs = new ResultArgs <StudyItemViewModelArgs>(args); var retArgs = await StudyHelper.WrapInTask <ResultArgs <StudyItemViewModelArgs> >(resultArgs); return(retArgs); }
public override async Task <ResultArgs <StudyItemViewModelArgs> > GetNextStudyItemViewModelAsync() { if (_AbortIsFlagged) { return(await StudyHelper.GetAbortedAsync()); } //USING THE TARGET PHRASE, //IF IT IS IN THE NATIVE LANGUAGE, THEN IT JUST POPS UP A NATIVE LANGUAGE STUDY QUESTION. //IF IT IS IN A DIFFERENT LANGUAGE, THEN IT POPS UP EITHER DIRECTION Q & A, 50% CHANCE. #region Thinking var targetId = Guid.NewGuid(); History.Events.ThinkingAboutTargetEvent.Publish(targetId); #endregion var retriever = await StudyDataRetriever.CreateNewAsync(); #region Thinked History.Events.ThinkedAboutTargetEvent.Publish(targetId); #endregion if (_AbortIsFlagged) { return(await StudyHelper.GetAbortedAsync()); } var nativeLanguageText = retriever.StudyData.NativeLanguageText; if (string.IsNullOrEmpty(nativeLanguageText)) { throw new StudyException("No native language set."); } if (_Target == null) { throw new StudyException("No PhraseEdit to study, _StudyJobInfo.Target == null."); } var phraseEdit = _Target; var phraseText = phraseEdit.Text; if (string.IsNullOrEmpty(phraseText)) { throw new StudyException("Attempted to study empty phrase text, (PhraseEdit)_Target.Text is null or empty."); } var languageText = phraseEdit.Language.Text; //WE HAVE A PHRASEEDIT WITH A LANGUAGE AND WE HAVE OUR NATIVE LANGUAGE, //SO WE HAVE ENOUGH TO PROCURE A VIEW MODEL NOW. var result = await StudyItemViewModelFactory.Ton.ProcureAsync(phraseEdit, nativeLanguageText); if (_AbortIsFlagged) { return(await StudyHelper.GetAbortedAsync()); } var studyItemViewModel = result.Object; studyItemViewModel.Shown += new EventHandler(studyItemViewModel_Shown); var args = new StudyItemViewModelArgs(studyItemViewModel); var resultArgs = new ResultArgs <StudyItemViewModelArgs>(args); _Phrase = phraseEdit;//hack return(await StudyHelper.WrapInTask <ResultArgs <StudyItemViewModelArgs> >(resultArgs)); }