Exemplo n.º 1
0
        //public List<IndividualTestReport> IndividualTestReport(long candid, long batchid)
        //{
        //    var TR = new List<IndividualTestReport>();
        //    TR.AddRange(_db.IndividualTestResult_sp(candid, batchid,1).Select(s =>new IndividualTestReport{
        //        ID = s.ID,
        //        BatchName = s.BatchName,
        //        Code = s.STAFF_ID,
        //        FirstName = s.FirstName,
        //       Branch = ErecruitHelper.getCandidateBranch(s.STAFF_ID),
        //        Division = ErecruitHelper.getCandidateDivision(s.STAFF_ID),
        //        LastName = s.LastName,
        //        Question = s.QuestionDetails,
        //        Answer = string.IsNullOrEmpty(s.ChosenAnswerDetails) ? "UnAnswered" : s.ChosenAnswerDetails,
        //        CorrectAnswer = string.IsNullOrEmpty(s.CorrectAnswer)?"No Answer Set for the Question.":s.CorrectAnswer,
        //        IndicatorImg = s.Correct.Value ? "CORRECT":"WRONG",
        //        TotalCorrect = s.TotalCorrect.ToString(),
        //        TotalWrong = s.TotalWrong.ToString(),
        //        TotalUnanswered = s.TotalUnAnswered.ToString(),
        //        TotalQuestions = s.TotalQuestions.ToString(),
        //        Percentage = s.Percentage.ToString(),
        //        DateMarked = s.TimeMarked.Value.ToString("dd/MM/yyy")
        //    }));
        //    return TR;
        //}
        public List<IndividualTestReport> BatchTestReport(string type, string tid, DateTime fr , DateTime to)
        {
            var TR = new List<IndividualTestReport>();

               // var cutoff = _db.T_Settings.FirstOrDefault(s => s.SettingsName == "CUT_OFF_MARK").SettingsValue;
            int countP = 0;
            var countF = 0;
            if (fr == null && to == null)
            {
                TR.AddRange(_db.BatchResultByCondition_sp(type, tid).Select(s => new IndividualTestReport
                {
                    Condition = s.Condition,
                    ConditionName = s.ConditionName,
                    BatchName = s.BATCH_NAME,
                    Code = s.STAFF_ID,
                    FirstName = s.FIrst_Name,
                    LastName = s.Last_Name,
                    Branch = ErecruitHelper.getCandidateBranch(s.STAFF_ID),
                    Division = ErecruitHelper.getCandidateDivision(s.STAFF_ID),
                    TotalCorrect = s.Correct.ToString(),
                    TotalWrong = s.Wrong.ToString(),
                    TotalUnanswered = s.Unanswered.ToString(),
                    TotalQuestions = s.TotalQuestion.ToString(),
                    Percentage = s.Percentage.ToString(),
                    DateMarked = s.DateLogged.Value.ToString("dd/MM/yyy"),
                    Cutoff = "50",
                    Passed = s.Percentage >= 50? countP++:0,
                    Failed = s.Percentage < 50?countF++:0
                }));
            }
            else if (fr != null && to == null)
            {
                TR.AddRange(_db.BatchResultByConditionNTime_sp(type, tid,fr,DateTime.Now).Select(s => new IndividualTestReport
                {
                    Condition = s.Condition,
                    ConditionName = s.ConditionName,
                    BatchName = s.BATCH_NAME,
                    Code = s.STAFF_ID,
                    FirstName = s.FIrst_Name,
                    LastName = s.Last_Name,
                    Branch = ErecruitHelper.getCandidateBranch(s.STAFF_ID),
                    Division = ErecruitHelper.getCandidateDivision(s.STAFF_ID),
                    TotalCorrect = s.Correct.ToString(),
                    TotalWrong = s.Wrong.ToString(),
                    TotalUnanswered = s.Unanswered.ToString(),
                    TotalQuestions = s.TotalQuestion.ToString(),
                    Percentage = s.Percentage.ToString(),
                    DateMarked = s.DateLogged.Value.ToString("dd/MM/yyyy"),
                    Cutoff = "50",
                    Passed = s.Percentage >= 50 ? countP++ : 0,
                    Failed = s.Percentage < 50 ? countF++ : 0
                }));
            }
            else if (fr == null && to != null)
            {
                TR.AddRange(_db.BatchResultByConditionNTime_sp(type, tid, DateTime.Now, to).Select(s => new IndividualTestReport
                {
                    Condition = s.Condition,
                    ConditionName = s.ConditionName,
                    BatchName = s.BATCH_NAME,
                    Code = s.STAFF_ID,
                    FirstName = s.FIrst_Name,
                    LastName = s.Last_Name,
                    Branch = ErecruitHelper.getCandidateBranch(s.STAFF_ID),
                    Division = ErecruitHelper.getCandidateDivision(s.STAFF_ID),
                    TotalCorrect = s.Correct.ToString(),
                    TotalWrong = s.Wrong.ToString(),
                    TotalUnanswered = s.Unanswered.ToString(),
                    TotalQuestions = s.TotalQuestion.ToString(),
                    Percentage = s.Percentage.ToString(),
                    DateMarked = s.DateLogged.Value.ToString("dd/MM/yyyy"),
                    Cutoff = "50",
                    Passed = s.Percentage >= 50 ? countP++ : 0,
                    Failed = s.Percentage < 50 ? countF++ : 0
                }));
            }
            else
            {
                TR.AddRange(_db.BatchResultByConditionNTime_sp(type, tid, fr,to).Select(s => new IndividualTestReport
                {
                    Condition = s.Condition,
                    ConditionName = s.ConditionName,
                    BatchName = s.BATCH_NAME,
                    Code = s.STAFF_ID,
                    FirstName = s.FIrst_Name,
                    LastName = s.Last_Name,
                    Branch = ErecruitHelper.getCandidateBranch(s.STAFF_ID),
                    Division = ErecruitHelper.getCandidateDivision(s.STAFF_ID),
                    TotalCorrect = s.Correct.ToString(),
                    TotalWrong = s.Wrong.ToString(),
                    TotalUnanswered = s.Unanswered.ToString(),
                    TotalQuestions = s.TotalQuestion.ToString(),
                    Percentage = s.Percentage.ToString(),
                    DateMarked = s.DateLogged.Value.ToString("dd/MM/yyyy"),
                    Cutoff = "50",
                    Passed = s.Percentage >= 50 ? ++countP : 0,
                    Failed = s.Percentage < 50 ? ++countF : 0
                }));
            }

            return TR;
        }