Exemplo n.º 1
0
        private void CreateStateCertificate(Certificate certificate, Account account, StateLicensure licensure, CourseProgress courseProgress, DateTime dateEarnedUtc)
        {
            var certTemplate = new Bitmap(TemplatePathState);

            var ceu =
                courseProgress.Course.StateCEUs.First(
                    s => courseProgress.Course.StateCEUs.Any(c => c.StateAbbr == s.StateAbbr));

            var g = Graphics.FromImage(certTemplate);
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

            var alignCenter = new StringFormat
            {
                Alignment = StringAlignment.Center,
                LineAlignment = StringAlignment.Center
            };

            g.DrawString(account.FirstName + " " + account.LastName,
                new System.Drawing.Font("Arial", 28), Brushes.Black, new RectangleF(515, 818, 400, 100));

            g.DrawString(licensure.LicenseNum + "\n" + licensure.StateAbbr,
                new System.Drawing.Font("Arial", 28), Brushes.Black, new RectangleF(1498, 800, 400, 100));

            g.DrawString(ceu.Category.Number,
                new System.Drawing.Font("Arial", 28), Brushes.Black, new RectangleF(2218, 818, 400, 100));

            g.DrawString(courseProgress.Course.DisplayTitle,
                new System.Drawing.Font("Arial", 28), Brushes.Black, new RectangleF(587, 1040, 1252, 100));

            g.DrawString(ceu.ActivityID,
                new System.Drawing.Font("Arial", 28), Brushes.Black, new RectangleF(2155, 1040, 400, 100));

            g.DrawString(courseProgress.LastActivityUtc.ToLocalTime().ToString("d"),
                new System.Drawing.Font("Arial", 28), Brushes.Black, new RectangleF(515, 1263, 400, 100));

            g.DrawString(ceu.ActivityType,
               new System.Drawing.Font("Arial", 28), Brushes.Black, new RectangleF(2200, 1263, 400, 100));

            var activityTime = TimeSpan.FromMinutes(courseProgress.ActiveTime);
            g.DrawString(activityTime.Hours + ":" + activityTime.Minutes,
                new System.Drawing.Font("Arial", 28), Brushes.Black, new RectangleF(515, 1484, 400, 100));

            var hours = TimeSpan.FromHours((double)ceu.Hours);
            g.DrawString(hours.Hours + ":" + hours.Minutes,
                new System.Drawing.Font("Arial", 28), Brushes.Black, new RectangleF(1225, 1484, 400, 100));

            var percentage = courseProgress.TestProgress.CompletedQuestions.Count(r => r.CorrectOnAttempt != null) /
                             (decimal)courseProgress.Course.Test.Questions.Count;
            var grade = (percentage * 100).Round(true, 0) + "%";
            g.DrawString(grade, new System.Drawing.Font("Arial", 28), Brushes.Black, new RectangleF(1915, 1484, 400, 100));

            if (!courseProgress.VerificationInitials.IsNullOrEmpty() && courseProgress.VerificationDate.HasValue)
                g.DrawString(courseProgress.VerificationInitials + "  " + courseProgress.VerificationDate.Value.ToShortDateString(),
                    new System.Drawing.Font("Arial", 24), Brushes.Black, new RectangleF(595, 1685, 277, 100),
                    alignCenter);

            g.DrawString(DateTime.Now.ToString("d"),
                new System.Drawing.Font("Arial", 28), Brushes.Black, new RectangleF(788, 2240, 276, 100),
                alignCenter);

            certTemplate.Save(CertificatePath + certificate.ID + "_state_" + licensure.ID + ".jpg", ImageFormat.Jpeg);
        }
