Пример #1
0
        public ActionResult Validate(HttpPostedFileBase FileUpload)
        {
            try
            {
                if (FileUpload != null)
                {
                    string path = Request.MapPath("~/UserBitmaps");
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    string fullPath = path + "//" + FileUpload.FileName + PDFHelpers.GetMD5(new Random().Next().ToString());;
                    FileUpload.SaveAs(fullPath);

                    var bitmaps   = ArchiveUnZiper.GetBitmapsFromZipArchive(fullPath);
                    var validator = new DocumentValidator(bitmaps);
                    var examIDs   = validator.GetExamIDs();
                    if (examIDs.Count == 1 && examIDs.First() == 0)
                    {
                        return(View());
                    }

                    foreach (var examID in examIDs)
                    {
                        var egzaminAP = _answerPositionService.GetAllAnswersPositionsByExamID(examID);

                        var examResults = validator.CheckExam(examID, Mapper.Map <List <AnswerPositionDTO> >(egzaminAP));

                        var studentID = _resultService.GetStudentIDByExamID(examID);
                        if (studentID != null)
                        {
                            examResults.StudentID = (int)studentID;
                        }
                        _resultService.DeletePreviousResults(examID);
                        _resultService.Insert(Mapper.Map <Result>(examResults));
                    }

                    if (examIDs.Count > 0)
                    {
                        _resultService.SetIsValidatetFlagByExamID(examIDs.FirstOrDefault());
                        var examCoreStudentGroupID = _generatedExamService.GetByID(examIDs.FirstOrDefault()).ExamCoreStudentGroupID;

                        return(Json(new { success = true, failure = false, responseText = "Success.", responseHref = Url.Action("Index/", "Results", new { examCoreStudentGroupID = examCoreStudentGroupID.ToString() }) }, JsonRequestBehavior.AllowGet));
                    }
                }
                return(Json(new { success = false, failure = true, responseText = "Error during validating exam." }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, failure = true, responseText = "Error during validating exam." }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            Mapper.Initialize(cfg => cfg.AddProfile <DTOProfile>());
            ExamGeneratorDBContext cont      = new ExamGeneratorDBContext();
            AnswerService          serviceA  = new AnswerService(cont);
            QuestionService        serviceQ  = new QuestionService(cont);
            ExamCoreService        serviceE  = new ExamCoreService(cont, serviceA, serviceQ);
            AnswerPositionService  serviceAP = new AnswerPositionService(cont);

            var bitmaps   = ArchiveUnZiper.GetBitmapsFromZipArchive("sprawdziany.zip");
            var validator = new DocumentValidator(bitmaps);
            var examIDs   = validator.GetExamIDs();

            foreach (var item in examIDs)
            {
                var egzaminAP = serviceAP.GetAllAnswersPositionsByExamID(item);
                validator.CheckExam(item, Mapper.Map <List <AnswerPositionDTO> >(egzaminAP));
                Console.WriteLine();
            }
            Console.Read();
        }
Пример #3
0
        public ActionResult CheckUploadExams(HttpPostedFileBase FileUpload)
        {
            string path     = Request.MapPath("~/UserBitmaps");
            string fullPath = path + "//" + FileUpload.FileName + PDFHelpers.GetMD5(new Random().Next().ToString());

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            FileUpload.SaveAs(fullPath);

            var bitmaps   = ArchiveUnZiper.GetBitmapsFromZipArchive(fullPath);
            var validator = new DocumentValidator(bitmaps);
            var examIDs   = validator.GetExamIDs();

            foreach (var item in examIDs)
            {
                var egzaminAP   = _answerPositionService.GetAllAnswersPositionsByExamID(item);
                var examResults = validator.CheckExam(item, Mapper.Map <List <AnswerPositionDTO> >(egzaminAP));
            }
            return(RedirectToAction("Details", "StudentGroups", new { id = 0 }));
        }