public void Update(int id, [FromBody] TestQuestionModel value) { var existingTestQuestion = testQuestions.Find(id); if (existingTestQuestion != null) { existingTestQuestion.CorrectAnswerId = value.CorrectAnswerId; existingTestQuestion.Statement = value.Statement; db.SaveChanges(); } }
void setQuestionData(TestQuestionModel testQuestionCommonModel) { var testQuestionModel = testQuestionCommonModel.Question; if (testQuestionModel != null) { Question = testQuestionModel.Title; Description = $"<head><meta charset=\"utf-8\">" + $"<font size=\"5\" " + $"color=\"{Theme.Current.TestPassingQuestionColor}\">" + $"{testQuestionModel.Description}" + $"</font>"; _questionNumber = testQuestionCommonModel.Number; _questionType = testQuestionModel.QuestionType; setAnswers(testQuestionModel.Answers); } }
/// <summary> /// Displays the next question. /// </summary> /// <returns>True if there are questions left, false otherwise</returns> private bool DisplayNextQuestion() { var questions = test.Questions; if (questions.Count > 0) { currentQuestion = questions[0]; lblQuestion.Text = currentQuestion.Statement; var questionAnswers = answers.Where(a => a.QuestionId == currentQuestion.Id).ToList(); lbAnswers.Top = lblQuestion.Top + lblQuestion.Height + 10; lbAnswers.DataSource = questionAnswers; lbAnswers.SelectedIndex = -1; return(true); } return(false); }
public void SetUp() { //Initializaing Mappings DtoMappings.Initialize(); //Initializing Data TestShoutBoxMessage = new ShoutBoxMessageModel { Author = "test", Message = "test", ShoutBoxId = 1, TimePosted = new DateTime(2010, 10, 10, 10, 10, 10) }; TestShoutBoxMessage1 = new ShoutBoxMessageModel { Author = "test", Message = "testLatest", ShoutBoxId = 1, TimePosted = new DateTime(2011, 10, 10, 10, 10, 10) }; TestQuestionAnswer = new TestQuestionAnswer { Correct = true, NumberSelected = 0, Text = "test" }; TestQuestion = new TestQuestionModel { QuestionText = "test question", QuestionLabel = "test", Answers = new List <TestQuestionAnswer> { TestQuestionAnswer } }; TestTestType = new TestTypeModel { TypeName = "test" }; TestPofile = new ProfileModel { LoginName = "test", Email = "*****@*****.**", IsActive = true }; TestTest = new TestModel { Author = TestPofile, CreationDate = new DateTime(2010, 1, 1), Name = "test", TestType = TestTestType }; LatestTest = new TestModel { Author = TestPofile, CreationDate = new DateTime(2011, 1, 1), Name = "test", TestType = TestTestType }; TestCourseType = new CourseTypeModel { TypeName = "Fizyka" }; TestCourseType1 = new CourseTypeModel { TypeName = "Matematyka" }; TestGroupType = new GroupTypeModel { TypeName = "test" }; TestGroupType1 = new GroupTypeModel { TypeName = "test1" }; TestGroup = new GroupModel { GroupType = TestGroupType, GroupName = "test" }; TestForum = new ForumModel { Author = "test", Name = "test" }; TestShoutBox = new ShoutboxModel(); TestShoutBox.Messages.Add(TestShoutBoxMessage); TestShoutBox.Messages.Add(TestShoutBoxMessage1); TestSurvey = new SurveyModel { SurveyText = "Smiga chodzi fruwa ?", DateCreated = new DateTime(2010, 1, 1) }; TestLatestSurvey = new SurveyModel { SurveyText = "Smiga chodzi fruwa ?", DateCreated = new DateTime(2011, 1, 1) }; TestCourse2 = new CourseModel { CourseType = TestCourseType1, ShoutBox = TestShoutBox, Forum = TestForum, Group = TestGroup, CreationDate = DateTime.Now, Description = "test1", Logo = "/test1.jpg", Name = "test1", Password = "******" }; TestCourse3 = new CourseModel { CourseType = TestCourseType1, ShoutBox = TestShoutBox, Forum = TestForum, Group = TestGroup, CreationDate = DateTime.Now, Description = "test1", Logo = "/test1.jpg", Name = "test1", Password = null }; TestContentType = new ContentTypeModel { TypeName = "test" }; TestContent = new ContentModel { ContentUrl = "test", CreationDate = DateTime.Now, DownloadNumber = 0, Name = "test", Text = "test", Type = TestContentType }; TestJournalMark = new JournalMarkModel { Name = "Zaliczenie", Value = "5" }; TestJournal = new JournalModel { Course = TestCourse3, Marks = new List <JournalMarkModel> { TestJournalMark }, Name = "test journal" }; FileModel = new FileModel { FileName = "test", Address = "test" }; SectionModel = new SectionModel { IconName = "test", Text = "test", Title = "tset" }; LearningMaterialModel = new LearningMaterialModel { Level = 1, CreationDate = DateTime.Now, Description = "test", Goals = "test", Summary = "test", UpdateDate = DateTime.Now, VersionNumber = "111", Tests = new List <TestModel> { TestTest }, Files = new List <FileModel> { FileModel }, Sections = new List <SectionModel> { SectionModel } }; TestCourse1 = new CourseModel { CourseType = TestCourseType, ShoutBox = TestShoutBox, Forum = TestForum, Group = TestGroup, CreationDate = DateTime.Now, Description = "test", Logo = "/test.jpg", Name = "test", Password = "******", LearningMaterials = new List <LearningMaterialModel> { LearningMaterialModel } }; using (var session = DataAccess.OpenSession()) { session.Save(TestPofile); session.Save(TestShoutBoxMessage); session.Save(TestShoutBoxMessage1); session.Save(TestCourseType); session.Save(TestGroupType); session.Save(TestGroupType1); session.Save(TestGroup); session.Save(TestForum); session.Save(TestShoutBox); session.Save(TestCourseType1); session.Save(TestSurvey); session.Save(TestLatestSurvey); session.Save(TestTestType); session.Save(TestTest); session.Save(LatestTest); session.Save(TestCourse1); session.Save(TestCourse2); session.Save(TestQuestionAnswer); session.Save(TestQuestion); session.Save(TestCourse3); session.Save(TestJournalMark); session.Save(TestJournal); session.Save(TestContentType); session.Save(TestContent); session.Save(FileModel); session.Save(SectionModel); session.Save(LearningMaterialModel); session.Flush(); } }
public static TestQuestion TestQuestionModelToTestQuestion(TestQuestionModel value) { return(new TestQuestion { Id = value.Id, Statement = value.Statement, CorrectAnswerId = value.CorrectAnswerId }); }
public void Add([FromBody] TestQuestionModel value) { testQuestions.Add(TestQuestionConverter.TestQuestionModelToTestQuestion(value)); db.SaveChanges(); }