Exemplo n.º 2
0
        public Guid Insert()
        {
            /* SQL TO DELETE ALL COURSE DATA
                delete from progress
                delete from [option]
                delete from question
                delete from StateCEU
                delete from questioned where not courseid is null
                delete from PrerequisiteCourses
                delete from course
                delete from questioned
                delete from category where not ParentCategoryID is null
                delete from category
            */

            // ADD TO EXISTING CATEGORY:
            //var subcategory = _entityRepository.GetByID<SubCategory>("".ToGuid());

            // ADD TO NEW CATEGORY:
            var category = new MainCategory {Title = "Main Cat"};
            _entityRepository.Save(category);

            var subcategory = new SubCategory(category) {Title = "Sub Cat"};
            _entityRepository.Save(subcategory);

            var course = new Course
            {
                Title = "Test Course 1",
                DateCreatedUtc = DateTime.UtcNow,
                StateCEUs = new List<StateCEU>
                {
                    new StateCEU {StateAbbr = "OH", Category = new CertificationCategory { Name = "name", Number = "a", StateAbbr = "OH"}, Hours = 1}
                },
                Category = subcategory,
                Status = CourseStatus.Active,
                Sections = new List<Section>
                {
                    new Section
                    {
                        Title = "Section 1",
                        SortOrder = 1,
                        Document = new Document
                        {
                            PageCount = 2,
                            PDFUrl = "app/temp/sample.pdf",
                            PageImageUrlFormat = "app/css/images/temp/pdf-placeholder{0}.jpg"
                        },
                        Questions = new List<Question>
                        {
                            new SingleImageQuestion
                            {
                                QuestionText = "S1 Question 1",
                                CorrectResponseHeading = "Correct!",
                                CorrectResponseText = "Yay",
                                ImageUrl = "app/css/images/temp/img-answer-large.jpg",
                                SortOrder = 1,
                                Options = new List<Option>
                                {
                                    new TextOption {Text = "Wrong", Correct = false, SortOrder = 1},
                                    new TextOption {Text = "Right", Correct = true, SortOrder = 2}
                                }
                            },
                            new TextQuestion
                            {
                                QuestionText = "S1 Question 2",
                                CorrectResponseHeading = "Correct!",
                                CorrectResponseText = "Yay",
                                SortOrder = 2,
                                Options = new List<Option>
                                {
                                    new TextOption {Text = "Right", Correct = true, SortOrder = 1},
                                    new TextOption {Text = "Also Right", Correct = true, SortOrder = 2},
                                    new TextOption {Text = "Wrong", Correct = false, SortOrder = 3}
                                }
                            }
                        }
                    },
                    new Section
                    {
                        Title = "Section 2",
                        SortOrder = 2,
                        Document = new Document
                        {
                            PageCount = 2,
                            PDFUrl = "app/temp/sample.pdf",
                            PageImageUrlFormat = "app/css/images/temp/pdf-placeholder{0}.jpg"
                        },
                        Questions = new List<Question>
                        {
                            new SingleImageQuestion
                            {
                                QuestionText = "S2 Question 1",
                                CorrectResponseHeading = "Correct!",
                                CorrectResponseText = "Yay",
                                ImageUrl = "app/css/images/temp/img-answer-large.jpg",
                                SortOrder = 1,
                                Options = new List<Option>
                                {
                                    new TextOption {Text = "Wrong", Correct = false, SortOrder = 1},
                                    new TextOption {Text = "Right", Correct = true, SortOrder = 2}
                                }
                            },
                            new TextQuestion
                            {
                                QuestionText = "S2 Question 2",
                                CorrectResponseHeading = "Correct!",
                                CorrectResponseText = "Yay",
                                SortOrder = 2,
                                Options = new List<Option>
                                {
                                    new TextOption {Text = "Right", Correct = true, SortOrder = 1},
                                    new TextOption {Text = "Also Right", Correct = true, SortOrder = 2},
                                    new TextOption {Text = "Wrong", Correct = false, SortOrder = 3}
                                }
                            }
                        }
                    }
                },
                Test = new Test
                {
                    Title = "Test Title",
                    Questions = new List<Question>
                        {
                            new SingleImageQuestion
                            {
                                QuestionText = "T Question 1",
                                CorrectResponseHeading = "Correct!",
                                CorrectResponseText = "Yay",
                                ImageUrl = "app/css/images/temp/img-answer-large.jpg",
                                SortOrder = 1,
                                Options = new List<Option>
                                {
                                    new TextOption {Text = "Wrong", Correct = false, SortOrder = 1},
                                    new TextOption {Text = "Right", Correct = true, SortOrder = 2}
                                }
                            },
                            new TextQuestion
                            {
                                QuestionText = "T Question 2",
                                CorrectResponseHeading = "Correct!",
                                CorrectResponseText = "Yay",
                                SortOrder = 2,
                                Options = new List<Option>
                                {
                                    new TextOption {Text = "Right", Correct = true, SortOrder = 1},
                                    new TextOption {Text = "Also Right", Correct = true, SortOrder = 2},
                                    new TextOption {Text = "Wrong", Correct = false, SortOrder = 3}
                                }
                            }
                        }
                }
            };
            _entityRepository.Save(course);

            var StateLicensure = new StateLicensure
            {
                LicenseNum = "12345",
                Category = "cat1",
                StateAbbr = "LA"
            };
            _entityRepository.Save(StateLicensure);

            return course.ID;
        }