Example #1
0
        public void LogTest(bool success, Answer[] answCorrectly, int resetLearningPhase, bool english)
        {
            if (!archived)
            {
                nStudyAttempts++;

                if (success)
                {
                    learningPhase++;

                    if (learningPhase == (english ? 7 : 5))
                    {
                        archived = true;
                        nextTest = DateTime.Now.AddDays(6).AddHours(22);
                    }
                }
            }
            else
            {
                nRecallAttempts++;

                if (success)
                {
                    nRecallSuccesses++;

                    if (DateTime.Now.Subtract(lastTest).TotalDays < 1) //in case of a bug where last test occured today (probably caused when the user tests a learned word, fails the test, and then in Options checks the word as learned again)
                        nextTest = DateTime.Now.AddDays(6).AddHours(22);
                    else
                        nextTest = DateTime.Now.AddDays(nextTest.Subtract(lastTest).Days + 6).AddHours(22);
                }
                else
                {
                    archived = false;
                    learningPhase = resetLearningPhase;
                }
            }

            lastTest = DateTime.Now;

            def.LearnedDefs(answCorrectly);
        }
Example #2
0
        bool checkAnswers()
        {
            answers = new List<Tuple<int, int, Color, string>>();
            answCorrectly = new Answer[mtbDefs.Count];
            int i = 0;
            bool typos = false;

            if (mtbDefs != null)
                while (mtbDefs.Count > 0)
                {
                    answCorrectly[i] = new Answer(mtbDefs[0].Tag.ToString());
                    answCorrectly[i].correct = true;

                    mtbDefs[0].TextMaskFormat = MaskFormat.IncludePromptAndLiterals;

                    for (int j = 0; j < kwBounds[0].Count; j++)
                    {
                        bool res;
                        Color answerColor = Color.Black;

                        if (mtbDefs[0].Text.Length < kwBounds[0][j].Item2)
                        {
                            res = false;
                            answerColor = Color.Red;
                        }
                        else
                        {
                            string answerGiven = mtbDefs[0].Text.Substring(kwBounds[0][j].Item1, kwBounds[0][j].Item2 - kwBounds[0][j].Item1).ToLower();
                            string correctAnswer = mtbDefs[0].Tag.ToString().Substring(kwBounds[0][j].Item1, kwBounds[0][j].Item2 - kwBounds[0][j].Item1).ToLower();

                            res = answerGiven == correctAnswer;

                            if (res)
                                //correct answer
                                answerColor = Color.Green;
                            else if (isTypo(correctAnswer, answerGiven.Replace("_", "")))
                            {
                                //typo in answer
                                typos = true;
                                res = true;
                                answerColor = Color.LightGreen;
                            }
                            else
                            {
                                //wrong answer
                                res = false;
                                answerColor = Color.Red;
                            }
                        }

                        answCorrectly[i].correct = answCorrectly[i].correct && res;
                        answers.Add(new Tuple<int, int, Color, string>(lineOffset(i) + kwBounds[0][j].Item1, lineOffset(i) + kwBounds[0][j].Item2, answerColor, mtbDefs[0].Text));
                    }

                    mtbDefs[0].Dispose();
                    panelDef.Controls.Remove(mtbDefs[0]);
                    mtbDefs.RemoveAt(0);
                    kwBounds.RemoveAt(0);

                    i++;
                }

            if (typos)
                MessageBox.Show("It will be accepted anyway.", "You have a typo in your answer", MessageBoxButtons.OK, MessageBoxIcon.Information);

            return answers.All(a => a.Item3 != Color.Red);
        }
Example #3
0
        public void LearnedDefs(Answer[] answCorrectly)
        {
            if (answCorrectly == null)
                return;

            for (int i = 0; i < defs.Length; i++)
                if (defs[i][0] != '"' && partsOfSpeech[i] != "Source" && !learned[i])
                {
                    //find answer
                    foreach (Answer answer in answCorrectly)
                        if (answer.def == "(" + partsOfSpeech[i] + ") " + defs[i])
                        {
                            learned[i] = answer.correct;
                            break;
                        }
                }
        }