public override void Execute(FlashcardsClient client, string userName)
        {
            var testAnswers = GetTestAnswers(client);

            if (testAnswers == null)
            {
                return;
            }
            var testVerdict = client.GetCheckedTest(testAnswers);

            if (testVerdict.WrongAnswers == 0)
            {
                Console.WriteLine($"Correct answers: {testVerdict.CorrectAnswers}/{testVerdict.Answers.Count}");
                Console.WriteLine("Well done! You solved test correctly!");
            }
            else
            {
                Console.WriteLine($"Correct answers: {testVerdict.CorrectAnswers}/{testVerdict.Answers.Count}");
                Console.WriteLine($"Wrong answers: {testVerdict.WrongAnswers}/{testVerdict.Answers.Count}");
                Console.WriteLine("Correct answers for your mistakes");
                foreach (var(id, verdict) in testVerdict.Answers)
                {
                    if (!verdict.Correct)
                    {
                        ExerciseHandler.ShowCorrectAnswers(
                            client.LastReceivedTest.Exercises.First(e => e.Id == id).Question,
                            verdict.CorrectAnswer);
                    }
                }
            }
        }
Пример #2
0
        // GET: Cont
        public ActionResult Index()
        {
            //GenerateFilesForBlockCiphers();
            ExerciseHandler handler = new ExerciseHandler();

            Constants.thereIsHomework = handler.CheckIfHomework();
            return(View());
        }
Пример #3
0
        public ActionResult Download()
        {
            List <Exercise> ExList  = new List <Exercise>();
            ExerciseHandler handler = new ExerciseHandler();

            ExList = handler.GetExerciseToDownload();
            return(View(ExList));
        }
Пример #4
0
        public ActionResult All()
        {
            ExerciseHandler handler = new ExerciseHandler();

            Constants.thereIsHomework = handler.CheckIfHomework();
            List <Cipher> partialTable = new List <Cipher>();

            GetAllCiphers();
            partialTable.Add(table.getTable().ElementAt(table.getTable().Count - 1));
            partialTable.Add(table.getTable().ElementAt(table.getTable().Count - 2));
            partialTable.Add(table.getTable().ElementAt(table.getTable().Count - 3));

            return(View(partialTable));
        }
Пример #5
0
        public ActionResult ExercisesPage(string cipher)
        {
            var             blaa    = cipher;
            List <Exercise> ExList  = new List <Exercise>();
            ExerciseHandler handler = new ExerciseHandler();

            if (cipher == null)
            {
                ExList = handler.GetMandatoryExercices(true);
            }
            else
            {
                ExList = handler.GetExercicesForCipher(cipher);
            }
            return(View(ExList));
        }
        private static TestAnswers GetTestAnswers(FlashcardsClient client)
        {
            if (client.LastReceivedTest == null)
            {
                Console.WriteLine("You had not request for a test. Do it by command -test");
                return(null);
            }
            var testAnswers = new List <ExerciseAnswer>();

            foreach (var exercise in client.LastReceivedTest.Exercises)
            {
                testAnswers.Add(ExerciseHandler.HandleQuestion(exercise));
            }
            return(new TestAnswers {
                TestId = client.LastReceivedTest.TestId, Answers = testAnswers
            });
        }
Пример #7
0
        public ActionResult Download(string bla)
        {
            XmlDocument doc = new XmlDocument();

            XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
            XmlElement     root           = doc.DocumentElement;

            doc.InsertBefore(xmlDeclaration, root);
            XmlElement exercitii = doc.CreateElement(string.Empty, "Exercitii", string.Empty);

            doc.AppendChild(exercitii);
            foreach (var item in Constants.exercitiiSel)
            {
                XmlElement Cifru     = doc.CreateElement(string.Empty, "Cifru", string.Empty);
                XmlText    cifruText = doc.CreateTextNode(item.Cifru);
                Cifru.AppendChild(cifruText);
                exercitii.AppendChild(Cifru);

                XmlElement Enunt     = doc.CreateElement("Enunt");
                XmlText    enuntText = doc.CreateTextNode(item.Enunt);
                Enunt.AppendChild(enuntText);
                exercitii.AppendChild(Enunt);

                XmlElement Cerinta     = doc.CreateElement("Text");
                XmlText    cerintaText = doc.CreateTextNode(item.TextNormal);
                Cerinta.AppendChild(cerintaText);
                exercitii.AppendChild(Cerinta);

                XmlElement Raspuns      = doc.CreateElement("Raspuns");
                XmlText    raspunstText = doc.CreateTextNode(item.TextCriptat);
                Raspuns.AppendChild(raspunstText);
                exercitii.AppendChild(Raspuns);
            }
            doc.Save("D:\\document.xml");
            List <Exercise> ExList  = new List <Exercise>();
            ExerciseHandler handler = new ExerciseHandler();

            ExList = handler.GetExerciseToDownload();
            return(View(ExList));
        }
Пример #8
0
        public ActionResult AddExercise(string cipher, string cerinta, string detalii, bool privat, string text, string raspuns, bool obligatoriu, bool profPrivat)
        {
            Exercise        ex      = new Exercise();
            ExerciseHandler handler = new ExerciseHandler();

            ex.Cifru       = cipher;
            ex.Detalii     = detalii;
            ex.Enunt       = cerinta;
            ex.Privat      = privat;
            ex.TextNormal  = text;
            ex.TextCriptat = raspuns;
            ex.Obligatoriu = obligatoriu;
            if (profPrivat == true)
            {
                ex.Prof = Constants.name;
            }
            else
            {
                ex.Prof = "";
            }
            handler.AddExercise(ex);

            return(View(MakeTitleList()));
        }