public void RemoveQuestionLine(int questionLineId) { QuestionLine questionLine = GetQuestionLine(questionLineId); context.Questions.Remove(questionLine); context.SaveChanges(); }
public void UpdateQuestionLine(QuestionLine questionLine) { QuestionLine oldQuestionLine = GetQuestionLine(questionLine.Id); oldQuestionLine.Answer = questionLine.Answer; oldQuestionLine.IsPublic = questionLine.IsPublic; context.SaveChanges(); }
void Ready() { PlaylistData data = Data.Instance.triviaData.data; foreach (PlaylistData.VideoData d in data.playlist) { QuestionLine line = Instantiate(qline); line.transform.SetParent(container); line.Init(d, OnClicked); line.transform.transform.localScale = Vector3.one; } }
public PartialViewResult UpdateQuestion(QuestionLine question) { QuestionLine refer = questionLineService.GetQuestionLine(question.Id); refer.IsPublic = question.IsPublic; refer.Answer = question.Answer; questionLineService.UpdateQuestionLine(refer); ViewBag.Message = "Изменения в вопросе были сохранены"; return(PartialView("Modal/_QuestionPartial", question)); }
public PartialViewResult AddQuestion(QuestionLine line) { ViewBag.Themes = themeService.GetThemes().Select(x => x.Description); line.Date = DateTime.Now; line.IsPublic = false; if (ModelState.IsValid) { ViewBag.SuccessMessage = "Вопрос задан"; questionLineService.AddQuestionLine(line); ModelState.Clear(); return(PartialView("_UserQuestionForm")); } return(PartialView("_UserQuestionForm", line)); }
private QuestionObject CreateQuestionObject() { List <Alternative> alternatives = new List <Alternative>(); foreach (string alternative in AlternativeTexts) { alternatives.Add(new Alternative { Text = alternative }); } alternatives.RemoveAt(0); List <QuestionLine> questionLines = new List <QuestionLine>(); foreach (GameObject questionLine in QuestionLineList) { Dropdown correctAlternativeDropdown = questionLine.transform.GetChild(1).GetComponent <Dropdown>(); QuestionLine ql = new QuestionLine { Text = questionLine.transform.GetChild(0).GetComponent <InputField>().text }; //print(correctAlternativeDropdown.value + " : " + alternatives[correctAlternativeDropdown.value].Text); if (correctAlternativeDropdown.value == 0) { ql.CorrectAlternative = null; } else { ql.CorrectAlternative = alternatives[correctAlternativeDropdown.value - 1]; } questionLines.Add(ql); } QuestionObject qObj = new QuestionObject { Alternatives = alternatives, QuestionLines = questionLines }; return(qObj); }
public void AddQuestionLine(QuestionLine questionLine) { context.Questions.Add(questionLine); context.SaveChanges(); }
public PartialViewResult GetAnswer(int questionId) { QuestionLine question = questionLineService.GetQuestionLine(questionId); return(PartialView("Modal/_QuestionPartial", question)); }
public void UpdateQuestionLine(QuestionLine questionLine) { questionLineRepository.UpdateQuestionLine(questionLine); }
public void AddQuestionLine(QuestionLine questionLine) { questionLineRepository.AddQuestionLine(questionLine); }
private void LoadQuestions(string filename) { string file = "Assets/Resources/Quiz/" + filename; string line; StreamReader r = new StreamReader(file); using (r) { do { line = r.ReadLine(); if (line != null) { try { string[] line_values = SplitCsvLine(line); QuestionLine line_entry = new QuestionLine(); line_entry.setQuestion(line_values[0]); if (line_values.Length == 3) { List <string> tempAns1 = getShapeResults(line_values[1]); line_entry.setAnswer1(tempAns1.ElementAt(0)); tempAns1.RemoveAt(0); line_entry.charactersForAns1 = tempAns1; List <string> tempAns2 = getShapeResults(line_values[2]); line_entry.setAnswer2(tempAns2.ElementAt(0)); tempAns2.RemoveAt(0); line_entry.charactersForAns2 = tempAns2; line_entry.setNumAnswers(2); } else if (line_values.Length == 4) { List <string> tempAns1 = getShapeResults(line_values[1]); line_entry.setAnswer1(tempAns1.ElementAt(0)); tempAns1.RemoveAt(0); line_entry.charactersForAns1 = tempAns1; List <string> tempAns2 = getShapeResults(line_values[2]); line_entry.setAnswer2(tempAns2.ElementAt(0)); tempAns2.RemoveAt(0); line_entry.charactersForAns2 = tempAns2; List <string> tempAns3 = getShapeResults(line_values[3]); line_entry.setAnswer3(tempAns3.ElementAt(0)); tempAns3.RemoveAt(0); line_entry.charactersForAns3 = tempAns3; line_entry.setNumAnswers(3); } else if (line_values.Length == 5) { List <string> tempAns1 = getShapeResults(line_values[1]); line_entry.setAnswer1(tempAns1.ElementAt(0)); tempAns1.RemoveAt(0); line_entry.charactersForAns1 = tempAns1; List <string> tempAns2 = getShapeResults(line_values[2]); line_entry.setAnswer2(tempAns2.ElementAt(0)); tempAns2.RemoveAt(0); line_entry.charactersForAns2 = tempAns2; List <string> tempAns3 = getShapeResults(line_values[3]); line_entry.setAnswer3(tempAns3.ElementAt(0)); tempAns3.RemoveAt(0); line_entry.charactersForAns3 = tempAns3; List <string> tempAns4 = getShapeResults(line_values[4]); line_entry.setAnswer4(tempAns4.ElementAt(0)); tempAns4.RemoveAt(0); line_entry.charactersForAns4 = tempAns4; line_entry.setNumAnswers(4); } lines.Add(line_entry); } catch (Exception e) { Debug.Log("ERROR in dialogue line number " + (lines.Count)); } } } while (line != null); r.Close(); } }
public static string CreateQuestionData(string researchIdName) { StringBuilder sb = new StringBuilder(); GoocaBoocaDataModels.GoocaBoocaDataBase gb = new GoocaBoocaDataBase(); var research = gb.GetResearch(researchIdName); sb.AppendLine("Key\tText\tType\tAnswers"); List<QuestionLine> list = new List<QuestionLine>(); foreach (var item in research.Questiones.Where(n => n.IsActive == true)) { QuestionLine ql = new QuestionLine() { Key = "q_" + item.QuestionId.ToString(), Text = item.QuestionText, Type = "順序" }; if (item.QuestionType == "FreeText") { ql.Type = "文字列"; } foreach (var questionChoices in item.QuestionChoices.Where(n => n.IsActive == true)) { ql.AddAnswer(questionChoices.QuestionChoiceId.ToString(), questionChoices.QuestionChoiceText); } list.Add(ql); } foreach (var item in research.ItemCategory.Where(n => n.IsActive == true)) { QuestionLine ql = new QuestionLine() { Key = "c_" + item.ItemCategoryId.ToString(), Text = item.ItemCategoryName, Type = "数値" }; int cc = (research.AnswerCount / research.ItemCategory.Where(n => n.IsActive).Count()); for (int i = 0; i < cc + 1; i++) { ql.AddAnswer(i.ToString(), i.ToString()); } list.Add(ql); } foreach (var itemCategory in research.ItemCategory.Where(n => n.IsActive)) { foreach (var item in itemCategory.Items) { QuestionLine ql = new QuestionLine() { Key = "i_" + item.ItemId.ToString(), Text = item.Category.ItemCategoryName + ":" + item.ItemName + "{" + research.Tag + item.ItemName + "}", Type = "数値" }; list.Add(ql); //foreach (var itemAnswerChoice in research.ItemAnswerChoice.Where(n => n.IsActive)) //{ // ql.AddAnswer(itemAnswerChoice.ItemAnswerChoiceId.ToString(), itemAnswerChoice.AnswerString); //} } } Dictionary<string, List<string>> attribuuteDic = new Dictionary<string, List<string>>(); foreach (var item in gb.ItemAttributes.Where(n => n.Item.Resarch.ResearchId == research.ResearchId && n.IsActive == true)) { if (attribuuteDic.ContainsKey(item.AttributeName)) { attribuuteDic[item.AttributeName].Add(item.Value); } else { attribuuteDic.Add(item.AttributeName, new List<string>() { item.Value }); } } foreach (var item in attribuuteDic) { foreach (var item2 in item.Value.Distinct()) { QuestionLine ql = new QuestionLine() { Key = "attribute_" + item.Key + "_" + item2, Text = "属性:" + item.Key + "_" + item2, Type = "数値", AnswerNumericList = new List<double>() { 0, 0.25, 0.5, 0.75, 1 } }; list.Add(ql); } } foreach (var item in list) { sb.AppendLine(item.ToString()); } return sb.ToString(); }