Ejemplo n.º 1
0
        public Models.Certificate FetchCertificateForExam(LIM.Exam.Models.Exam azureExam)
        {
            Models.Certificate inst_report = FetchCertificatetByID(azureExam.ID);

            if (inst_report == null)
            {
                return(null);
            }

            inst_report.Path = Path.Combine(this._ContentRootPath, inst_report.Path);

            using (LocalReport rpt = new LocalReport()
            {
                ReportPath = inst_report.Path,
                DisplayName = inst_report.Title
            })
            {
                rpt.SetParameters(new ReportParameter()
                {
                    Name = "Name", Values = { azureExam.TakerName }
                });

                inst_report.FileName = (azureExam.TakerName + " " + rpt.DisplayName).Replace(" ", ".").Replace("/", ".") + ".pdf";

                inst_report.FileContents = rpt.Render("pdf");
            }

            return(inst_report);
        }
Ejemplo n.º 2
0
 private async Task SendCertificationEmail(LIM.Exam.Models.Exam azureExam)
 {
     await new LIM.SendGrid.SendGrid(_AppSettings.SendGridSettings).SendEmailAsync(
         "",
         "Certification Request",
         azureExam.Name,
         string.Format("New Request from {0} at Email: {1}", azureExam.TakerName, azureExam.TakerEmail)
         );
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> Submit(string txtEmail, string txtName)
        {
            //var remoteIpAddress = HttpContext.Connection.RemoteIpAddress;

            txtName  = txtName.Trim();
            txtEmail = txtEmail.Trim();

            if ((_context.HttpContext.Session.GetString("AzureExam") == null) || string.IsNullOrEmpty(txtName) || string.IsNullOrEmpty(txtEmail))
            {
                return(View("Index"));
            }

            LIM.Exam.Models.Exam azureExam = JsonConvert.DeserializeObject <LIM.Exam.Models.Exam>(_context.HttpContext.Session.GetString("AzureExam"));

            azureExam.HasStarted = true;
            azureExam.TakerEmail = System.Net.WebUtility.HtmlEncode(txtEmail);
            azureExam.TakerName  = System.Net.WebUtility.HtmlEncode(txtName);

            IEnumerable <LIM.Exam.Models.ExamResponse> rsps =
                LIM.Exam.ExamChecker.CollectExamResponses(azureExam, x => (Request.Form["answer_" + x.ID.ToString()] == "on"));

            int intTotalCorrectQuestions = LIM.Exam.ExamChecker.GradeExam(azureExam, rsps);

            TempData["TotalCorrectQuestions"] = intTotalCorrectQuestions;

            //========================================================
            DateTime dteAzureExamStartTime;

            DateTime.TryParse(_context.HttpContext.Session.GetString("AzureExamStartTime"), out dteAzureExamStartTime);

            TelemetryClient             appInsights = new TelemetryClient();
            Dictionary <string, string> properties  = new Dictionary <string, string>();
            var metrics = new Dictionary <string, double>();

            properties["Name: LessIsMoore Exam"]       = azureExam.Name;
            metrics["Score: LessIsMoore Exam"]         = intTotalCorrectQuestions;
            metrics["Duration(min): LessIsMoore Exam"] = (DateTime.Now - dteAzureExamStartTime).TotalMinutes;

            appInsights.TrackEvent("LessIsMoore Exam", properties, metrics);
            //========================================================

            if ((azureExam.TotalQuestions > 0) && (intTotalCorrectQuestions < azureExam.TotalQuestions))
            {
                return(View("Index", azureExam));
            }

            //report/exam
            _context.HttpContext.Session.SetString("ExamReport", JsonConvert.SerializeObject(azureExam));
            await SendCertificationEmail(azureExam);

            this.TempData["HasPassed"] = "YES";
            this.TempData["Name"]      = azureExam.TakerName;
            this.TempData["Email"]     = azureExam.TakerEmail;

            return(RedirectToAction("Index", new { ID = azureExam.ID }));
        }
Ejemplo n.º 4
0
        private LIM.Exam.Models.Exam PopulateQuestionsFromXML()
        {
            string strXMLPath =
                "<questions><question><text>Favorite Letter</text><answers><answer>A</answer><answer>B</answer><answer>Y</answer><answer>Z</answer></answers></question></questions>";

            LIM.Exam.Models.Exam azureExam = new LIM.Exam.Models.Exam();

            System.Xml.Linq.XDocument xdocument = System.Xml.Linq.XDocument.Parse(strXMLPath);

            azureExam.ExamQuestions =
                new LIM.Exam.ExamChecker().PopulateExamQuestionsFromXML(xdocument.Root.Elements("question"));

            return(azureExam);
        }
Ejemplo n.º 5
0
        public void VerifyExam_2_GradeExam(string strAnswer, string strResponse)
        {
            LIM.Exam.Models.Exam azureExam = PopulateQuestionsFromXML();

            azureExam.ExamQuestions.First()
            .ExamChoices.Where(x => x.Text.ToLower() == strAnswer)
            .First().IsCorrect = true;

            IEnumerable <LIM.Exam.Models.ExamResponse> rsps =
                LIM.Exam.ExamChecker.CollectExamResponses(azureExam, x => (x.Text.ToLower() == strResponse));

            int intTotalCorrectQuestions = LIM.Exam.ExamChecker.GradeExam(azureExam, rsps);

            Assert.True(intTotalCorrectQuestions >= azureExam.TotalQuestions);
        }
Ejemplo n.º 6
0
        public IActionResult Index(int id)
        {
            _context.HttpContext.Session.Remove("AzureExam");

            bool NoShuffleQuestions = !(_context.HttpContext.Request.Query["sf"] == "8d679ae7-e939-474c-a3ff-8501ee636b12");

            LIM.Exam.Models.Exam azureExam = PopulateExamQuestions(id, (x => {
                x.ShuffleQuestions = NoShuffleQuestions;
                x.ShuffleQuestionChoices = NoShuffleQuestions;
            }));

            _context.HttpContext.Session.SetString("AzureExam", JsonConvert.SerializeObject(azureExam));
            _context.HttpContext.Session.SetString("AzureExamStartTime", DateTime.Now.ToShortTimeString());

            return(View(azureExam));
        }
Ejemplo n.º 7
0
        public FileContentResult Index()
        {
            LIM.Exam.Models.Exam azureExam = JsonConvert.DeserializeObject <LIM.Exam.Models.Exam>(_context.HttpContext.Session.GetString("ExamReport"));

            if (azureExam == null)
            {
                throw new Exception("Exam not Found");
            }

            //_context.HttpContext.Session.Remove("ExamReport");

            LIM.Certificates.Models.Certificate inst_report = _reportsBLL.FetchCertificateForExam(azureExam);

            if (inst_report == null)
            {
                throw new Exception("Report not Found");
            }

            return(File(inst_report.FileContents, "application / pdf", inst_report.FileName));
        }
Ejemplo n.º 8
0
        private LIM.Exam.Models.Exam PopulateExamQuestions(int intExamID, Action <LIM.Exam.Models.Exam> cb)
        {
            LIM.Exam.Models.Exam azureExam = new LIM.Exam.Models.Exam();

            cb(azureExam);

            string strXMLPath = null;

            azureExam.ID = intExamID;

            if (azureExam.ID == 1)
            {
                strXMLPath     = "\\app_data\\AzureQuiz.xml";
                azureExam.Name = "Exam: Fast Start – Azure for Modern Web and Mobile Application Development";
            }
            else if (azureExam.ID == 2)
            {
                //..\\..\\..
                strXMLPath     = "\\app_data\\DevopsQuiz.xml";
                azureExam.Name = "Exam: Fast Start – Azure for Dev Ops";
            }
            else if (azureExam.ID == 3)
            {
                //..\\..\\..
                strXMLPath     = "\\app_data\\SDLQuiz.xml";
                azureExam.Name = "Exam: Security Development Lifecycle";
            }
            else
            {
                return(azureExam);
            }

            XDocument xdocument = XDocument.Load(_env.ContentRootPath + strXMLPath);

            azureExam.ExamQuestions =
                new LIM.Exam.ExamChecker().PopulateExamQuestionsFromXML(xdocument.Root.Elements("question"), azureExam.ShuffleQuestions, azureExam.ShuffleQuestionChoices);

            return(azureExam);
        }
Ejemplo n.º 9
0
 public void VerifyExam_1_PopulateQuestions()
 {
     LIM.Exam.Models.Exam azureExam = PopulateQuestionsFromXML();
     Assert.True(azureExam.TotalQuestions == 1);
 }