// This is executed in a new thread each time, so it is safe to use blocking calls protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { Completed.Set(); return; } PlayAction actionPlay = call.PlayTTSAsync("I'm a little teapot, short and stout. Here is my handle, here is my spout."); bool paused = false; while (!actionPlay.Completed) { paused = !paused; if (paused) { actionPlay.Pause(); } else { actionPlay.Resume(); } Thread.Sleep(3000); } HangupResult resultHangup = call.Hangup(); Successful = actionPlay.Result.Successful && resultHangup.Successful; Completed.Set(); }
protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { return; } // Request a random digit between 1 - 9 string winning_number = RandomDigit(); Console.WriteLine("Winning number is:" + winning_number); PromptResult guessResult = call.PromptTTS("Please, guess a number between one and nine.", new CallCollect() { Digits = new CallCollect.DigitsParams { Max = 1 } }, "female"); if (guessResult.Result == winning_number) { call.PlayTTS("Winner! Winner! Chicken Dinner! You guessed correctly.", "female"); } else { call.PlayTTS("You do not pass go! You have guessed incorrectly.", "female"); } call.PlayTTS("Thank you for playing, Good Bye!", "female"); call.Hangup(); }
public void setAnswered(AnswerBox.Answer answer, AnswerResult answerType) { lastAnswer = answer; lastAnswerResult = answerType; switch (answerType) { case AnswerResult.no_answer: AnsweredImage.Source = noImageSource; break; case AnswerResult.wrong: if (showAnswers) { AnsweredImage.Source = wrongImageSource; } else { AnsweredImage.Source = answeredImageSource; } break; case AnswerResult.correct: if (showAnswers) { AnsweredImage.Source = correctImageSource; } else { AnsweredImage.Source = answeredImageSource; } break; } }
// This is executed in a new thread each time, so it is safe to use blocking calls protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { Completed.Set(); return; } PlayAction actionPlayAudio = call.PlayAudioAsync("https://cdn.signalwire.com/default-music/welcome.mp3"); PlayAction actionPlayTTS = call.PlayTTSAsync("I'm a little teapot, short and stout. Here is my handle, here is my spout."); while (!actionPlayTTS.Completed) { Thread.Sleep(500); } actionPlayAudio.Stop(); call.Hangup(); Successful = actionPlayAudio.Result.Successful && actionPlayTTS.Result.Successful; Completed.Set(); }
public double GetUserScoreForTest(long activityPackageID, int numberOfPosition) { if (_ListOfAnswers.Count(c => c.ActivityPackageId == activityPackageID) == 0) { return(0.0); } else { IEnumerable <AnswerResult> temp = _ListOfAnswers.Where(c => c.ActivityPackageId == activityPackageID); if (temp.Count() < numberOfPosition) { return(0.0); } else { AnswerResult answer = temp.ElementAt(numberOfPosition - 1); if (answer.ScaledScore.HasValue == true) { return(answer.ScaledScore.Value); } else { return(0.0); } } } }
void Command_Window_Close_ModifiedUnmodifiedTabs(bool modified) { var topMost = TopMost; var active = Items.Where(tab => (tab.Active) && (tab.IsModified != modified)).ToList(); var answer = new AnswerResult(); var closeTabs = Items.Where(tab => (tab.Active) && (tab.IsModified == modified)).ToList(); if (!closeTabs.All(tab => tab.CanClose(answer))) { return; } closeTabs.ForEach(tab => Remove(tab)); if (!active.Any()) { return; } if (!active.Contains(topMost)) { topMost = active.First(); } TopMost = topMost; active.ForEach(tab => tab.Active = true); }
/// <summary> /// Handles the CardStateChanged event of the learnlogic control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="MLifter.BusinessLayer.CardStateChangedEventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev02, 2008-04-24</remarks> void learnlogic_CardStateChanged(object sender, CardStateChangedEventArgs e) { if (e is CardStateChangedNewCardEventArgs || (e is CardStateChangedShowResultEventArgs && ((CardStateChangedShowResultEventArgs)e).slideshow)) { Text = String.Format(Resources.STATUSBAR_CURRENTCHAPTER, e.dictionary.Cards.GetChapterName(e.cardid)); } else if (e is CardStateChangedShowResultEventArgs) { if (e.dictionary.Settings.SelfAssessment.Value) { Text = Resources.STATUSBAR_SELFASSESSMENT; } else { CardStateChangedShowResultEventArgs args = (CardStateChangedShowResultEventArgs)e; AnswerResult result = args.promoted ? AnswerResult.Correct : (args.result == AnswerResult.Almost ? AnswerResult.Almost : AnswerResult.Wrong); switch (result) { case AnswerResult.Correct: Text = Resources.STATUSBAR_RESPONSE_CORRECT; break; case AnswerResult.Wrong: Text = Resources.STATUSBAR_RESPONSE_INCORRECT; break; case AnswerResult.Almost: Text = Resources.STATUSBAR_RESPONSE_ALMOST; break; } } } }
// This is executed in a new thread each time, so it is safe to use blocking calls protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { Completed.Set(); return; } // TODO call.Record RecordResult resultRecord = call.Record(new CallRecord { Audio = new CallRecord.AudioParams { // Default parameters } }); Logger.LogInformation("Recording {0} @ {1}", resultRecord.Successful ? "successful" : "unsuccessful", resultRecord.Url); HangupResult resultHangup = call.Hangup(); Successful = resultRecord.Successful && resultHangup.Successful; Completed.Set(); }
void Command_Window_Close_TabsWithWithoutSelections(bool hasSelections) { var topMost = TopMost; var active = Items.Where(tab => (tab.Active) && (tab.HasSelections != hasSelections)).ToList(); var answer = new AnswerResult(); var closeTabs = Items.Where(tab => (tab.Active) && (tab.HasSelections == hasSelections)).ToList(); if (!closeTabs.All(tab => tab.CanClose(answer))) { return; } closeTabs.ForEach(tab => Remove(tab)); if (!active.Any()) { return; } if (!active.Contains(topMost)) { topMost = active.First(); } TopMost = topMost; active.ForEach(tab => tab.Active = true); }
/// <summary> /// Plays the commentary sound. /// </summary> /// <param name="soundid">The commentary sound id: 0 -> correct, 1 -> wrong, 2 -> almost.</param> /// <param name="standalone">if set to <c>true</c>, the [standalone commentary sound gets played].</param> /// <remarks>Documented by Dev02, 2008-03-17</remarks> private void PlayCommentarySound(Dictionary dictionary, AnswerResult result, bool standalone) { if (dictionary.Settings.EnableCommentary.Value) { Side side = dictionary.CurrentQueryDirection == EQueryDirection.Question2Answer ? Side.Answer : Side.Question; ECommentarySoundType type; switch (result) { case AnswerResult.Correct: type = standalone ? ECommentarySoundType.RightStandAlone : ECommentarySoundType.Right; break; case AnswerResult.Wrong: type = standalone ? ECommentarySoundType.WrongStandAlone : ECommentarySoundType.Wrong; break; case AnswerResult.Almost: type = standalone ? ECommentarySoundType.AlmostStandAlone : ECommentarySoundType.Almost; break; default: return; } CommentarySoundIdentifier identifier = CommentarySoundIdentifier.Create(side, type); if (dictionary.CommentarySound.ContainsKey(identifier)) { PlayMediaFile(dictionary.CommentarySound[identifier].Filename, result != AnswerResult.Correct); } } }
public Task <AnswerResult> GetByIdAsync(int id) { return(Task.Run(() => { AnswerResult answer = dbContext.AnswerResults.Find(id); return answer; })); }
// This is executed in a new thread each time, so it is safe to use blocking calls protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { Completed.Set(); return; } PlayAction actionPlay = call.PlayTTSAsync("I'm a little teapot, short and stout. Here is my handle, here is my spout.", volume: 16); Thread.Sleep(1000); bool increase = false; PlayVolumeResult resultPlayVolume = null; while (!actionPlay.Completed) { increase = !increase; resultPlayVolume = actionPlay.Volume(increase ? 8 : 0); if (!resultPlayVolume.Successful) { break; } Thread.Sleep(3000); } call.Hangup(); Successful = actionPlay.Result.Successful && resultPlayVolume.Successful; Completed.Set(); }
// This is executed in a new thread each time, so it is safe to use blocking calls protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { Completed.Set(); return; } PromptResult resultPrompt = call.PromptTTS( "I'm a little teapot.", new CallCollect { Digits = new CallCollect.DigitsParams() { Max = 1 } }); HangupResult resultHangup = call.Hangup(); Successful = resultPrompt.Successful && resultHangup.Successful; Completed.Set(); }
public AnswerResult AnswerWord(long userId, string possibleAnswer) { var wordStat = _wordRepository.GetCurrentWord(userId); if (wordStat == null) { throw new Exception($"There no words for this user which must be answered. userId={userId}"); } var learnMode = wordStat.Score.ToELearnMode(userId); var file = _wordRepository.GetWordFlashCard(wordStat.CardAll.Id); var result = new AnswerResult { WordStatistic = wordStat, Picture = file }; switch (learnMode) { case ELearnMode.OriginalWord: wordStat.Score.OriginalWordCount++; if (string.Join("", wordStat.OriginalWord.Take(MaxAnswerLength)) == possibleAnswer) { wordStat.Score.OriginalWordSuccessCount++; result.Success = true; } break; case ELearnMode.Pronunciation: wordStat.Score.PronunciationCount++; if (string.Join("", wordStat.Pronunciation.Take(MaxAnswerLength)) == possibleAnswer) { wordStat.Score.PronunciationSuccessCount++; result.Success = true; } break; case ELearnMode.Translation: wordStat.Score.TranslationCount++; if (string.Join("", wordStat.Translation.Take(MaxAnswerLength)) == possibleAnswer) { wordStat.Score.TranslationSuccessCount++; result.Success = true; } break; case ELearnMode.FullView: result.Success = true; break; } _wordRepository.SetScore(wordStat.Id, wordStat.Score); return(result); }
public void Delete(AnswerResult entity) { if (entity != null) { dbContext.Entry(entity).State = EntityState.Deleted; dbContext.SaveChanges(); } }
/// <summary> /// Return maximum score from AnswerResult /// </summary> /// <param name="answerResult">AnswerResult for question</param> /// <returns></returns> public double GetMaxScoreForAnswer(AnswerResult answerResult) { if (answerResult.MaxScore.HasValue) { return(answerResult.MaxScore.Value); } return(0); }
// This is executed in a new thread each time, so it is safe to use blocking calls protected override void OnIncomingCall(Call call) { Console.WriteLine("Answering"); // Answer the incoming call, block until it's answered or an error occurs AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { // The call was not answered successfully, stop the consumer and bail out Stop(); return; } call.PlayTTS("Welcome to SignalWire!"); Console.WriteLine("Connecting"); // Connect the inbound call to an outbound call ConnectResult resultConnect = call.Connect(new List <List <CallDevice> > { new List <CallDevice> { new CallDevice { Type = CallDevice.DeviceType.phone, Parameters = new CallDevice.PhoneParams { ToNumber = "+1555XXXXXXX", FromNumber = "+1555XXXXXXX", } } } }); if (resultConnect.Successful) { Console.WriteLine("Connected"); resultConnect.Call.PlayTTS("Welcome!"); // Wait upto 15 seconds for the connected side to hangup if (!resultConnect.Call.WaitForEnded()) //TimeSpan.FromSeconds(15))) { // If the other side of the outbound call doesn't hang up, then hang it up resultConnect.Call.Hangup(); } } call.PlayTTS("Thank you for trying SignalWire!"); // Hangup the inbound call call.Hangup(); // Stop the consumer Stop(); }
// This is executed in a new thread each time, so it is safe to use blocking calls protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { // If answering fails, test stops Completed.Set(); } }
public String GetUserAnswer(AnswerResult answerResult) { if (answerResult.LearnerResponse != null) { return(Uri.UnescapeDataString(answerResult.LearnerResponse.ToString())); } else { return(""); } }
/// <summary> /// Return user score from AnswerResult /// </summary> /// <param name="answerResult">AnswerResult for question</param> /// <returns></returns> public String GetUserScoreForAnswer(AnswerResult answerResult) { if (answerResult.ScaledScore != null) { if (answerResult.ScaledScore.HasValue == true) { return(Math.Round((double)answerResult.ScaledScore, 2).ToString()); } } return(""); }
void Command_Window_Close_ActiveInactiveTabs(bool active) { var answer = new AnswerResult(); var closeTabs = Items.Where(tab => tab.Active == active).ToList(); if (!closeTabs.All(tab => tab.CanClose(answer))) { return; } closeTabs.ForEach(tab => Remove(tab)); }
/// <summary> /// Handles the CardStateChanged event of the learnlogic control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="MLifter.BusinessLayer.CardStateChangedEventArgs"/> instance containing the event data.</param> /// <remarks>Documented by Dev02, 2008-04-24</remarks> void learnlogic_CardStateChanged(object sender, CardStateChangedEventArgs e) { if (e.dictionary.Settings.AutoplayAudio.Value) { bool example = (e as CardStateChangedEventArgs).dictionary.LearnMode == MLifter.BusinessLayer.LearnModes.Sentence; if (e is CardStateChangedNewCardEventArgs || (e is CardStateChangedShowResultEventArgs && ((CardStateChangedShowResultEventArgs)e).slideshow)) { if (e is CardStateChangedShowResultEventArgs && ((CardStateChangedShowResultEventArgs)e).preview) { return; } // [ML-1747] if (e.dictionary.LearnMode == MLifter.BusinessLayer.LearnModes.ImageRecognition) { return; } //play question side sound PlayMediaFile(e.dictionary.Cards.GetAudioFile(e.cardid, Side.Question, example), true); } if (e is CardStateChangedShowResultEventArgs) { CardStateChangedShowResultEventArgs args = (CardStateChangedShowResultEventArgs)e; if (args.preview) { return; } //play answer side sound and commentary sounds AnswerResult result = args.promoted ? AnswerResult.Correct : (args.result == AnswerResult.Almost ? AnswerResult.Almost : AnswerResult.Wrong); if (FileValid(args.dictionary.Cards.GetAudioFile(args.cardid, Side.Answer, example))) { if (result != AnswerResult.Correct) { PlayCommentarySound(args.dictionary, result, false); //not correct commentary sound is to be played before the cardaudio } PlayMediaFile(args.dictionary.Cards.GetAudioFile(args.cardid, Side.Answer, example), false); if (result == AnswerResult.Correct) { PlayCommentarySound(args.dictionary, result, false); //correct commentary sound is to be played after the cardaudio } } else //play the standalone commentary sounds only if the card sound is not available { PlayCommentarySound(args.dictionary, result, true); } } } }
// This is executed in a new thread each time, so it is safe to use blocking calls protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { Completed.Set(); return; } UdpClient udpClient = new UdpClient(RTPPort); TapAction actionTap = call.TapAsync( new CallTap { Type = CallTap.TapType.audio, Parameters = new CallTap.AudioParams { Direction = CallTap.AudioParams.AudioDirection.both, } }, new CallTapDevice { Type = CallTapDevice.DeviceType.rtp, Parameters = new CallTapDevice.RTPParams { Address = RTPAddr, Port = RTPPort, } } ); IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, RTPPort); byte[] data = udpClient.Receive(ref ipEndPoint); Task <UdpReceiveResult> resultReceive = udpClient.ReceiveAsync(); bool gotData = false; gotData = resultReceive.Wait(5000); if (gotData) { Logger.LogInformation("Received {0} RTP bytes", data.Length); } actionTap.Stop(); HangupResult resultHangup = call.Hangup(); Successful = gotData && actionTap.Result.Successful && resultHangup.Successful; Completed.Set(); }
private object SuccessfulResponse(string query, AnswerResult answerResult, QueryResultTable table) { var resultsTable = InteractiveSqlJson.QueryResultToJson(table); var response = new { query = query, results = resultsTable, isCorrectAnswer = answerResult.IsCorrect, hint = answerResult.Hint.ValueOrElse(null) }; return Json(response); }
/// <summary> /// Submits the self assessment reponse. /// </summary> /// <param name="doknow">if set to <c>true</c> [doknow].</param> /// <remarks>Documented by Dev02, 2008-04-23</remarks> public void SubmitSelfAssessmentReponse(bool doknow, bool dontaskagain) { if (learnlogic != null && cardEventArgs is CardStateChangedShowResultEventArgs) { //whether the question was answered right or wrong by the user AnswerResult result = ((CardStateChangedShowResultEventArgs)cardEventArgs).result; string answer = ((CardStateChangedShowResultEventArgs)cardEventArgs).answer; UserInputSubmitSelfAssessmentResponseEventArgs args = new UserInputSubmitSelfAssessmentResponseEventArgs(doknow, dontaskagain, result, answer); UserInputSubmit(this, args); } }
protected override void OnIncomingCall(Call call) { AnswerResult resultAnswer = call.Answer(); if (!resultAnswer.Successful) { // The call was not answered successfully, stop the consumer and bail out Completed.Set(); Stop(); return; } TaskCompletionSource <bool> eventing = new TaskCompletionSource <bool>(); call.OnFaxError += (a, c, e, p) => { Logger.LogError("Actual fax receive had an error"); eventing.SetResult(true); }; call.OnFaxFinished += (a, c, e, p) => { var settings = p.Fax.ParametersAs <CallingEventParams.FaxParams.FaxSettings.FinishedSettings>(); if (settings.Success) { Successful = true; } else { Logger.LogError("Actual fax receive had an issue: {0}", settings.ResultText); } eventing.SetResult(true); }; FaxResult receiveResult = call.FaxReceive(); if (!receiveResult.Successful) { Successful = false; Logger.LogError("Receive fax was unsuccessful"); eventing.SetResult(true); } else { eventing.Task.Wait(); if (!Successful) { Logger.LogError("Fax receive did not give a successful finished event"); } } Completed.Set(); }
void Close_Click(object sender, RoutedEventArgs e) { var selected = listView.SelectedItems.Cast <TextEditor>().ToList(); var answer = new AnswerResult(); if (!selected.All(tab => tab.CanClose(answer))) { return; } selected.ForEach(item => tabs.Remove(item)); listView.ItemsSource = tabs.Items.ToList(); }
public void setPlayer(int i, XInputController controller) { inGame = false; readied = false; this.controller = controller; controlSource = ControlSource.controller; connected = controller.connected; name = NameTextBox.Text; score = 0; canAnswer = false; lastAnswerResult = AnswerResult.no_answer; player = i; setColor(); readiedSound = new MediaPlayer(); }
public void setPlayer(int i, XKeyboard keyboard) { inGame = false; readied = false; this.keyboard = keyboard; controlSource = ControlSource.keyboard; connected = true; name = NameTextBox.Text; score = 0; canAnswer = false; lastAnswerResult = AnswerResult.no_answer; player = i; setColor(); readiedSound = new MediaPlayer(); }
public void CardStackUnitTest() { if (TestInfrastructure.IsActive(TestContext)) { using (Dictionary dictionary = TestInfrastructure.GetConnection(TestContext)) { DictionaryTest.FillDictionary(dictionary); CardStack target = new CardStack(new LearnLogic(MLifterTest.DAL.OpenUserProfileTests.GetUserAdmin, (MLifter.DAL.DataAccessErrorDelegate) delegate { return; })); target.StackChanged += new EventHandler(CardStack_StackChanged); cardstackChanged = false; target.Clear(); Assert.IsTrue(cardstackChanged, "CardStackChanged event did not fire for Clear."); int cardcount = 0; int rightcount = 0; TimeSpan duration = new TimeSpan(0); foreach (ICard card in dictionary.Cards.Cards) { for (int i = 0; i < 100; i++) { cardcount++; bool promoted = GetRandBool(); if (promoted) { rightcount++; } DateTime asked = DateTime.Now - new TimeSpan(0, 0, random.Next(1000)); DateTime answered = DateTime.Now; duration += (answered - asked); AnswerResult result = promoted ? AnswerResult.Correct : AnswerResult.Wrong; StackCard stackCard = new StackCard(card, result, promoted, EQueryDirection.Question2Answer, LearnModes.Word, asked, answered, Thread.CurrentThread.CurrentCulture, Thread.CurrentThread.CurrentCulture, card.Answer.ToString(), 0, 0, false, dictionary, 0); cardstackChanged = false; target.Push(stackCard); Assert.IsTrue(cardstackChanged, "CardStackChanged event did not fire for Push."); } } Assert.AreEqual(cardcount, target.Count, "Not all cards were added to the stack."); Assert.AreEqual(duration, target.SessionDuration, "Session duration sum does not match."); Assert.AreEqual(rightcount, target.RightCount, "RightCount does not match."); Assert.AreEqual(cardcount - rightcount, target.WrongCount, "WrongCount does not match."); Assert.IsTrue(rightcount > 0 && target.VisibleStack.Count > 0, "No StackCards in VisibleStack property."); } } }
public void CreateAnswerResultWithParameters() { const long ActivityAttemptId = 2349; const long ActivityPackageId = 83294; const string ActivityTitle = "Some Activity"; long? interactionId = 12382; const CompletionStatus CompletionStatus = CompletionStatus.NotAttempted; const SuccessStatus SuccessStatus = SuccessStatus.Failed; var attemptResult = new AttemptResult(); const string LearnerResponse = "C"; const string CorrectResponse = "-328"; InteractionType?learnerResponseType = Common.Models.Shared.Statistics.InteractionType.Numeric; float? scaledScore = 0.58f; float? minScore = 0; float? maxScore = 50; float? rawScore = 29; string primaryResourceFromManifest = "0.html"; var answerResult = new AnswerResult( ActivityAttemptId, ActivityPackageId, ActivityTitle, interactionId, CompletionStatus, SuccessStatus, attemptResult, LearnerResponse, CorrectResponse, learnerResponseType, minScore, maxScore, rawScore, scaledScore, primaryResourceFromManifest); Assert.AreEqual(ActivityAttemptId, answerResult.ActivityAttemptId); Assert.AreEqual(ActivityPackageId, answerResult.ActivityPackageId); Assert.AreEqual(ActivityTitle, answerResult.ActivityTitle); Assert.AreEqual(interactionId, answerResult.InteractionId); Assert.AreEqual(CompletionStatus, answerResult.CompletionStatus); Assert.AreEqual(SuccessStatus, answerResult.SuccessStatus); Assert.AreSame(attemptResult, answerResult.AttemptResult); Assert.AreEqual(LearnerResponse, answerResult.LearnerResponse); Assert.AreEqual(CorrectResponse, answerResult.CorrectResponse); Assert.AreEqual(learnerResponseType, answerResult.LearnerResponseType); Assert.AreEqual(scaledScore, answerResult.ScaledScore); }
public JsonResult CheckAnswer(AnswerInfo answerInfo) { Task task = data.FindTask(answerInfo.TaskId); UserProfile user = data.FindUser(WebSecurity.CurrentUserId); if (answerInfo.UserId != 0) { UserProfile author = data.FindUser(answerInfo.UserId); if (author.UserId != user.UserId) { return CheckAnswerWithoutAuthor(user, task, answerInfo); } AnswerResult result = new AnswerResult(); result.Success = false; result.Message = Messages.UserAuthor; return Json(result); } return CheckAnswerWithoutAuthor(user, task, answerInfo); }
private JsonResult CheckAnswerWithoutAuthor(UserProfile user, Task task, AnswerInfo answerInfo) { AnswerResult result = new AnswerResult(); if (!user.Tasks2.Contains(task)) { if (data.IsAnswerCorrect(answerInfo.TaskId, answerInfo.Answer)) { data.UserSolveTask(user, task); result.Success = true; result.Message = Messages.UserSuccess; } else { data.UserFailToSolveTask(user, task); result.Success = false; result.Message = Messages.UserFail; } return Json(result); } result.Success = false; result.Message = Messages.UserAlreadySolve; return Json(result); }
/// <summary> /// Updates score, stack and promotes or demotes the card. /// </summary> /// <param name="promote">if set to <c>true</c> [promote].</param> /// <param name="result">The result.</param> /// <remarks>Documented by Dev02, 2008-04-23</remarks> private void PromoteDemoteCard(ref bool promote, AnswerResult result, string answer, int correctSynonyms, bool overrideSynonyms, bool overrideTyping) { if (currentCardID >= 0) { int old_box, new_box; //Important for the DB-LogEntry bool canceledDemote = overrideSynonyms; new_box = old_box = user.Dictionary.Cards.GetCardByID(currentCardID).BaseCard.Box; if (user.Dictionary.LearningBox == 0) //grade card { //show confirm demote dialog if (!promote && user.Dictionary.Settings.ConfirmDemote.GetValueOrDefault()) { UserGradingDialogEventArgs args = new UserGradingDialogEventArgs(user.Dictionary, currentCardID, UserGradingDialogEventArgs.GradingDialogKind.ConfirmDemote); OnUserDialog(args); promote = args.promote; if (promote) canceledDemote = true; } if (overrideTyping) canceledDemote = true; //promote/demote card if (promote) { user.Dictionary.PromoteCard(currentCardID); new_box = user.Dictionary.Cards.GetCardByID(currentCardID).BaseCard.Box; } else { user.Dictionary.DemoteCard(currentCardID); new_box = user.Dictionary.Cards.GetCardByID(currentCardID).BaseCard.Box; } if (user.Dictionary.Score > user.Dictionary.Highscore) user.Dictionary.Highscore = user.Dictionary.Score; } else user.Dictionary.CardUsed(currentCardID); //only set the card used timestamp //add card to stack (important to be the last step since it triggers the cardstack_changed event) cardStack.Push(new StackCard( user.Dictionary.Cards.GetCardByID(currentCardID).BaseCard, result, promote, user.Dictionary.CurrentQueryDirection, user.Dictionary.LearnMode, currentCardAsked, currentCardAnswered, user.Dictionary.Cards.GetCardByID(currentCardID).BaseCard.Question.Culture, user.Dictionary.Cards.GetCardByID(currentCardID).BaseCard.Answer.Culture, answer, old_box, new_box, canceledDemote, user.Dictionary, correctSynonyms)); } }
/// <summary> /// Initializes a new instance of the <see cref="CardStateChangedShowResultEventArgs"/> class. /// </summary> /// <param name="dictionary">The dictionary.</param> /// <param name="cardid">The cardid.</param> /// <param name="promoted">if set to <c>true</c> [promoted].</param> /// <param name="result">The result.</param> /// <param name="answer">The answer.</param> /// <param name="slideshow">if set to <c>true</c> [slideshow].</param> /// <param name="preview">if set to <c>true</c> [preview].</param> /// <remarks>Documented by Dev02, 2008-04-23</remarks> public CardStateChangedShowResultEventArgs(Dictionary dictionary, int cardid, bool promoted, AnswerResult result, string answer, bool slideshow, bool preview) : base(dictionary, cardid) { this.promoted = promoted; this.result = result; this.answer = answer; this.slideshow = slideshow; this.preview = preview; }
/// <summary> /// ตรวจสอบคำตอบเพื่อใช้ในการแสดงผล /// </summary> /// <param name="result">ผลลัพธ์</param> public void PlayAnswerResult(AnswerResult result) { if (result.IsCorrect == true && _lastClickedCup != null) _lastClickedCup.CupCorrect(); else if (result.IsCorrect == false && _lastClickedCup != null) _lastClickedCup.StartCupIncorrect(); if (result.IsFinish) _isAutoAnswerOn = true; }
/// <summary> /// Grades the Text answer. /// </summary> /// <param name="args">The <see cref="MLifter.BusinessLayer.UserInputSubmitTextEventArgs"/> instance containing the event data.</param> /// <param name="result">The result (optional).</param> /// <returns>Promote or Demote.</returns> /// <remarks>Documented by Dev02, 2008-04-23</remarks> private bool GradeTextAnswer(UserInputSubmitTextEventArgs args, out AnswerResult result, out bool overrideSynonyms, out bool overrideTyping) { bool correct = args.correctsynonyms > 0; result = correct ? AnswerResult.Correct : AnswerResult.Wrong; overrideSynonyms = overrideTyping = false; //[ML-1331] Textbox counts synonyms somethimes wrong: following lines were wrong: // else if (user.Dictionary.Settings.GradeSynonyms.FirstKnown.Value) promotesynonyms = args.correctsynonyms >= 1; // else if (user.Dictionary.Settings.GradeSynonyms.OneKnown.Value) promotesynonyms = args.correctfirstsynonym; // ... were wrong // Grade Synonyms bool promotesynonyms = true; if (args.synonyms > 1 && args.correctsynonyms < args.synonyms) { if (user.Dictionary.Settings.GradeSynonyms.AllKnown.Value) promotesynonyms = args.synonyms == args.correctsynonyms; else if (user.Dictionary.Settings.GradeSynonyms.HalfKnown.Value) promotesynonyms = args.synonyms > 0 ? 2 * args.correctsynonyms >= args.synonyms : false; else if (user.Dictionary.Settings.GradeSynonyms.FirstKnown.Value) promotesynonyms = args.correctfirstsynonym; else if (user.Dictionary.Settings.GradeSynonyms.OneKnown.Value) promotesynonyms = args.correctsynonyms >= 1; else if (user.Dictionary.Settings.GradeSynonyms.Prompt.Value) { UserGradingDialogEventArgs e = new UserGradingDialogEventArgs(user.Dictionary, currentCardID, UserGradingDialogEventArgs.GradingDialogKind.GradeSynonym); OnUserDialog(e); overrideSynonyms = promotesynonyms = e.promote; } } // Grade Typing bool promotetyping = true; if (args.typingerrors > 0 && !overrideSynonyms) { if (user.Dictionary.Settings.GradeTyping.AllCorrect.Value) promotetyping = false; else if (user.Dictionary.Settings.GradeTyping.HalfCorrect.Value) promotetyping = args.answer.Length > 0 ? 2 * args.typingerrors < args.answer.Length : false; else if (user.Dictionary.Settings.GradeTyping.NoneCorrect.Value) promotetyping = true; else if (user.Dictionary.Settings.GradeTyping.Prompt.Value) { UserGradingDialogEventArgs e = new UserGradingDialogEventArgs(user.Dictionary, currentCardID, UserGradingDialogEventArgs.GradingDialogKind.GradeTypo); OnUserDialog(e); overrideTyping = promotetyping = e.promote; } } //final decision about promoting bool promote = correct && promotesynonyms && promotetyping; if (overrideSynonyms) promote = promotesynonyms; if (overrideTyping) promote = promotetyping; if (correct && !promote) result = AnswerResult.Almost; return promote; }
public UserInputSubmitSelfAssessmentResponseEventArgs(bool doknow, bool dontaskagain, AnswerResult result, string answer) : base() { this.doknow = doknow; this.dontaskagain = dontaskagain; this.result = result; this.answer = answer; }
/// <summary> /// Plays the commentary sound. /// </summary> /// <param name="soundid">The commentary sound id: 0 -> correct, 1 -> wrong, 2 -> almost.</param> /// <param name="standalone">if set to <c>true</c>, the [standalone commentary sound gets played].</param> /// <remarks>Documented by Dev02, 2008-03-17</remarks> private void PlayCommentarySound(Dictionary dictionary, AnswerResult result, bool standalone) { if (dictionary.Settings.EnableCommentary.Value) { Side side = dictionary.CurrentQueryDirection == EQueryDirection.Question2Answer ? Side.Answer : Side.Question; ECommentarySoundType type; switch (result) { case AnswerResult.Correct: type = standalone ? ECommentarySoundType.RightStandAlone : ECommentarySoundType.Right; break; case AnswerResult.Wrong: type = standalone ? ECommentarySoundType.WrongStandAlone : ECommentarySoundType.Wrong; break; case AnswerResult.Almost: type = standalone ? ECommentarySoundType.AlmostStandAlone : ECommentarySoundType.Almost; break; default: return; } CommentarySoundIdentifier identifier = CommentarySoundIdentifier.Create(side, type); if (dictionary.CommentarySound.ContainsKey(identifier)) PlayMediaFile(dictionary.CommentarySound[identifier].Filename, result != AnswerResult.Correct); } }
/// <summary> /// แสดงการเล่นอนิเมชันเมื่อตอบถูก /// </summary> /// <param name="result">ผลลัพธ์ของการเล่นเกม</param> public void PlayAnswerResult(AnswerResult result) { if (result.IsCorrect == true) { _correctCount++; const int GotoQuestionTwo = 1; const int GotoQuestionThree = 2; const int GotoQuestioFour = 3; const int GotoQuestionFive = 4; const int Finish = 5; // เลื่อนกรอบคำถาม if (_correctCount < _answerRequest) nextItem(_nextQuestionRectangle); // ปิดการแสดงผลของคำถามที่ตอบถูกแล้ว switch (_correctCount) { case GotoQuestionTwo: Sb_FadeItemOne.Begin(); break; case GotoQuestionThree: Sb_FadeItemTwo.Begin(); break; case GotoQuestioFour: Sb_FadeItemThree.Begin(); break; case GotoQuestionFive: Sb_FadeItemFour.Begin(); break; case Finish: Sb_FadeAway.Begin(); resetPoint(); break; default: break; } } }