public List <TestSessionModel> GetUserTestSessions(UserTestModel userAndTest) { var sessions = new List <TestSessionModel>(); using (var connection = factory.CreateConnection()) { connection.ConnectionString = connectionString; var command = connection.CreateCommand(); command.CommandText = "[TestInfo].[GetUserTestSessions]"; command.CommandType = CommandType.StoredProcedure; var testIdParam = command.CreateParameter(); testIdParam.ParameterName = "@TestID"; testIdParam.DbType = DbType.Int32; testIdParam.Value = userAndTest.TestID; var userIdParam = command.CreateParameter(); userIdParam.ParameterName = "@UserID"; userIdParam.DbType = DbType.Int32; userIdParam.Value = userAndTest.UserID; command.Parameters.AddRange(new[] { testIdParam, userIdParam }); connection.Open(); using (IDataReader reader = command.ExecuteReader()) { while (reader.Read()) { var session = new TestSessionModel { TestSessionID = (int)reader["TestSessionID"], TestID = (int)reader["TestID"], UserID = (int)reader["UserID"], BeginTime = (DateTime)reader["BeginTime"], EndTime = (DateTime)reader["EndTime"], QuestionsCount = (int)reader["QuestionsCount"], RightAnswers = (int)reader["RightAnswers"], }; if (!reader.IsDBNull(reader.GetOrdinal("Time"))) { session.Time = (DateTime)reader["Time"]; } sessions.Add(session); } } } return(sessions); }
public TestSessionModel GetTestSessionInfo(int testSessionId) { var sessions = new List <TestSessionModel>(); using (var connection = factory.CreateConnection()) { connection.ConnectionString = connectionString; var command = connection.CreateCommand(); command.CommandText = "[TestInfo].[GetTestSessionInfo]"; command.CommandType = CommandType.StoredProcedure; var testSesIdParam = command.CreateParameter(); testSesIdParam.ParameterName = "@TestSessionID"; testSesIdParam.DbType = DbType.Int32; testSesIdParam.Value = testSessionId; command.Parameters.Add(testSesIdParam); connection.Open(); using (IDataReader reader = command.ExecuteReader()) { while (reader.Read()) { var session = new TestSessionModel { TestSessionID = (int)reader["TestSessionID"], TestID = (int)reader["TestID"], UserID = (int)reader["UserID"], BeginTime = (DateTime)reader["BeginTime"], EndTime = (DateTime)reader["EndTime"], QuestionsCount = (int)reader["QuestionsCount"], RightAnswers = (int)reader["RightAnswers"], }; if (!reader.IsDBNull(reader.GetOrdinal("Time"))) { session.Time = (DateTime)reader["Time"]; } sessions.Add(session); } } } return(sessions.FirstOrDefault()); }
private void VM_DatePicketSelectedEvent(object sender, TestSessionModel e) { Device.BeginInvokeOnMainThread(() => { this.DomainCode = e.DomainCode; DOBpicker.IsShowPicker = true; var success = DateTime.TryParse(e.TestDate, out DateTime dateTime); if (success) //on inital load value will be mm/dd/yyyy { if (vM.Records != null) { var selectedTestRecord = vM.Records.FirstOrDefault(p => p.DomainCode == e.DomainCode); if (selectedTestRecord != null) { var maxDateItem = vM.Records.Where(p => p.IsDateVisible).OrderByDescending(p => p.DateOfTest).FirstOrDefault(); var mindateItem = vM.Records.Where(p => p.IsDateVisible).OrderBy(p => p.DateOfTest).FirstOrDefault(); var dataservice = DependencyService.Get <ICommonDataService>(); var dobSpliteDate = dataservice.DOB.Split('/'); DateTime dobDateTime = new DateTime(Convert.ToInt32(dobSpliteDate[2]), Convert.ToInt32(dobSpliteDate[0]), Convert.ToInt32(dobSpliteDate[1])); if (maxDateItem != null && mindateItem != null) { var dateDiff = maxDateItem.DateOfTest - mindateItem.DateOfTest; if (dateDiff.TotalDays == 0) { var mindate = mindateItem.DateOfTest.AddDays(-30); if (mindate < dobDateTime.Date) { vM.MinimumDate = dobDateTime.Date; } else { vM.MinimumDate = mindate; } var maxDate = maxDateItem.DateOfTest.AddDays(30); if (maxDate > DateTime.Now.Date) { vM.MaximumDate = DateTime.Now; } else { vM.MaximumDate = maxDate; } } else if (dateDiff.TotalDays == 30) { vM.MinimumDate = mindateItem.DateOfTest; vM.MaximumDate = maxDateItem.DateOfTest; } else { var diffDays = 30 - dateDiff.TotalDays; var mindate = mindateItem.DateOfTest.AddDays(-diffDays); if (mindate < dobDateTime.Date) { vM.MinimumDate = dobDateTime.Date; } else { vM.MinimumDate = mindate; } var maxDate = maxDateItem.DateOfTest.AddDays(diffDays); if (maxDate > DateTime.Now.Date) { vM.MaximumDate = DateTime.Now; } else { vM.MaximumDate = maxDate.Date; } } } } } DOBpicker.Date = dateTime; DOBpicker.ManualMaxDate = true; DOBpicker.ManualMinDate = true; DOBpicker.MaximumDate = vM.MaximumDate; DOBpicker.MinimumDate = vM.MinimumDate; } else { DOBpicker.Date = DateTime.Now; } DOBpicker.IsVisible = true; if (Device.RuntimePlatform == Device.UWP) { DOBpicker.ShowDatePicker(); } else { DOBpicker.Focus(); } //DOBpicker.Focus(); }); }
private void OnEntryTextChanged(object sender, TextChangedEventArgs args) { if (!string.IsNullOrWhiteSpace(args.NewTextValue)) { char[] charArray = (sender as Entry).Text.ToCharArray(); Regex reg = null; reg = new System.Text.RegularExpressions.Regex("^[0-9][0-9]*$"); bool isValid = args.NewTextValue.ToCharArray().All(x => char.IsDigit(x)); //Make sure all characters are numbers bool isValidInput = reg.IsMatch(((Entry)sender).Text); if ((sender as Entry).Text.Length == 2 && charArray[0] == '0') { bool firstCharZero = charArray[0].Equals('0'); ((Entry)sender).Text = firstCharZero ? args.NewTextValue.Replace(args.NewTextValue, charArray[1].ToString()): args.NewTextValue; } else { ((Entry)sender).Text = (isValid && isValidInput) ? args.NewTextValue : args.NewTextValue.Remove(args.NewTextValue.Length - 1); } if (isValid && isValidInput) { Entry text = (Entry)sender; TestSessionModel context = text.BindingContext as TestSessionModel; string subDomain = null; string parentDomainCode = null; int input = 0, range = 0; var entryText = ((Entry)sender).Text; if (entryText != string.Empty) { input = Int32.Parse(entryText); if (context != null) { subDomain = context.Domain.ToString(); parentDomainCode = context.ParentDomainCode.ToString(); } if (subDomain == "Self-Care") { range = 74; ((Entry)sender).Text = ValidateRange(range, input); } else if (subDomain == "Personal Responsibility" || subDomain == "Peer Interaction" || subDomain == "Perceptual Motor") { range = 48; ((Entry)sender).Text = ValidateRange(range, input); } else if (subDomain == "Adult Interaction") { range = 54; ((Entry)sender).Text = ValidateRange(range, input); } else if (subDomain == "Self-Concept and Social Role" || subDomain == "Reasoning and Academic Skills" || subDomain == "Perception and Concepts") { range = 66; ((Entry)sender).Text = ValidateRange(range, input); } else if (subDomain == "Receptive Communication") { range = 68; ((Entry)sender).Text = ValidateRange(range, input); } else if (subDomain == "Expressive Communication") { range = 82; ((Entry)sender).Text = ValidateRange(range, input); } else if (subDomain == "Gross Motor") { range = 90; var result = ValidateRange(range, input); if (result != null) { isAcademic = false; ((Entry)sender).Text = result.ToString(); } else { isAcademic = true; ((Entry)sender).Unfocus(); ((Entry)sender).Focus(); } } else if (subDomain == "Fluency") { range = 90; if (Device.RuntimePlatform != Device.iOS) { var result = ValidateRange(range, input); if (result != null) { isAcademic = false; ((Entry)sender).Text = result.ToString(); } else { isAcademic = true; ((Entry)sender).Unfocus(); ((Entry)sender).Focus(); } } else { ((Entry)sender).Text = ValidateRange(range, input); } } else if (subDomain == "Fine Motor" || subDomain == "Attention and Memory") { range = 60; ((Entry)sender).Text = ValidateRange(range, input); } else if (subDomain == "Social-Emotional" || subDomain == "Communication" || subDomain == "Motor" || subDomain == "Cognitive") { range = 40; ((Entry)sender).Text = ValidateRange(range, input); } else if (subDomain == "Print Concepts" || subDomain == "Letter-Sound Correspondence") { range = 12; if (Device.RuntimePlatform != Device.iOS) { var result = ValidateRange(range, input); if (result != null) { isAcademic = false; ((Entry)sender).Text = result.ToString(); } else { isAcademic = true; ((Entry)sender).Unfocus(); ((Entry)sender).Focus(); } } else { ((Entry)sender).Text = ValidateRange(range, input); } } else if (subDomain == "Rhyming" || subDomain == "Syllables" || subDomain == "Onset Rime" || subDomain == "Phoneme Identification" || subDomain == "Phoneme Blending and Segmenting" || subDomain == "Phoneme Manipulation" || subDomain == "Early Decoding" || subDomain == "Sight Words" || subDomain == "Nonsense Words" || subDomain == "Long Vowel Patterns" || subDomain == "Inflectional Endings" || subDomain == "Geometry" || subDomain == "Operations and Algebraic Thinking" || subDomain == "Measurement and Data") { range = 10; if (Device.RuntimePlatform != Device.iOS) { var result = ValidateRange(range, input); if (result != null) { isAcademic = false; ((Entry)sender).Text = result.ToString(); } else { isAcademic = true; ((Entry)sender).Unfocus(); ((Entry)sender).Focus(); } } else { ((Entry)sender).Text = ValidateRange(range, input); } } else if (subDomain == "Letter Identification") { range = 52; if (Device.RuntimePlatform != Device.iOS) { var result = ValidateRange(range, input); if (result != null) { isAcademic = false; ((Entry)sender).Text = result.ToString(); } else { isAcademic = true; ((Entry)sender).Unfocus(); ((Entry)sender).Focus(); } } else { ((Entry)sender).Text = ValidateRange(range, input); } } else if (subDomain == "Listening Comprehension") { range = 14; if (Device.RuntimePlatform != Device.iOS) { var result = ValidateRange(range, input); if (result != null) { isAcademic = false; ((Entry)sender).Text = result.ToString(); } else { isAcademic = true; ((Entry)sender).Unfocus(); ((Entry)sender).Focus(); } } else { ((Entry)sender).Text = ValidateRange(range, input); } } else if (subDomain == "Numbers, Counting, and Sets") { range = 19; if (Device.RuntimePlatform != Device.iOS) { var result = ValidateRange(range, input); if (result != null) { isAcademic = false; ((Entry)sender).Text = result.ToString(); } else { isAcademic = true; ((Entry)sender).Unfocus(); ((Entry)sender).Focus(); } } else { ((Entry)sender).Text = ValidateRange(range, input); } } else if (parentDomainCode == "ADP") { range = 40; var result = ValidateRange(range, input); if (result != null) { isAdaptive = false; ((Entry)sender).Text = result.ToString(); } else { isAdaptive = true; ((Entry)sender).Unfocus(); ((Entry)sender).Focus(); } } } } } else { return; } }
public TestSessionOverViewModel(bool isReport = false) { IsDevelopmentalBasicReport = isReport; if (IsDevelopmentalBasicReport) { Title = "BDI-3 Developmental Complete Basic Report"; IsDateVisible = false; } else { Title = "Test Session Overview"; IsDateVisible = true; } commonDataService = DependencyService.Get <ICommonDataService>(); studentTestFormsService = DependencyService.Get <IStudentTestFormsService>(); LocalformInstanceId = commonDataService.LocaInstanceID; GetExaminerDetails(); clinicalTestFormService = DependencyService.Get <IClinicalTestFormService>(); ProgramLabel = "Select a program label"; GetProgramNotes(); if (IsDevelopmentalBasicReport) { if (ProgramLabel == "Select a program label") { ProgramLabel = string.Empty; } } var domains = default(List <ContentCategory>); if (commonDataService.IsCompleteForm) { domains = new List <ContentCategory>(commonDataService.BattleCategories); if (domains != null && domains.Any()) { var parentCategories = domains.Where(p => p.parentContentCategoryId == 0).OrderBy(p => p.sequenceNo); if (parentCategories != null && parentCategories.Any()) { var bdi3ScoringParser = Bdi3ScoringParser.GetInstance(); foreach (var parentCategory in parentCategories) { TestSessionRecords.Add(new TestSessionModel() { Domain = parentCategory.name, IsDateVisible = false }); var childCategories = domains.Where(p => p.parentContentCategoryId == parentCategory.contentCategoryId).OrderBy(p => p.sequenceNo); if (childCategories != null && childCategories.Any()) { foreach (var childCategory in childCategories) { var sessionmodel = new TestSessionModel() { ContentCategoryId = childCategory.contentCategoryId, ParentDomainCode = parentCategory.code, DomainCode = childCategory.code, LoadDomainBasedQuestionsAction = NavigateandRelaodQuestions, Domain = childCategory.name, TestDate = "mm/dd/yyyy", Examiner = "Select Examiner", Status = "Complete", IsDateVisible = true, DomainMargin = new Thickness(17, 0, 0, 0) }; if (commonDataService.StudentTestForms != null && commonDataService.StudentTestForms.Any()) { var testform = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == childCategory.contentCategoryId); if (testform != null) { sessionmodel.IsScoreSelected = testform.IsScoreSelected; sessionmodel.ContentCategoryId = childCategory.contentCategoryId; sessionmodel.TestDate = testform.testDate; sessionmodel.Notes = testform.Notes; sessionmodel.Status = testform.TSOStatus; sessionmodel.RawScore = testform.rawScore != null && testform.rawScore.HasValue ? testform.rawScore.Value.ToString() : ""; sessionmodel.PropertyChanged -= Sessionmodel_PropertyChanged; sessionmodel.PropertyChanged += Sessionmodel_PropertyChanged; sessionmodel.EnablerawScore = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == childCategory.contentCategoryId).rawScoreEnabled; if (testform.rawScore != null && testform.rawScore.HasValue) { var aescore = bdi3ScoringParser.GetAeFromRs(Convert.ToDouble(testform.rawScore), null, childCategory.name); sessionmodel.AE = aescore > 0 ? (aescore / 12 > 0 ? aescore / 12 + " yrs, " : "") + aescore % 12 + " mos" : "--"; var ss = bdi3ScoringParser.GetSsFromRs(Convert.ToDouble(testform.rawScore), childCategory.name, commonDataService.TotalAgeinMonths); if (ss > ScoringParser.NO_SCORE) { sessionmodel.SS = ss.ToString(); sessionmodel.PR = bdi3ScoringParser.GetPrFromSs((double)ss)?.FirstOrDefault()?.StringValue; } else { sessionmodel.SS = "--"; sessionmodel.PR = "--"; } } if (commonDataService.SearchStaffResponseModel != null && commonDataService.SearchStaffResponseModel.Any() && testform.examinerId != null && testform.examinerId.HasValue) { sessionmodel.ExaminerID = Convert.ToInt32(testform.examinerId); sessionmodel.Examiner = commonDataService.SearchStaffResponseModel.FirstOrDefault(p => p.UserID == testform.examinerId.Value.ToString()).FirstNameLastName; } } } TestSessionRecords.Add(sessionmodel); } } } bdi3ScoringParser = null; GC.Collect(); GC.Collect(); GC.SuppressFinalize(this); } } } else if (commonDataService.IsScreenerForm) { domains = new List <ContentCategory>(commonDataService.ScreenerCategories); foreach (var item in domains) { var sessionModel = new TestSessionModel() { ContentCategoryId = item.contentCategoryId, ParentDomainCode = item.code, DomainCode = item.code, Domain = item.name, TestDate = "mm/dd/yyyy", Examiner = "Select Examiner", Status = "Complete", RawScore = "23", IsDateVisible = true }; if (commonDataService.StudentTestForms != null && commonDataService.StudentTestForms.Any()) { var testform = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == item.contentCategoryId); if (testform != null) { sessionModel.IsScoreSelected = testform.IsScoreSelected; sessionModel.TestDate = testform.testDate; sessionModel.Notes = testform.Notes; sessionModel.Status = testform.TSOStatus; sessionModel.RawScore = testform.rawScore != null && testform.rawScore.HasValue ? testform.rawScore.Value.ToString() : ""; sessionModel.PropertyChanged -= Sessionmodel_PropertyChanged; sessionModel.PropertyChanged += Sessionmodel_PropertyChanged; sessionModel.EnablerawScore = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == item.contentCategoryId).rawScoreEnabled; if (commonDataService.SearchStaffResponseModel != null && commonDataService.SearchStaffResponseModel.Any() && testform.examinerId != null && testform.examinerId.HasValue) { sessionModel.ExaminerID = Convert.ToInt32(testform.examinerId); sessionModel.Examiner = commonDataService.SearchStaffResponseModel.FirstOrDefault(p => p.UserID == testform.examinerId.Value.ToString()).FirstNameLastName; } } } Records.Add(sessionModel); } } if (commonDataService.IsAcademicForm) { domains = domains = new List <ContentCategory>(commonDataService.AcademicCategories); var records = new List <TestSessionModel>(); if (domains != null && domains.Any()) { var parentDomains = domains.Where(p => p.parentContentCategoryId == 0).OrderBy(p => p.sequenceNo); if (parentDomains != null && parentDomains.Any()) { foreach (var item in parentDomains) { records.Add(new TestSessionModel() { Domain = item.name, IsDateVisible = false }); var childRecords = domains.Where(p => p.parentContentCategoryId == item.contentCategoryId).OrderBy(p => p.sequenceNo); if (childRecords != null && childRecords.Any()) { foreach (var subitem in childRecords) { var sessionmodel = new TestSessionModel() { DomainVisibility = true, ContentCategoryId = subitem.contentCategoryId, ParentDomainCode = item.code, DomainCode = subitem.code, LoadDomainBasedQuestionsAction = NavigateandRelaodQuestions, Domain = subitem.name, TestDate = "mm/dd/yyyy", Examiner = "Select Examiner", Status = "Complete", IsDateVisible = true, DomainMargin = new Thickness(17, 0, 0, 0) }; records.Add(sessionmodel); var testform = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == subitem.contentCategoryId); if (testform != null) { sessionmodel.IsScoreSelected = testform.IsScoreSelected; sessionmodel.ContentCategoryId = subitem.contentCategoryId; sessionmodel.TestDate = testform.testDate; sessionmodel.Notes = testform.Notes; sessionmodel.Status = testform.TSOStatus; if (sessionmodel.DomainCode == "PA" || sessionmodel.DomainCode == "PWR") { sessionmodel.RawScore = ""; } else { sessionmodel.RawScore = testform.rawScore != null && testform.rawScore.HasValue ? testform.rawScore.Value.ToString() : ""; } sessionmodel.PropertyChanged -= Sessionmodel_PropertyChanged; sessionmodel.PropertyChanged += Sessionmodel_PropertyChanged; sessionmodel.EnablerawScore = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == subitem.contentCategoryId).rawScoreEnabled; if (commonDataService.SearchStaffResponseModel != null && commonDataService.SearchStaffResponseModel.Any() && testform.examinerId != null && testform.examinerId.HasValue) { sessionmodel.ExaminerID = Convert.ToInt32(testform.examinerId); sessionmodel.Examiner = commonDataService.SearchStaffResponseModel.FirstOrDefault(p => p.UserID == testform.examinerId.Value.ToString()).FirstNameLastName; } if (sessionmodel.ContentCategoryId == 162 || sessionmodel.Domain.ToLower() == "fluency") { sessionmodel.IsFluency = true; if (testform.TimeTaken != null && testform.TimeTaken.HasValue) { sessionmodel.Timer = new TimeSpan(0, 0, 0, testform.TimeTaken.Value); } else { sessionmodel.Timer = new TimeSpan(0, 0, 0, 210); } } else { sessionmodel.IsNotFluency = true; } } var areas = domains.Where(p => p.parentContentCategoryId == subitem.contentCategoryId).OrderBy(p => p.sequenceNo); if (areas != null && areas.Any()) { sessionmodel.DomainColor = Color.Black; sessionmodel.IsDateVisible = false; sessionmodel.DomainVisibility = false; sessionmodel.LoadDomainBasedQuestionsAction = null; foreach (var area in areas) { var sessionmodel1 = new TestSessionModel() { DomainVisibility = true, ContentCategoryId = area.contentCategoryId, ParentDomainCode = subitem.code, DomainCode = area.code, LoadDomainBasedQuestionsAction = NavigateandRelaodQuestions, Domain = area.name, TestDate = "mm/dd/yyyy", Examiner = "Select Examiner", Status = "Complete", IsDateVisible = true, DomainMargin = new Thickness(27, 0, 0, 0) }; records.Add(sessionmodel1); var testform1 = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == area.contentCategoryId); if (testform1 != null) { sessionmodel1.IsScoreSelected = testform1.IsScoreSelected; sessionmodel1.ContentCategoryId = area.contentCategoryId; sessionmodel1.TestDate = testform1.testDate; sessionmodel1.Status = testform1.TSOStatus; sessionmodel1.Notes = testform1.Notes; sessionmodel1.IsNotFluency = true; sessionmodel1.RawScore = testform1.rawScore != null && testform1.rawScore.HasValue ? testform1.rawScore.Value.ToString() : ""; sessionmodel1.PropertyChanged -= Sessionmodel_PropertyChanged; sessionmodel1.PropertyChanged += Sessionmodel_PropertyChanged; sessionmodel1.EnablerawScore = commonDataService.StudentTestForms.FirstOrDefault(p => p.contentCategoryId == area.contentCategoryId).rawScoreEnabled; if (commonDataService.SearchStaffResponseModel != null && commonDataService.SearchStaffResponseModel.Any() && testform1.examinerId != null && testform1.examinerId.HasValue) { sessionmodel1.ExaminerID = Convert.ToInt32(testform1.examinerId); sessionmodel1.Examiner = commonDataService.SearchStaffResponseModel.FirstOrDefault(p => p.UserID == testform1.examinerId.Value.ToString()).FirstNameLastName; } } } } } } } } } AcademicTestSessionRecords = new List <TestSessionModel>(records); /*foreach(var record in AcademicTestSessionRecords) * { * if(record.Domain == "Fluency") * { * record.IsFluency = true; * record.Timer = new TimeSpan(0,0,0,210); * } * else * { * record.IsNotFluency = true; * } * * }*/ } domains = null; }