public IEnumerable <byte> ToBytes() { var bytes = new List <byte>(); bytes.AddRange(Header.ToBytes()); if (Questions != null && Questions.Any()) { bytes.AddRange(Questions.SelectMany(qu => qu.ToBytes())); } if (Answers != null && Answers.Any()) { bytes.AddRange(Answers.SelectMany(ans => ans.ToBytes())); } if (Authorities != null && Authorities.Any()) { bytes.AddRange(Authorities.SelectMany(auth => auth.ToBytes())); } if (Additionals != null && Additionals.Any()) { bytes.AddRange(Additionals.SelectMany(ads => ads.ToBytes())); } return(bytes); }
public bool IsValid() { return(!string.IsNullOrEmpty(Description) && Id != Guid.Empty && Questions != null && Questions.Any() ? Questions.All(s => s.IsValid()) : true); }
public void NextQuestion() { if (Questions.Any()) { CurrentQuestion = Questions[_rnd.Next(Questions.Count)]; Questions.Remove(_currentQuestion); } }
public async Task Startgame(SocketCommandContext context) { AcceptingNewPlayers = false; while (Questions.Any()) //If there are any questions remaining we keep playing { await AskQuestion(context); await Task.Delay(5 * 1000); } }
private void SynchronizeQuestionsCollections() { if (Questions.Any()) { Questions.Clear(); } foreach (var question in Test.Question) { Questions.Add(question); } }
public void RemoveQuestion(long questionId) { //Preconditions if (!Questions.Any(q => q.Id == questionId)) { throw new ArgumentException("There is no question with the id '" + questionId + "' in the match."); } RemoveStoredQuestionWithId(questionId); RemoveStoredAnswerSubmissionsForQuestionWithId(questionId); //Postconditions Debug.Assert(!Questions.Any(q => q.Id == questionId), "Postcondition: There should no longer be any question with a id of '" + questionId + "' in the match."); Debug.Assert(!AnswerSubmissions.Any(s => s.Question.Id == questionId), "Postcondition Fail: There should no longer be any answer submissions for questions with the id '" + questionId + "' " + "in the match."); }
public void Restart(bool regenerate) { if (regenerate) { if (Questions != null) { foreach (var q in Questions) { q.OnStateChanged -= ForwardQuestionStateChanged; } } Questions = _selector.Generate(_selectorOptions) .Select(CreateQuestion) .ToList(); foreach (var q in Questions) { q.OnStateChanged += ForwardQuestionStateChanged; } if (!Questions.Any()) { throw new GameGenerationException(); } } else { foreach (var q in Questions) { q.Clear(); } } Restart(); _pauseTimestamp = _startTimestamp = DateTime.Now; _paused = true; }
private async Task LoadQuestionsImpl() { if (Search.SelectedSite == null) { if (!await Search.LoadSites.IsExecuting.FirstAsync()) { await Search.LoadSites.Execute(); } else { await Search.LoadSites.FirstAsync(); } } if (!Questions.Any() || Search.SelectedSite.ApiSiteParameter != LoadedSite) { LoadedSite = Search.SelectedSite.ApiSiteParameter; var response = await NetworkApi.Questions(LoadedSite); var questions = response.Items.Select(q => new QuestionItemViewModel(q)).ToArray(); Questions = new ReactiveList <QuestionItemViewModel>(questions); } }
public DataContext(DbContextOptions <DataContext> options) : base(options) { if (!Questions.Any()) { Questions.Add(new QuestionModel() { //Id = 1, Name = "Reikia atlikti rangos darbus" }); Questions.Add(new QuestionModel() { //Id = 2, Name = "Rangos darbos atliks" }); Questions.Add(new QuestionModel() { //Id = 3, Name = "Verslo klientas" }); Questions.Add(new QuestionModel() { //Id = 4, Name = "Skaiciavimo budas" }); Questions.Add(new QuestionModel() { //Id = 5, Name = "Svarbus klientas" }); SaveChanges(); if (!DropDowns.Any()) { DropDowns.Add(new DropDownModel() { //Id = 1, Name = "Reikia atlikti rangos darbus", QuestionId = 1 }); DropDowns.Add(new DropDownModel() { //Id = 2, Name = "Rangos darbos atliks", QuestionId = 2 }); DropDowns.Add(new DropDownModel() { //Id = 3, Name = "Verslo klientas", QuestionId = 3 }); DropDowns.Add(new DropDownModel() { //Id = 4, Name = "Skaiciavimo budas", QuestionId = 4 }); DropDowns.Add(new DropDownModel() { //Id = 5, Name = "Svarbus klientas", QuestionId = 5 }); SaveChanges(); } if (!DropDownValues.Any()) { DropDownValues.Add(new DropDownValueModel() { //Id = 1, Name = "Paprastas klientas", DropDownId = 1 }); DropDownValues.Add(new DropDownValueModel() { //Id = 2, Name = "Svarbus klientas", DropDownId = 1 }); DropDownValues.Add(new DropDownValueModel() { //Id = 3, Name = "", DropDownId = 1 }); DropDownValues.Add(new DropDownValueModel() { //Id = 4, Name = "Rankinis", DropDownId = 2 }); DropDownValues.Add(new DropDownValueModel() { //Id = 5, Name = "Automatinis", DropDownId = 2 }); DropDownValues.Add(new DropDownValueModel() { //Id = 6, Name = "Taip", DropDownId = 3 }); DropDownValues.Add(new DropDownValueModel() { //Id = 7, Name = "Ne", DropDownId = 3 }); DropDownValues.Add(new DropDownValueModel() { //Id = 8, Name = "Kiti rangovai", DropDownId = 4 }); DropDownValues.Add(new DropDownValueModel() { //Id = 9, Name = "Mėnesio rangovas", DropDownId = 4 }); DropDownValues.Add(new DropDownValueModel() { //Id = 10, Name = "Metinis rangovas", DropDownId = 4 }); DropDownValues.Add(new DropDownValueModel() { //Id = 11, Name = "Ne", DropDownId = 5 }); DropDownValues.Add(new DropDownValueModel() { //Id = 12, Name = "Taip", DropDownId = 5 }); SaveChanges(); } } }
private void InvalidateIsEmpty() { Empty = !Questions.Any(questInfo => questInfo.Price > -1); }
/*****************************************************************************/ /// 結果計算 /*****************************************************************************/ public void CalcAnswers() { EvalVal = InspectModel.Score; EvalRank = InspectModel.Rank; HasAnyBlank = Questions.Any(x => x.Answer == AnswerValType.None); }
public void SetUpQuiz() { if (!Questions.Any()) { // 1. question Questions.Add(new Question("I tend to tell people what is on my mind.", "I tend to keep things to myself.", ATCEEnum.T, ATCEEnum.A)); // 2. question Questions.Add(new Question("I see myself as cool and guarded with others.", "I see myself as warm and friendly with others.", ATCEEnum.C, ATCEEnum.E)); // 3. question Questions.Add(new Question("I tend to show my emotions to others.", "I tend to keep my emotions inside.", ATCEEnum.E, ATCEEnum.C)); // 4. question Questions.Add(new Question("I see myself as fast-paced.", "I see myself as slow-paced.", ATCEEnum.T, ATCEEnum.A)); // 5. question Questions.Add(new Question("I see myself as a risk taker in most situations.", "I view myself as one who avoids or minimises risk in most situations.", ATCEEnum.T, ATCEEnum.A)); // 6. question Questions.Add(new Question("I see myself as playful and fun-loving.", "I see myself as serious and thoughtful.", ATCEEnum.E, ATCEEnum.C)); // 7. question Questions.Add(new Question("I tend to wait for others to initiate interactions with me.", "I tend to initiate interactions.", ATCEEnum.A, ATCEEnum.T)); // 8. question Questions.Add(new Question("I tend to talk in terms of opinions.", "I tend to talk in terms of facts.", ATCEEnum.E, ATCEEnum.C)); // 9. question Questions.Add(new Question("I tend to like to work with others.", "I tend to like to work alone.", ATCEEnum.E, ATCEEnum.C)); // 10. question Questions.Add(new Question("I tend to take charge of a situation.", "I tend to remain in the background.", ATCEEnum.T, ATCEEnum.A)); // 11. question Questions.Add(new Question("I see myself as open and direct.", "I see myself as quiet and moderate.", ATCEEnum.T, ATCEEnum.A)); // 12. question Questions.Add(new Question("I tend to focus on the outcome or results.", "I tend to focus on the process or the method.", ATCEEnum.T, ATCEEnum.A)); // 13. question Questions.Add(new Question("I tend to be more interested in how people feel.", "I tend to be more interested in what people think.", ATCEEnum.E, ATCEEnum.C)); // 14. question Questions.Add(new Question("I tend to be casual and informal in my dealings with others.", "I tend to be businesslike and formal in my dealings with people.", ATCEEnum.E, ATCEEnum.C)); // 15. question Questions.Add(new Question("I tend to avoid personal involvement with people.", "I tend to deal with people in a more personal way.", ATCEEnum.C, ATCEEnum.E)); // 16. question Questions.Add(new Question("I tend to confront conflict head-on.", "I tend to avoid conflict and confrontation.", ATCEEnum.T, ATCEEnum.A)); // 17. question Questions.Add(new Question("I tend to get inpatient with others.", "I see myself as patient with others.", ATCEEnum.T, ATCEEnum.A)); // 18. question Questions.Add(new Question("I tend to have a lot of interaction with others.", "I tend to have limited interaction with others.", ATCEEnum.E, ATCEEnum.C)); // 19. question Questions.Add(new Question("I tend to be more task orientated.", "I tend to be more relationship orientated.", ATCEEnum.C, ATCEEnum.E)); // 20. question Questions.Add(new Question("I tend to be standoffish and aloof with others.", "I tend to be open and disclosing with others.", ATCEEnum.C, ATCEEnum.E)); // 21. question Questions.Add(new Question("I see myself as more competitive with others.", "I see myself as more cooperative in dealing with others.", ATCEEnum.T, ATCEEnum.A)); // 22. question Questions.Add(new Question("I see myself as more reserved in dealing with others.", "I see myself as more forceful with other people.", ATCEEnum.A, ATCEEnum.T)); // 23. question Questions.Add(new Question("I tend to be indifferent to the feelings of others.", "I tend to get involved with the feelings of others.", ATCEEnum.C, ATCEEnum.E)); // 24. question Questions.Add(new Question("I tend to make quick decisions.", "I tend to take longer in making decisions.", ATCEEnum.T, ATCEEnum.A)); // 25. question Questions.Add(new Question("I see myself as easygoing and tolerant.", "I see myself as requiring of myself and others.", ATCEEnum.E, ATCEEnum.C)); // 26. question Questions.Add(new Question("I tend to follow the lead of others.", "I tend to direct the actions of others.", ATCEEnum.A, ATCEEnum.T)); // 27. question Questions.Add(new Question("I tend to be a cautious and measured communicator.", "I tend to be an impulsive and dramatic communicator.", ATCEEnum.C, ATCEEnum.E)); // 28. question Questions.Add(new Question("I tend to keep my opinions and thoughts to myself.", "I tend to readily share my opinions and ideas.", ATCEEnum.A, ATCEEnum.T)); // 29. question Questions.Add(new Question("I tend to want to do things my way when I work with others.", "I tend to be accepting when I work with other people.", ATCEEnum.T, ATCEEnum.A)); // 30. question Questions.Add(new Question("I tend to share my personal feelings with others.", "I tend to keep my personal feelings to myself.", ATCEEnum.E, ATCEEnum.C)); } }