public void AjouterQ(int numQ, string fichier) { List <string> reponses = new List <string>(); reponses.Add(Acces.retournerReponse(numQ, 1, "questions.xml")); reponses.Add(Acces.retournerReponse(numQ, 2, "questions.xml")); reponses.Add(Acces.retournerReponse(numQ, 3, "questions.xml")); reponses.Add(Acces.retournerReponse(numQ, 4, "questions.xml")); Questions.Add(new TestFrage(Acces.retournerQuestion(numQ, "questions.xml"), reponses, Acces.retournerReponseJusteInt(numQ, "questions.xml"), Acces.retournerPoids(numQ, "questions.xml"), Acces.Image(numQ, "questions.xml"))); }
/// <summary> /// Инициализирует класс <see cref="Survey"/> /// </summary> /// <param name="File">Файл опроса</param> public Survey(String File) { try { XmlDocument Document = new XmlDocument(); Document.Load(File); XmlNode Survey = Document.DocumentElement; this.Name = Survey.Attributes["name"].InnerText; this.Description = Survey.Attributes["description"].InnerText; this.Author = Survey.Attributes["author"].InnerText; this.Questions = new List <Question>(); foreach (XmlNode Question in Survey.SelectNodes("question")) { List <String> Answers = new List <String>(); foreach (XmlNode Answer in Question.SelectNodes("answer")) { Answers.Add(Answer.InnerText); } Questions.Add( new Question( Question.Attributes["type"].InnerText, Question.Attributes["name"].InnerText, Convert.ToInt32(Question.Attributes["true"].InnerText), (Question.Attributes["image"].InnerText != "") ? Question.Attributes["image"].InnerText.ToImage() : null, Answers.ToArray())); } } catch { throw new Exception("Файл имел неверный формат!"); } }
public virtual void ReadXml(System.Xml.Linq.XElement element) { //CurrentID Question.CurrentID = element.ReadInt("QuCurrentID"); Answer.CurrentID = element.ReadInt("AnCurrentID"); //qustions XElement elem = element.Element("Questions"); Questions.Clear(); foreach (XElement e in elem.Elements()) { Question qustion = new Question(true); qustion.ReadXml(e); Questions.Add(qustion); } //answers elem = element.Element("Answers"); Answers.Clear(); foreach (XElement e in elem.Elements()) { Answer answer = new Answer(true); answer.ReadXml(e); Answers.Add(answer); } }
private void ExecuteAddCommand() { var w = new Window { Content = new AddQuestionViewModel() }; w.Height = 525; w.Width = 320; DataStore.WindowRegistration = w; w.ShowDialog(); var tmp = DataStore.AddedQuestion; var error = DataStore.ErrorCode; if (error == 0) { if (tmp != null) { Questions.Add(tmp); } } else { //TODO Alert user with dialog and error code translation. } }
void ExecuteLoadQuestionsCommand() { if (IsBusy) { return; } IsBusy = true; try { Questions.Clear(); var questions = Category.Questions; foreach (var question in questions) { Questions.Add(question); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private void AddQuestionToList(TestQuestion question) { if (Questions.Count < PageCount) { Questions.Add(question); } }
public StudentSurveyOnLecturerSurveyEntry(string[] columns) : base(columns) { for (int index = 1; index <= 10; index++) { Questions.Add(new SurveyQuestion(index, ConvertQuantitativeAnswer(columns[index]))); } for (int index = 11; index <= 13; index++) { if (!string.IsNullOrEmpty(columns[index]) && !IsNoise(columns[index])) { temporaryAnswers.Add(columns[index]); } } Questions.Add(new SurveyQuestion(11, string.Join(".", temporaryAnswers.ToList()), isQuantitative: false)); temporaryAnswers.Clear(); for (int index = 14; index <= 16; index++) { if (!string.IsNullOrEmpty(columns[index]) && !IsNoise(columns[index])) { temporaryAnswers.Add(columns[index]); } } Questions.Add(new SurveyQuestion(12, string.Join(".", temporaryAnswers.ToList()), isQuantitative: false)); }
async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Questions.Clear(); var questions = await DataStore.GetItemsAsync(true); foreach (var question in questions) { Questions.Add(question); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private void ProceedPrephase() { Position++; string slide = SlidesForStage.FirstOrDefault(x => x.StartsWith(string.Format("{0}\\{1}-{2}-", wfolder, Stage, Position))); if (Stage.Equals("b") && string.IsNullOrEmpty(slide)) { Stage = "q"; Position = 0; SlidesForStage = Directory.GetFiles(wfolder, "q-*.xml"); Random rnd = new Random(); object obj = Properties.Resources.ResourceManager.GetObject("dilemma_1"); int i = 1; while (obj != null) { string[] parts = obj.ToString().Split(';'); Questions.Add(new DilemmaFromResource() { Question = parts[2], Text = parts[1], ID = i++, Title = parts[0] }); obj = Properties.Resources.ResourceManager.GetObject("dilemma_" + i); } Questions = new List <DilemmaFromResource>(Questions.OrderBy(z => rnd.NextDouble())); } else { LoadForm(slide); } }
public IActionResult OnPostAnswerAsync() { Questions = JsonSerializer.Deserialize <List <TagalogListItem> >( Encoding.UTF8.GetString(Convert.FromBase64String(SessionData))); if (QuestionAnswer?.Equals((DifficultyLevel == DifficultyLevel.Easy ? Questions.First().English : Questions.First().Tagalog), StringComparison.CurrentCultureIgnoreCase) ?? false) { AnswerResponse = "Great job, you are rocking this."; Questions.RemoveAt(0); } else { AnswerResponse = $"Oops, {Questions.First().Tagalog}: {Questions.First().English} - That's going to cost ya big time."; Questions.Add(Questions.First()); Questions = Questions.OrderBy(x => Guid.NewGuid()).ToList(); } ModelState.Clear(); Init(); SessionData = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonSerializer.Serialize(Questions))); QuestionAnswer = ""; return(Page()); }
private void OnAddQuestion() { Int32.TryParse(CountryId, out int countryId); var question = new Question(countryId); Questions.Add(question); }
public UnitAndLecturerSurveyEntry(string[] columns) : base(columns) { for (int index = 1; index <= 6; index++) { Questions.Add(new SurveyQuestion(index, ConvertQuantitativeAnswer(columns[index]))); } for (int index = 7; index <= 8; index++) { if (!string.IsNullOrEmpty(columns[index]) && !IsNoise(columns[index])) { Questions.Add(new SurveyQuestion(index, columns[index], isQuantitative: false)); } } for (int index = 9; index <= 12; index++) { Questions.Add(new SurveyQuestion(index, ConvertQuantitativeAnswer(columns[index]))); } if (!string.IsNullOrEmpty(columns[13]) && !IsNoise(columns[13])) { Questions.Add(new SurveyQuestion(13, columns[13], isQuantitative: false)); } }
public void Deserialize(BinaryReader reader) { ID = NetworkHelper.Nthos(reader.ReadUInt16()); Flags = (DnsPacketFlags)NetworkHelper.Nthos(reader.ReadUInt16()); ushort questionCount = NetworkHelper.Nthos(reader.ReadUInt16()); ushort answerCount = NetworkHelper.Nthos(reader.ReadUInt16()); ushort authoritativeCount = NetworkHelper.Nthos(reader.ReadUInt16()); ushort additionalCount = NetworkHelper.Nthos(reader.ReadUInt16()); for (int i = 0; i < questionCount; i++) { DnsQuestion question = new DnsQuestion(); question.Deserialize(reader); Questions.Add(question); } for (int i = 0; i < answerCount; i++) { DnsResourceRecord record = DnsResourceRecord.DeserializeResourceRecord(reader); Answers.Add(record); } for (int i = 0; i < authoritativeCount; i++) { DnsResourceRecord record = DnsResourceRecord.DeserializeResourceRecord(reader); Authoritatives.Add(record); } for (int i = 0; i < additionalCount; i++) { DnsResourceRecord record = DnsResourceRecord.DeserializeResourceRecord(reader); Additionals.Add(record); } }
public void AddQuestion([NotNull] Question question) { var propertyType = GetQuestionsPropertyType(); if (propertyType != null) { var property = _model.GetProperty(propertyType); if (property == null) { property = _model.AddProperty(propertyType, null); if (property is IPropertyJsonSerializableObject jsonSerializableObject) { var questions = new Questions(); questions.Add(question); jsonSerializableObject.Value = questions; } } else if (property is IPropertyJsonSerializableObject jsonSerializableObject) { if (!(jsonSerializableObject.Value is Questions questions)) { questions = new Questions(); jsonSerializableObject.Value = questions; } questions.Add(question); } } }
public List <QuestionModel> LoadQuestion() { try { string[] lines = System.IO.File.ReadAllLines(questionsFileName); Regex CSVParser = new Regex(",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))"); foreach (var row in lines) { String[] Fields = CSVParser.Split(row); for (int i = 0; i < Fields.Length; i++) { Fields[i] = Fields[i].TrimStart(' ', '"'); Fields[i] = Fields[i].TrimEnd('"'); } QuestionModel model = new QuestionModel { ID = int.Parse(Fields[0]), TimeOfQuestion = DateTime.Parse(Fields[1]), ViewNumber = int.Parse(Fields[2]), VoteNumber = int.Parse(Fields[3]), Title = Fields[4], Message = Fields[5], Image = Fields[6] }; Questions.Add(model); } } catch (Exception) { return(new List <QuestionModel>()); } return(Questions); }
public void AddQuestion() { if (!String.IsNullOrEmpty(_addquestiontext)) { _question.QuestionDescription = _addquestiondescription; _question.QuestionTitle = _addquestiontext; switch (AddQuestionId) { case 0: _question.QuestionTypeID = 1; break; case 1: _question.QuestionTypeID = 2; break; } QuestionRepository.Insert(_question); QuestionRepository.Save(); Questions.Add(new QuestionViewModel(_question)); RaisePropertyChanged("Questions"); _question = new Question(); OnLightboxClose(); } else { MessageBox.Show("Vul een vraag in", "Vraag", MessageBoxButton.OK, MessageBoxImage.Error); } }
public Response(byte[] data) { Error = ""; TimeStamp = DateTime.Now; Header = new Header(data); using (PersistedReader reader = new PersistedReader(Header.Buffer, Header.Payload)) { for (int intI = 0; intI < Header.QuestionCount; intI++) { Questions.Add(new Question(reader)); } for (int intI = 0; intI < Header.AnswersCount; intI++) { Answers.Add(new Resource(reader)); } for (int intI = 0; intI < Header.AuthorityCount; intI++) { Authorities.Add(new Resource(reader)); } for (int intI = 0; intI < Header.AdditionalCount; intI++) { Additionals.Add(new Resource(reader)); } } }
public SectionViewModel(SectionWrapper section) { foreach (var questionWraper in section.Questions) { Questions.Add(questionWraper); } }
//public QuizViewModel(Quiz quiz) //{ // ActiveQuiz = quiz; // //_student = Repository<User>.GetInstance().GetDataList().Where(x => x.Id == quiz.UserId).ToList().First() as User; // //HandInExam(); //} // SetQuizContent(); //} public void SetQuizContent2() { ObservableCollection <Question> activeQuiz;// using (var db = new QuizContext()) { ActiveQuiz = db.Quizs.Include("User").Include("Questions").Include("Questions.Alternatives") .Where(s => s.Id == ActiveQuiz.Id).FirstOrDefault <Quiz>(); activeQuiz = new ObservableCollection <Question>(ActiveQuiz.Questions); ActiveQuiz.User = db.Users.Include("Results").Include("Quizs").Include("Education") .Where(s => s.Id == ActiveQuiz.User.Id).FirstOrDefault <User>(); } //Randomize //QuestionType.RankQuestion foreach (var question in activeQuiz) { if (question.Type == QuestionType.RankQuestion) { question.Alternatives = question.Alternatives.OrderBy(a => randomizer.Next()).ToList(); } Questions.Add(question); } }
/// <summary> /// Adds a question to the survey's question list. /// </summary> /// <param name="newQ"></param> public void AddQuestion(SurveyQuestion newQ) { if (!Questions.Contains(newQ, new SurveyQuestionComparer())) { Questions.Add(newQ); UpdateEssentialQuestions(); } }
public void AddQuestion(string question) { Questions.Add(new Question() { Message = question, Date = DateTime.Now }); }
public void AddQuestions(IEnumerable <Question> questions) { EnsureIsDraft(); foreach (var q in questions) { Questions.Add(q); } }
/// <summary> /// Adds a question to the survey's question list. /// </summary> /// <param name="newQ"></param> public void AddQuestion(SurveyQuestion newQ, bool withRenumber) { Questions.Add(newQ); if (withRenumber) { Renumber(0); } UpdateEssentialQuestions(); }
/// <summary> /// Adds each question in the list to the survey's question list. /// </summary> /// <param name="newQ"></param> public void AddQuestions(BindingList <SurveyQuestion> questions) { foreach (SurveyQuestion sq in questions) { Questions.Add(sq); } UpdateEssentialQuestions(); }
public SurveyDefinitionModel(int id, string title) { Id = id; Title = title; Questions.Add(new QuestionMultipleRadioModel()); Questions.Add(new QuestionMultipleRadioModel()); Questions.Add(new QuestionMultipleCheckBoxModel()); Questions.Add(new QuestionMultipleCheckBoxModel()); }
void ParseQueue(Queue <NonnullRichTextBuilder> richTexts) { Questions.Clear(); int stride = 1 + MultiChoiceItem.N_OPTIONS; while (richTexts.Count > 0) { Questions.Add(MultiChoiceItem.NewWith(richTexts)); } }
public QuizQuestionAnswerVM(IAnswerRepo AnswerRepo, Quiz quiz) { Quiz = quiz; this.Questions = new Collection <Question>(); this.QuestionAnswerVMs = new Collection <QuestionAnswerVM>(); foreach (QuizQuestion qq in quiz.QuizQuestions) { Questions.Add(qq.Question); } }
public void addQuestion() { Question q = new Question(); q.Job = Job; q.QuestionText = "Question" + ++maxValue; Questions.Add(new QuestionUC(q)); Button b = new Button(); b.Content = "-"; QuestionButtons.Add(b); }
public void Add() { Question item = new Question(); item.IsDefault = true; QuestionRepository.Instance.SetItem(item); Questions.Add(item); SelectedQuestion = item; }
private void DuplicateQuestion(QuestionViewModel q) { var newQuestion = q.Duplicate(); if (newQuestion == null) { return; } Questions.Add(newQuestion); }