protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string currentPageFileName = new FileInfo(this.Request.Url.AbsolutePath).Name;
                var    PermMgr             = new PermissionManager(Session);

                if (PermMgr.IsAdmin || PermMgr.CanManageTestBatches)
                {
                    string alink = Request["z"];

                    if (!string.IsNullOrEmpty(alink))
                    {
                        var candBatch = _db.T_Batch.FirstOrDefault(s => s.Id == long.Parse(alink));

                        var bs = _db.T_BatchSet.Where(s => s.BatchId == candBatch.Id);

                        var candNo = bs.Count();

                        var res = bs.Select(a => new ViewBatchResultsGridModel
                        {
                            ID          = (long)a.CandidateId,
                            Code        = ErecruitHelper.getCandidateCode((long)a.CandidateId).ToString(),
                            FirstName   = ErecruitHelper.getCandidateFirstName((long)a.CandidateId).ToString(),
                            LastName    = ErecruitHelper.getCandidateLastName((long)a.CandidateId).ToString(),
                            Score       = a.TestScore == null ? "Not Attempted" : a.TestScore + "%",
                            DateOfBirth = ErecruitHelper.getCandidateDOB((long)a.CandidateId).ToString(),
                            Sex         = ErecruitHelper.getCandidateSex((long)a.CandidateId).ToString(),
                            Passport    = ErecruitHelper.getCandidateImgUrl((long)a.CandidateId).ToString(),
                            Alt         = ErecruitHelper.getCandidateCode((long)a.CandidateId).ToString()
                        });

                        bname.InnerHtml           = candBatch.Name;
                        NoCands.InnerHtml         = candNo.ToString();
                        dateTaken.InnerHtml       = ErecruitHelper.GetDateStringFromDate((DateTime)candBatch.StartDate);
                        BatchScoreList.DataSource = res.ToList();
                        BatchScoreList.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {
                ErecruitHelper.SetErrorData(ex, Session);
                Response.Redirect("ErrorPage.aspx", false);
            }
        }
        protected void check_Click(object sender, EventArgs e)
        {
            var code = Code.Text;

            var cand = _db.T_Candidate.FirstOrDefault(s => s.Code == code);

            if (!(cand == null))
            {
                var b_set = _db.T_BatchSet.Where(s => s.CandidateId == cand.Id).ToList();
                int count = b_set.Count();
                if (count > 1)
                {
                    var quests = b_set.Select(a => new PrevBatchGridModel
                    {
                        ID        = a.Id,
                        BatchName = ErecruitHelper.getBatchName((long)a.BatchId),
                        Code      = a.Finished == true ? ErecruitHelper.getCandidateCode((long)a.CandidateId) + "," + a.Id : ErecruitHelper.getCandidateCode((long)a.CandidateId),
                        DateTaken = a.Finished == true ? ErecruitHelper.GetDateStringFromDate((DateTime)a.TimeStarted) : "Not Finished."
                    }).Distinct().ToList();
                    batchHistory.DataSource = quests;
                    batchHistory.DataBind();
                    batchHistoryPanel.Visible = true;
                    ScoreListPanel.Visible    = false;
                    SessionHelper.NullCandidateCode(Session);
                    Session["BatchSetId"] = null;
                }
                else if (count == 1)
                {
                    batchHistoryPanel.Visible = false;
                    SessionHelper.SetCandidateCode(code, Session);
                    Session["BatchSetId"] = null;
                    Response.Redirect("ViewTestScore.aspx", false);
                }
                else
                {
                    resultLbl.Text            = String.Empty;
                    batchHistoryPanel.Visible = false;
                }
            }
            else
            {
                resultLbl.Text            = "This is not a valid candidate code";
                batchHistoryPanel.Visible = false;
            }
        }
示例#3
0
        public List<TestReportModel> TestReport(string dateFrom, string dateTo)
        {
            var TR = new List<TestReportModel>();
             QuizBookDbEntities1 _db = new QuizBookDbEntities1();

            if (!string.IsNullOrEmpty(dateFrom) && !string.IsNullOrEmpty(dateTo))
            {

                var f = ErecruitHelper.GetCurrentDateFromDateString(dateFrom);
                var t = ErecruitHelper.GetCurrentDateFromDateString(dateTo);
                var tr = _db.T_CTestTracker.Where(s => s.CurrentStartTime.Value.Date >= f.Date && s.CurrentStartTime.Value.Date <= t.Date).OrderByDescending(s => s.CurrentStartTime).Select(s => s.BatchId).Distinct();
                var bs = _db.T_BatchSet.Where(s => tr.Contains(s.BatchId)).ToList();
                TR = bs.Select(a => new TestReportModel
                {
                    ID = (long)a.CandidateId,
                    Code = ErecruitHelper.getCandidateCode((long)a.CandidateId).ToString(),
                    FirstName = ErecruitHelper.getCandidateFirstName((long)a.CandidateId).ToString(),
                    LastName = ErecruitHelper.getCandidateLastName((long)a.CandidateId).ToString(),
                    Qualification = ErecruitHelper.getCandidate((long)a.CandidateId).Degree,
                    Grade = ErecruitHelper.getCandidate((long)a.CandidateId).ClassOfDegree,
                    Contact = ErecruitHelper.getCandidate((long)a.CandidateId).Email,
                    Refferal = ErecruitHelper.getCandidate((long)a.CandidateId).Referer,
                    from =ErecruitHelper.GetDateStringFromDateX(f),
                    to = ErecruitHelper.GetDateStringFromDateX(t),
                    Email = ErecruitHelper.getCandidate((long)a.CandidateId).Email,
                    TestDate = ErecruitHelper.GetDateStringFromDateX(ErecruitHelper.getTracker(a.CandidateId.Value,a.BatchId.Value).CurrentStartTime.Value),
                    Score = a.TestScore == null ? "Not Attempted" : a.TestScore + "%",
                    Age = (DateTime.Now.Year - (ErecruitHelper.getCandidateDobx((long)a.CandidateId) != null ? ErecruitHelper.getCandidateDobx((long)a.CandidateId).Value.Year: 0)).ToString(),
                    DateOfBirth = ErecruitHelper.GetDateStringFromDateX(ErecruitHelper.getCandidate((long)a.CandidateId).DateOfBirth.Value),
                    Sex = ErecruitHelper.getCandidateSex((long)a.CandidateId).ToString(),
                    Passport = ErecruitHelper.getCandidateImgUrl((long)a.CandidateId).ToString(),
                    Alt = ErecruitHelper.getCandidateCode((long)a.CandidateId).ToString()

                }).ToList();

            }
            else if (string.IsNullOrEmpty(dateFrom) && !string.IsNullOrEmpty(dateTo))
            {

                var f = DateTime.Now;
                var t = ErecruitHelper.GetCurrentDateFromDateString(dateTo);
                var tr = _db.T_CTestTracker.Where(s => s.CurrentStartTime.Value.Date >= f.Date && s.CurrentStartTime.Value.Date <= t.Date).OrderByDescending(s => s.CurrentStartTime).Select(s => s.BatchId).Distinct();
                var bs = _db.T_BatchSet.Where(s => tr.Contains(s.BatchId)).ToList();
                TR = bs.Select(a => new TestReportModel
                {
                    ID = (long)a.CandidateId,
                    Code = ErecruitHelper.getCandidateCode((long)a.CandidateId).ToString(),
                    FirstName = ErecruitHelper.getCandidateFirstName((long)a.CandidateId).ToString(),
                    LastName = ErecruitHelper.getCandidateLastName((long)a.CandidateId).ToString(),
                    Qualification = ErecruitHelper.getCandidate((long)a.CandidateId).Degree,
                    Grade = ErecruitHelper.getCandidate((long)a.CandidateId).ClassOfDegree,
                    Contact = ErecruitHelper.getCandidate((long)a.CandidateId).Email,
                    Refferal = ErecruitHelper.getCandidate((long)a.CandidateId).Referer,
                    Email = ErecruitHelper.getCandidate((long)a.CandidateId).Email,
                    from = ErecruitHelper.GetDateStringFromDateX(f),
                    to = ErecruitHelper.GetDateStringFromDateX(t),
                    TestDate = ErecruitHelper.GetDateStringFromDateX(ErecruitHelper.getTracker(a.CandidateId.Value, a.BatchId.Value).CurrentStartTime.Value),
                    Score = a.TestScore == null ? "Not Attempted" : a.TestScore + "%",
                    Age = (DateTime.Now.Year - (ErecruitHelper.getCandidateDobx((long)a.CandidateId) != null ? ErecruitHelper.getCandidateDobx((long)a.CandidateId).Value.Year : 0)).ToString(),
                    DateOfBirth = ErecruitHelper.GetDateStringFromDateX(ErecruitHelper.getCandidate((long)a.CandidateId).DateOfBirth.Value),
                    Sex = ErecruitHelper.getCandidateSex((long)a.CandidateId).ToString(),
                    Passport = ErecruitHelper.getCandidateImgUrl((long)a.CandidateId).ToString(),
                    Alt = ErecruitHelper.getCandidateCode((long)a.CandidateId).ToString()

                }).ToList();

            }
            else if (!string.IsNullOrEmpty(dateFrom) && string.IsNullOrEmpty(dateTo))
            {
                var f = ErecruitHelper.GetCurrentDateFromDateString(dateFrom);
                var t = DateTime.Now;
                var tr = _db.T_CTestTracker.Where(s => s.CurrentStartTime.Value.Date >= f.Date && s.CurrentStartTime.Value.Date <= t.Date).OrderByDescending(s => s.CurrentStartTime).Select(s => s.BatchId).Distinct();
                var bs = _db.T_BatchSet.Where(s => tr.Contains(s.BatchId)).ToList();
                TR = bs.Select(a => new TestReportModel
                {
                    ID = (long)a.CandidateId,
                    Code = ErecruitHelper.getCandidateCode((long)a.CandidateId).ToString(),
                    FirstName = ErecruitHelper.getCandidateFirstName((long)a.CandidateId).ToString(),
                    LastName = ErecruitHelper.getCandidateLastName((long)a.CandidateId).ToString(),
                    Qualification = ErecruitHelper.getCandidate((long)a.CandidateId).Degree,
                    Grade = ErecruitHelper.getCandidate((long)a.CandidateId).ClassOfDegree,
                    Contact = ErecruitHelper.getCandidate((long)a.CandidateId).Email,
                    Refferal = ErecruitHelper.getCandidate((long)a.CandidateId).Referer,
                    Email = ErecruitHelper.getCandidate((long)a.CandidateId).Email,
                    from = ErecruitHelper.GetDateStringFromDateX(f),
                    to = ErecruitHelper.GetDateStringFromDateX(t),
                    TestDate = ErecruitHelper.GetDateStringFromDateX(ErecruitHelper.getTracker(a.CandidateId.Value, a.BatchId.Value).CurrentStartTime.Value),
                    Score = a.TestScore == null ? "Not Attempted" : a.TestScore + "%",
                    Age = (DateTime.Now.Year - (ErecruitHelper.getCandidateDobx((long)a.CandidateId) != null ? ErecruitHelper.getCandidateDobx((long)a.CandidateId).Value.Year : 0)).ToString(),
                    DateOfBirth = ErecruitHelper.GetDateStringFromDateX(ErecruitHelper.getCandidate((long)a.CandidateId).DateOfBirth.Value),
                    Sex = ErecruitHelper.getCandidateSex((long)a.CandidateId).ToString(),
                    Passport = ErecruitHelper.getCandidateImgUrl((long)a.CandidateId).ToString(),
                    Alt = ErecruitHelper.getCandidateCode((long)a.CandidateId).ToString()

                }).ToList();
            }
            else
            {
                var f = DateTime.Now;
                var tr = _db.T_CTestTracker.Where(s => s.CurrentStartTime.Value.Date == f.Date).OrderByDescending(s=>s.CurrentStartTime).Select(s => s.BatchId).Distinct();
                var bs = _db.T_BatchSet.Where(s => tr.Contains(s.BatchId)).ToList();
                TR = bs.Select(a => new TestReportModel
                {
                    ID = (long)a.CandidateId,
                    Code = ErecruitHelper.getCandidateCode((long)a.CandidateId).ToString(),
                    FirstName = ErecruitHelper.getCandidateFirstName((long)a.CandidateId).ToString(),
                    LastName = ErecruitHelper.getCandidateLastName((long)a.CandidateId).ToString(),
                    Qualification = ErecruitHelper.getCandidate((long)a.CandidateId).Degree,
                    Grade = ErecruitHelper.getCandidate((long)a.CandidateId).ClassOfDegree,
                    Contact = ErecruitHelper.getCandidate((long)a.CandidateId).Email,
                    Refferal = ErecruitHelper.getCandidate((long)a.CandidateId).Referer,
                    Email = ErecruitHelper.getCandidate((long)a.CandidateId).Email,
                    from = ErecruitHelper.GetDateStringFromDateX(f),

                    TestDate = ErecruitHelper.GetDateStringFromDateX(ErecruitHelper.getTracker(a.CandidateId.Value, a.BatchId.Value).CurrentStartTime.Value),
                    Score = a.TestScore == null ? "Not Attempted" : a.TestScore + "%",
                    Age = (DateTime.Now.Year - (ErecruitHelper.getCandidateDobx((long)a.CandidateId) != null ? ErecruitHelper.getCandidateDobx((long)a.CandidateId).Value.Year : 0)).ToString(),
                    DateOfBirth = ErecruitHelper.GetDateStringFromDateX(ErecruitHelper.getCandidate((long)a.CandidateId).DateOfBirth.Value),
                    Sex = ErecruitHelper.getCandidateSex((long)a.CandidateId).ToString(),
                    Passport = ErecruitHelper.getCandidateImgUrl((long)a.CandidateId).ToString(),
                    Alt = ErecruitHelper.getCandidateCode((long)a.CandidateId).ToString()

                }).ToList();
            }

            return TR;
        }
        protected void check_Click(object sender, EventArgs e)
        {
            var code = Code.Text;

            var cand = _db.T_Candidate.FirstOrDefault(s => s.Code == code);

            if (!(cand == null))
            {
                var b_set = _db.T_BackGroundQuestAnswers.Where(s => s.CandidateId == cand.Id).ToList();
                int count = b_set.Count();
                if (count > 1)
                {
                    var quests = b_set.Select(a => new PrevBatchGridModel
                    {
                        ID        = a.Id,
                        BatchName = ErecruitHelper.getBatchName((long)a.BatchId),
                        Code      = ErecruitHelper.getCandidateCode((long)a.CandidateId) + "," + a.BatchId,
                        DateTaken = ErecruitHelper.GetDateStringFromDate((DateTime)a.Dateadded)
                    }).Distinct().ToList();
                    batchHistory.DataSource = quests;
                    batchHistory.DataBind();
                    batchHistoryPanel.Visible = true;

                    SessionHelper.NullCandidateCode(Session);
                    Session["Batchid"] = null;
                }
                else if (count == 1)
                {
                    batchHistoryPanel.Visible = false;
                    SessionHelper.SetCandidateCode(code, Session);
                    Session["Batchid"] = b_set[0].BatchId;
                    Response.Redirect("BackgroundView.aspx", false);
                }
                else
                {
                    resultLbl.Text            = "No History";
                    batchHistoryPanel.Visible = false;
                }
            }
            else
            {
                resultLbl.Text            = "This is not a valid candidate code";
                batchHistoryPanel.Visible = false;
            }
            //if (!string.IsNullOrEmpty(code))
            //{
            //    var cand = _db.T_Candidate.FirstOrDefault(s => s.Code == code);

            //    if (cand != null)
            //    {

            //        var b_id = _db.T_BatchSet.Where(s => s.CandidateId == cand.Id).Select(x => x.BatchId);

            //        var candBatch = _db.T_Batch.FirstOrDefault(s => b_id.Contains(s.Id) && s.IsActive.Value);
            //        if (candBatch != null)
            //        {


            //            var cbSet = _db.T_BatchSet.FirstOrDefault(s => s.BatchId == candBatch.Id && s.CandidateId == cand.Id);
            //            var c_off = _db.T_Settings.FirstOrDefault(s => s.SettingsName == ErecruitHelper.Settings.CUT_OFF_MARK.ToString()).SettingsValue;
            //            if (cbSet != null && cbSet.Finished == true)
            //            {
            //                if (double.Parse(cbSet.TestScore) > double.Parse(c_off))
            //                {
            //                    SessionHelper.SetCandidateCode(code, Session);
            //                    Response.Redirect("BackgroundView.aspx", false);
            //                }
            //                else
            //                {
            //                    resultLbl.Text = "The candidate did not pass the test.";
            //                }
            //            }
            //            else
            //            {
            //                var rsltTxt = "The candidate has not concluded the test.";



            //                resultLbl.Text = rsltTxt;
            //            }

            //        }
            //        else
            //        {
            //            resultLbl.Text = "The candidate has not been assigned to a test batch.";

            //        }

            //    }
            //    else
            //    {
            //        resultLbl.Text = "This is not a valid candidate code";
            //    }
            //}
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string currentPageFileName = new FileInfo(this.Request.Url.AbsolutePath).Name;
            var    PermMgr             = new PermissionManager(Session);

            if (PermMgr.IsAdmin || PermMgr.CanManageTestResults)
            {
                var c = SessionHelper.FetchCandidateCode(Session);
                if (!string.IsNullOrEmpty(c))
                {
                    var cand = _db.T_Candidate.FirstOrDefault(s => s.Code == c);
                    if (!(cand == null))
                    {
                        var b_id = _db.T_BatchSet.Where(s => s.CandidateId == cand.Id).Select(x => x.BatchId).ToList();

                        if (b_id.Count() != 0)
                        {
                            var bs        = new T_BatchSet();
                            var candBatch = new T_Batch();

                            if (Session["BatchSetId"] != null)
                            {
                                bs        = _db.T_BatchSet.FirstOrDefault(s => s.Id == long.Parse(Session["BatchSetId"].ToString()));
                                candBatch = _db.T_Batch.FirstOrDefault(s => s.Id == bs.BatchId);
                                var b_set  = _db.T_BatchSet.Where(s => s.CandidateId == cand.Id).ToList();
                                var quests = b_set.Select(a => new PrevBatchGridModel
                                {
                                    ID        = a.Id,
                                    BatchName = ErecruitHelper.getBatchName((long)a.BatchId),
                                    Code      = a.Finished == true ? ErecruitHelper.getCandidateCode((long)a.CandidateId) + "," + a.Id : ErecruitHelper.getCandidateCode((long)a.CandidateId),
                                    DateTaken = a.Finished == true ? a.TimeStarted.ToString() : "Not Finished."
                                }).Distinct().ToList();
                                batchHistory.DataSource = quests;
                                batchHistory.DataBind();
                                batchHistoryPanel.Visible = true;
                            }
                            else
                            {
                                bs        = _db.T_BatchSet.FirstOrDefault(s => s.CandidateId == cand.Id);
                                candBatch = _db.T_Batch.FirstOrDefault(s => s.Id == bs.BatchId);
                            }

                            if (bs.Finished == true)
                            {
                                int    totalQuestions = _db.T_BatchQuestions.Count(s => s.BatchId == candBatch.Id);
                                int    correct        = _db.T_CandidateAnswers.Count(s => s.CandidateId == cand.Id && s.BatchId == candBatch.Id && s.Correct == true);
                                double percentage     = (double)correct / totalQuestions;
                                percentage = Math.Round((percentage * 100), 2);

                                var rsltTxt = "Candidate Name: " + cand.FirstName + " " + cand.LastName + "<br /><br />Got " + correct + " question(s)  out of " + totalQuestions + " questions.<br /><br />Percentage Score: " + percentage + " %";

                                name.Text = rsltTxt;
                                CID.Value = cand.Code;
                                BID.Value = candBatch.Id.ToString();
                                BindScoreGrid(cand.Id, candBatch);
                            }
                            else
                            {
                                var rsltTxt = "The candidate has not concluded the test.";

                                name.Text = rsltTxt;
                                batchHistoryPanel.Visible = false;
                                ScoreListPanel.Visible    = false;
                            }
                        }
                        else
                        {
                            resultLbl.Text            = "The candidate has not been assigned to a test batch.";
                            batchHistoryPanel.Visible = false;
                            ScoreListPanel.Visible    = false;
                        }
                    }
                    else
                    {
                        resultLbl.Text            = "This is not a valid candidate code";
                        batchHistoryPanel.Visible = false;
                        ScoreListPanel.Visible    = false;
                    }
                }
            }
            else
            {
                batchHistoryPanel.Visible = false;
                ScoreListPanel.Visible    = false;
                Response.Redirect("NoPermission.aspx", false);
            }
        }