Пример #1
0
        private GetNextSentenceResult HandleExerciseSection(UserProfile profile)
        {
            // PRE: By the time we come here. we have already been moved to either
            // starting next pack or being in a valid question dimension by the state evaluator
            // if starting exercise pack
            //       select sample sentence.
            //       return it.
            // else
            //       select sentence for this question dimension.
            //       return it.

            Sentence sentence = null;
            bool isQuestion = false;
            QuestionDimension dimension = QuestionDimension.Unknown;
            bool found = false;

            sentence = SentenceOperations.FindSentence(profile);

            if(sentence != null)
            {
                found = true;
            }

            if (!SectionUtilities.StartingExercisePack(profile))
            {
                isQuestion = true;
                dimension = profile.CurrentState.CourseLocationInfo.TopicLocationInfo.ExerciseSectionState.CurrentQuestionDimension;
            }

            GetNextSentenceResult result = new GetNextSentenceResult(sentence: sentence, success: found, isQuestion: isQuestion, dimension: dimension, isReview: false);

            return result;
        }
Пример #2
0
        private GetNextSentenceResult HandleReviewSection(UserProfile profile)
        {
            // PRE: We have already been moved to the review section by the state evaluator.
            // select sentence for review.
            // return it.

            Sentence sentence = null;
            bool found = false;

            sentence = SentenceOperations.FindSentence(profile);

            if (sentence != null)
            {
                found = true;
            }

            GetNextSentenceResult result = new GetNextSentenceResult(sentence: sentence, success: found, isQuestion: true, dimension: QuestionDimension.Understanding, isReview: true);

            return result;
        }
Пример #3
0
        public static BaseSentenceModel CreateExcerciseViewModel(GetNextSentenceResult sentenceResult, UserProfile profile)
        {
            BaseSentenceModel resultModel;
            var sentence = sentenceResult.Sentence;

            // While in Excercise Controller, sentence should either be a Sample sentence or a Question sentence
            // Review sentence would be an error
            if (sentenceResult.IsReview)
            {
                Trace.TraceError("Unexpected sentence result.  Should not receive Review sentence during excericse flow.");
            }
            if (sentenceResult.IsQuestion)
            {
                bool isGrammarQ = (sentenceResult.QuestionDimension == QuestionDimension.Grammar);

                if (!isGrammarQ)
                {
                    // If it's not grammar question it's a default contextual question
                    var model = new QuestionExcerciseViewModel(sentence.SentenceText, sentence.SentenceTranslation);
                    resultModel = model;

                    // Retriev all the Question related information from the sentence
                    PopulateQuestionFields(sentenceResult, model);
                }
                else
                {
                    // Create a Grammar Question
                    var model = new GrammarQuestionExcerciseViewModel(sentence.SentenceText, sentence.SentenceTranslation);
                    resultModel = model;

                    // Retriev all the Question related information from the sentence
                    PopulateQuestionFields(sentenceResult, model);

                    //
                    // Populate Grammar Analysis related model fields
                    PopulateGrammarAnalysisFields(sentence, model.GrammarAnalysis);

                    //
                    // Populate Grammar Entries related model fields
                    PopulateGrammarEntriesFields(sentence, model.GrammarEntries);
                }
            }
            else
            {
                // It's a regular sample sentence.  Now create right model depending on whether user is
                // Contextual or Analytical

                if (LearningTypeScorePolicies.IsAnalytical(profile))
                {
                    var model = new AnalyticalExcerciseViewModel(sentence.SentenceText, sentence.SentenceTranslation);
                    resultModel = model;

                    //
                    // Populate Grammar Analysis related model fields
                    PopulateGrammarAnalysisFields(sentence, model.GrammarAnalysis);

                    //
                    // Populate Grammar Entries related model fields
                    PopulateGrammarEntriesFields(sentence, model.GrammarEntries);
                }
                else
                {
                    var model = new ContextualExcerciseViewModel(sentence.SentenceText, sentence.SentenceTranslation);
                    resultModel = model;

                    //
                    // Populate Grammar Entries related model fields
                    PopulateGrammarEntriesFields(sentence, model.GrammarEntries);
                }
            }

            return resultModel;
        }
Пример #4
0
        private static void PopulateQuestionFields(GetNextSentenceResult sentenceResult, QuestionExcerciseViewModel model)
        {
            var sentence = sentenceResult.Sentence;
            Question q;
            if (sentence.Questions.TryGetValue(sentenceResult.QuestionDimension, out q))
            {
                model.QuestionSubText = q.QuestionSubstring;
                model.BlankIndices = q.BlankPositions;
                model.CorrectAnswerChoice = q.CorrectAnswerIndex;

                foreach (var a in q.AnswerChoices)
                {
                    ViewModelAnswerChoice vmac = new ViewModelAnswerChoice();
                    vmac.Choice = a.Answer;
                    model.AnswerChoices.Add(vmac);
                }

                foreach (var seg in q.AnswerSegments)
                {
                    AnswerSegment answerSeg = new AnswerSegment();
                    answerSeg.Text = seg;
                    model.AnswerSegments.Add(answerSeg);
                }
            }
            else
            {
                // TODO: Handle internal errors like this.  Should stop the flow?
                Trace.TraceError("Failed to get retrieve Question from sentence.");
            }
        }