public void OnItemClick(QuestionItem item) { if (item.isTrue) { //回答正确 提示正确 面板关闭 继续 GameTools.FadeUI(rightPrompt, false, 0.2f, oneCallback: () => { GameTools.WaitDoSomeThing(this, 1f, () => { rightPrompt.gameObject.SetActive(false); }); }); SetPlaneState(false); // lanternRiddles.OnQuestionItemClick(true); OnQuestionItemClick.Invoke(true); } else { InitQusetion(); //回答错误 提示错误 面板关闭 重新开始 GameTools.FadeUI(errorPrompt, false, 0.2f, oneCallback: () => { GameTools.WaitDoSomeThing(this, 1f, () => { errorPrompt.gameObject.SetActive(false); }); }); SetPlaneState(false); //lanternRiddles.OnQuestionItemClick(false); OnQuestionItemClick.Invoke(false); } }
// handle question public async Task <IActionResult> Question(string question) { var decodedQuestion = ""; try { var decodedQuestionBytes = Convert.FromBase64String(question); decodedQuestion = Encoding.UTF8.GetString(decodedQuestionBytes); } catch (Exception) { // not base 64 => Use incoming queestion decodedQuestion = question; } var answer = GetAnswers.GetAnswer(decodedQuestion); var added = DateTime.Now; var ip = "0.0.0.0"; var newQuestion = new QuestionItem { QuestionBase64 = question, Question = decodedQuestion, Answer = answer, Added = added, Ip = ip }; newQuestion = _questionRepository.AddQuestion(newQuestion); _hub.Clients.All.newQuestion(newQuestion); return(await Task.Run(() => Content(answer))); }
public async Task <ActionResult <QuestionItem> > PostQuestionItem(QuestionItem questionItem) { _context.QuestionItems.Add(questionItem); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetQuestionItem), new { id = questionItem.Id }, questionItem)); }
/// <summary> /// Handles the Click event of the AddQuestionBtn control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> protected void AddQuestionBtn_Click(object sender, EventArgs e) { // Determine the TypeOption string TypeOption; if (RdBtnRadio.Checked) { TypeOption = "RD"; } else { TypeOption = "CH"; } // new question go to the end of the list QuestionItem t = new QuestionItem(); t.QuestionName = txtNewQuestion.Text; t.QuestionID = -1; t.QuestionOrder = 999; portalQuestion.Add(t); // write tab to database SurveyDB NewQuestion = new SurveyDB(); t.QuestionID = NewQuestion.AddQuestion(ModuleID, t.QuestionName, t.QuestionOrder, TypeOption); // Reset the order numbers for the tabs within the list OrderQuestions(); // Redirect to edit page Response.Redirect(Request.RawUrl); }
private void LoadItem(int itemId) { var group = APIMASH_StackExchangeCollection.GetGroupByTitle("All"); Item = APIMASH_StackExchangeCollection.GetItem(itemId); DisplayName = ""; }
public async Task <Result> Handle(DeleteTestItemCommand command, CancellationToken cancellationToken) { Test test = uow.Tests.GetByIdWithTestItems(command.TestId); if (test == null) { return(Result.NotFound()); } if (test.OwnerId != command.UserId) { return(Result.Unauthorized()); } QuestionItem item = test.Questions.FirstOrDefault(x => x.QuestionItemId == command.TestItemId); if (item == null) { return(Result.NotFound()); } test.RemoveQuestion(item); await uow.Save(); return(Result.Ok()); }
/// <summary> /// 问卷视图呈现 /// </summary> /// <param name="Id"></param> private void RendSurveryView(string Id) { IList <QuestionItem> Ents = QuestionItem.FindAllByProperties(0, QuestionItem.Prop_SortIndex, QuestionItem.Prop_SurveyId, Id); if (Ents.Count > 0) { StringBuilder Stb = new StringBuilder(); for (int i = 0; i < Ents.Count; i++) { StringBuilder SubStb = new StringBuilder(); IList <QuestionAnswerItem> qiEnts = QuestionAnswerItem.FindAllByProperties(0, QuestionAnswerItem.Prop_SortIndex, QuestionAnswerItem.Prop_SurveyId, Ents[i].SurveyId, QuestionAnswerItem.Prop_QuestionItemId, Ents[i].SubItemId); //SubItemId //IList<QuestionAnswerItem> qiEnts = QuestionAnswerItem.FindAllByProperties(0, QuestionAnswerItem.Prop_SortIndex, QuestionAnswerItem.Prop_QuestionItemId, Ents[i].SubItemId); //SubItemId for (int k = 0; k < qiEnts.Count; k++) { if (k > 0) { SubStb.Append(","); } SubStb.Append(JsonHelper.GetJsonString(qiEnts[k])); } Ents[i].SubItems = "[" + SubStb.ToString() + "]"; if (i > 0) { Stb.Append(","); } Stb.Append(JsonHelper.GetJsonString(Ents[i])); } this.PageState.Add("ItemList", "[" + Stb.ToString() + "]"); } if (SqEnt != null) { this.PageState.Add("Survey", SqEnt); } }
private void ReSetImgIds() { string SubItemId = RequestData.Get("SubItemId") + ""; var Ent = QuestionItem.FindFirstByProperties(QuestionItem.Prop_SubItemId, SubItemId); this.PageState.Add("ImgIds", Ent.ImgIds + "[]" + Ent.Ext1); }
private async Task HandleSubmit(QuestionItem model) { ResponseModelBase response; if (string.IsNullOrEmpty(model.Id)) { response = await _questionService.CreateQuestion(model); } else { response = await _questionService.UpdateQuestion(model.Id, model); } if (response.isSuccessful) { ModalForm.HideModal(); await Filter(); if (string.IsNullOrEmpty(model.Id)) { toastService.ShowSuccess("Assessment added successfully"); } else { toastService.ShowSuccess("Assessment updated successfully"); } } else { toastService.ShowError(response.message); } }
public async Task <IActionResult> PutQuestionItem([FromRoute] int id, [FromBody] QuestionItem questionItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != questionItem.ID) { return(BadRequest()); } _context.Entry(questionItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!QuestionItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void RendSurveryView(string Id) { IList <QuestionItem> qcEnts = QuestionItem.FindAllByProperties(0, QuestionItem.Prop_SortIndex, QuestionItem.Prop_SurveyId, Id); if (qcEnts.Count > 0) { StringBuilder Stb = new StringBuilder(); for (int i = 0; i < qcEnts.Count; i++) { StringBuilder SubStb = new StringBuilder(); IList <QuestionAnswerItem> qiEnts = QuestionAnswerItem.FindAllByProperties(0, QuestionAnswerItem.Prop_SortIndex, QuestionAnswerItem.Prop_QuestionItemId, qcEnts[i].SubItemId); for (int k = 0; k < qiEnts.Count; k++) { if (k > 0) { SubStb.Append(","); } SubStb.Append(JsonHelper.GetJsonString(qiEnts[k])); } qcEnts[i].SubItems = "[" + SubStb.ToString() + "]"; if (i > 0) { Stb.Append(","); } Stb.Append(JsonHelper.GetJsonString(qcEnts[i])); } this.PageState.Add("ItemList", "[" + Stb.ToString() + "]"); } string sql = @"select * from FL_Culture..SurveyQuestion where Id='{0}' "; this.PageState.Add("Survey", DataHelper.QueryDictList(string.Format(sql, Id))); }
protected void Page_Load(object sender, EventArgs e) { SurveyId = RequestData.Get <string>("id") + ""; switch (this.RequestAction) { case RequestActionEnum.Update: DoSave(); break; case RequestActionEnum.Delete: ent = this.GetTargetData <SurveyQuestion>(); ent.DoDelete(); return; default: if (RequestActionString == "GetId") { QuestionItem qItem = new QuestionItem(); qItem.SubItemId = Guid.NewGuid().ToString(); qItem.DoCreate(); this.PageState.Add("SubItemId", qItem.Id + "|" + qItem.SubItemId); } else if (RequestActionString == "Close") { DoClose(); } else { DoSelect(); } break; } }
public ActionResult DeleteConfirmed(int id) { QuestionItem questionItem = db.QuestionItems.Find(id); db.QuestionItems.Remove(questionItem); db.SaveChanges(); return(RedirectToAction("Index")); }
private void DoSelect() { if (!string.IsNullOrEmpty(QuestionContentId)) { IList <QuestionItem> items = QuestionItem.FindAllByProperty(QuestionItem.Prop_QuestionContentId, QuestionContentId); this.PageState.Add("DataList", items); } }
/// <summary> /// Get a web control instance of the question row /// and adds it with its options to the table /// </summary> private void AddQuestionWebControl(Table questionTable, QuestionData.QuestionsRow question) { QuestionItem questionWebControl = QuestionItemFactory.Create(question, LanguagesDropdownlist.SelectedValue, this.UniqueID, 0, null, true, true); // Set question's style // and bind the data Style questionStyle = new Style(); questionStyle.CssClass = "surveyQuestion"; Style answerStyle = new Style(); answerStyle.CssClass = "surveyAnswer"; //Style markStyle = new Style(); //markStyle.CssClass = "icon-warning-sign"; if (questionWebControl is ActiveQuestion) { ((ActiveQuestion)questionWebControl).EnableClientSideValidation = false; ((ActiveQuestion)questionWebControl).EnableServerSideValidation = false; ((ActiveQuestion)questionWebControl).ValidationMarkStyle.CssClass = "icon-warning-sign"; //GB } if (questionWebControl is SectionQuestion) { ((SectionQuestion)questionWebControl).SectionOptionStyle.CssClass = "questionOptions"; ((SectionQuestion)questionWebControl).ValidationMarkStyle.CssClass = "icon-warning-sign"; //GB } if (questionWebControl is MatrixQuestion) { ((MatrixQuestion)questionWebControl).MatrixHeaderStyle = answerStyle; ((MatrixQuestion)questionWebControl).MatrixItemStyle = answerStyle; ((MatrixQuestion)questionWebControl).MatrixAlternatingItemStyle = answerStyle; ((MatrixQuestion)questionWebControl).ValidationMarkStyle.CssClass = "icon-warning-sign"; //GB } questionWebControl.RenderMode = ControlRenderMode.ReadOnly; questionWebControl.AnswerStyle = answerStyle; questionWebControl.QuestionStyle = questionStyle; questions.Add(questionWebControl); // Add the question and its options to the table questionTable.Rows.Add(BuildQuestionOptionsRow(question)); if (questionWebControl is MatrixQuestion) { // questionWebControl.Width = new Unit(400.0,UnitType.Pixel); questionTable.Rows.Add(BuildRow(questionWebControl)); } else { questionTable.Rows.Add(BuildRow(questionWebControl)); } }
public void ClosePanel() { currentQuestion = null; questionPanel.transform.localPosition = panelTopStart; SoundManager.ChoosePlayMusic(0); gameObject.SetActive(false); }
public void CheckAnswer_CorrectAnswer_ReturnsTrue() { QuestionItem item = new QuestionItem { Question = "1", Answer = "42" }; QuestionState state = BuildQuestionState(item); bool result = state.CheckAnswer("42"); Assert.IsTrue(result); }
public void TryGetQuestion_NoQuestions_ReturnFalse() { QueueQuestionRepository provider = new QueueQuestionRepository(); QuestionItem question = null; var result = provider.TryGetQuestion(ref question); Assert.IsFalse(result); }
private static QuestionItemDTO ItemToDTO(QuestionItem questionItem) => new QuestionItemDTO { Id = questionItem.Id, Question = questionItem.Question, Options = questionItem.Options, CorrectQuestion = questionItem.CorrectQuestion, KnowMore = questionItem.KnowMore, };
public void IsQuestionAnswered_NoAnswer_ReturnsFalse() { QuestionItem item = new QuestionItem { Question = "1", Answer = "42" }; QuestionState state = BuildQuestionState(item); bool result = state.HasQuestionBeenAnswered; Assert.IsFalse(result); }
public void CheckAnswer_WrongAnswer_ReturnsFalse() { QuestionItem item = new QuestionItem { Question="1", Answer="42"}; QuestionState state = BuildQuestionState(item); bool result = state.CheckAnswer("incorect answer"); Assert.IsFalse(result); }
private async Task PostNewQuestion(IDialogContext context) { try { string conversationId = context.MakeMessage().Conversation.Id; byte level = context.ConversationData.GetValueOrDefault <byte>(KEY_LEVEL); Trace.TraceInformation($"PostNewQuestion: conversation: {conversationId}; level: {level}"); QuestionItem newQuestion = await _questionData.GetRandomQuestion(conversationId, (QuestionComplexity)level); Trace.TraceInformation($"PostNewQuestion: {newQuestion.Id}, {newQuestion.Question}, {newQuestion.Answer}"); if (newQuestion != null) { newQuestion.InitUrls("https://db.chgk.info/images/db/"); context.ConversationData.SetValue(KEY, newQuestion); IMessageActivity message = context.MakeMessage(); message.Id = newQuestion.Id.ToString(); CardAction answerAction = new CardAction() { Title = "Answer", Type = "imBack", Value = "answer" }; message.Text = $"**Question:**<br/>{newQuestion.Question}<br/><br/>" + $"**Author:** {newQuestion.Authors ?? "Unknkown"}<br/>" + $"**Tour:** {newQuestion.TournamentTitle ?? "Unknkown"}"; message.Attachments = newQuestion.QuestionImageUrls.Select(ToAttachement).ToList(); message.SuggestedActions = new SuggestedActions { Actions = new List <CardAction> { answerAction } }; await context.PostAsync(message); } else { await context.SayAsync("I'm sorry there are no more questions for you. Please, try to set another level :-("); } } catch (Exception ex) { Trace.TraceError("Exception in PostNewQuestion", ex); await context.SayAsync("I'm sorry - something wrong has happened."); } }
public void PoseAQuestion_OneQuestion_OnePost() { QuestionItem questionItem = new QuestionItem { Question = "Name", Answer = "Alex" }; IChatApi chatapi = new StubChatApi(); QuizComunicator comunicator = new QuizComunicator(chatapi); comunicator.PoseAQuestion(questionItem); Assert.AreEqual(1, chatapi.PostCount); }
public void CheckAnswer_WrongAnswer_ReturnsFalse() { QuestionItem item = new QuestionItem { Question = "1", Answer = "42" }; QuestionState state = BuildQuestionState(item); bool result = state.CheckAnswer("incorect answer"); Assert.IsFalse(result); }
// 查询签到用户调查问题回答信息 public static int getUserAnswerList(out List <AnswerItem> list, int user_id) { list = null; try { if (listQuestions == null) { DbSelect.getQuestionList(out listQuestions, null); } using (SqlConnection conn = ConnectDb()) { Dictionary <String, String[]> conditions = new Dictionary <String, String[]>(); conditions.Add("UserID", new String[] { new Operator(OperatorTypeEnum.Equal), user_id.ToString() }); SqlParameter[] pms; String sql = String.Format(sql_GetUserAnswerList, getUserAnswerItemFilter(conditions, out pms)); SqlCommand cmd = new SqlCommand(sql, conn); if (pms != null) { cmd.Parameters.AddRange(pms); } SqlDataReader dr = cmd.ExecuteReader(); list = new List <AnswerItem>(); while (dr.Read()) { int q_id = (int)dr["QuestionID"]; int ans_id = (int)dr["AnswerID"]; QuestionItem ques = listQuestions.Find((QuestionItem q) => { return(q.ID == q_id); }); if (ques == null) { AnswerItem answer = new AnswerItem(); list.Add(answer); } else { AnswerItem answer = ques.Answers.Find((AnswerItem ans) => { return(ans.ID == ans_id); }); list.Add(answer); } } dr.Close(); dr.Dispose(); } } catch (Exception ex) { throw new Exception(String.Format("查询签到用户调查问题回答信息时出错:{0}", ex.Message)); } return(OK); }
public ActionResult Edit([Bind(Include = "Id,QuestionId,Title")] QuestionItem questionItem) { if (ModelState.IsValid) { db.Entry(questionItem).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.QuestionId = new SelectList(db.Questions, "Id", "Id", questionItem.QuestionId); return(View(questionItem)); }
public ActionResult SaveItem(QuestionItem questionItem) { if (ModelState.IsValid) { db.QuestionItems.AddOrUpdate(questionItem); //db.Entry(post).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(questionItem)); }
private void DoSelect() { if (!string.IsNullOrEmpty(SurveyId)) { var Ent = SurveyQuestion.Find(SurveyId); if (string.IsNullOrEmpty(Ent.TemplateId)) { string sql = @"select * from FL_Culture..QuestionItem where SurveyId='{0}' order by SortIndex "; sql = string.Format(sql, SurveyId); this.PageState.Add("DataList", DataHelper.QueryDictList(sql)); } else { //判断是否合并过 string SQL = "select * from FL_Culture..QuestionItem where SurveyId='{0}' "; SQL = string.Format(SQL, SurveyId); var Ents = DataHelper.QueryDictList(SQL); if (Ents.Count > 0) { string sql = @"select * from FL_Culture..QuestionItem where SurveyId='{0}' order by SortIndex "; sql = string.Format(sql, SurveyId); this.PageState.Add("DataList", DataHelper.QueryDictList(sql)); //SearchCriterion.SetOrder("SortIndex"); //IList<QuestionItem> Items = QuestionItem.FindAll(SearchCriterion, Expression.Sql(" SurveyId='" + SurveyId + "'")); //this.PageState.Add("DataList", Items); return; } //合并模板 var TemplateId = Ent.TemplateId; var ItemEnts = QuestionItem.FindAllByProperties(QuestionItem.Prop_SurveyId, TemplateId); var SubItemEnts = QuestionAnswerItem.FindAllByProperties(QuestionAnswerItem.Prop_SurveyId, TemplateId); foreach (var ent in ItemEnts) { QuestionItem Item = new QuestionItem(); Item = ent; Item.SurveyId = SurveyId; Item.DoCreate(); } foreach (var subEnt in SubItemEnts) { QuestionAnswerItem subItem = new QuestionAnswerItem(); subItem = subEnt; subItem.SurveyId = SurveyId; subItem.DoCreate(); } SearchCriterion.SetOrder("SortIndex"); IList <QuestionItem> items = QuestionItem.FindAll(SearchCriterion, Expression.Sql(" SurveyId='" + SurveyId + "'")); this.PageState.Add("DataList", items); } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> private void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { // Set the ImageUrl for controls from current Theme upBtn.ImageUrl = CurrentTheme.GetImage("Buttons_Up", "Up.gif").ImageUrl; downBtn.ImageUrl = CurrentTheme.GetImage("Buttons_Down", "Down.gif").ImageUrl; editBtn.ImageUrl = CurrentTheme.GetImage("Buttons_Edit", "Edit.gif").ImageUrl; deleteBtn.ImageUrl = CurrentTheme.GetImage("Buttons_Delete", "Delete.gif").ImageUrl; } //********************************************************* // Checks whether the survey exist, if not it creates one //********************************************************* SurveyDB SurveyCheck = new SurveyDB(); // puts the desc of Survey in the title lblDescSurvey.Text = SurveyCheck.ExistAddSurvey(ModuleID, PortalSettings.CurrentUser.Identity.Email); //TBD: Create a sproc that gets these fields: //CreatedBy.Text = (string) dr["CreatedByUser"]; //CreatedDate.Text = ((DateTime) dr["CreatedDate"]).ToShortDateString(); // Fill the Question Listbox SurveyDB QuestionList = new SurveyDB(); SqlDataReader QList = QuestionList.GetQuestionList(ModuleID); try { while (QList.Read()) { QuestionItem t = new QuestionItem(); t.QuestionName = QList["Question"].ToString(); t.QuestionID = (int)QList["QuestionID"]; t.QuestionOrder = (int)QList["ViewOrder"]; t.TypeOption = QList["TypeOption"].ToString(); portalQuestion.Add(t); } } finally { QList.Close(); //by Manu, fixed bug 807858 } // if ( this is the first visit to the page, bind the tab data to the page listbox if (Page.IsPostBack == false) { this.QuestionList.DataTextField = "QuestionName"; this.QuestionList.DataValueField = "QuestionID"; this.QuestionList.DataSource = portalQuestion; this.QuestionList.DataBind(); } }
//导入模板 private void ImpTpl() { if (!string.IsNullOrEmpty(id)) { string TemplateId = RequestData.Get("TemplateId") + ""; SurveyQuestion TemplateEnt = SurveyQuestion.TryFind(TemplateId); //问卷模板 SurveyQuestion Ent = SurveyQuestion.Find(id); if (string.IsNullOrEmpty(Ent.Description) && TemplateEnt != null) //描述 { Ent.Description = TemplateEnt.Description; } Ent.TemplateId = TemplateId; Ent.DoUpdate(); string SurveyId = id; int SortIndex = 1; string sql = "select count(1) T from FL_Culture..QuestionItem where SurveyId='{0}' "; sql = string.Format(sql, SurveyId); object obj = DataHelper.QueryValue(sql); if (obj != null) { SortIndex += int.Parse(obj.ToString()); } //合并模板 var ItemEnts = QuestionItem.FindAllByProperties(0, QuestionItem.Prop_SortIndex, QuestionItem.Prop_SurveyId, TemplateId); var SubItemEnts = QuestionAnswerItem.FindAllByProperties(QuestionAnswerItem.Prop_SurveyId, TemplateId); foreach (var ents in ItemEnts) { QuestionItem Item = new QuestionItem(); Item = ents; Item.SurveyId = SurveyId; Item.SortIndex = SortIndex; Item.Ext2 = "imp"; //导入标志 imp Item.DoCreate(); SortIndex++; } foreach (var subEnt in SubItemEnts) { QuestionAnswerItem subItem = new QuestionAnswerItem(); subItem = subEnt; subItem.SurveyId = SurveyId; subItem.Ext1 = "imp"; subItem.DoCreate(); } IList <QuestionItem> items = QuestionItem.FindAll(Expression.Sql(" SurveyId='" + SurveyId + "' order by SortIndex ")); this.PageState.Add("QItem", items); } }
private IEnumerator WaitUserSelect() { questionItem = DialogueManager.Instance.Question(question); questionItem.AddClick_SelectA(SelectA); questionItem.AddClick_SelectB(SelectB); questionItem.AddClick_Close(Close); while (!isClick) { yield return(null); } }
//******************************************************* // // The EditBtn_Click server event handler is used to edit // the selected question // //******************************************************* /// <summary> /// Handles the Click event of the EditBtn control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.Web.UI.ImageClickEventArgs"/> instance containing the event data.</param> protected void EditBtn_Click(object sender, ImageClickEventArgs e) { // Redirect to edit page of currently selected tab if (QuestionList.SelectedIndex != -1) { // Determine the QuestionID QuestionItem t = (QuestionItem)portalQuestion[QuestionList.SelectedIndex]; int tabID = int.Parse(Request.Params["tabID"]); Response.Redirect("SurveyOptionEdit.aspx?mID=" + ModuleID + "&QuestionID=" + t.QuestionID + "&Question=" + t.QuestionName + "&TypeOption=" + t.TypeOption + "&tabID=" + tabID); } }
public void OnChatMessageReceived_OneQuestionandCorrectAnswer_QuestionAnswered() { QuestionItem questionItem1 = new QuestionItem { Question = "Name1", Answer = "Alex1" }; StubChatApi chatapi = new StubChatApi(); QuizComunicator comunicator = new QuizComunicator(chatapi); comunicator.PoseAQuestion(questionItem1); ChatMessage message = new ChatMessage {Username = "******", Message = "Alex1"}; chatapi.AnswerRecived(message); Assert.IsTrue(comunicator.IsQuestionAnswered); }
public void OnChatMessageReceived_OneQuestionandIncorrectAnswer_NotifyWrongAnswer() { QuestionItem questionItem1 = new QuestionItem { Question = "Name1", Answer = "Alex1" }; StubChatApi chatapi = new StubChatApi(); QuizComunicator comunicator = new QuizComunicator(chatapi); comunicator.PoseAQuestion(questionItem1); ChatMessage message = new ChatMessage { Username = "******", Message = "SOMETHING INCORRECT" }; chatapi.AnswerRecived(message); Assert.AreEqual("Wrong Answer!", chatapi.LastMessage); }
public void TryGetQuestion_TwoQuestions_SecondQuestionReturnedSecond() { QueueQuestionRepository provider = new QueueQuestionRepository(); var q1 = new QuestionItem { Question = "1", Answer = "blah1" }; var q2 = new QuestionItem { Question = "2", Answer = "blah2" }; provider.AddQuestion(q1); provider.AddQuestion(q2); QuestionItem question1 = null; QuestionItem question2 = null; var result1 = provider.TryGetQuestion(ref question1); var result2 = provider.TryGetQuestion(ref question2); Assert.IsTrue(result2); Assert.AreEqual("2", question2.Question); Assert.AreEqual("blah2", question2.Answer); }
public static QuestionState BuildQuestionState(QuestionItem question) { return new QuestionState(question, new FuzzyAnswerMatchStrategy()); }
private QuestionState BuildQuestionState(QuestionItem question) { return new QuestionState(question, new FuzzyAnswerMatchStrategy(0)); }
public QuestionState(QuestionItem item, IAnswerMatchingStrategy matchingStrategy) { this.item = item; _matchingStrategy = matchingStrategy; }
public void AddQuestion(QuestionItem questionItem) { _questions.Value.Enqueue(questionItem); }
public bool TryGetQuestion(ref QuestionItem question) { if (!_questions.Value.Any()) return false; question = GetQuestion(); return true; }