Example #1
0
        private async void StartAssessmentClicked()
        {
            _commonDataService.DOB            = DOB;
            _commonDataService.IsAcademicForm = false;
            _commonDataService.IsScreenerForm = false;
            _commonDataService.IsCompleteForm = false;
            if (PopupNavigation.Instance.PopupStack != null && PopupNavigation.Instance.PopupStack.Count == 1)
            {
                await PopupNavigation.Instance.PopAsync(false);
            }
            UserDialogs.Instance.ShowLoading("Loading...");
            await Task.Delay(300);

            var clinicalTestForm = new StudentTestFormOverview
            {
                LocalStudentId = OfflineStudentId,
                assessmentId   = IsBattelleDevelopmentalCompleteChecked ? AssignmentTypes.BattelleDevelopmentalCompleteID : IsBattelleDevelopmentalScreenerChecked ? AssignmentTypes.BattelleDevelopmentalScreenerID : AssignmentTypes.BattelleDevelopmentalAcademicSurveyID
            };

            int.TryParse(Application.Current.Properties["UserID"].ToString(), out var addedBy);
            clinicalTestForm.createdByUserId = addedBy;
            clinicalTestForm.createDate      = DateTime.Now;
            var label   = ProgramNote == "Select a program label" ? null : ProgramNote;
            var labelId = label != null?_commonDataService.ProgramNoteModels.FirstOrDefault(p => p.LabelName == ProgramNote)?.LabelId : null;

            clinicalTestForm.FormStatus = "Not started";
            DateTime dateTime;

            DateTime.TryParse(TestDate, out dateTime);
            clinicalTestForm.formParameters = JsonConvert.SerializeObject(
                new FormParamterClass()
            {
                ProgramLabelId = labelId,
                TestDate       = dateTime,
            });
            clinicalTestFormService.InsertTestForm(clinicalTestForm);
            _commonDataService.StudentTestFormOverview = clinicalTestForm;
            LocalTestFormID = clinicalTestForm.LocalTestRecodId;
            var contentBaseCeiling = _commonDataService.ContentBasalCeilings;

            if (IsBattelleEarlyAcademicSurveyChecked)
            {
                var academicCategories = _commonDataService.AcademicCategories;
                if (academicCategories != null && academicCategories.Any())
                {
                    var lstStudentTestForms = new List <StudentTestForms>();
                    var parentCategories    = _commonDataService.AcademicCategories.Where(p => p.parentContentCategoryId == 0).ToList();
                    foreach (var parentCategory in parentCategories)
                    {
                        var childCategory = _commonDataService.AcademicCategories.Where(p => p.parentContentCategoryId == parentCategory.contentCategoryId);
                        if (childCategory != null && childCategory.Any())
                        {
                            foreach (var item in childCategory)
                            {
                                var studentTestForms = new StudentTestForms
                                {
                                    TSOStatus             = "Not Started",
                                    LocalformInstanceId   = LocalTestFormID,
                                    testDate              = TestDate,
                                    examinerId            = Convert.ToInt32(_commonDataService.SearchStaffResponseModel.FirstOrDefault(p => p.FirstNameLastName == Examiner)?.UserID),
                                    contentCategoryId     = item.contentCategoryId,
                                    createDate            = DateTime.Now,
                                    BaselCeilingReached   = contentBaseCeiling.FirstOrDefault(p => p.contentCategoryId == item.contentCategoryId) == null,
                                    IsBaselCeilingApplied = contentBaseCeiling.FirstOrDefault(p => p.contentCategoryId == item.contentCategoryId) != null,
                                };
                                var childchildCategory = _commonDataService.AcademicCategories.Where(p => p.parentContentCategoryId == item.contentCategoryId);
                                if (childchildCategory != null && childchildCategory.Any())
                                {
                                    foreach (var childitem in childchildCategory)
                                    {
                                        var childitemstudentTestForms = new StudentTestForms
                                        {
                                            TSOStatus             = "Not Started",
                                            LocalformInstanceId   = LocalTestFormID,
                                            testDate              = TestDate,
                                            examinerId            = Convert.ToInt32(_commonDataService.SearchStaffResponseModel.FirstOrDefault(p => p.FirstNameLastName == Examiner)?.UserID),
                                            contentCategoryId     = childitem.contentCategoryId,
                                            createDate            = DateTime.Now,
                                            BaselCeilingReached   = contentBaseCeiling.FirstOrDefault(p => p.contentCategoryId == childitem.contentCategoryId) == null,
                                            IsBaselCeilingApplied = contentBaseCeiling.FirstOrDefault(p => p.contentCategoryId == childitem.contentCategoryId) != null,
                                        };
                                        lstStudentTestForms.Add(childitemstudentTestForms);
                                    }
                                }
                                else
                                {
                                    lstStudentTestForms.Add(studentTestForms);
                                }
                            }
                        }
                        else
                        {
                            var studentTestForms = new StudentTestForms
                            {
                                TSOStatus           = "Not Started",
                                LocalformInstanceId = LocalTestFormID,
                                testDate            = TestDate,
                                examinerId          = Convert.ToInt32(_commonDataService.SearchStaffResponseModel.FirstOrDefault(p => p.FirstNameLastName == Examiner)?.UserID),
                                contentCategoryId   = parentCategory.contentCategoryId,
                                createDate          = DateTime.Now
                            };
                            lstStudentTestForms.Add(studentTestForms);
                        }
                    }
                    studentTestFormsService.DeleteAll(LocalTestFormID);
                    studentTestFormsService.InsertAll(lstStudentTestForms);
                    _commonDataService.LocaInstanceID   = LocalTestFormID;
                    _commonDataService.StudentTestForms = new List <StudentTestForms>(lstStudentTestForms);
                    _commonDataService.IsAcademicForm   = true;

                    var navigationParams = new AdminstrationNavigationParams
                    {
                        LocalInstanceID           = LocalTestFormID,
                        DOB                       = DOB,
                        TestDate                  = TestDate,
                        FullName                  = FullName,
                        OfflineStudentID          = OfflineStudentId,
                        IsDevelopmentCompleteForm = false
                    };
                    await Application.Current.MainPage.Navigation.PushModalAsync(new AcademicformWithMatAndItems(navigationParams));

                    _commonDataService.ClearAddChildContent?.Invoke();
                }
            }

            if ((IsBattelleDevelopmentalCompleteChecked && !string.IsNullOrEmpty(Examiner)) || (IsBattelleDevelopmentalScreenerChecked && !string.IsNullOrEmpty(Examiner)))
            {
                var totalCategories = IsBattelleDevelopmentalScreenerChecked ? _commonDataService.ScreenerCategories : _commonDataService.BattleCategories.Where(p => p.contentCategoryLevelId == 2).ToList();
                if (totalCategories != null && totalCategories.Any())
                {
                    var lstStudentTestForms = new List <StudentTestForms>();
                    foreach (var item in totalCategories)
                    {
                        if (IsBattelleDevelopmentalScreenerChecked)
                        {
                            _commonDataService.IsScreenerForm = true;
                        }
                        else if (IsBattelleDevelopmentalCompleteChecked)
                        {
                            _commonDataService.IsCompleteForm = true;
                        }
                        var studentTestForms = new StudentTestForms
                        {
                            TSOStatus           = "Not Started",
                            LocalformInstanceId = LocalTestFormID,
                            testDate            = TestDate,
                            examinerId          = Convert.ToInt32(_commonDataService.SearchStaffResponseModel
                                                                  .FirstOrDefault(p => p.FirstNameLastName == Examiner)?.UserID),
                            contentCategoryId     = item.contentCategoryId,
                            createDate            = DateTime.Now,
                            BaselCeilingReached   = contentBaseCeiling.FirstOrDefault(p => p.contentCategoryId == item.contentCategoryId) == null,
                            IsBaselCeilingApplied = true // contentBaseCeiling.FirstOrDefault(p => p.contentCategoryId == item.contentCategoryId) != null,
                        };
                        lstStudentTestForms.Add(studentTestForms);
                    }
                    studentTestFormsService.DeleteAll(LocalTestFormID);
                    studentTestFormsService.InsertAll(lstStudentTestForms);
                    _commonDataService.LocaInstanceID   = LocalTestFormID;
                    _commonDataService.StudentTestForms = new List <StudentTestForms>(lstStudentTestForms);
                }

                var navigationParams = new AdminstrationNavigationParams
                {
                    LocalInstanceID           = LocalTestFormID,
                    DOB                       = DOB,
                    TestDate                  = TestDate,
                    FullName                  = FullName,
                    OfflineStudentID          = OfflineStudentId,
                    IsDevelopmentCompleteForm = IsBattelleDevelopmentalCompleteChecked
                };
                _commonDataService.ClearAddChildContent?.Invoke();
                await Application.Current.MainPage.Navigation.PushModalAsync(new AdministrationView(navigationParams));
            }
        }