public virtual void RequestAddAnswer(int _QuestionID, string _AnswerString) { int index = GetAQuestionIndexByID(_QuestionID); if (-1 == index) { return; } QuestionAndAnswers target = this.m_Questions[index]; bool isNewAnswer = true; for (int i = 0; i < target.m_Answers.Count; ++i) { if (target.m_Answers[i].AnswerString == _AnswerString) { isNewAnswer = false; target.m_Answers[i].Count += 1; } } if (isNewAnswer) { target.m_Answers.Add(new AnswerChoice(_AnswerString, 1)); } Debug.Log("RequestAddAnswer()"); target.m_Answers.Sort(); }
public IHttpActionResult PutQuestionAndAnswers(int id, QuestionAndAnswers questionAndAnswers) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != questionAndAnswers.QuestionAndAnswersId) { return(BadRequest()); } db.Entry(questionAndAnswers).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!QuestionAndAnswersExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void LoadQuestionsFromFile() { string[] lines = TextFile.File.ReadAllLines(@"F:\EliteExamples\EliteCareerHubExamples\InterviewQuetions.txt"); foreach (string ln in lines) { QuestionAndAnswers qa = new QuestionAndAnswers(); string[] values = ln.Split("?"); qa.Question = values[0]; string[] options = values[1].Split(","); qa.Options = options.ToList(); qa.Answer = values[2]; originalQandAns.Add(qa); } foreach (QuestionAndAnswers ln in originalQandAns) { Assignment qa = new Assignment(); qa.Question = ln.Question; qa.Options = ln.Options; qa.Answer = ln.Answer; subQandA.Add(qa); } }
public ActionResult DeleteConfirmed(int id) { QuestionAndAnswers questionAndAnswers = db.QuestionAndAnswers.Find(id); db.QuestionAndAnswers.Remove(questionAndAnswers); db.SaveChanges(); return(RedirectToAction("Index")); }
private void Process_StartRequestQuestion() { if (m_Server) { m_AttackQuestion = m_Server.GetAQuestion(); m_DefendQuestion = m_Server.GetAQuestion(); } m_State = LanguageUIState.LanguageUIState_WaitRequestQuestion; }
private void UpdateQuiz(QuestionAndAnswers questionAndAnswers) { _activeQuestionAndAnswers = questionAndAnswers; QuestionText = questionAndAnswers.Question; for (int i = 0; i < 4; i++) { AnswerBoxes[i].Text = questionAndAnswers.Answers[i]; } }
private List <QuestionAndAnswers> PopulateList(TextAsset thisCSV, bool enableDebug) { List <QuestionAndAnswers> result = new List <QuestionAndAnswers>(); string[,] grid = this.SplitCSVText(thisCSV.text); int gridColumnAmount = grid.GetUpperBound(0); int gridRowAmount = grid.GetUpperBound(1); for (int currentRow = 1; currentRow < gridRowAmount; currentRow++) { QuestionAndAnswers currentQuestion = new QuestionAndAnswers(); for (int currentColumn = 0; currentColumn < gridColumnAmount; currentColumn++) { if (currentColumn == 0) { // Question case if (enableDebug) { Debug.Log("Question at column " + currentColumn + " and row " + currentRow + " \"" + grid[currentColumn, currentRow] + "\""); } currentQuestion.question = grid[currentColumn, currentRow]; } else if (currentColumn == gridColumnAmount - 1) { // Right answer case if (enableDebug) { Debug.Log("Right answer at column " + currentColumn + " and row " + currentRow + " \"" + grid[currentColumn, currentRow] + "\""); } currentQuestion.rightAnswer = grid[currentColumn, currentRow]; } else { // Wrong answers case if (enableDebug) { Debug.Log("Wrong answer at column " + currentColumn + " and row " + currentRow + " \"" + grid[currentColumn, currentRow] + "\""); } currentQuestion.wrongAnswers.Add(grid[currentColumn, currentRow]); } } result.Add(currentQuestion); } return(result); }
public IHttpActionResult GetQuestionAndAnswers(int id) { QuestionAndAnswers questionAndAnswers = db.QuestionAndAnswers.Find(id); if (questionAndAnswers == null) { return(NotFound()); } return(Ok(questionAndAnswers)); }
public IHttpActionResult PostQuestionAndAnswers(QuestionAndAnswers questionAndAnswers) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.QuestionAndAnswers.Add(questionAndAnswers); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = questionAndAnswers.QuestionAndAnswersId }, questionAndAnswers)); }
public ActionResult Edit([Bind(Include = "QuestionAndAnswersId,ProsId,Question,Answer,AreaOfExpertiseId,UserRating,UserId")] QuestionAndAnswers questionAndAnswers) { if (ModelState.IsValid) { db.Entry(questionAndAnswers).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AreaOfExpertiseId = new SelectList(db.AreaOfExpertise, "AreaOfExpertiseId", "AreaOfExpertiseName", questionAndAnswers.AreaOfExpertiseId); ViewBag.ProsId = new SelectList(db.Pros, "ProsId", "FirstName", questionAndAnswers.ProsId); return(View(questionAndAnswers)); }
public IHttpActionResult DeleteQuestionAndAnswers(int id) { QuestionAndAnswers questionAndAnswers = db.QuestionAndAnswers.Find(id); if (questionAndAnswers == null) { return(NotFound()); } db.QuestionAndAnswers.Remove(questionAndAnswers); db.SaveChanges(); return(Ok(questionAndAnswers)); }
// GET: QuestionAndAnswers/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } QuestionAndAnswers questionAndAnswers = db.QuestionAndAnswers.Find(id); if (questionAndAnswers == null) { return(HttpNotFound()); } return(View(questionAndAnswers)); }
public void StartPlayFlow() { if (this.optionButtonList.Count > 0) { for (int index = 0; index < this.optionButtonList.Count; index++) { gameObjectButtonList[index].onButtonPressed -= AfterOptionIsPressed; OnAnimationEnded -= gameObjectButtonList[index].InteractableAtEndofAnimation; Destroy(this.optionButtonList[index].gameObject); } this.optionButtonList.Clear(); this.gameObjectButtonList.Clear(); } QuestionManager.Categories targetCategory = QuestionManager.instance.GetRandomCategory(); targetQuestionCardScript = carouselBehaviour.StartSwipeToCategory(targetCategory).GetComponent <QuestionCard>(); QuestionAndAnswers targetQuestionData = QuestionManager.instance.GetRandomQuestionByCategory(targetCategory); targetQuestionCardScript.SetQuestionText(targetQuestionData.question); int RandomButton = Random.Range(0, 4); int wrongAnswerIndex = 0; for (int index = 0; index < 4; index++) { if (index == RandomButton) { OptionCard correctOptionButton = Instantiate(PrefabManager.instance.GetPrefabByName("OptionCard"), this.optionContainer).GetComponent <OptionCard>(); correctOptionButton.SetOptionCardQuestion(targetQuestionData.rightAnswer, true); this.optionButtonList.Add(correctOptionButton.GetComponent <RectTransform>()); this.gameObjectButtonList.Add(correctOptionButton); correctOptionButton.onButtonPressed += this.AfterOptionIsPressed; } else { OptionCard wrongOptionButton = Instantiate(PrefabManager.instance.GetPrefabByName("OptionCard"), this.optionContainer).GetComponent <OptionCard>(); wrongOptionButton.SetOptionCardQuestion(targetQuestionData.wrongAnswers[wrongAnswerIndex], false); this.optionButtonList.Add(wrongOptionButton.GetComponent <RectTransform>()); this.gameObjectButtonList.Add(wrongOptionButton); wrongOptionButton.onButtonPressed += this.AfterOptionIsPressed; wrongAnswerIndex++; } } }
// GET: QuestionAndAnswers/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } QuestionAndAnswers questionAndAnswers = db.QuestionAndAnswers.Find(id); if (questionAndAnswers == null) { return(HttpNotFound()); } ViewBag.AreaOfExpertiseId = new SelectList(db.AreaOfExpertise, "AreaOfExpertiseId", "AreaOfExpertiseName", questionAndAnswers.AreaOfExpertiseId); ViewBag.ProsId = new SelectList(db.Pros, "ProsId", "FirstName", questionAndAnswers.ProsId); return(View(questionAndAnswers)); }
/// <summary> /// The call to this method with the parameter to avoid repetition of the return value, /// will return a QuestionAndAnswers structure and instantaneously prevent it from repeating. /// Be sure to use each return value. /// </summary> /// <param name="category"> /// The category the category from which the random question will be selected /// </param> /// <param name="getRepeatedEnabled"> /// If is set to true, will avoid the repetition of the return value /// </param> /// <returns> /// Returns a QuestionAndAnswers structure /// </returns> public QuestionAndAnswers GetRandomQuestionByCategory(Categories category, bool getRepeatedEnabled = false) { QuestionAndAnswers result = new QuestionAndAnswers(); List <QuestionAndAnswers> currentQuestionsList = null; if (getRepeatedEnabled) { // Simple get-repeated behaviour this.questionsByCategory.TryGetValue(category, out currentQuestionsList); result = currentQuestionsList[this.questionsRandomizer.Next(currentQuestionsList.Count)]; } else { // Not so simple bloody get-unrepeated behaviour this.remainingQuestions.TryGetValue(category, out currentQuestionsList); if (currentQuestionsList != null) { if (currentQuestionsList.Count > 0) { result = currentQuestionsList[this.questionsRandomizer.Next(currentQuestionsList.Count)]; currentQuestionsList.Remove(result); } else { Debug.LogWarning("No unrepeated questions remaining. Returning repeated question"); // Simple get-repeated behaviour this.questionsByCategory.TryGetValue(category, out currentQuestionsList); result = currentQuestionsList[this.questionsRandomizer.Next(currentQuestionsList.Count)]; } } else { Debug.LogError("Null list returned"); } } return(result); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); var question = FindViewById <EditText>(Resource.Id.questionText); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button> (Resource.Id.fetchAnswerButton); button.Click += async(sender, e) => { var QnA = new QuestionAndAnswers(); JsonValue json = await AnswerHttp(question.Text); //QnA.FetchAnswer (question.Text); ParseAndDisplay(json); }; }
// GET: Questions/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var question = await _context.Question .Include(q => q.ForumMember) .FirstOrDefaultAsync(m => m.Id == id); var answers = await _context.Answer.Where(a => a.QuestionId == question.Id).Include(a => a.ForumMember).ToListAsync(); if (question == null) { return(NotFound()); } QuestionAndAnswers qa = new QuestionAndAnswers(); qa.Answers = answers; qa.Question = question; return(View(qa)); }
public QuestionAndAnswers(QuestionAndAnswers thisObj) { this.question = thisObj.question; this.wrongAnswers = thisObj.wrongAnswers; this.rightAnswer = thisObj.rightAnswer; }
private void OnCorrectlyAnswered(QuestionAndAnswers questionAndAnswers) { CorrectlyAnswered?.Invoke(this, new PointsEventArgs(questionAndAnswers.Points)); }
private void Process_StartRequestQuestion() { if( m_Server ) { m_AttackQuestion = m_Server.GetAQuestion() ; m_DefendQuestion = m_Server.GetAQuestion() ; } m_State = LanguageUIState.LanguageUIState_WaitRequestQuestion ; }