Пример #1
0
        private void BtnCreateTests_Click(object sender, EventArgs e)
        {
            try
            {
                OutPutPath = FileUtils.SaveFileLocation();
                if (string.IsNullOrEmpty(OutPutPath))
                {
                    return;
                }
                Sem = new ShuffleExamModel(QuestionSet, Convert.ToInt32(txtNumberOfTest.Value));

                //Create Test
                PaperModel paperModel = new PaperModel
                {
                    Path = OutPutPath,
                    Sem  = Sem,
                };
                Process.Start(OutPutPath);

                using (ProgressBarForm progress = new ProgressBarForm(paperModel.CreateTests))
                {
                    progress.ShowDialog(this);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        public ActionResult AddEditPaper(PaperModel pm)
        {
            var questionList = new List <ShortQueModel>();

            XDocument questions = new XDocument(new XDeclaration("1.0", "UTF - 8", "yes"),
                                                new XElement("QuestionList",
                                                             from QList in pm.QuestionList
                                                             select new XElement("Question",
                                                                                 new XElement("QueId", QList.QueId),
                                                                                 new XElement("IsIncluded", QList.IsSelected),
                                                                                 new XElement("OrderNo", QList.OrderNo)))
                                                );

            DateTime?examDate = null;

            if (pm.ExamDate != null)
            {
                try
                {
                    examDate = Convert.ToDateTime(pm.ExamDate);
                }
                catch { }
            }

            _Context.sp_InsertUpdatePaper(pm.PaperId, pm.Title, pm.Details, examDate, pm.StartTime, pm.EndTime, pm.TotalMarks, pm.PassingMarks, questions.ToString());

            return(RedirectToAction("PaperList"));
        }
Пример #3
0
        public static void SelectOptions(Pencil pencil, PaperModel paper)
        {
            Console.WriteLine();
            Console.WriteLine("Pick your next action by entering the corresponding number");
            Console.WriteLine("1. Write More");
            Console.WriteLine("2. Erase a Word");
            Console.WriteLine("3. Sharpen Your Pencil");
            Console.WriteLine("4. Exit the Program");
            int.TryParse(Console.ReadLine(), out int userChoice);

            switch (userChoice)
            {
            case 1:
                WriteMore(pencil, paper);
                break;

            case 2:
                EraseAWord(pencil, paper);
                break;

            case 3:
                pencil.Sharpen();
                Console.WriteLine();
                Console.WriteLine("Remaining sharpens: " + pencil.PencilLength);
                Console.WriteLine();
                SelectOptions(pencil, paper);
                break;

            case 4:
                Console.WriteLine("Goodbye");
                break;
            }
        }
Пример #4
0
        /// <summary>
        /// 打乱问题顺序
        /// </summary>
        /// <param name="paperM"></param>
        private void UpsetProblem(PaperModel paperM)
        {
            Random     rd         = new Random();
            List <int> upsetIndex = new List <int>();

            for (int i = 0; i < paperM.Problems.Count; i++)
            {
                upsetIndex.Add(i);
            }
            int Index;
            int TrueIndex;
            List <ProblemModel> problems = new List <ProblemModel>();
            ProblemModel        tempM;

            while (upsetIndex.Count > 0)
            {
                Index     = rd.Next(0, upsetIndex.Count);
                TrueIndex = upsetIndex[Index];
                tempM     = paperM.Problems[TrueIndex];
                UpsetAnswer(tempM);
                problems.Add(tempM);
                upsetIndex.RemoveAt(Index);
            }
            paperM.Problems = problems;
        }
Пример #5
0
 public static void EraseAWord(Pencil pencil, PaperModel paper)
 {
     Console.WriteLine(paper.WrittenContent);
     Console.WriteLine("What word would you like to erase?");
     pencil.UseEraser(Console.ReadLine(), paper);
     Console.WriteLine(paper.WrittenContent);
     ReplaceErasedWord(pencil, paper);
 }
Пример #6
0
        public MResultModel GetExamInfoByPaperID(Guid PaperID)
        {
            MResultModel resM;
            PaperModel   listM = _paperBLL.GetExamInfoByPaperID(PaperID);

            resM = MResultModel <PaperModel> .GetSuccessResultM(listM, "查询成功");

            return(resM);
        }
 private void newBtn_Click(object sender, EventArgs e)
 {
     Constants.PaperSet.ListPaperMatrixId = null;
     papersNumberInput.Enabled            = true;
     papersNumberInput.Maximum            = PaperModel.MaxNumberOfTests(QuestionSet.QuestionList);
     papersNumberInput.Value   = papersNumberInput.Maximum;
     papersNumberInput.Enabled = true;
     newBtn.Enabled            = false;
 }
Пример #8
0
        public void AddPage(PageInfo front, PageInfo back)
        {
            PaperModel info = new PaperModel
            {
                left  = front,
                right = back
            };

            pages.Add(info);
        }
Пример #9
0
 public static void WriteMore(Pencil pencil, PaperModel paper)
 {
     Console.WriteLine(paper.WrittenContent);
     Console.WriteLine();
     Console.WriteLine("Add whatever you'd like to what you've written!");
     pencil.WriteInputOntoPaper(Console.ReadLine(), paper);
     Console.WriteLine(paper.WrittenContent);
     Console.WriteLine();
     SelectOptions(pencil, paper);
 }
Пример #10
0
        public PaperModel ReplaceErasedWord(string wordReplacement, PaperModel paper)
        {
            var spaceBeingFilledByReplacementWord = FindSubstringBeingReplacedByNewWord(paper.WrittenContent, wordReplacement);

            var replacementWordAccountingForOverlap = BuildReplacementStringAccountingForOverlap(spaceBeingFilledByReplacementWord, wordReplacement);

            paper.WrittenContent = paper.WrittenContent.Remove(IndexOfLastErasedWord, wordReplacement.Length).Insert(IndexOfLastErasedWord, replacementWordAccountingForOverlap);

            return(paper);
        }
        private PaperView CreatePaperView()
        {
            IPaperModel     model     = new PaperModel();
            IPaperView      view      = new PaperView();
            IPaperPresenter presenter = SimpleResolver.Instance.Get <IPaperPresenter>(
                new object[] { model, view }
                );

            view.ShowView();
            return(view as PaperView);
        }
Пример #12
0
        private PaperModel EraseContentAccountingForDurability(PaperModel paper, string wordToBeDeleted, int lastInstanceOfWordBeingDeleted)
        {
            var indexAdjustment = wordToBeDeleted.Length - FindNumberOfLettersToBeErasedByEraserDurability(wordToBeDeleted);

            var lastIndexPositionAdjustedForDurability = lastInstanceOfWordBeingDeleted + indexAdjustment;

            paper.SpaceWhereErasedWordWas = lastIndexPositionAdjustedForDurability;

            paper.WrittenContent = RemoveSpecifiedWordAndReplaceWithWhiteSpace(paper.WrittenContent, wordToBeDeleted.Substring(indexAdjustment), lastIndexPositionAdjustedForDurability);

            return(paper);
        }
Пример #13
0
        public void OncePencilIsDullRemainingCharactersWrittenAsWhiteSpaces()
        {
            //Arrange
            NumberTwoPencil = new Pencil(1);
            Paper           = new PaperModel();
            var twoLetters = "jb";

            //Act
            NumberTwoPencil.WriteInputOntoPaper(twoLetters, Paper);

            //Assert
            Assert.AreEqual("j ", Paper.WrittenContent);
        }
Пример #14
0
        public void CamelCaseInputStillReplacedByWhiteSpaceOncePencilDull()
        {
            //Arrange
            NumberTwoPencil = new Pencil(3);
            Paper           = new PaperModel();
            var myInitials = "Jjb";

            //Act
            NumberTwoPencil.WriteInputOntoPaper(myInitials, Paper);

            //Assert
            Assert.AreEqual("Jj ", Paper.WrittenContent);
        }
Пример #15
0
        public void PencilStopsWritingIfDurabilityEqualOrLessThanZero()
        {
            //Arrange
            NumberTwoPencil = new Pencil(5);
            Paper           = new PaperModel();
            var mumble       = "what if";
            var whatWasHeard = "what i ";

            //Act
            NumberTwoPencil.WriteInputOntoPaper(mumble, Paper);

            //Assert
            StringAssert.AreEqualIgnoringCase(whatWasHeard, Paper.WrittenContent);
        }
Пример #16
0
        public void IfDurabilityLowerThanTwoPencilDoesNotWriteCapitalLetter()
        {
            //Arrange
            NumberTwoPencil = new Pencil(1);
            Paper           = new PaperModel();
            var capitalLetter = "J";

            //Act
            NumberTwoPencil.WriteInputOntoPaper(capitalLetter, Paper);

            //Assert
            Assert.AreNotEqual(capitalLetter, Paper.WrittenContent);
            Assert.AreEqual(Paper.WrittenContent, "j");
        }
Пример #17
0
        public void PaperContainsTextPencilWrites()
        {
            //Arrange
            var letterToSanta     = "Dear Santa, I hope you're well";
            var constructionPaper = new PaperModel();

            NumberTwoPencil = new Pencil();

            //Act
            NumberTwoPencil.WriteInputOntoPaper(letterToSanta, constructionPaper);

            //Assert
            StringAssert.AreEqualIgnoringCase(letterToSanta, constructionPaper.WrittenContent);
        }
Пример #18
0
        public void PencilDurabilityFunctionReducesDurabilityByOnePerLetter()
        {
            //Arrange
            var backOfEnvelope = new PaperModel();
            var groceryList    = "eggs and milk";
            var inkLeft        = 9;
            var bicPen         = new Pencil(20);

            //Act
            bicPen.WriteInputOntoPaper(groceryList, backOfEnvelope);

            //Assert
            Assert.AreEqual(inkLeft, bicPen.PencilDurability);
        }
Пример #19
0
        public void WhiteSpacesInGivenInputDoNotReduceDurability()
        {
            //Arrange
            var receipt               = new PaperModel();
            var highlighter           = new Pencil(20);
            var taxDeductiblePurchase = "office supplies";
            var inkLeft               = 6;

            //Act
            highlighter.WriteInputOntoPaper(taxDeductiblePurchase, receipt);

            //Assert
            Assert.AreEqual(inkLeft, highlighter.PencilDurability);
        }
Пример #20
0
 public bool DeletePaper(PaperModel model)
 {
     try
     {
         dbcontext.Papers.Remove(model);
         dbcontext.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(false);
     }
 }
Пример #21
0
        public PaperModel Erase(string wordToBeDeleted, PaperModel paper)
        {
            var lastInstanceOfWordBeingDeleted = paper.WrittenContent.LastIndexOf(wordToBeDeleted);

            if (lastInstanceOfWordBeingDeleted >= 0)
            {
                if (EraserDurability == null)
                {
                    return(EraseWithoutDurability(paper, wordToBeDeleted, lastInstanceOfWordBeingDeleted));
                }
                paper = EraseContentAccountingForDurability(paper, wordToBeDeleted, lastInstanceOfWordBeingDeleted);
            }
            return(paper);
        }
Пример #22
0
        public static void Main(string[] args)
        {
            PaperModel paper  = new PaperModel();
            Pencil     pencil = CreatePencil();

            Console.WriteLine("Ok, let's try writing something. Type whatever you'd like below!");
            pencil.WriteInputOntoPaper(Console.ReadLine(), paper);
            Console.WriteLine();
            Console.WriteLine("You wrote -- " + paper.WrittenContent);
            SelectOptions(pencil, paper);


            Console.ReadLine();
        }
Пример #23
0
        public void CapitalLettersReduceDurabilityByTwo()
        {
            //Arrange
            NumberTwoPencil = new Pencil(20);
            var barbaricYawp = "MY YAWPS TOP";

            Paper = new PaperModel();
            var bigWhoppingZero = 0;

            //Act
            NumberTwoPencil.WriteInputOntoPaper(barbaricYawp, Paper);

            //Assert
            Assert.AreEqual(bigWhoppingZero, NumberTwoPencil.PencilDurability);
        }
Пример #24
0
        public void APencilWithLengthReducedToZeroWillNotSharpenAgain()
        {
            //Arrange
            HydratedPencil.PencilLength = 0;
            Paper = new PaperModel();
            var expectedDurability = 4;
            var aWord = "A word";

            //Act
            HydratedPencil.WriteInputOntoPaper(aWord, Paper);
            HydratedPencil.Sharpen();

            //Assert
            Assert.AreEqual(expectedDurability, HydratedPencil.PencilDurability);
        }
Пример #25
0
        public async Task <bool> AddPaperAsync(PaperModel model)
        {
            try
            {
                await dbcontext.Papers.AddAsync(model);

                dbcontext.SaveChanges();
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }
Пример #26
0
        public void DisplayAPaper(int paperId)
        {
            PaperModel ppM = Mapper.FromDataTransferObject(PaperBLL.GetPaper(paperId));

            View.Id             = ppM.PaperId;
            View.MaNhaCungCap   = ppM.PaperCode;
            View.TenGiay        = ppM.PaperName;
            View.DinhLuong      = ppM.Substance;
            View.ShortDim       = ppM.ShortDim;
            View.LongDim        = ppM.LongDim;
            View.UnitPrice      = ppM.UnitPrice;
            View.ProfiMarginSet = ppM.ProfitMarginSet;
            View.CateId         = ppM.CategoryId;
            View.CategoryName   = (PaperCateBLL.GetRecord(ppM.CategoryId)).CategoryName;
        }
Пример #27
0
        public void ProgramDoesntBreakIfWordToBeErasedDoesntExist()
        {
            //Arrange
            PeacockQuill = new Pencil(1);
            Parchment    = new PaperModel()
            {
                WrittenContent = "wizarding world of wizards world"
            };
            var wordToBeRemoved = "gopher";
            var instacesOfWordAfterTwoRemovals = 0;

            PeacockQuill.UseEraser(wordToBeRemoved, Parchment);

            //Assert
            Assert.AreEqual(instacesOfWordAfterTwoRemovals, Regex.Matches(Parchment.WrittenContent, wordToBeRemoved).Count);
        }
Пример #28
0
        public void SharpenerMethodSetsDurabilityEqualToOriginalSharpeness()
        {
            //Arrange
            var inputDurability     = 100;
            var sentenceToBeWritten = "Tip toe through the tulips";

            Pencil = new Pencil(inputDurability);
            Paper  = new PaperModel();

            //Act
            Pencil.WriteInputOntoPaper(sentenceToBeWritten, Paper);
            Pencil.Sharpen();

            //Assert
            Assert.AreEqual(inputDurability, Pencil.PencilDurability);
        }
Пример #29
0
        public void UsingSharpenMethodDecrementsPencilLengthByOne()
        {
            //Assert

            var lengthAfterSharpening = 3;
            var aWord = "A word";

            Paper = new PaperModel();

            //Act
            HydratedPencil.WriteInputOntoPaper(aWord, Paper);
            HydratedPencil.Sharpen();

            //Assert
            Assert.AreEqual(lengthAfterSharpening, HydratedPencil.PencilLength);
        }
 /// <summary>
 /// Creates and adds a few ItemViewModel objects into the Items collection.
 /// </summary>
 public void LoadData()
 {
     _paperModel = PaperModel.FromFile();
     if (_paperModel.Papers.Count > 0)
     {
         this.Papers.Source          = this.Items = _paperModel.Papers;
         Papers.View.CurrentChanged += handleCurrentPaperChanged;
         this.IsDataLoaded           = true;
         NotifyPropertyChanged("IsDataLoaded");
     }
     else
     {
         var svc = new PaperService();
         svc.GetPapers(onPapersReceived, onError);
     }
 }