public TestPaper(int id, string userId, int subjectId, DateTime beginTime, int testDuration, int singleCount, decimal singPer, int multiCount, decimal multiPer, int judgeCount, decimal judgePer, List <Question> questions) { if (id <= 0) { throw new ArgumentNullException(nameof(id)); } if (questions == null) { throw new ArgumentNullException(nameof(questions)); } if (questions.Count <= 0) { throw new ArgumentNullException(nameof(questions)); } Id = id; UserId = userId; SubjectId = subjectId; BeginTime = beginTime; TestDuration = testDuration; SingleCount = singleCount; SingPer = singPer; MultiCount = multiCount; MultiPer = multiPer; JudgeCount = judgeCount; JudgePer = judgePer; Questions.Clear(); Questions.AddRange(questions); }
public MySqlContext(DbContextOptions options) : base(options) { //Database.EnsureDeleted(); Database.EnsureCreated(); if (Articles.Count() == 0) { PutData data = new PutData(); Articles.AddRange(data.articles); Comments.AddRange(data.comments); SuperUsers.Add(data.super); TeacherUsers.AddRange(data.teacher); StudentUsers.AddRange(data.studentUser); TestStudents.AddRange(data.testStudents); QuestionAnswers.AddRange(data.questionAnswers); Tests.AddRange(data.tests); Themes.AddRange(data.themes); TestThemes.AddRange(data.TestThemas); Questions.AddRange(data.questions1); Questions.AddRange(data.questions2); Questions.AddRange(data.questions3); Marks.AddRange(data.Marks1); Marks.AddRange(data.Marks2); EventProfileUsers.AddRange(data.EventProfileUsers); Meetups.AddRange(data.Meetups); Speakers.AddRange(data.Speakers); SaveChanges(); } }
public CardData(int id, string image, IEnumerable <QuestionData> questions) : this() { Id = id; Image = image; Questions.AddRange(questions); }
public CardData(CardData data) : this() { Id = data.Id; Image = data.Image; Instance = data.Instance; Questions.AddRange(data.Questions); }
private void UpdateQuestions(QuestionList questionList) { foreach (var question in questionList.items) { question.title = WebUtility.HtmlDecode(question.title); } using (Questions.SuppressChangeNotifications()) { Questions.Clear(); Questions.AddRange(questionList.items); } }
public IActionResult GetGameData([FromBody] List <QuestionModel> Questions) { var data = new List <QuestionModel>(); //Null object can be received on initial application load if (Questions == null) { Questions = new List <QuestionModel>(); try { using (var questionDb = new QuestionsDb()) { data = questionDb.Questions.OrderByDescending(c => c.creation_date).Take(25).ToList(); } } catch { } } else { //Determine last question on the DOM, order did change when object was passed from the angular controller var lastQuestionCreated = Questions.LastOrDefault(); int lastCreationDate = 0; if (lastQuestionCreated != null) { lastCreationDate = lastQuestionCreated.creation_date; try { //Get 25 more questions that are older than the last question from the array using (var questionDb = new QuestionsDb()) { data = questionDb.Questions.Where(c => c.creation_date < lastCreationDate).OrderByDescending(c => c.creation_date).Take(25).ToList(); } } catch { } } } try { //Get coorisponding answers to questions grabbed to be returned using (var answersDb = new AnswersDb()) { foreach (var question in data) { question.answers = answersDb.Answers.Where(c => c.question_id == question.question_id).OrderBy(c => Guid.NewGuid()).ToList(); } } } catch { } //Add data to Questions received from the angular controller in preparation of returning the entire list Questions.AddRange(data); return(Json(Questions)); }
async Task ExecuteRefreshCommandAsync() { var result = await StoreManager.QuestionsService.GetQuestionsAsync(position, pageIndex, pageSize); if (result.Success) { var questions = JsonConvert.DeserializeObject <List <Questions> >(result.Message.ToString()); if (questions.Count > 0) { if (pageIndex == 1 && Questions.Count > 0) { Questions.Clear(); } Questions.AddRange(questions); if (position != 4) { await SqliteUtil.Current.UpdateQuestions(questions); } pageIndex++; if (Questions.Count >= pageSize) { LoadStatus = LoadMoreStatus.StausDefault; CanLoadMore = true; } else { LoadStatus = LoadMoreStatus.StausEnd; CanLoadMore = false; } } else { CanLoadMore = false; LoadStatus = pageIndex > 1 ? LoadMoreStatus.StausEnd : LoadMoreStatus.StausNodata; } } else { Crashes.TrackError(new Exception() { Source = result.Message }); LoadStatus = pageIndex > 1 ? LoadMoreStatus.StausError : LoadMoreStatus.StausFail; } }
async Task ExecuteRefreshCommandAsync() { var result = await StoreManager.QuestionsService.GetQuestionsAsync(position, pageIndex, pageSize); if (result.Success) { var questions = JsonConvert.DeserializeObject <List <Questions> >(result.Message.ToString()); if (questions.Count > 0) { if (pageIndex == 1 && Questions.Count > 0) { Questions.Clear(); } Questions.AddRange(questions); pageIndex++; if (Questions.Count >= pageSize) { LoadStatus = LoadMoreStatus.StausDefault; CanLoadMore = true; } else { LoadStatus = LoadMoreStatus.StausEnd; CanLoadMore = false; } } else { CanLoadMore = false; LoadStatus = pageIndex > 1 ? LoadMoreStatus.StausEnd : LoadMoreStatus.StausNodata; } } else { Log.SendLog("QuestionsViewModel.GetQuestionsAsync:" + result.Message); LoadStatus = pageIndex > 1 ? LoadMoreStatus.StausError : LoadMoreStatus.StausFail; } }
public async void GetClientQuestionsAsync() { Questions.AddRange(await SqliteUtil.Current.QueryQuestionsByType(position, pageSize)); }
private void SeedData() { Answer a1 = new Answer() { Text = "List" }; Answer a2 = new Answer() { Text = "ArrayList" }; Answer a3 = new Answer() { Text = "Enum" }; Answer a4 = new Answer() { Text = "True" }; Answer a5 = new Answer() { Text = "False" }; Answer a6 = new Answer() { Text = "Top-most element of the Stack can be " + "accessed using the Peek() method" }; Answer a7 = new Answer() { Text = "It is used to maintain a FIFO list" }; Answers.AddRange(a1, a2, a3, a4, a5, a6, a7); SaveChanges(); TestQuestion q1 = new TestQuestion() { AnswerId = a3.Id, Answers = new List <Answer>() { a1, a2, a3 }, Text = "What is NOT a collection?" }; TestQuestion q2 = new TestQuestion() { AnswerId = a4.Id, Answers = new List <Answer>() { a4, a5 }, Text = "In a HashTable Key cannot be null, but Value can be." }; TestQuestion q3 = new TestQuestion() { AnswerId = a6.Id, Answers = new List <Answer>() { a6, a7 }, Text = "Which of the following statements are correct about the Stack?" }; Questions.AddRange(q1, q2, q3); SaveChanges(); Theme th1 = new Theme() { Title = "Collections" }; Themes.Add(th1); SaveChanges(); Test t1 = new Test() { Description = "Test about collections", StartDate = DateTime.Now, Deadline = DateTime.Now.AddDays(30), MaxRate = 100, MinRatingForPass = 80, Questions = new List <TestQuestion>() { q1, q2, q3 }, Theme = th1, Title = "Collections Test" }; Tests.Add(t1); SaveChanges(); }