/// <summary> /// Users the input submit. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The <see cref="MLifter.BusinessLayer.UserInputSubmitTextEventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev03, 2009-04-28</remarks> void UserInputSubmit(object sender, UserInputSubmitEventArgs args) { try { learnlogic.OnUserInputSubmit(this, args); } catch (Generics.ServerOfflineException) { TaskDialog.MessageBox(Resources.LEARNING_WINDOW_SERVER_OFFLINE_DIALOG_TITLE, Resources.LEARNING_WINDOW_SERVER_OFFLINE_DIALOG_TITLE, Resources.LEARNING_WINDOW_SERVER_OFFLINE_DIALOG_CONTENT, TaskDialogButtons.OK, TaskDialogIcons.Error); learnlogic.CloseLearningModuleWithoutSaving(); } }
/// <summary> /// Users the input submit. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The <see cref="MLifter.BusinessLayer.UserInputSubmitTextEventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev03, 2009-04-28</remarks> void UserInputSubmit(object sender, UserInputSubmitEventArgs args) { try { learnlogic.OnUserInputSubmit(this, args); } catch (Generics.ServerOfflineException) { TaskDialog.MessageBox(Resources.LEARNING_WINDOW_SERVER_OFFLINE_DIALOG_TITLE, Resources.LEARNING_WINDOW_SERVER_OFFLINE_DIALOG_TITLE, Resources.LEARNING_WINDOW_SERVER_OFFLINE_DIALOG_CONTENT, TaskDialogButtons.OK, TaskDialogIcons.Error); learnlogic.CloseLearningModuleWithoutSaving(); } }
/// <summary> /// Called when [the user submits input]. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="MLifter.BusinessLayer.UserInputSubmitEventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev02, 2008-04-23</remarks> public void OnUserInputSubmit(object sender, UserInputSubmitEventArgs e) { OnLearnLogicIsWorking(); try { if (!UserSessionAlive) return; //deactivate countdown timer if (countdownTimer != null && countdownTimer.Enabled) { countdownTimer.Stop(); countdownTimer.Dispose(); } //store answered timestamp if (!(e is UserInputSubmitSelfAssessmentResponseEventArgs)) currentCardAnswered = DateTime.Now.ToUniversalTime(); Debug.WriteLine("User input submitted: " + currentCardID); //evaluate answer if (e is UserInputSubmitMultipleChoiceEventArgs) { //the user has submitted a multiple choice choice UserInputSubmitMultipleChoiceEventArgs args = (UserInputSubmitMultipleChoiceEventArgs)e; bool promote = (args.result == MultipleChoiceResult.Correct); AnswerResult result = promote ? AnswerResult.Correct : AnswerResult.Wrong; if (!user.Dictionary.Settings.SelfAssessment.Value) PromoteDemoteCard(ref promote, result, args.answer, 0, false, false); //show the result if (!user.Dictionary.Settings.SelfAssessment.Value && user.Dictionary.Settings.SkipCorrectAnswers.Value && promote) AskNextCard(); else { CardStateChangedShowResultEventArgs cardstateargs = new CardStateChangedShowResultEventArgs( user.Dictionary, currentCardID, promote, result, args.answer, false, false); OnCardStateChanged(cardstateargs); } } else if (e is UserInputSubmitSelfAssessmentResponseEventArgs) { //the user has clicked on a button in self assessment mode if (user.Dictionary.Settings.SelfAssessment.Value) { UserInputSubmitSelfAssessmentResponseEventArgs args = (UserInputSubmitSelfAssessmentResponseEventArgs)e; if (args.dontaskagain) user.Dictionary.EnableCard(currentCardID, false); else { bool promote = args.doknow; PromoteDemoteCard(ref promote, args.result, args.answer, 0, false, false); } } AskNextCard(); } else if (e is UserInputSubmitDeactivateCardEventArgs) { //the user has clicked the deactivate card button user.Dictionary.EnableCard(currentCardID, false); if (slideshow) Dictionary.LoadSlideShowContent(); AskNextCard(); } else if (e is UserInputSubmitSlideshowEventArgs) { //the slide show mode card has been seen, time for the next card UserInputSubmitSlideshowEventArgs args = (UserInputSubmitSlideshowEventArgs)e; //set the card used timestamp user.Dictionary.CardUsed(currentCardID); if (args.stopslideshow) this.SlideShow = false; else AskNextCard(); } else if (e is UserInputSubmitTextEventArgs) { //the user has submitted a simple Text answer UserInputSubmitTextEventArgs args = (UserInputSubmitTextEventArgs)e; //in case any grading dialog is active => show result before if (user.Dictionary.Settings.ConfirmDemote.Value || user.Dictionary.Settings.GradeSynonyms.Prompt.Value || (user.Dictionary.Settings.CorrectOnTheFly.Value && user.Dictionary.Settings.GradeTyping.Prompt.Value)) { int typingErrors = 0; bool promoted = (args.correctsynonyms > 0); AnswerResult result_tmp = (args.correctsynonyms > 0) ? AnswerResult.Correct : AnswerResult.Wrong; if (user.Dictionary.Settings.CorrectOnTheFly.Value) //Override if Typing Mode is activated (Correct on the fly) { typingErrors = args.typingerrors; promoted = (typingErrors == 0); result_tmp = (typingErrors == 0) ? AnswerResult.Correct : AnswerResult.Wrong; } OnCardStateChanged(new CardStateChangedShowResultEventArgs(user.Dictionary, currentCardID, promoted, result_tmp, args.answer, false, true)); } AnswerResult result; bool overrideSynonyms, overrideTyping; bool promote = GradeTextAnswer(args, out result, out overrideSynonyms, out overrideTyping); if (!user.Dictionary.Settings.SelfAssessment.Value) PromoteDemoteCard(ref promote, result, args.answer, args.correctsynonyms, overrideSynonyms, overrideTyping); //show the result if (user.Dictionary.Settings.SkipCorrectAnswers.Value && promote) AskNextCard(); else { CardStateChangedShowResultEventArgs cardstateargs = new CardStateChangedShowResultEventArgs( user.Dictionary, currentCardID, promote, result, args.answer, false, false); OnCardStateChanged(cardstateargs); } } else if (e is UserInputSubmitPreviousCard) { //display previous card AskPreviousCard(); } else { //display next card AskNextCard(); } } catch (Npgsql.NpgsqlException ex) { throw new ServerOfflineException(ex); } finally { OnLearnLogicIsIdle(); } }