public byte[] GetBytes() { byte[] bytes = new byte[0]; var ans = Header.GetBytes(); ans = ans.Concat(Question.GetBytes()); ans = ans.Concat(Answers.Aggregate(bytes, (localBytes, answer) => localBytes.Concat(answer.GetBytes()).ToArray())); return(ans.ToArray()); }
public async Task StartPoll() { started = DateTime.Now; NadekoBot.Client.MessageReceived += Vote; var msgToSend = $"📃**{originalMessage.Author.Username}** has created a poll which requires your attention:\n\n**{question}**\n"; var num = 1; msgToSend = Answers.Aggregate(msgToSend, (current, answ) => current + $"`{num++}.` **{answ}**\n"); if (!IsPublic) { msgToSend += "\n**Private Message me with the corresponding number of the answer.**"; } else { msgToSend += "\n**Send a Message here with the corresponding number of the answer.**"; } await originalMessage.Channel.SendConfirmAsync(msgToSend).ConfigureAwait(false); }
/// <summary> /// Generates a TSV table based on the results of the test. /// </summary> /// <param name="stuff">An array containing information to identify that /// patient. Will contain the test's id, the patient's id, the score and the /// results as calculated by Scalemate based on the test design.</param> /// <returns>The raw TSV table.</returns> private string GenerateTSV(string[] stuff) { string outlet = ""; if (SurveyAnswers == null) { outlet = stuff.Aggregate("", (box, it) => box + it + "\t") + Answers.Aggregate("\r\n", (box, it) => box + it + "\t"); } else { outlet = stuff.Aggregate("", (box, it) => box + it + "\t") + SurveyAnswers.Aggregate("\r\n", (box, it) => box + it + "\t") + Answers.Aggregate("\r\n", (box, it) => box + it + "\t"); } return(outlet); }
public async Task <IActionResult> OnGetAsync(int id) { GameSession = await gameSessionRepository.GetGameSessionAsync(id); if (GameSession == null) { return(NotFound()); } Answers = await gameSessionRepository.GetGameSessionQuestionsAndAnswersAsync(id); Duration = GameSession.EndTime - GameSession.StartTime; Score = Answers.Aggregate(0, (accumulator, answer) => answer.Choice.IsCorrect ? accumulator + (int)answer.Choice.Question.Difficulty + 1 : accumulator); Total = Answers.Aggregate(0, (accumulator, answer) => accumulator + (int)answer.Choice.Question.Difficulty + 1); return(Page()); }
public string AnswersToString() { return(Answers.Aggregate("", (current, question) => current + (question + "\n"))); }