Ejemplo n.º 1
0
        protected async Task <bool> StudySessionConflictExists(StudySession newSession)
        {
            var currentUser = await _userManager.GetUserAsync(HttpContext.User);

            var activeStudySessions = await _context.GetStudySessionsByUser(currentUser.Id, true).ToListAsync();

            DateTime newSessionStart, newSessionEnd, existingSessionStart, existingSessionEnd;

            bool studySessionConflict = false;

            if (activeStudySessions.Count > 0)
            {
                activeStudySessions.Remove(newSession);
                foreach (var existingSession in activeStudySessions)
                {
                    newSessionStart      = newSession.GetStudySessionStart();
                    newSessionEnd        = newSession.GetStudySessionEnd();
                    existingSessionStart = existingSession.GetStudySessionStart();
                    existingSessionEnd   = existingSession.GetStudySessionEnd();

                    studySessionConflict = newSessionStart < existingSessionEnd && existingSessionStart < newSessionEnd;

                    if (studySessionConflict)
                    {
                        studySessionConflict = true;
                        break;
                    }
                }
            }
            return(studySessionConflict);
        }
Ejemplo n.º 2
0
        private void studySubjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //create menu/form to ask which method they'd like to study by
            System.Windows.Forms.DialogResult dialogResult =
                MessageBox.Show("Would you like to study this subject's child subjects along with it?",
                                "Studying Options", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
            if (dialogResult == System.Windows.Forms.DialogResult.Cancel)
            {
                return; //no studying today
            }
            bool includeChildren = dialogResult == System.Windows.Forms.DialogResult.Yes ? true : false;

            //in the future add other study methods
            //hide main form, create study dialog, and let study session occur
            this.Hide();
            List <Card> cards = populateCards((Subject)lastSelectedNode.Tag, includeChildren);

            if (cards.Count < 3)
            {
                Helper.ShowError("There must be at least 3 cards to study.");
                return;
            }
            StudySession session = StudyView.CreateSession(cards);

            //get and display results
            ResultView.ShowResults(session);
            //add study session to past study sessions
            ((RootSubject)treeMain.Nodes[0].Tag).PastStudySessions.Add(session);
            //show main form and edit flag or prompt for saving
            this.Show();
            doEdited();
        }
        public void incorrect_items_stay_in_review_queue_until_correct()
        {
            var items = new ReviewItemListBuilder()
                        .WithDueItems(1)
                        .Build();
            var session = new StudySession <ReviewItem>(items);

            var incorrectTimes = 0;

            foreach (var reviewItem in session)
            {
                if (incorrectTimes++ < 3)
                {
                    session.Review(reviewItem, ReviewOutcome.Incorrect);
                }
                else
                {
                    break;
                }
            }

            session.Review(session.First(), ReviewOutcome.Perfect);

            Assert.That(session, Is.Empty);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> EditPost(int?id)
        {
            StudySession studySessionToUpdate = await _context.GetStudySessionById(id);

            var updateResult = await TryUpdateModelAsync(studySessionToUpdate);

            if (updateResult)
            {
                try
                {
                    if (await StudySessionConflictExists(studySessionToUpdate))
                    {
                        TempData["Message"] = new SystemMessage(MessageType.Warning,
                                                                "Studieøkten du planlegger kolliderer med en som allerede er planlagt.").GetSystemMessage();
                        await PrepareCreateEditView();

                        return(View(studySessionToUpdate));
                    }
                    await _context.SaveChangesAsync();

                    TempData["Message"] = new SystemMessage(MessageType.Success, "Studieøkten ble oppdatert.")
                                          .GetSystemMessage();
                    return(RedirectToAction("Index"));
                }
                catch (Exception)
                {
                    TempData["Message"] =
                        new SystemMessage(MessageType.Critical, "Det oppstod en feil under oppdatering av studieøkten.")
                        .GetSystemMessage();
                }
            }
            return(View(studySessionToUpdate));
        }
        public void reviewing_updates_ReviewOutcome(ReviewOutcome outcome)
        {
            var item = new ReviewItemBuilder().Due().Build();

            var session = new StudySession<ReviewItem>(new[] { item }) { Clock = _clock };
            var review = session.Review(item, outcome);

            Assert.That(review.ReviewOutcome, Is.EqualTo(outcome));
        }
        public ActionResult ChangeInstructor(StudySession Model, String InFromDate, String InToDate)
        {
            DateTime FromDate = InFromDate.ParseStringToDateTime();
            DateTime ToDate   = InToDate.ParseStringToDateTime();

            StuSesBO.ChangeInstructor(Model.RollCallID, Model.InstructorID, Model.Note, FromDate, ToDate);

            return(Json(new { message = "Success" }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult SessionDetail(int ID)
        {
            StudySession      Session   = StuSesBO.GetSessionByID(ID);
            SelectListFactory slFactory = new SelectListFactory();

            ViewBag.InstructorID       = slFactory.MakeSelectList <Instructor>("InstructorID", "FullName", Session.InstructorID);
            ViewBag.LastAttendanceDate = RollBO.LastAttendanceDate(Session.RollCallID);

            return(PartialView("_SessionDetail", Session));
        }
        public void limit_existing_cards_per_session()
        {
            var items   = new ReviewItemListBuilder().WithExistingItems(_maxExistingCardsPerSession + 1).Build();
            var session = new StudySession <ReviewItem>(items)
            {
                MaxExistingCards = _maxExistingCardsPerSession
            };

            Assert.That(session.Count(), Is.EqualTo(_maxExistingCardsPerSession));
        }
        public void incorrect_review_resets_PreviousReviewDate()
        {
            var correctReviewStreak = 3;
            var item = new ReviewItemBuilder().Due().WithCorrectReviewStreak(correctReviewStreak).Build();

            var session = new StudySession<ReviewItem>(new[] { item });
            var review = session.Review(item, ReviewOutcome.Incorrect);

            Assert.That(review.PreviousCorrectReview, Is.EqualTo(DateTime.MinValue));
        }
        public void item_is_not_due_for_review()
        {
            var items = new ReviewItemListBuilder()
                        .WithFutureItems(1)
                        .Build();

            var session = new StudySession <ReviewItem>(items);

            Assert.That(session.IsDue(items.First()), Is.False);
        }
Ejemplo n.º 11
0
        public static StudySession CreateSession(List <Card> cards)
        {
            StudyView study = new StudyView(cards);

            study.ShowDialog();
            StudySession session = new StudySession();

            session.SessionCards = study.studyCards;
            return(session);
        }
        public void correct_review_outcome_increments_CorrectReviewStreak(ReviewOutcome outcome)
        {
            var correctReviewStreak = 3;
            var item = new ReviewItemBuilder().Due().WithCorrectReviewStreak(correctReviewStreak).Build();

            var session = new StudySession <ReviewItem>(new[] { item });
            var review  = session.Review(item, outcome);

            Assert.That(review.CorrectReviewStreak, Is.EqualTo(correctReviewStreak + 1));
        }
        public void correct_review_outcome_increments_CorrectReviewStreak(ReviewOutcome outcome)
        {
            var correctReviewStreak = 3;
            var item = new ReviewItemBuilder().Due().WithCorrectReviewStreak(correctReviewStreak).Build();

            var session = new StudySession<ReviewItem>(new[] { item });
            var review = session.Review(item, outcome);

            Assert.That(review.CorrectReviewStreak, Is.EqualTo(correctReviewStreak + 1));
        }
        public void incorrect_review_resets_PreviousReviewDate()
        {
            var correctReviewStreak = 3;
            var item = new ReviewItemBuilder().Due().WithCorrectReviewStreak(correctReviewStreak).Build();

            var session = new StudySession <ReviewItem>(new[] { item });
            var review  = session.Review(item, ReviewOutcome.Incorrect);

            Assert.That(review.PreviousCorrectReview, Is.EqualTo(DateTime.MinValue));
        }
        public void correct_review_outcome_sets_PreviousCorrectReview(ReviewOutcome outcome)
        {
            var correctReviewStreak = 3;
            var item       = new ReviewItemBuilder().Due().WithCorrectReviewStreak(correctReviewStreak).Build();
            var reviewDate = item.ReviewDate;

            var session = new StudySession <ReviewItem>(new[] { item });
            var review  = session.Review(item, outcome);

            Assert.That(review.PreviousCorrectReview, Is.EqualTo(reviewDate));
        }
        public void only_return_due_items()
        {
            var dueItems = 2;
            var items    = new ReviewItemListBuilder()
                           .WithDueItems(dueItems)
                           .WithFutureItems(3)
                           .Build();
            var session = new StudySession <ReviewItem>(items);

            Assert.That(session.Count(), Is.EqualTo(dueItems));
        }
Ejemplo n.º 17
0
        public static void ShowResults(StudySession session)
        {
            ResultView results   = new ResultView();
            int        correct   = session.SessionCards.Sum(x => x.CardStatus == (int)CardStatus.Correct ? 1 : 0);
            int        incorrect = session.SessionCards.Sum(x => x.CardStatus == (int)CardStatus.Incorrect ? 1 : 0);

            results.textCorrect.Text    = correct.ToString();
            results.textIncorrect.Text  = incorrect.ToString();
            results.textPercentage.Text = ((int)((double)correct / (correct + incorrect) * 100)).ToString();
            results.ShowDialog();
        }
        public void correct_review_outcome_sets_PreviousCorrectReview(ReviewOutcome outcome)
        {
            var correctReviewStreak = 3;
            var item = new ReviewItemBuilder().Due().WithCorrectReviewStreak(correctReviewStreak).Build();
            var reviewDate = item.ReviewDate;

            var session = new StudySession<ReviewItem>(new[] { item });
            var review = session.Review(item, outcome);

            Assert.That(review.PreviousCorrectReview, Is.EqualTo(reviewDate));
        }
        public void reviewing_updates_DifficultyRating_based_on_review_strategy(ReviewOutcome outcome)
        {
            var item = new ReviewItemBuilder().Due().WithDifficultyRating(DifficultyRating.MostDifficult).Build();

            var session = new StudySession <ReviewItem>(new[] { item })
            {
                ReviewStrategy = new SimpleReviewStrategy()
            };
            var review = session.Review(item, outcome);

            Assert.That(review.DifficultyRating, Is.EqualTo(DifficultyRating.Easiest));
        }
        public void incorrect_items_stay_in_review_queue()
        {
            var items = new ReviewItemListBuilder()
                        .WithDueItems(1)
                        .Build();
            var session = new StudySession <ReviewItem>(items);

            var item   = session.First();
            var review = session.Review(item, ReviewOutcome.Incorrect);

            Assert.That(session.First(), Is.EqualTo(review));
        }
Ejemplo n.º 21
0
        public bool Insert(RollCall InRollCall)
        {
            SubjectBusiness SubBO   = new SubjectBusiness(this.RollSystemDB);
            ClassBusiness   ClassBO = new ClassBusiness(this.RollSystemDB);

            RollCall rollcall = InRollCall;
            //Set thoi gian EndTime, dua vao start time
            var rollSubject = SubBO.GetSubjectByID(InRollCall.SubjectID);

            rollcall.EndTime = rollcall.StartTime.
                               Add(TimeSpan.FromMinutes(90 * rollSubject.NumberOfSlot)).
                               Add(TimeSpan.FromMinutes(15 * (rollSubject.NumberOfSlot - 1)));

            //VD: 20 slot se la 28 ngay. 15 slot la 21 ngay, 18 slot van 28 ngay
            int TotalDate = (int)Math.Ceiling((double)rollSubject.NumberOfSession / 5) * 7;

            //Tru 1 ngay de ket thuc vao chu nhat
            rollcall.EndDate = rollcall.BeginDate.AddDays(TotalDate).AddDays(-1);

            //Dua toan bo hoc sinh hien tai cua class vao
            var rollClass = ClassBO.GetClassByID(InRollCall.ClassID);

            foreach (var Student in rollClass.Students)
            {
                rollcall.Students.Add(Student);
            }

            //Tao cac studying session cua roll call nay
            DateTime SessionDate = rollcall.BeginDate;

            for (int i = 0; i < rollSubject.NumberOfSession; i++)
            {
                StudySession StuSes = new StudySession()
                {
                    InstructorID = InRollCall.InstructorID,
                    ClassID      = rollcall.ClassID,
                    StartTime    = rollcall.StartTime,
                    EndTime      = rollcall.EndTime,
                    SessionDate  = SessionDate,
                    Note         = SessionDate.ToString("dd-MM-yyyy") + " : "
                };
                rollcall.StudySessions.Add(StuSes);
                do
                {
                    SessionDate = SessionDate.AddDays(1);
                } while (SessionDate.DayOfWeek == DayOfWeek.Saturday || SessionDate.DayOfWeek == DayOfWeek.Sunday);
            }

            //Set trang thai của roll call la incoming
            rollcall.Status = 1;

            return(base.Insert(rollcall));
        }
        public void reviewing_updates_ReviewOutcome(ReviewOutcome outcome)
        {
            var item = new ReviewItemBuilder().Due().Build();

            var session = new StudySession <ReviewItem>(new[] { item })
            {
                Clock = _clock
            };
            var review = session.Review(item, outcome);

            Assert.That(review.ReviewOutcome, Is.EqualTo(outcome));
        }
Ejemplo n.º 23
0
        public bool Update(RollCall InRollCall)
        {
            StudySessionBusiness StuSesBO = new StudySessionBusiness(this.RollSystemDB);
            //Ko cho sua lop, chi cho sua instructor, thoi gian, ngay thang
            RollCall rollCall = GetRollCallByID(InRollCall.RollCallID);

            //Doi giao vien va thoi gian
            rollCall.InstructorID = InRollCall.InstructorID;
            rollCall.StartTime    = InRollCall.StartTime;
            rollCall.EndTime      = rollCall.StartTime.
                                    Add(TimeSpan.FromMinutes(90 * rollCall.Subject.NumberOfSlot)).
                                    Add(TimeSpan.FromMinutes(15 * (rollCall.Subject.NumberOfSlot - 1)));

            //Doi ngay thang
            rollCall.BeginDate = InRollCall.BeginDate;
            //VD: 20 slot se la 28 ngay. 15 slot la 21 ngay, 18 slot van 28 ngay
            int TotalDate = (int)Math.Ceiling((double)rollCall.Subject.NumberOfSession / 5) * 7;

            //Tru 1 ngay de ket thuc vao chu nhat
            rollCall.EndDate = rollCall.BeginDate.AddDays(TotalDate).AddDays(-1);


            //Xoa het studysesion cu
            foreach (var Session in rollCall.StudySessions.ToList())
            {
                rollCall.StudySessions.Remove(Session);
                StuSesBO.Delete(Session);
            }

            //Them studysession moi
            DateTime SessionDate = rollCall.BeginDate;

            for (int i = 0; i < rollCall.Subject.NumberOfSession; i++)
            {
                StudySession StuSes = new StudySession()
                {
                    InstructorID = rollCall.InstructorID,
                    ClassID      = rollCall.ClassID,
                    StartTime    = rollCall.StartTime,
                    EndTime      = rollCall.EndTime,
                    SessionDate  = SessionDate,
                    Note         = SessionDate.ToString("dd-MM-yyyy") + " : "
                };
                rollCall.StudySessions.Add(StuSes);
                do
                {
                    SessionDate = SessionDate.AddDays(1);
                } while (SessionDate.DayOfWeek == DayOfWeek.Saturday || SessionDate.DayOfWeek == DayOfWeek.Sunday);
            }
            base.Detach(rollCall);
            return(base.Update(rollCall));
        }
        public void correct_items_are_removed_from_review_queue(ReviewOutcome outcome)
        {
            var items = new ReviewItemListBuilder()
                        .WithDueItems(1)
                        .Build();
            var session = new StudySession <ReviewItem>(items);

            var item = session.First();

            session.Review(item, outcome);

            Assert.That(session.Count(), Is.EqualTo(0));
        }
        public void limit_existing_cards_when_there_are_also_new_cards()
        {
            var items = new ReviewItemListBuilder()
                        .WithExistingItems(_maxExistingCardsPerSession - 1)
                        .WithNewItems(1)
                        .WithExistingItems(2)
                        .Build();

            var session = new StudySession <ReviewItem>(items)
            {
                MaxExistingCards = _maxExistingCardsPerSession
            };

            Assert.That(session.Count(x => x.ReviewDate != DateTime.MinValue), Is.EqualTo(_maxExistingCardsPerSession));
        }
        public ActionResult AddSession(StudySession Model, TimeSpan _StartTime, String _SessionDate, String _Note)
        {
            try
            {
                Model.SessionDate = _SessionDate.ParseStringToDateTime();
                Model.Note        = _SessionDate + " : " + _Note;
                Model.StartTime   = _StartTime;
                StuSesBO.Insert(Model);
            }
            catch (Exception e)
            {
                return(Json(new { message = "Error", error = e.Message }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new { message = "Success" }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 27
0
        private async Task shouldWeContinue(IDialogContext context, IAwaitable <Boolean> result)
        {
            var cont = await result;

            if (cont)
            {
                await intreduceQuestion(context);
            }
            else
            {
                await writeMessageToUser(context, conv().getPhrase(Pkey.letsStartOver));

                StudySession = new StudySession();
                setDialogsVars(context);
                await chooseSubject(context);
            }
        }
        public ActionResult Edit(StudySession Model, TimeSpan _StartTime, String _SessionDate)
        {
            try
            {
                //Bug tao select list cua MVC
                Model.StartTime = _StartTime;

                //Parse datetime kieu manual
                Model.SessionDate = _SessionDate.ParseStringToDateTime();

                StuSesBO.Update(Model);
            }
            catch (Exception e)
            {
                return(Json(new { message = "Error", error = e.Message }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { message = "Success" }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 29
0
        public void setDialogsVars(IDialogContext context)
        {
            try
            {
                if (user == null)
                {
                    user = new User();
                }
                User thisUser = user as User;
                context.UserData.SetValue <User>("user", thisUser);

                if (studySession == null)
                {
                    studySession = new StudySession();
                }
                context.UserData.SetValue <StudySession>("studySession", studySession);
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 30
0
        private async Task chooseSubject(IDialogContext context)
        {
            StudySession.CurrentQuestion = null;
            await writeMessageToUser(context, conv().getPhrase(Pkey.letsLearn));

            IMessageActivity message;

            //choose study subject menu gallery
            if (context.Activity.ChannelId != "telegram")
            {
                await writeMessageToUser(context, conv().getPhrase(Pkey.chooseStudyUnits));

                message = context.MakeMessage();
                foreach (var m in edc().getStudyCategory())
                {
                    var action = new CardAction(type: "imBack", value: m, title: m);
                    var hc     = new HeroCard(title: m, images: getImage(m), tap: action, buttons:
                                              new CardAction[] { action });
                    message.Attachments.Add(hc.ToAttachment());
                    message.AttachmentLayout = "carousel";
                }
            }
            else
            {
                await createMenuOptions(context, conv().getPhrase(Pkey.chooseStudyUnits)[0], edc().getStudyCategory(), StartLearning);

                return;
            }


            context.UserData.RemoveValue("studySession");
            StudySession         = new StudySession();
            User.UserLastSession = context.Activity.Timestamp;
            setDialogsVars(context);
            await context.PostAsync(message);

            updateRequestTime(context);
            context.Wait(StartLearning);
            return;
        }
Ejemplo n.º 31
0
        public async Task <IActionResult> Create()
        {
            try
            {
                await PrepareCreateEditView();

                var studySession = new StudySession
                {
                    StartDate = DateTime.Now.Date,
                    StartTime = DateTime.Now.TimeOfDay,
                    Duration  = new TimeSpan(1, 0, 0)
                };
                return(View(studySession));
            }
            catch (Exception)
            {
                TempData["Message"] = new SystemMessage(MessageType.Critical,
                                                        "Det oppstod en feil under henting av informasjon fra databasen.").GetSystemMessage();
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 32
0
        public async Task <IActionResult> Create(StudySession model)
        {
            if (!ModelState.IsValid)
            {
                await PrepareCreateEditView();

                return(View(model));
            }

            try
            {
                if (await StudySessionConflictExists(model))
                {
                    TempData["Message"] = new SystemMessage(MessageType.Warning,
                                                            "Studieøkten du planlegger kolliderer med en som allerede er planlagt.").GetSystemMessage();
                    await PrepareCreateEditView();

                    return(View(model));
                }

                _context.StudySessions.Add(model);
                await _context.SaveChangesAsync();

                TempData["Message"] =
                    new SystemMessage(MessageType.Success, $"Studieøkten {model.Title} ble lagret.").GetSystemMessage();
            }
            catch (Exception)
            {
                TempData["Message"] = new SystemMessage(MessageType.Critical, "Det oppstod en feil under lagring")
                                      .GetSystemMessage();
                await PrepareCreateEditView();

                return(View(model));
            }

            return(RedirectToAction("Index"));
        }
        public void item_is_not_due_for_review()
        {
            var items = new ReviewItemListBuilder()
                   .WithFutureItems(1)
                   .Build();

            var session = new StudySession<ReviewItem>(items);

            Assert.That(session.IsDue(items.First()), Is.False);

        }
        public void limit_existing_cards_when_there_are_also_new_cards()
        {
            var items = new ReviewItemListBuilder()
                               .WithExistingItems(_maxExistingCardsPerSession - 1)
                               .WithNewItems(1)
                               .WithExistingItems(2)
                               .Build();

            var session = new StudySession<ReviewItem>(items) { MaxExistingCards = _maxExistingCardsPerSession};

            Assert.That(session.Count(x => x.ReviewDate != DateTime.MinValue), Is.EqualTo(_maxExistingCardsPerSession));
        }
        public void limit_existing_cards_per_session()
        {
            var items = new ReviewItemListBuilder().WithExistingItems(_maxExistingCardsPerSession + 1).Build();
            var session = new StudySession<ReviewItem>(items) { MaxExistingCards = _maxExistingCardsPerSession };

            Assert.That(session.Count(), Is.EqualTo(_maxExistingCardsPerSession));
        }
        public void only_return_due_items()
        {
            var dueItems = 2;
            var items = new ReviewItemListBuilder()
                            .WithDueItems(dueItems)
                            .WithFutureItems(3)
                            .Build();
            var session = new StudySession<ReviewItem>(items);

            Assert.That(session.Count(), Is.EqualTo(dueItems));
        }
        public void incorrect_items_stay_in_review_queue_until_correct()
        {
            var items = new ReviewItemListBuilder()
                            .WithDueItems(1)
                            .Build();
            var session = new StudySession<ReviewItem>(items);

            var incorrectTimes = 0;
            foreach (var reviewItem in session)
            {
                if (incorrectTimes++ < 3)
                    session.Review(reviewItem, ReviewOutcome.Incorrect);
                else break;
            }

            session.Review(session.First(), ReviewOutcome.Perfect);

            Assert.That(session, Is.Empty);
        }
        public void incorrect_items_stay_in_review_queue()
        {
            var items = new ReviewItemListBuilder()
                            .WithDueItems(1)
                            .Build();
            var session = new StudySession<ReviewItem>(items);

            var item = session.First();
            var review = session.Review(item, ReviewOutcome.Incorrect);

            Assert.That(session.First(), Is.EqualTo(review));
        }
        public void correct_items_are_removed_from_review_queue(ReviewOutcome outcome)
        {
            var items = new ReviewItemListBuilder()
                            .WithDueItems(1)
                            .Build();
            var session = new StudySession<ReviewItem>(items);

            var item = session.First();
            session.Review(item, outcome);

            Assert.That(session.Count(), Is.EqualTo(0));
        }
Ejemplo n.º 40
0
        public void endOfSessionIntegrationTest()
        {
            var ss = new StudySession();

            Question1.AnswerScore = 100;
            Question2.AnswerScore = 90;
            Question3.AnswerScore = 80;

            ss.QuestionAsked.Add(Question1);
            ss.QuestionAsked.Add(Question2);
            ss.QuestionAsked.Add(Question3);

            ConvCtrl = new ConversationController(new User(), ss);


            //good

            AssertNLP.contains(ConvCtrl.endOfSession(), DBbotPhrase(Pkey.goodSessionEnd));


            ss = new StudySession();
            Question1.AnswerScore = 45;
            Question2.AnswerScore = 34;
            Question3.AnswerScore = 12;

            ss.QuestionAsked.Add(Question1);
            ss.QuestionAsked.Add(Question2);
            ss.QuestionAsked.Add(Question3);

            ConvCtrl = new ConversationController(new User(), ss);

            //bad
            AssertNLP.contains(ConvCtrl.endOfSession(), DBbotPhrase(Pkey.badSessionEnd));


            ss = new StudySession();
            Question1.AnswerScore = 45;
            Question2.AnswerScore = 34;


            ss.QuestionAsked.Add(Question1);
            ss.QuestionAsked.Add(Question2);


            ConvCtrl = new ConversationController(new User(), ss);

            AssertNLP.contains(ConvCtrl.endOfSession(), DBbotPhrase(Pkey.earlyDiparture));



            ss = new StudySession();


            ss.QuestionAsked.Add(Question1);
            ss.QuestionAsked.Add(Question2);
            ss.QuestionAsked.Add(Question3);

            ConvCtrl = new ConversationController(new User(), ss);//sad


            AssertNLP.contains(ConvCtrl.endOfSession(), DBbotPhrase(Pkey.badSessionEnd));
        }
        public void reviewing_updates_DifficultyRating_based_on_review_strategy(ReviewOutcome outcome)
        {
            var item = new ReviewItemBuilder().Due().WithDifficultyRating(DifficultyRating.MostDifficult).Build();

            var session = new StudySession<ReviewItem>(new[] { item }) { ReviewStrategy = new SimpleReviewStrategy() };
            var review = session.Review(item, outcome);

            Assert.That(review.DifficultyRating, Is.EqualTo(DifficultyRating.Easiest));
        }
Ejemplo n.º 42
0
        private string formateVars(string phraseRes, string textVar)
        {
            if (StudySession == null)
            {
                //studySession = new StudySession();

                StudySession = new StudySession();
            }

            phraseRes = phraseRes.Replace("<genderGuf>", getGufSecond());
            phraseRes = phraseRes.Replace("<genderPostfixH>", ifGufFemenin("ה"));
            phraseRes = phraseRes.Replace("<genderPostfixT>", ifGufFemenin("ת"));
            phraseRes = phraseRes.Replace("<text>", textVar);
            phraseRes = phraseRes.Replace("<subject>", StudySession.Category);
            phraseRes = phraseRes.Replace("<numOfQuestions>", StudySession.SessionLength + "");
            phraseRes = phraseRes.Replace("<questionNum>", (StudySession.QuestionAsked.Count + 2) + "");
            phraseRes = phraseRes.Replace("<questionDone>", (StudySession.QuestionAsked.Count + 1) + "");
            phraseRes = phraseRes.Replace("<userName>", User.UserName);
            phraseRes = phraseRes.Replace("<botName>", BOT_NAME);
            phraseRes = phraseRes.Replace("<botSubject>", BOT_SUBJECT);
            phraseRes = phraseRes.Replace("<genderPostfixY>", ifGufFemenin("י"));
            phraseRes = phraseRes.Replace("<genderMany>", getGenderName("many"));
            phraseRes = phraseRes.Replace("<!genderMany>", getGenderOpositeName("many"));
            phraseRes = phraseRes.Replace("<timeOfday>", getTimeOfDay());
            phraseRes = phraseRes.Replace("<questionsLeft>", (StudySession.SessionLength - StudySession.QuestionAsked.Count).ToString());

            if (!phraseRes.Contains("\""))
            {
                phraseRes = phraseRes.Replace("נ ", "ן ");
                phraseRes = phraseRes.Replace("מ ", "מ ");
                phraseRes = phraseRes.Replace("צ ", "צ ");
                phraseRes = phraseRes.Replace("כ ", "ך ");
                phraseRes = phraseRes.Replace("פ ", "ף ");
            }

            //formatEmuji emoji
            if (phraseRes.Contains("<e:"))
            {
                phraseRes = formatEmuji(phraseRes);
            }



            //example <יודע#יודעת>
            while (phraseRes.Contains("<") && phraseRes.Contains(">"))
            {
                if (phraseRes.Contains("#"))
                {
                    var start   = phraseRes.IndexOf("<");
                    var end     = phraseRes.IndexOf(">");
                    var replace = phraseRes.Substring(start + 1, end - start - 1).Split('#');
                    var gender  = User.UserGender == "feminine" ? replace[1] : replace[0];
                    phraseRes = phraseRes.Remove(start, end - start + 1);
                    phraseRes = phraseRes.Insert(start, gender);
                }


                //    throw new PhraseFormatException();
            }

            return(phraseRes);
        }