public override void UpdateSelectedExaminer(string selectedText)
 {
     AcademicTestSessionRecords.Where(p => p.DomainCode == SelectedItemDomainCode).FirstOrDefault().Examiner   = selectedText;
     AcademicTestSessionRecords.Where(p => p.DomainCode == SelectedItemDomainCode).FirstOrDefault().ExaminerID = Convert.ToInt32(ExaminerList.FirstOrDefault(p => p.text == selectedText)?.id);
 }
Exemple #2
0
        public async Task SaveTestSessionOverView()
        {
            await Task.Delay(0);

            if (commonDataService.StudentTestFormOverview != null)
            {
                var model = JsonConvert.DeserializeObject <FormParamterClass>(commonDataService.StudentTestFormOverview.formParameters);
                model.ProgramLabelId = null;
                var programSelected = ProgramNoteList.FirstOrDefault(p => p.selected);
                if (programSelected != null && model.ProgramLabelId != programSelected.id)
                {
                    model.ProgramLabelId = programSelected.id;
                }
                commonDataService.StudentTestFormOverview.formParameters = JsonConvert.SerializeObject(model);
            }
            IsOverviewChanged = false;
            if (commonDataService.StudentTestForms != null && commonDataService.StudentTestForms.Any())
            {
                if (commonDataService.IsCompleteForm)
                {
                    foreach (var item in commonDataService.StudentTestForms)
                    {
                        var str        = item.rawScore.HasValue ? item.rawScore.Value + "" : "";
                        var testrecord = TestSessionRecords.FirstOrDefault(p => p.ContentCategoryId == item.contentCategoryId);
                        if (testrecord != null && (testrecord.TestDate != item.testDate || testrecord.RawScore != str || testrecord.ExaminerID != item.examinerId))
                        {
                            IsOverviewChanged = true;
                            break;
                        }
                    }
                }
                else if (commonDataService.IsAcademicForm)
                {
                    foreach (var item in commonDataService.StudentTestForms)
                    {
                        var str        = item.rawScore != null && item.rawScore.HasValue ? item.rawScore.Value + "" : "";
                        var testrecord = AcademicTestSessionRecords.FirstOrDefault(p => p.ContentCategoryId == item.contentCategoryId);
                        if (testrecord != null && (testrecord.TestDate != item.testDate || testrecord.RawScore != str || testrecord.ExaminerID != item.examinerId))
                        {
                            IsOverviewChanged = true;
                            break;
                        }
                    }

                    if (!IsOverviewChanged)
                    {
                        var testRecord = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == 162);
                        if (testRecord != null)
                        {
                            var overviewrecord = AcademicTestSessionRecords.FirstOrDefault(p => p.ContentCategoryId == 162);
                            if (overviewrecord != null)
                            {
                                if (!overviewrecord.ShowTimerErrorMessage && !testRecord.TimeTaken.HasValue)
                                {
                                    IsOverviewChanged = true;
                                }
                                else if (overviewrecord.ShowTimerErrorMessage && testRecord.TimeTaken.HasValue)
                                {
                                    IsOverviewChanged = true;
                                }
                                else if (!overviewrecord.ShowTimerErrorMessage && testRecord.TimeTaken.HasValue && testRecord.TimeTaken.Value != Convert.ToInt32(overviewrecord.Timer.TotalSeconds))
                                {
                                    IsOverviewChanged = true;
                                }
                                else if (!overviewrecord.ShowTimerErrorMessage && !testRecord.TimeTaken.HasValue)
                                {
                                    IsOverviewChanged = true;
                                }
                            }
                        }
                    }
                }
                else
                {
                    foreach (var item in commonDataService.StudentTestForms)
                    {
                        var str        = item.rawScore.HasValue ? item.rawScore.Value + "" : "";
                        var testrecord = Records.FirstOrDefault(p => p.ContentCategoryId == item.contentCategoryId);
                        if (testrecord != null && (testrecord.TestDate != item.testDate || testrecord.RawScore != str || testrecord.ExaminerID != item.examinerId))
                        {
                            IsOverviewChanged = true;
                            break;
                        }
                    }
                }
            }
            if (IsOverviewChanged)
            {
                //studentTestFormsService.DeleteAll(LocalformInstanceId);
                if (commonDataService.IsCompleteForm)
                {
                    if (TestSessionRecords != null && TestSessionRecords.Any())
                    {
                        var lstStudentTestForms = new List <StudentTestForms>();
                        foreach (var item in TestSessionRecords)
                        {
                            if (!item.IsDateVisible)
                            {
                                continue;
                            }
                            var StudentTestForms = new StudentTestForms();
                            StudentTestForms.IsBaselCeilingApplied  = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == item.ContentCategoryId).IsBaselCeilingApplied;
                            StudentTestForms.BaselCeilingReached    = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == item.ContentCategoryId).BaselCeilingReached;
                            StudentTestForms.LocalStudentTestFormId = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == item.ContentCategoryId).LocalStudentTestFormId;
                            StudentTestForms.LocalformInstanceId    = LocalformInstanceId;
                            StudentTestForms.testDate        = item.TestDate;
                            StudentTestForms.Notes           = item.Notes;
                            StudentTestForms.TSOStatus       = item.Status;
                            StudentTestForms.rawScore        = !string.IsNullOrEmpty(item.RawScore) ? Convert.ToInt32(item.RawScore) : default(int?);
                            StudentTestForms.rawScoreEnabled = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == item.ContentCategoryId).rawScoreEnabled;
                            if (item.Examiner != null && item.Examiner != "Select Examiner")
                            {
                                StudentTestForms.examinerId = Convert.ToInt32(commonDataService.SearchStaffResponseModel.FirstOrDefault(p => p.FirstNameLastName == item.Examiner).UserID);
                            }
                            StudentTestForms.contentCategoryId = item.ContentCategoryId;
                            StudentTestForms.createDate        = DateTime.Now;
                            lstStudentTestForms.Add(StudentTestForms);
                        }
                        //studentTestFormsService.InsertAll(lstStudentTestForms);
                        commonDataService.StudentTestForms = new List <StudentTestForms>(lstStudentTestForms);
                    }
                }
                else if (commonDataService.IsAcademicForm)
                {
                    if (AcademicTestSessionRecords != null && AcademicTestSessionRecords.Any())
                    {
                        var lstStudentTestForms = new List <StudentTestForms>();
                        foreach (var item in AcademicTestSessionRecords)
                        {
                            if (!item.DomainVisibility)
                            {
                                continue;
                            }
                            var StudentTestForms = new StudentTestForms();
                            StudentTestForms.IsBaselCeilingApplied  = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == item.ContentCategoryId).IsBaselCeilingApplied;
                            StudentTestForms.BaselCeilingReached    = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == item.ContentCategoryId).BaselCeilingReached;
                            StudentTestForms.LocalformInstanceId    = LocalformInstanceId;
                            StudentTestForms.LocalStudentTestFormId = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == item.ContentCategoryId).LocalStudentTestFormId;
                            StudentTestForms.testDate = item.TestDate;
                            if (item.ContentCategoryId == 162)
                            {
                                if (!item.ShowTimerErrorMessage)
                                {
                                    StudentTestForms.TimeTaken = Convert.ToInt32(item.Timer.TotalSeconds);
                                }
                                else
                                {
                                    StudentTestForms.TimeTaken = null;
                                }
                            }
                            StudentTestForms.Notes           = item.Notes;
                            StudentTestForms.TSOStatus       = item.Status;
                            StudentTestForms.rawScore        = !string.IsNullOrEmpty(item.RawScore) ? Convert.ToInt32(item.RawScore) : default(int?);
                            StudentTestForms.rawScoreEnabled = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == item.ContentCategoryId).rawScoreEnabled;
                            if (item.Examiner != null && item.Examiner != "Select Examiner")
                            {
                                StudentTestForms.examinerId = Convert.ToInt32(commonDataService.SearchStaffResponseModel.FirstOrDefault(p => p.FirstNameLastName == item.Examiner).UserID);
                            }
                            StudentTestForms.contentCategoryId = item.ContentCategoryId;
                            StudentTestForms.createDate        = DateTime.Now;
                            lstStudentTestForms.Add(StudentTestForms);
                        }
                        //studentTestFormsService.InsertAll(lstStudentTestForms);
                        commonDataService.StudentTestForms = new List <StudentTestForms>(lstStudentTestForms);
                    }
                }
                else
                {
                    var lstStudentTestForms = new List <StudentTestForms>();
                    foreach (var item in Records)
                    {
                        if (!item.IsDateVisible)
                        {
                            continue;
                        }
                        var StudentTestForms = new StudentTestForms();
                        StudentTestForms.IsBaselCeilingApplied  = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == item.ContentCategoryId).IsBaselCeilingApplied;
                        StudentTestForms.BaselCeilingReached    = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == item.ContentCategoryId).BaselCeilingReached;
                        StudentTestForms.LocalformInstanceId    = LocalformInstanceId;
                        StudentTestForms.LocalStudentTestFormId = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == item.ContentCategoryId).LocalStudentTestFormId;
                        StudentTestForms.testDate        = item.TestDate;
                        StudentTestForms.Notes           = item.Notes;
                        StudentTestForms.TSOStatus       = item.Status;
                        StudentTestForms.rawScore        = !string.IsNullOrEmpty(item.RawScore) ? Convert.ToInt32(item.RawScore) : default(int?);
                        StudentTestForms.rawScoreEnabled = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == item.ContentCategoryId).rawScoreEnabled;
                        if (item.Examiner != null && item.Examiner != "Select Examiner")
                        {
                            StudentTestForms.examinerId = Convert.ToInt32(commonDataService.SearchStaffResponseModel.FirstOrDefault(p => p.FirstNameLastName == item.Examiner).UserID);
                        }
                        StudentTestForms.contentCategoryId = item.ContentCategoryId;
                        StudentTestForms.createDate        = DateTime.Now;
                        lstStudentTestForms.Add(StudentTestForms);
                    }
                    commonDataService.StudentTestForms = new List <StudentTestForms>(lstStudentTestForms);
                }
                commonDataService.ResetTestDate?.Invoke();
            }
        }