/// <summary> /// Save Survey button click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveButton_Click(object sender, EventArgs e) { if (this.Questions.Count <= 0) { return; } if (string.IsNullOrWhiteSpace(NameTextBox.Text)) { MessageBox.Show(ErrMsg.NameMissingError); return; } Survey newSurvey; if (this.TextSurveyRadio.Checked) { newSurvey = new TextSurvey(this.Questions); } else if (this.ScaleSurveyRadio.Checked) { newSurvey = new ScaleSurvey(this.Questions); } else if (this.MultiSurveyRadio.Checked) { newSurvey = new MultiSurvey(this.Questions); } else if (this.ScaleCustomRadio.Checked) { newSurvey = new ScaleSurvey(this.Questions); } else { return; } newSurvey.name = NameTextBox.Text; newSurvey.SetGroup(BlockNumeric.Value); newSurvey.SetSubGroup(SubBlockNumeric.Value); if (this.ExistingTrial == null) { MainForm.AddSurvey(newSurvey); } else { ReturnEdit = newSurvey; } Close(); }
public void UpdateTrialsByTimeline() { this.trialList = new List <Trial>(); foreach (var item in this.timeline) { Survey newSurvey = null; List <Question> qList; switch (item["type"]) { case "bRMS": var newBrms = this.getBrmsFromDic(item); newBrms.block = decimal.Parse(item["block"].ToString()); newBrms.sub_block = decimal.Parse(item["sub_block"].ToString()); this.trialList.Add(newBrms); break; case "survey-text": qList = Utils.GetQuestionsListFromJson( "survey-text", item["questions"].ToString()); newSurvey = new TextSurvey(qList) { name = item["name"].ToString(), block = decimal.Parse(item["block"].ToString()), sub_block = decimal.Parse(item["sub_block"].ToString()) }; break; case "survey-likert": qList = Utils.GetQuestionsListFromJson( "survey-likert", item["questions"].ToString()); newSurvey = new ScaleSurvey(qList) { name = item["name"].ToString(), block = decimal.Parse(item["block"].ToString()), sub_block = decimal.Parse(item["sub_block"].ToString()) }; break; case "survey-multi-choice": qList = Utils.GetQuestionsListFromJson( "survey-multi-choice", item["questions"].ToString()); newSurvey = new MultiSurvey(qList) { name = item["name"].ToString(), block = decimal.Parse(item["block"].ToString()), sub_block = decimal.Parse(item["sub_block"].ToString()) }; break; case "fullscreen": var newFullscreen = new FullScreen((string)item["message"]) { name = item["name"].ToString(), block = decimal.Parse(item["block"].ToString()), sub_block = decimal.Parse(item["sub_block"].ToString()) }; this.trialList.Add(newFullscreen); break; case "instructions": var newIntro = new Instructions { name = item["name"].ToString(), pages = Utils.GetPagesFromJson(item["pages"].ToString()), block = decimal.Parse(item["block"].ToString()), sub_block = decimal.Parse(item["sub_block"].ToString()) }; this.trialList.Add(newIntro); break; } if (newSurvey != null) { this.trialList.Add(newSurvey); } } }