/// <summary> /// Submits current criteria /// </summary> private void SubmitCriteria() { try { // Check if input data is valid if (!ValidateInputData()) { throw new Exception("Dane w polach są niepoprawne."); } // Everything is ok, convert strings to integers and edit grading object if (PointsGrading.IsMarkAIncluded) { PointsGrading.MarkA.TopLimit = int.Parse(EditingTopValueA); PointsGrading.MarkA.BottomLimit = int.Parse(EditingBottomValueA); } PointsGrading.MarkB.TopLimit = int.Parse(EditingTopValueB); PointsGrading.MarkB.BottomLimit = int.Parse(EditingBottomValueB); PointsGrading.MarkC.TopLimit = int.Parse(EditingTopValueC); PointsGrading.MarkC.BottomLimit = int.Parse(EditingBottomValueC); PointsGrading.MarkD.TopLimit = int.Parse(EditingTopValueD); PointsGrading.MarkD.BottomLimit = int.Parse(EditingBottomValueD); PointsGrading.MarkE.TopLimit = int.Parse(EditingTopValueE); PointsGrading.MarkE.BottomLimit = int.Parse(EditingBottomValueE); PointsGrading.MarkF.TopLimit = int.Parse(EditingTopValueF); PointsGrading.MarkF.BottomLimit = int.Parse(EditingBottomValueF); // Get away from editing mode IsCriteriaEditModeOn = false; ErrorMessage = string.Empty; OnPropertyChanged(nameof(PointsGrading)); } catch (Exception ex) { ErrorMessage = ex.Message; return; } try { mTestEditor.Builder.AddGrading(PointsGrading); } catch (Exception ex) { DI.UI.ShowMessage(new MessageBoxDialogViewModel() { Title = "Test editor", Message = $"Nieznany bład. {ex.Message}", }); return; } mTestEditor.GoNextPhase(); }
/// <summary> /// Go to the next phase of creation/edition of the test /// </summary> private void GoNextPhase() { if (CurrentQuestionEditorViewModel != null && CurrentQuestionEditorViewModel.AnyUnsavedChanges) { if (AskToSave()) { if (!SubmitQuestion()) { return; } } QuestionTypeDialogVisible = true; CurrentQuestionEditorViewModel = null; } if (mTestEditor.Builder.CurrentQuestions.Count == 0) { DI.UI.ShowMessage(new MessageBoxDialogViewModel() { Message = "Nie można przejść dalej, ponieważ test nie posiada pytań!", Title = "Test editor", }); return; } if (mTestEditor.Builder.CurrentPointScore <= 4) { DI.UI.ShowMessage(new MessageBoxDialogViewModel() { Message = "Nie można przejść dalej, ponieważ maksymalna liczba punktów za test jest mniejsza od 5!", Title = "Test editor", }); return; } mTestEditor.GoNextPhase(); }
/// <summary> /// Submits current page /// </summary> private void Submit() { int durationHours = 0, durationMinutes = 0, durationSeconds = 0; try { // Follow the order of properties like in the view mTestEditor.Builder.AddName(Name); if (string.IsNullOrEmpty(DurationHours)) { DurationHours = "00"; } if (string.IsNullOrEmpty(DurationMinutes)) { DurationMinutes = "00"; } if (string.IsNullOrEmpty(DurationSeconds)) { DurationSeconds = "00"; } if ((DurationHours.TrimStart('0') != "" && !int.TryParse(DurationHours.TrimStart('0'), out durationHours)) || durationHours > 3) { throw new Exception("Niepoprawna wartość w polu godzin."); } if ((DurationMinutes.TrimStart('0') != "" && !int.TryParse(DurationMinutes.TrimStart('0'), out durationMinutes)) || durationMinutes > 60) { throw new Exception("Niepoprawna wartość w polu minut."); } if ((DurationSeconds.TrimStart('0') != "" && !int.TryParse(DurationSeconds.TrimStart('0'), out durationSeconds)) || durationSeconds > 60) { throw new Exception("Niepoprawna wartość w polu sekund."); } mTestEditor.Builder.AddDuration(new TimeSpan(durationHours, durationMinutes, durationSeconds)); mTestEditor.Builder.AddTags(Tags); mTestEditor.Builder.AddNote(Note); } catch (Exception ex) { ErrorMessage = ex.Message; return; } // Chcek if something changed compared to the original information if (EditingModeOn) { if (mOriginalInfo.Name != Name || mOriginalInfo.Duration.TotalSeconds != (durationHours * 3600 + durationMinutes * 60 + durationSeconds) || mOriginalInfo.Tags != Tags || mOriginalInfo.Note != Note) { mTestEditor.TestChanged(); } } // If everything went fine proceed to the next phase of creation/edition of this test mTestEditor.GoNextPhase(); }