public void DeleteQuestionTest_Default() { QuestionTable.SaveQuestion(defaultQuestion); int res = QuestionTable.DeleteQuestion(defaultQuestion); Assert.AreEqual(res, 1); }
public ActionResult PostQuestion(MultiModel obj) { if (Session["id"] != null) { List <LangTable> list = db.LangTables.ToList(); ViewBag.langList = new SelectList(list, "LangId", "LangName"); QuestionTable tableModel = new QuestionTable(); tableModel.UserId = (int)Session["id"]; if (obj.QuestionModel.LangId != null) { tableModel.LangId = (int)obj.QuestionModel.LangId; } tableModel.QuestionTitle = obj.QuestionModel.QuestionTitle; tableModel.QuestionDesc = obj.QuestionModel.QuestionDesc; db.QuestionTables.Add(tableModel); db.SaveChanges(); ModelState.Clear(); Response.Write("<script>alert('Your question has been successfully posted')</script>"); } else { Response.Write("<script>alert('You must log in to post question')</script>"); return(RedirectToAction("Index")); } return(View(obj)); }
public void GetQuestionIdTest_Exists() { QuestionTable.SaveQuestion(defaultQuestion); long res = QuestionTable.GetQuestionId(defaultQuestion); Assert.AreNotEqual(-1, res); }
void ReleaseDesignerOutlets() { if (DoneButton != null) { DoneButton.Dispose(); DoneButton = null; } if (MainView != null) { MainView.Dispose(); MainView = null; } if (QuestionTable != null) { QuestionTable.Dispose(); QuestionTable = null; } if (SectionInfoLabel != null) { SectionInfoLabel.Dispose(); SectionInfoLabel = null; } if (SkipButton != null) { SkipButton.Dispose(); SkipButton = null; } }
void ReleaseDesignerOutlets() { if (MainView != null) { MainView.Dispose(); MainView = null; } if (ParticipantIdEntry != null) { ParticipantIdEntry.Dispose(); ParticipantIdEntry = null; } if (ParticipantNameEntry != null) { ParticipantNameEntry.Dispose(); ParticipantNameEntry = null; } if (QuestionTable != null) { QuestionTable.Dispose(); QuestionTable = null; } if (WeightEntry != null) { WeightEntry.Dispose(); WeightEntry = null; } }
public void TestExamResult() { int userId = 1; QuestionAnswer answer1 = new QuestionAnswer("Ostrava", true); QuestionAnswer answer2 = new QuestionAnswer("Praha", false); Question question = QuestionTable.InsertQuestion(this.connection, userId, "test", "closed", new List <QuestionAnswer>() { answer1, answer2 }); Exam exam = ExamTable.InsertExam(this.connection, userId, "test exam", 10, 1, 1, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(1)); exam.AddQuestion(question.Id, 20); ExamTable.UpdateExam(this.connection, exam); int examResultId = ExamResultTable.InsertExamResult(this.connection, exam.Id, userId); ExamResult examResult = ExamResultTable.GetExamResultById(this.connection, examResultId); Assert.AreEqual(examResultId, examResult.Id); Assert.AreEqual(userId, examResult.OwnerId); Assert.AreEqual("created", examResult.State); ExamAnswer answer = new ExamAnswer(question.Id, "Ostrava"); Assert.IsTrue(ExamResultTable.HandInExamResult(this.connection, examResult, new List <ExamAnswer>() { answer })); examResult = ExamResultTable.GetExamResultById(this.connection, examResult.Id); Assert.AreEqual("finished", examResult.State); Assert.AreEqual(exam.Questions[0].Points, examResult.Points); }
public void Initialize() { new DataBaseOperations(); DataBaseOperations.ConnectToDB(); s_connection = DataBaseOperations.Connection; QT = new QuestionTable("TableName"); }
public bool updateRecord([PexAssumeUnderTest] QuestionTable target, object record) { bool result = target.updateRecord(record); return(result); // TODO: add assertions to method QuestionTableTest.updateRecord(QuestionTable, Object) }
public bool createTable([PexAssumeUnderTest] QuestionTable target) { bool result = target.createTable(); return(result); // TODO: add assertions to method QuestionTableTest.createTable(QuestionTable) }
//Removes the related question from the current feedback form protected void DeleteButton_Click(object sender, EventArgs e) { LinkButton delButton = sender as LinkButton; string dID = delButton.ID; string qID = "Q" + dID.Substring(1, dID.Length - 1); string rID = "R" + dID.Substring(1, dID.Length - 1); TableRow qRow = QuestionTable.FindControl(rID) as TableRow; Label qLabel = qRow.FindControl(qID) as Label; string question = qLabel.Text.Substring(22, qLabel.Text.Length - 27); title = Title_Textbox.Text; qRow.Visible = false; using (var _db = new MPAS.Models.ApplicationDbContext()) { _db.Database.ExecuteSqlCommand("DELETE FROM Feedback WHERE Question = @p0 AND Role = @p1 AND Title = @p2", question, role, title); } //Enables the Question textbox and Add button if the maximum amount of questions had been reached before the deletion if (DatabaseUtilities.CountFeedback(role, title) == 9) { Question_Textbox.Enabled = true; Add_Button.Enabled = true; Question_Textbox.Text = ""; } }
public ActionResult DeleteConfirmed(long id) { QuestionTable questionTable = db.QuestionTables.Find(id); db.QuestionTables.Remove(questionTable); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: QuestionTables/Create public ActionResult Create() { //for defult date QuestionTable questionTable = new QuestionTable(); questionTable.Date = DateTime.Now.Date; return(View(questionTable)); }
public QuizzViewModel(Category category, int questionNumber = 10) { SelectedCategory = category; _loader = new QuestionTable(questionNumber); _loader.LoadQuestionsByCategory(SelectedCategory.Id); statistic = new QuizzStats(); this.NextQuestion(); }
public void GetQuestionIdTest_DoesNotExist() { QuestionTable.SaveQuestion(defaultQuestion); QuestionTable.DeleteQuestion(defaultQuestion); long res = QuestionTable.GetQuestionId(defaultQuestion); Assert.AreEqual(-1, res); }
void StartLearning() { var result = _learningService.SetupAndGetFirstQuestion(_questions); _currentState = StatesTypeEnum.Answer; _currentQuestion = result.NextQuestion; _status = result.Status; SetDialog(); }
// again clicked private void Button3_Click(object sender, EventArgs e) { var result = _learningService.ProcessResultAndGetNextQuestion(_currentQuestion, QuestionResult.Again); _currentQuestion = result.NextQuestion; _status = result.Status; _currentState = StatesTypeEnum.Answer; SetDialog(); }
public void SaveQuestionTest_FreeTextType() { Question question = new Question("Free Type", new string[] { "A;B;C;D" }); question.IsFreeText = true; int res = QuestionTable.SaveQuestion(question); QuestionTable.DeleteQuestion(question); Assert.AreEqual(res, 1); }
public ActionResult Edit([Bind(Include = "QusID,Date,Question,Type,Subject,Image,Tag")] QuestionTable questionTable) { if (ModelState.IsValid) { db.Entry(questionTable).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(questionTable)); }
private void InitDatabase() { DatabaseCreator.CreateQuizzDatabase(StringResources.DbFile); var demo = new Category("Demo"); var question = new Question("Demo question", new string[] { "Correct answer", "Alternative 1", "Alternative 2", "Alternative 3" }); var textQuestion = new Question("This is text question", new string[] { "Accepted answer;separate;correct;answers;by;semicolon" }); textQuestion.IsFreeText = true; QuestionTable.SaveQuestion(textQuestion); CategoryQuestionTable.AddCategoryQuestion(demo, question); }
public void createTable68() { using (PexTraceListenerContext.Create()) { QuestionTable questionTable; bool b; questionTable = new QuestionTable(); b = this.createTable((DBTable)questionTable); Assert.AreEqual <bool>(false, b); } }
public ActionResult Create([Bind(Include = "QusID,Date,Question,Type,Subject,Image,Tag")] QuestionTable questionTable) { if (ModelState.IsValid) { db.QuestionTables.Add(questionTable); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(questionTable)); }
public void TestRetrieveNumberOfColsInTableMethodShouldReturnIntNotNUll() { //Arrange var sut = new QuestionTable("TableName"); //Act int numberReturned = sut.RetriveNumberOfColsInTable(); //Assert Assert.IsNotNull(numberReturned); }
/// <summary> /// Constructs a TriviaAdministration object with database and question types as instance fields through use of interfaces /// </summary> /// <param name="questionPackName">The question object</param> /// <param name="database">The database object related to questions</param> public QuestionPack(String questionPackName, int pointValue) { //constructs the QuestionPack this.QuestionPackName = questionPackName; this.PointValue = pointValue; Database = new QuestionTable(questionPackName); //populates the List<Questions> for this QuestionPack this.QuestionPackQuestions = new List <IQuestion>(); PopulateListFromTable(); }
public ActionResult AddQuestion(AddQuestionViewModel addQuestionViewModel) { using (var context = new surveyEntities()) { QuestionTable questionTable = new QuestionTable(); questionTable.Question = addQuestionViewModel.Question; questionTable.Survey_ID = addQuestionViewModel.Survey_ID; context.QuestionTables.Add(questionTable); context.SaveChanges(); } return(View()); }
public void updateRecord616() { QuestionTable questionTable; bool b; questionTable = new QuestionTable(); b = this.updateRecord(questionTable, (object)null); Assert.AreEqual <bool>(false, b); Assert.IsNotNull((object)questionTable); Assert.AreEqual <string> ("Record is not QuestionData type", ((DBTable)questionTable).errorMessage); }
public void SaveQuestionTest_Modify() { string temp = defaultQuestion.QuestionText; QuestionTable.SaveQuestion(defaultQuestion); defaultQuestion.QuestionText = "MODIFIED QUESTION"; int res = QuestionTable.SaveQuestion(defaultQuestion); defaultQuestion.QuestionText = temp; Assert.AreEqual(res, 1); }
public void SaveQuestionTest_Modify2() { string temp = defaultQuestion.QuestionText; QuestionTable.SaveQuestion(defaultQuestion); defaultQuestion.QuestionText = "MODIFIED QUESTION"; QuestionTable.SaveQuestion(defaultQuestion); long id = QuestionTable.GetQuestionId(defaultQuestion); defaultQuestion.QuestionText = temp; Assert.AreNotEqual(id, -1); }
public void TestTableExistsMethodToSeeIfAKnownTableExists() { // Arrange var sut = new QuestionTable("TableName"); // Act bool tableExists = sut.TableExists(sut.TableName); bool expected = true; bool actual = tableExists; //Assert Assert.AreEqual(expected, actual); }
public void createTable230() { using (PexTraceListenerContext.Create()) { QuestionTable questionTable; bool b; questionTable = new QuestionTable(); b = this.createTable(questionTable); Assert.AreEqual <bool>(false, b); Assert.IsNotNull((object)questionTable); Assert.AreEqual <string>("Failed to open database connection", ((DBTable)questionTable).errorMessage); } }
// GET: QuestionTables/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } QuestionTable questionTable = db.QuestionTables.Find(id); if (questionTable == null) { return(HttpNotFound()); } return(View(questionTable)); }