public void SelectEditStudentExplanationTest() { this.SchoolNet().LoadWebPage(); AnswerChoice answerChoice = new AnswerChoice(ItemType.TrueFalse, "T", 0, "ctl01"); answerChoice.SelectEditStudentExplanation(); }
public void SelectHotSpotTest() { this.SchoolNet().LoadWebPage(); AnswerChoice answerChoice = new AnswerChoice(ItemType.HotSpotSingleSelection, "A", 0, "ctl01"); answerChoice.SelectHotSpot(); }
public void SelectLabelTest() { this.SchoolNet().LoadWebPage(); AnswerChoice answerChoice = new AnswerChoice(ItemType.TrueFalse, "T", 0, "ctl01"); answerChoice.SelectLabel(); }
public void SelectContentAddTest() { this.SchoolNet().LoadWebPage(); AnswerChoice answerChoice = new AnswerChoice(ItemType.TrueFalse, "A", 0, "ctl01"); answerChoice.SelectContentAdd(); }
public void EditLabelTest() { this.SchoolNet().LoadWebPage(); AnswerChoice answerChoice = new AnswerChoice(ItemType.MultipleChoice, "A", 0, "ctl01"); answerChoice.EditLabel("B"); }
public void SelectContentEditTest() { this.SchoolNet().LoadWebPage(); AnswerChoice answerChoice = new AnswerChoice(ItemType.MultipleChoice, "A", 0, "ctl01"); answerChoice.SelectContentEdit(); }
public IHttpActionResult PutAnswerChoice(int id, AnswerChoice answerChoice) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != answerChoice.ID) { return(BadRequest()); } db.Entry(answerChoice).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AnswerChoiceExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Checks question correctness /// </summary> /// <param name="question">a question object</param> /// <returns>true or false depending on the answer</returns> private bool checkQuestion(TealUnity.Question question) { if (question.GetType() == typeof(MCQuestion)) { string[] answer_choices = { "AnswerChoice1", "AnswerChoice2", "AnswerChoice3", "AnswerChoice4" }; AnswerChoice[] answers = new AnswerChoice[4]; for (int i = 0; i < answers.Length; i++) { bool toggle = GameObject.Find(answer_choices[i]).GetComponentInChildren <Toggle>().isOn; AnswerChoice answer = new AnswerChoice("Answer", toggle); answers[i] = answer; } return(((MCQuestion)question).checkCorrectness(answers)); } else if (question.GetType() == typeof(InputQuestion <string>)) { string answer = GameObject.Find("AnswerField").GetComponent <InputField>().text; return(((InputQuestion <string>)question).checkCorrectness(answer)); } else if (question.GetType() == typeof(InputQuestion <float>)) { try { float answer = float.Parse(GameObject.Find("AnswerField").GetComponent <InputField>().text); return(((InputQuestion <float>)question).checkCorrectness(answer)); } catch (FormatException) { return(false); } } return(false); }
private void SetUniqueControlIdentifiers() { //get a hash of the answer choice's: label and unique control identifier using WebDriver.FindElements(By.ClassName) UniqueControlIdentifiers = GetUniqueControlIdentifiers(ByAnswerLabels); //get the list of answer labels var keyList = new List <string>(); foreach (var key in UniqueControlIdentifiers.Keys) { keyList.Add(key); } AnswerChoiceList = new List <AnswerChoice>(); //for each element in the hash foreach (var key in UniqueControlIdentifiers.Keys) { //is the key numeric? int index; bool isNumeric = int.TryParse(key, out index); if (isNumeric == false) { //get a numeric zero based index based on the letter of the answer label index = this.GetIndexByAlphabet(key, keyList); //get the unique control identifier string uniqueId = UniqueControlIdentifiers[key]; Report.Write("Unique control identifier by key: " + key + "; index: " + index + "; ID: " + uniqueId); //create an answer choice object var answerChoice = new AnswerChoice(ItemType.MultipleChoice, key, index, uniqueId, ControlPrefix); //add the answer choice object to the collection (A, B, C, D) AnswerChoiceList.Add(answerChoice); } } }
// // GET: /AnswerChoice/Edit/5 public ActionResult Edit(int id) { AnswerChoice answerchoice = db.AnswerChoices.Find(id); ViewBag.QuestionId = new SelectList(db.Questions, "QuestionId", "QuestionText", answerchoice.QuestionId); return(View(answerchoice)); }
public void RemoveLineTest() { this.SchoolNet().LoadWebPage(); AnswerChoice answerChoice = new AnswerChoice(ItemType.TrueFalse, "T", 0, "ctl01"); answerChoice.RemoveLine(); }
/// <summary> /// Sets an answer choice at the given index. /// </summary> /// <param name="answer_choice">The answer choice</param> /// <param name="index">The index where the answer choice is to be inserted. /// The index should be between 0 and 3.</param> public void setAnswerChoise(AnswerChoice answer_choice, int index) { if (index >= 0 && index <= 3) { this.answer_choices[index] = answer_choice; } }
public void EditContentTest() { this.SchoolNet().LoadWebPage(); AnswerChoice answerChoice = new AnswerChoice(ItemType.MultipleChoice, "A", 0, "ctl01"); string expected = "my test"; answerChoice.EditContent(expected); }
public ActionResult DeleteConfirmed(int id) { AnswerChoice answerchoice = db.AnswerChoices.Find(id); db.AnswerChoices.Remove(answerchoice); db.SaveChanges(); return(RedirectToAction("Index")); }
public void GetPointsPossibleTest() { this.SchoolNet().LoadWebPage(); AnswerChoice answerChoice = new AnswerChoice(ItemType.TrueFalse, "T", 0, "ctl01"); string expected = "1"; string actual = answerChoice.GetPointsPossible(expected); Assert.AreEqual(expected, actual); }
public void GetContentTest() { this.SchoolNet().LoadWebPage(); AnswerChoice answerChoice = new AnswerChoice(ItemType.MultipleChoice, "A", 0, "ctl01"); string expected = "my test"; string actual = answerChoice.GetContent(expected); Assert.AreEqual(expected, actual); }
public void UnCheckIsCorrectResponseTest() { this.SchoolNet().LoadWebPage(); AnswerChoice answerChoice = new AnswerChoice(ItemType.TrueFalse, "T", 0, "ctl01"); answerChoice.UnCheckIsCorrectResponse(); Assert.AreEqual(true, answerChoice.AnswerLineItem.IsCorrectResponse.Selected); Assert.AreEqual(false, answerChoice.IsCorrectAnswer); }
public void ShouldGetAAnswerChoiceByTheId() { var expectedAnswerChoice = new AnswerChoice(); this.answerChoiceRepository.Setup(repo => repo.GetAnswerChoiceById(this.expectedId)).Returns(expectedAnswerChoice); var response = this.answerChoicesController.Get(this.expectedId) as JsonResult; Assert.Same(expectedAnswerChoice, response.Value); }
public void AnswerChoiceTest() { this.SchoolNet().LoadWebPage(); AnswerChoice answerChoice = new AnswerChoice(ItemType.TrueFalse, "T", 0, "ctl01"); Assert.AreEqual(ItemType.TrueFalse, answerChoice.ItemType); Assert.AreEqual("T", answerChoice.Label); Assert.AreEqual(0, answerChoice.Index); Assert.AreEqual("ctl01", answerChoice.UniqueId); }
public void ByHotSpotTest() { this.SchoolNet().LoadWebPage(); int index = 0; string uniqueId = "ctl01"; AnswerChoice form = new AnswerChoice(ItemType.HotSpotSingleSelection, "A", index, uniqueId); Assert.AreEqual("By.CssSelector: #tblAnswers tbody[ng-repeat='answer in TestItem.Answers']:nth-of-type(" + index + ") button.btn", form.ByHotSpot().ToString(), "ByHotSpotTest locator matches"); }
public void EditPointsPossibleTest() { this.SchoolNet().LoadWebPage(); AnswerChoice answerChoice = new AnswerChoice(ItemType.TrueFalse, "T", 0, "ctl01"); answerChoice.EditPointsPossible("1"); Assert.AreEqual(1, answerChoice.PointValue); answerChoice.EditPointsPossible(2); Assert.AreEqual(2, answerChoice.PointValue); }
public void ShouldUpdateAAnswerChoice() { var expectedAnswerChoiceToBeUpdated = new AnswerChoice(); this.answerChoiceRepository.Setup(repo => repo.UpdateAnswerChoice(this.expectedId, expectedAnswerChoiceToBeUpdated)).Returns(new AnswerChoice()); var actualResponse = this.answerChoicesController.Put(this.expectedId, expectedAnswerChoiceToBeUpdated); Assert.IsType <NoContentResult>(actualResponse); }
public DomainModelResponse Add(QuestionnaireAddRequest request) { Questionnaire Questionnaire = new Questionnaire(); Questionnaire.QuestionnaireCode = request.QuestionnaireCode; Questionnaire.IsATemplate = request.IsATemplate; Questionnaire.LastChangedTime = DateTime.UtcNow; StringBuilder qIds = new StringBuilder(); if (request.QuestionIds != null) { foreach (int i in request.QuestionIds) { qIds.Append(i.ToString()); qIds.Append(","); } qIds.Remove(qIds.Length - 1, 1); } if (request.Questions != null) { List <QuestionType> questionTypes = _repQuestionType.Get().ToList(); foreach (var q in request.Questions) { EntityModel.Question eQ = new EntityModel.Question() { QuestionText = q.questionText, LastChangedTime = DateTime.UtcNow, QuestionType = questionTypes.Where(x => x.Type.Equals(q.questionType, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(), QuestionTypeId = questionTypes.Where(x => x.Type.Equals(q.questionType, StringComparison.OrdinalIgnoreCase)).FirstOrDefault().QuestionTypeId, Priority = q.Priority.ToString() }; _repQuestion.Add(eQ); _uow.Commit(); eQ = _repQuestion.Get(filter: f => f.QuestionText == q.questionText).FirstOrDefault(); qIds.Append(eQ.QuestionId.ToString()); qIds.Append(","); foreach (var ans in q.answerChoices) { AnswerChoice ac = new AnswerChoice() { Answer = ans, Question = eQ, QuestionId = eQ.QuestionId }; _repAnswerChoice.Add(ac); } } qIds.Remove(qIds.Length - 1, 1); } Questionnaire.QuestionSet = qIds.ToString(); _repQuestionnaire.Add(Questionnaire); _uow.Commit(); _questionnaireResponse.addResponse("Add", MessageCodes.InfoCreatedSuccessfully, "questionnaire : " + request.QuestionnaireCode); return(_questionnaireResponse); }
public ActionResult Edit(AnswerChoice answerchoice) { if (ModelState.IsValid) { db.Entry(answerchoice).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.QuestionId = new SelectList(db.Questions, "QuestionId", "QuestionText", answerchoice.QuestionId); return(View(answerchoice)); }
public IActionResult Put(int id, AnswerChoice answerChoice) { var updatedAnswerChoice = this.answerChoiceRepository.UpdateAnswerChoice(id, answerChoice); if (updatedAnswerChoice == null) { return(this.NotFound()); } return(this.NoContent()); }
public IHttpActionResult GetAnswerChoice(int id) { AnswerChoice answerChoice = db.AnswerChoice.Find(id); if (answerChoice == null) { return(NotFound()); } return(Ok(answerChoice)); }
public ActionResult Create(AnswerChoice answerchoice) { if (ModelState.IsValid) { db.AnswerChoices.Add(answerchoice); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.QuestionId = new SelectList(db.Questions, "QuestionId", "QuestionText", answerchoice.QuestionId); return(View(answerchoice)); }
public IHttpActionResult PostAnswerChoice(AnswerChoice answerChoice) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.AnswerChoice.Add(answerChoice); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = answerChoice.ID }, answerChoice)); }
public IHttpActionResult DeleteAnswerChoice(int id) { AnswerChoice answerChoice = db.AnswerChoice.Find(id); if (answerChoice == null) { return(NotFound()); } db.AnswerChoice.Remove(answerChoice); db.SaveChanges(); return(Ok(answerChoice)); }
// GET: AnswerChoices/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AnswerChoice answerChoice = db.AnswerChoices.Find(id); if (answerChoice == null) { return(HttpNotFound()); } return(View(answerChoice)); }