예제 #1
0
        private void GenerateAndSendResults()
        {
            AssesmentReportTO report = new AssesmentReportTO();

            report.AssesmentInfo = info;
            report.Sections      = new List <SectionReportTO>();

            List <SectionPointsTO> list = AssesmentPersistence.GetAssesmentPoints(id);

            for (int i = 0; i < info.Evaluation.Sections.Count; i++)
            {
                SectionReportTO section = new SectionReportTO();
                section.Name       = info.Evaluation.Sections[i].Name;
                section.Percentage = 0;
                SectionPointsTO sectionPoints = list.Find(x => x.SectionID == info.Evaluation.Sections[i].ID);
                if (sectionPoints != null)
                {
                    section.Percentage = sectionPoints.Points;
                }

                report.Sections.Add(section);
            }

            report.Analysis = GetAnalysis();
            string savedFilePath = Pdf.GenerateSimplePdf(report);

            SendReport(savedFilePath);
        }
예제 #2
0
        public AssesmentReportTO GetReport()
        {
            AssesmentReportTO report = new AssesmentReportTO();

            report.AssesmentInfo = info;
            if (report.AssesmentInfo.EmployeeId != null)
            {
                report.AssesmentInfo.Employee = GetDbEmployee((int)report.AssesmentInfo.EmployeeId);
            }
            report.Sections = new List <SectionReportTO>();

            List <SectionPointsTO> list = GetDbAssesmentPointsBySection(id);
            List <SectionPointsTO> possiblePointsList = GetDbPointsBySection(id);

            for (int i = 0; i < info.Evaluation.Sections.Count; i++)
            {
                SectionReportTO section = new SectionReportTO();
                section.Name       = info.Evaluation.Sections.ElementAt(i).Name;
                section.Percentage = 0;
                SectionPointsTO sectionPoints         = list.Find(x => x.SectionID == info.Evaluation.Sections.ElementAt(i).SectionId);
                SectionPointsTO sectionPossiblePoints = possiblePointsList.Find(x => x.SectionID == info.Evaluation.Sections.ElementAt(i).SectionId);
                if (sectionPoints != null)
                {
                    section.Percentage = Math.Round(Convert.ToDouble(sectionPoints.Points) / Convert.ToDouble(sectionPossiblePoints.Points) * 100);
                }

                report.Sections.Add(section);
            }

            report.Analysis = GetAnalysis();

            return(report);
        }
        public static List <SectionPointsTO> GetAssesmentPoints(int assesmentID)
        {
            List <SectionPointsTO> list = new List <SectionPointsTO>();

            string execCommand = string.Format("SELECT s.ID, SUM(Points) as Points " +
                                               " FROM question q " +
                                               " JOIN assesment_response ar on q.id = ar.questionid " +
                                               " JOIN section s on  s.id=q.SectionID " +
                                               " WHERE ar.assesmentid = {0} and ar.answerisright = 1 " +
                                               " GROUP by s.ID", assesmentID);

            DataTable table = ExecuteCommand(execCommand);

            if (table != null && table.Rows.Count > 0)
            {
                foreach (DataRow item in table.Rows)
                {
                    SectionPointsTO points = new SectionPointsTO();
                    points.SectionID = Convert.ToInt32(item["ID"]);
                    points.Points    = Convert.ToInt32(item["Points"]);

                    list.Add(points);
                }
            }

            return(list);
        }