public QuestionData( string qtext, AnswerData answer1, AnswerData answer2, AnswerData answer3, AnswerData answer4) : this(qtext, new List<AnswerData>() { answer1, answer2, answer3, answer4 }) { //Empty constructor }
AnswerData MakePlayerAnswer() { var answer = new AnswerData(); answer.Answer = "the answer goes here"; answer.Points = 1000; answer.Choosers = TestUtility.GetPlayerData(); answer.Type = GameAnswerType.Player; return answer; }
/// <summary> /// Adds a new answer to the matrix question specified by the question id property in the database /// </summary> /// <param name="newAnswer">Answer object with information about what to add. Only Id must be ommited</param> public void AddMatrixAnswer(AnswerData newAnswer) { SqlConnection connection = new SqlConnection(DbConnection.NewDbConnectionString); SqlCommand insertCommand = new SqlCommand("vts_spAnswerMatrixAddNew", connection); insertCommand.CommandType = CommandType.StoredProcedure; insertCommand.Parameters.Add(new SqlParameter("@AnswerText", SqlDbType.VarChar, 0xfa0, "AnswerText")); insertCommand.Parameters.Add(new SqlParameter("@ImageURL", SqlDbType.VarChar, 0x3e8, "ImageURL")); insertCommand.Parameters.Add(new SqlParameter("@AnswerTypeID", SqlDbType.Int, 4, "AnswerTypeID")); insertCommand.Parameters.Add(new SqlParameter("@ParentQuestionID", SqlDbType.Int, 4, "QuestionID")); insertCommand.Parameters.Add(new SqlParameter("@AnswerID", SqlDbType.Int, 4, "AnswerID")); insertCommand.Parameters["@AnswerID"].Direction = ParameterDirection.Output; DbConnection.db.UpdateDataSet(newAnswer, "Answers", insertCommand, new SqlCommand(), new SqlCommand(), UpdateBehavior.Transactional); }
/// <summary> /// Construct a new Answers object. /// </summary> public Answers() { ansData = new AnswerData(); try { ansData.ReadXml(Path.Combine(Settings.AnswerPath, "index.xml")); } catch (System.IO.FileNotFoundException) { } catch (System.IO.DirectoryNotFoundException) { } ansData.CaseSensitive = false; }
/// <summary> /// Parse an AnswerDataCollection, /// converts the data to webcontrols and assign them to a new section /// </summary> protected override AnswerSection GetAnswerSection(AnswerData answers, int sectionNumber, int sectionUid) { if (answers == null) { throw new ArgumentException("No instance set for the data of the question control"); } RadioButtonAnswerSection section = new RadioButtonAnswerSection(); section.SectionUid = sectionUid; section.SectionNumber = sectionNumber; section.LanguageCode = base.LanguageCode; section.Answers = AnswerItemFactory.CreateAnswerItemCollection(answers, this, section, AnswerSelectionMode.Radio, base.AnswerStyle, base.RenderMode, base.LanguageCode, this.UniqueID + GlobalConfig.AnswerSectionName + sectionUid, true, base.VoterAnswersState, base.EnableAnswersDefault); return section; }
// Parsed data from Firebase into data that this scene can use. private void RoundDataLoader(DocumentStore data) { List <object> roundData = data["roundData"] as List <object>; DocumentStore singleRoundData = roundData[1] as DocumentStore; currentRoundData = new RoundData(); currentRoundData.name = singleRoundData["name"] as string; int pointsAdedForCorrectAnswer = Convert.ToInt32(singleRoundData["pointsAdedForCorrectAnswer"]); int timeLimitInSeconds = Convert.ToInt32(singleRoundData["timeLimitInSeconds"]); currentRoundData.timeLimitInSeconds = timeLimitInSeconds; currentRoundData.pointsAdedForCorrectAnswer = pointsAdedForCorrectAnswer; List <object> questions = singleRoundData["questions"] as List <object>; QuestionData[] questionsData = new QuestionData[questions.Count - 1]; for (int i = 1; i < questions.Count; i++) { DocumentStore question = questions[i] as DocumentStore; QuestionData questionData = new QuestionData(); questionData.questionText = question["question"] as string; List <object> answers = question["answers"] as List <object>; List <object> images = null; List <object> imagesBackground = null; if (question.ContainsKey("images")) { images = question["images"] as List <object>; } if (question.ContainsKey("imagesBackground")) { imagesBackground = question["imagesBackground"] as List <object>; } int correct = Convert.ToInt32(question["correct"]); AnswerData[] answersData = new AnswerData[answers.Count]; for (int j = 0; j < answers.Count; j++) { AnswerData answer = new AnswerData(); answer.answerText = answers[j] as string; answer.isCorrect = correct == j; if (imagesBackground != null && imagesBackground.Count > j) { string imageBackground = imagesBackground[j] as string; Color color; if (imageBackground != null && ColorUtility.TryParseHtmlString(imageBackground, out color)) { answer.background = color; } } if (images != null && images.Count > j) { string imageName = images[j] as string; if (imageName != null) { string directory = Application.dataPath; string localpath = "/Scenes/Games/Trivia/Images/"; if (File.Exists(directory + localpath + imageName)) { Debug.Log("The file exists!!!"); byte[] bytes = File.ReadAllBytes(directory + localpath + imageName); Texture2D texture = new Texture2D(1, 1); texture.LoadImage(bytes); Sprite sprite = Sprite.Create( texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f) ); answer.image = sprite; } } } answersData[j] = answer; } questionData.answers = answersData; questionsData[i - 1] = questionData; } currentRoundData.questions = questionsData; questionPool = currentRoundData.questions; timeRemaining = currentRoundData.timeLimitInSeconds; initialTime = currentRoundData.timeLimitInSeconds; UpdateTimeRemainingDisplay(); playerScore = 0; questionIndex = 0; ShowQuestion(); isRoundActive = true; }
public void SetUp(AnswerData answerdata) { answerData = answerdata; answerText.text = answerData.answerText; }
static List <int> GetGrayClueIndexsByCurrentAnswer(int fixedRowOrColIndex, bool isFixedRow, List <ColorableClueNumber> scaningClues) { //同样的,得到id->得到currentAnswer->到达断点时,if数量匹配,then add,else break; //所以你要先有个id int chainedCount = 0; int selectClueIndex = 0; int maxRowOrColIndex = (isFixedRow ? (MainGame.maxColumns + 1) : (MainGame.maxRows + 1)); int lastValue = -1; List <int> result = new List <int>(); for (int tempColOrRowIndex = 1; tempColOrRowIndex < maxRowOrColIndex; tempColOrRowIndex++) { int gridId = -1; if (isFixedRow) { gridId = MainGame.ConvertToGridID(tempColOrRowIndex, fixedRowOrColIndex, MainGame.maxColumns); } else { gridId = MainGame.ConvertToGridID(fixedRowOrColIndex, tempColOrRowIndex, MainGame.maxColumns); } if (myPuzzleAnswers.ContainsKey(gridId)) { AnswerData ad = myPuzzleAnswers[gridId]; if (selectClueIndex > scaningClues.Count) { result.Clear(); break; } //bool isBreaking = false; if (ad.currentAnswer) { chainedCount++; if (selectClueIndex >= scaningClues.Count) { result.Clear(); break; } else if (tempColOrRowIndex == maxRowOrColIndex - 1 && chainedCount == scaningClues[selectClueIndex].number) { result.Add(selectClueIndex); } } else { if (lastValue == 1) { if (selectClueIndex < scaningClues.Count && scaningClues[selectClueIndex].number == chainedCount) { //Debug.Log("add selecteIndex : " + selectClueIndex + ", current chainCount = " + chainedCount); result.Add(selectClueIndex); selectClueIndex++; chainedCount = 0; } else { result.Clear(); break; } } } lastValue = ad.currentAnswer ? 1 : 0; } } if (result.Count != scaningClues.Count) { result.Clear(); } return(result); }
public void Setup(AnswerData data) { answerData = data; answerText.text = answerData.answerText; }
public string GetQuestionPart(QuestionData.QuestionsRow q, AnswerData.AnswersRow a) { switch (ddlAutoQuestionNaming.SelectedValue) { case "Question":/* if (IsMatrixQuestion(q)) return TrimSplit((q.ParentQuestionText + splitChar + q.QuestionText + splitChar + q.AnswerText)); else */ return TrimSplit(q.QuestionText); case "QuestionDisplayOrderNumber":/* if (IsMatrixQuestion(q)) return TrimSplit(q.DisplayOrder.ToString() + splitChar + q.RowOrder.ToString() + splitChar + q.AnswerText); else */ return TrimSplit(q.DisplayOrder.ToString()); case "QuestionID":/* if (IsMatrixQuestion(q)) return TrimSplit((q.IsParentQuestionIdTextNull() ? string.Empty : q.ParentQuestionIdText) + splitChar + q.RowOrder.ToString() + splitChar + (q.IsAnswerTextNull() ? string.Empty : q.AnswerText)); else */ return TrimSplit(q.IsQuestionIdTextNull() ? q.QuestionText : q.QuestionIdText); case "QuestionAlias":/* if (IsMatrixQuestion(q)) return TrimSplit(q.ParentQuestionAliasText.ToString() + splitChar + q.RowOrder.ToString() + splitChar + q.AnswerText); else */ return TrimSplit(q.IsAliasNull() ? q.QuestionText : q.Alias); default: return TrimSplit("Invalid DDl Value"); } }
/// <summary> /// Get all answers from a give question /// </summary> /// <param name="questionId">question which is owning the answers</param> /// <param name="languageCode">Language in which to return the answers, -1 act as the default language</param> /// <returns></returns> public AnswerData GetAnswers(int questionId, string languageCode) { //SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@QuestionId", questionId), new SqlParameter("@LanguageCode", languageCode) }; ArrayList sqlParams = new ArrayList(); { sqlParams.Add(new SqlParameter("@QuestionId", questionId).SqlValue); sqlParams.Add(new SqlParameter("@LanguageCode", languageCode).SqlValue); } AnswerData dataSet = new AnswerData(); DbConnection.db.LoadDataSet("vts_spQuestionGetAnswers", dataSet, new string[] { "Answers" }, sqlParams.ToArray()); return dataSet; }
/// <summary> /// Parse an AnswerDataCollection, converts the data /// to webcontrols and returns a filled answer section /// </summary> protected abstract AnswerSection GetAnswerSection(AnswerData answers, int sectionNumber, int sectionUid);
public void Setup(AnswerData data) { answerData = data; GetComponentInChildren <TextMeshProUGUI>().text = answerData.answerText; }
public void SetUp(AnswerData data) { answerData = data; answerText.text = ArabicFixer.Fix(answerData.text); }
void AddFilter(QuestionData.QuestionsRow q, AnswerData.AnswersRow a, FilterData.FiltersRow p) { FilterData filterData = new FilterData(); FilterData.FiltersRow filterRow = filterData.Filters.NewFiltersRow(); filterRow.LogicalOperatorTypeID = short.Parse(LogicalOperatorDropDownList.SelectedValue); filterRow.Description = FilterName(q, a, p); filterRow.SurveyId = SurveyId; filterRow.ParentFilterId = p.FilterId; filterData.Filters.AddFiltersRow(filterRow); new Filter().AddFilter(filterData); FilterRuleData filterRuleData = new FilterRuleData(); FilterRuleData.FilterRulesRow filterRuleRow = filterRuleData.FilterRules.NewFilterRulesRow(); filterRuleRow.QuestionId = q.QuestionId; filterRuleRow.AnswerId = a.AnswerId; filterRuleRow.FilterId = filterRow.FilterId; filterRuleData.FilterRules.AddFilterRulesRow(filterRuleRow); new Filter().AddRule(filterRuleData); }
public string FilterName(QuestionData.QuestionsRow q, AnswerData.AnswersRow a, FilterData.FiltersRow f) { const string splitChar = "|"; return f.FilterId == 0 ? FilterName(q, a, splitChar) : FilterName(q, a, f, splitChar); }
public string FilterName(QuestionData.QuestionsRow q, AnswerData.AnswersRow a, FilterData.FiltersRow f, string splitChar) { return GetSubstr(GetFilterPart(f, splitChar)) + splitChar + FilterName(q, a, splitChar); }
public string FilterName(QuestionData.QuestionsRow q, AnswerData.AnswersRow a, string splitChar) { return GetSubstr(GetQuestionPart(q, a)) + splitChar + GetSubstr(GetAnswerPart(a)); }
public string GetAnswerPart(AnswerData.AnswersRow a) { switch (ddlAutoAnswerNaming.SelectedValue) { case "Answer": return a.AnswerText; case "AnswerDisplayOrderNumber":/* if (!a.IsRowOrderNull()) return TrimSplit(a.AnswerDisplayOrder.ToString()); else*/ return a.DisplayOrder.ToString(); case "AnswerID": return a.IsAnswerIDTextNull() ? a.AnswerText : a.AnswerIDText; case "AnswerAlias": return a.IsAnswerAliasNull() ? a.AnswerText : a.AnswerAlias; case "SliderRange": return a.IsSliderRangeNull() ? a.AnswerText : a.SliderRange; case "SliderValue": return a.IsSliderValueNull() ? a.AnswerText : a.SliderValue.ToString(); case "SliderMin": return a.IsSliderMinNull() ? a.AnswerText : a.SliderMin.ToString(); case "SliderMax": return a.IsSliderMaxNull() ? a.AnswerText : a.SliderMax.ToString(); case "SliderAnimate": return a.IsSliderAnimateNull() ? a.AnswerText : a.SliderAnimate.ToString(); case "SliderStep": return a.IsSliderAnimateNull() ? a.AnswerText : a.SliderStep.ToString(); default: return "Invalid DDl Value"; } }
public void PickAnswer(AnswerData answer, QuestionData question) { userAnswers.Add(new AnswerQuizStruct(question, answer)); }
private void UpdateAnswerButton_Click(object sender, System.EventArgs e) { int oldTypeMode = new Answers().GetAnswerTypeMode(AnswerId); // Create the updated BE AnswerData answer = new AnswerData(); AnswerData.AnswersRow updatedAnswer = answer.Answers.NewAnswersRow(); updatedAnswer.AnswerText = AnswerTextTextBox.Text; updatedAnswer.ImageURL = AnswerImageURLTextBox.Text; updatedAnswer.AnswerTypeId = int.Parse(AnswerTypeDropDownList.SelectedValue); updatedAnswer.RatePart = RatingPartCheckbox.Checked; updatedAnswer.AnswerId = AnswerId; updatedAnswer.AnswerIDText = txtAnswerID.Text; updatedAnswer.AnswerAlias = txtAnswerAlias.Text; updatedAnswer.SliderRange = SliderRangeDDL.SelectedValue.ToString(); updatedAnswer.SliderValue = int.Parse(SliderValueTextBox.Text); updatedAnswer.SliderMin = int.Parse(SliderMinTextBox.Text); updatedAnswer.SliderMax = int.Parse(SliderMaxTextBox.Text); updatedAnswer.SliderAnimate = SliderAnimateCheckbox.Checked; updatedAnswer.SliderStep = int.Parse(SliderStepTextBox.Text); if (DefaultTextTextBox.Text.Length > 0) { updatedAnswer.DefaultText = DefaultTextTextBox.Text; } else { updatedAnswer.SetDefaultTextNull(); } updatedAnswer.Selected = SelectionCheckBox.Checked; updatedAnswer.ScorePoint = Information.IsNumeric(ScoreTextBox.Text) ? int.Parse(ScoreTextBox.Text) : 0; updatedAnswer.AnswerPipeAlias = AnswerPipeAliasTextBox.Text; updatedAnswer.Mandatory = MandatoryCheckBox.Checked; if (RegExDropDownList.SelectedIndex > 0) { updatedAnswer.RegularExpressionId = int.Parse(RegExDropDownList.SelectedValue); } answer.Answers.AddAnswersRow(updatedAnswer); new Answer().UpdateAnswer(answer, LanguageCode); int newTypeMode = new Answers().GetAnswerTypeMode(AnswerId); // Check if need to delete persisted properties if it was // previously an extended item if (oldTypeMode != newTypeMode && ((AnswerTypeMode)oldTypeMode & AnswerTypeMode.ExtendedType) > 0) { new Answer().DeleteAnswerProperties(AnswerId); } MessageLabel.Visible = true; ((PageBase)Page).ShowNormalMessage(MessageLabel, ((PageBase)Page).GetPageResource("SelectionUpdatedMessage")); SetUIState(newTypeMode, false); // Let the subscribers know that something changed OnOptionChanged(); }
public void SetUp(AnswerData data) { answerData = data; answerText.text = answerData.contenido; }
public void InitializeButton(AnswerData data) { answerData = data; ComponentText = answerData.Answer; SetGraphic(); }
private void BindAnswerTable(AnswerData questionAnswers, PlaceHolder container, int sectionNumber) { Table selectionTable = new Table(); TableRow selectionRow; TableCell answerTypeCell, answerTextCell; selectionTable.CssClass = (sectionNumber % 2) == 0 ? "innerText" : "alternatingSection"; // Get all answer items available for this // question foreach (AnswerData.AnswersRow answer in questionAnswers.Answers) { selectionRow = new TableRow(); answerTypeCell = new TableCell(); answerTypeCell.Width = Unit.Pixel(10); answerTypeCell.VerticalAlign = VerticalAlign.Top; answerTextCell = new TableCell(); string answerText = Server.HtmlEncode( System.Text.RegularExpressions.Regex.Replace(new PipeManager().PipeValuesInText( answer.QuestionId, answer.AnswerText, _voterAnswers.VotersAnswers, null), "<[^>]*>", " ")); System.Web.UI.WebControls.Image spotImage = new System.Web.UI.WebControls.Image(); spotImage.ImageUrl = "images/spot_on.gif"; // Check if the voter has answered this answer VoterAnswersData.VotersAnswersRow voterAnswer = _voterAnswers.VotersAnswers.FindByVoterIdAnswerIdSectionNumber(_voterId, answer.AnswerId, sectionNumber); if (voterAnswer != null) { // Check answer type if (((((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Field) > 0) || (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Custom) > 0) || (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.DataSource) > 0)) && (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Selection) == 0)) { spotImage.ImageUrl = "images/spot_text.gif"; answerTextCell.Text = FormatVoterAnswer(answerText, voterAnswer.AnswerText, true); } else if (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Field) > 0 && ((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Selection) > 0) { answerTextCell.Text = FormatVoterAnswer(answerText, voterAnswer.AnswerText, true); _questionScore += answer.ScorePoint; } else if (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Upload) > 0) { spotImage.ImageUrl = "images/spot_file.gif"; answerTextCell.Controls.Add(new LiteralControl(answerText + "<br />")); answerTextCell.Controls.Add(GenerateFileList(voterAnswer.AnswerText)); } else { answerTextCell.Text = string.Format("<b>{0}</b>", answerText); _questionScore += answer.ScorePoint; } } else { // Check answer type if (((((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Field) > 0) || (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Custom) > 0) || (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.DataSource) > 0)) && (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Selection) == 0)) { spotImage.ImageUrl = "images/spot_text.gif"; answerTextCell.Text = FormatVoterAnswer(answerText, null, false); } else if (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Upload) > 0) { spotImage.ImageUrl = "images/spot_file.gif"; answerTextCell.Text = answerText + "<br />" + GetPageResource("NoFileUploadedMessage"); } else { answerTextCell.Text = answerText; spotImage.ImageUrl = "images/spot_off.gif"; } } answerTypeCell.Controls.Add(spotImage); selectionRow.Cells.Add(answerTypeCell); selectionRow.Cells.Add(answerTextCell); selectionTable.Rows.Add(selectionRow); } selectionTable.Width = Unit.Percentage(100); container.Controls.Add(selectionTable); }
/// <summary> /// Get all answers for a given question that can be selected /// </summary> /// <param name="questionId">question which is owning the answers</param> /// <returns></returns> public AnswerData GetSelectableAnswers(int questionId) { ArrayList sqlParams = new ArrayList(); { sqlParams.Add(new SqlParameter("@QuestionID", questionId).SqlValue); } AnswerData dataSet = new AnswerData(); DbConnection.db.LoadDataSet("vts_spQuestionGetSelectableAnswers", dataSet, new string[] { "Answers" }, sqlParams.ToArray()); return dataSet; }
public void Setup(AnswerData data) { answerData = data; answerText.text = answerData.answerText; //answerImage. = answerData.answerImage; //not working yet }
private void BindAnswerTable(AnswerData questionAnswers, PlaceHolder container, int sectionNumber) { Table selectionTable = new Table(); TableRow selectionRow; TableCell answerTypeCell, answerTextCell; selectionTable.CssClass = (sectionNumber%2) == 0 ? "innerText" : "alternatingSection" ; // Get all answer items available for this // question foreach (AnswerData.AnswersRow answer in questionAnswers.Answers) { selectionRow = new TableRow(); answerTypeCell = new TableCell(); answerTypeCell.Width = Unit.Pixel(10); answerTypeCell.VerticalAlign = VerticalAlign.Top; answerTextCell = new TableCell(); string answerText = Server.HtmlEncode( System.Text.RegularExpressions.Regex.Replace(new PipeManager().PipeValuesInText( answer.QuestionId, answer.AnswerText, _voterAnswers.VotersAnswers, null), "<[^>]*>", " ")); System.Web.UI.WebControls.Image spotImage = new System.Web.UI.WebControls.Image(); spotImage.ImageUrl = "images/spot_on.gif"; // Check if the voter has answered this answer VoterAnswersData.VotersAnswersRow voterAnswer = _voterAnswers.VotersAnswers.FindByVoterIdAnswerIdSectionNumber(_voterId, answer.AnswerId, sectionNumber); if (voterAnswer != null) { // Check answer type if (((((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Field) > 0) || (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Custom) > 0) || (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.DataSource) > 0)) && (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Selection) == 0)) { spotImage.ImageUrl = "images/spot_text.gif"; answerTextCell.Text = FormatVoterAnswer(answerText, voterAnswer.AnswerText, true); } else if ( ((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Field) > 0 && ((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Selection) > 0) { answerTextCell.Text = FormatVoterAnswer(answerText, voterAnswer.AnswerText,true); _questionScore += answer.ScorePoint; } else if(((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Upload) > 0) { spotImage.ImageUrl = "images/spot_file.gif"; answerTextCell.Controls.Add(new LiteralControl(answerText + "<br />")); answerTextCell.Controls.Add(GenerateFileList(voterAnswer.AnswerText)); } else { answerTextCell.Text = string.Format("<b>{0}</b>", answerText); _questionScore += answer.ScorePoint; } } else { // Check answer type if (((((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Field) > 0) || (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Custom) > 0) || (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.DataSource) > 0)) && (((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Selection) == 0)) { spotImage.ImageUrl = "images/spot_text.gif"; answerTextCell.Text = FormatVoterAnswer(answerText, null, false); } else if(((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Upload) > 0) { spotImage.ImageUrl = "images/spot_file.gif"; answerTextCell.Text = answerText + "<br />" + GetPageResource("NoFileUploadedMessage"); } else { answerTextCell.Text = answerText; spotImage.ImageUrl = "images/spot_off.gif"; } } answerTypeCell.Controls.Add(spotImage); selectionRow.Cells.Add(answerTypeCell); selectionRow.Cells.Add(answerTextCell); selectionTable.Rows.Add(selectionRow); } selectionTable.Width = Unit.Percentage(100); container.Controls.Add(selectionTable); }
private void UpdateAnswerButton_Click(object sender, System.EventArgs e) { int oldTypeMode = new Answers().GetAnswerTypeMode(AnswerId); // Create the updated BE AnswerData answer = new AnswerData(); AnswerData.AnswersRow updatedAnswer = answer.Answers.NewAnswersRow(); updatedAnswer.AnswerText = AnswerTextTextBox.Text; updatedAnswer.ImageURL = AnswerImageURLTextBox.Text; updatedAnswer.AnswerTypeId = int.Parse(AnswerTypeDropDownList.SelectedValue); updatedAnswer.RatePart = RatingPartCheckbox.Checked; updatedAnswer.AnswerId = AnswerId; updatedAnswer.AnswerIDText = txtAnswerID.Text; updatedAnswer.AnswerAlias = txtAnswerAlias.Text; updatedAnswer.SliderRange = SliderRangeDDL.SelectedValue.ToString(); updatedAnswer.SliderValue = int.Parse(SliderValueTextBox.Text); updatedAnswer.SliderMin = int.Parse(SliderMinTextBox.Text); updatedAnswer.SliderMax = int.Parse(SliderMaxTextBox.Text); updatedAnswer.SliderAnimate = SliderAnimateCheckbox.Checked; updatedAnswer.SliderStep = int.Parse(SliderStepTextBox.Text); if (DefaultTextTextBox.Text.Length>0) { updatedAnswer.DefaultText = DefaultTextTextBox.Text; } else { updatedAnswer.SetDefaultTextNull(); } updatedAnswer.Selected = SelectionCheckBox.Checked; updatedAnswer.ScorePoint = Information.IsNumeric(ScoreTextBox.Text) ? int.Parse(ScoreTextBox.Text) : 0; updatedAnswer.AnswerPipeAlias = AnswerPipeAliasTextBox.Text; updatedAnswer.Mandatory = MandatoryCheckBox.Checked; if (RegExDropDownList.SelectedIndex > 0) { updatedAnswer.RegularExpressionId = int.Parse(RegExDropDownList.SelectedValue); } answer.Answers.AddAnswersRow(updatedAnswer); new Answer().UpdateAnswer(answer, LanguageCode); int newTypeMode = new Answers().GetAnswerTypeMode(AnswerId); // Check if need to delete persisted properties if it was // previously an extended item if (oldTypeMode != newTypeMode && ((AnswerTypeMode)oldTypeMode & AnswerTypeMode.ExtendedType)>0) { new Answer().DeleteAnswerProperties(AnswerId); } MessageLabel.Visible = true; ((PageBase)Page).ShowNormalMessage(MessageLabel,((PageBase)Page).GetPageResource("SelectionUpdatedMessage")); SetUIState(newTypeMode, false); // Let the subscribers know that something changed OnOptionChanged(); }
/// <summary> /// Converts a stronlgy typed MatrixChildQuestionData dataset /// to a webcontrol collection /// </summary> /// <param name="childQuestions">The questions / answers data</param> /// <param name="parentControlUniqueID"> /// Unique ID required to identify global groups /// like radiobutton groups /// </param> /// <returns>a web control collection of MatrixChildQuestion</returns> public static MatrixChildCollection CreateQuestionChildCollection(MatrixChildQuestionData childQuestions, Section sectionContainer, string languageCode, string parentControlUniqueID, AnswerSelectionMode selectionMode, Style answerStyle, ControlRenderMode renderMode, VoterAnswersData.VotersAnswersDataTable voterAnswersState, bool enableAnswersDefault) { MatrixChildCollection childs = new MatrixChildCollection(); foreach (MatrixChildQuestionData.ChildQuestionsRow row in childQuestions.ChildQuestions.Rows) { MatrixChildQuestion question = new MatrixChildQuestion(); question.QuestionId = row.QuestionId; question.Text = new PipeManager().PipeValuesInText(row.QuestionId, row.QuestionText, voterAnswersState, languageCode); AnswerData answers = new AnswerData(); // answers.Merge(row.GetAnswersRows()); MatrixChildQuestionData.AnswersRow[] ar = row.GetAnswersRows(); foreach (MatrixChildQuestionData.AnswersRow r in ar) { r.Table.Namespace = answers.Namespace; } answers.Merge(ar); question.Answers = AnswerItemFactory.CreateAnswerItemCollection(answers, question, sectionContainer, selectionMode, answerStyle, renderMode, languageCode, parentControlUniqueID, false, voterAnswersState, enableAnswersDefault); childs.Add(question); } return childs; }
public static bool ValidateAnswer(AnswerData theAnswer) { return(string.IsNullOrEmpty(theAnswer.Text)); }
public void Setup(AnswerData data) //pass in answer data and set up for display { answerData = data; answerText.text = answerData.answerText; }
private void OnLike(AnswerData choice) { Client.Messenger.SubmitLike(choice.Answer); }
public void Setup(AnswerData data) { answerData = data; }
void OnChoiceSelected(AnswerData choice) { Client.Messenger.SubmitChosenAnswer(choice.Answer); }
// 자기가 담당하는 답변의 내용으로 채워준다. public void SetUp(AnswerData newData) { answerData = newData; buttonText.text = answerData.answerText; }
/// <summary> /// Update the matrix column in the database /// </summary> /// <param name="updatedAnswer">Answer to update, must specify the answer id</param> public void UpdateMatrixAnswer(AnswerData updatedAnswer, string languageCode) { AnswerFactory.Create().UpdateMatrixAnswer(updatedAnswer, languageCode); }
public void SetUp(AnswerData data) { answerData = data; answerImage.sprite = answerData.AnswerImage; }
/// <summary> /// Adds a new answer to the matrix question specified by the question id property in the database /// </summary> /// <param name="newAnswer">Answer object with information about what to add. Only Id must be ommited</param> public void AddMatrixAnswer(AnswerData newAnswer) { AnswerFactory.Create().AddMatrixAnswer(newAnswer); }
public void Load(string filepath) { string path = filepath; string jsonString = File.ReadAllText(path); JSONObject dataJson = (JSONObject)JSON.Parse(jsonString); // Set values QuizName = dataJson["Quizname"].Value; CurTopicName = dataJson["CurTopicName"].Value; RoundNumber = dataJson["RoundNumber"].AsInt; //indexes IroundCur = dataJson["IroundCur"].AsInt; ItopicCur = dataJson["ItopicCur"].AsInt; IquestionCur = dataJson["IquestionCur"].AsInt; Scores = new int[NumberOfTeams]; Jokers = new bool[NumberOfTeams]; for (int i = 0; i < Scores.Length; i++) { Scores[i] = dataJson[("Score" + i)].AsInt; Jokers[i] = dataJson[("Joker" + i)].AsBool; } // Rounds List <RoundData> rdList = new List <RoundData>(); for (int i = 0; i < dataJson["Rounds"].AsArray.Count; i++) { List <TopicData> tdList = new List <TopicData>(); for (int j = 0; j < dataJson["Rounds"].AsArray[i]["Topics"].AsArray.Count; j++) { List <QuestionData> qdList = new List <QuestionData>(); for (int k = 0; k < dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray.Count; k++) { AnswerData[] adTab = new AnswerData[dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray[k]["Answers"].AsArray.Count]; for (int l = 0; l < adTab.Length; l++) { AnswerData ad = new AnswerData(dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray[k]["Answers"].AsArray[l]["AnswerText"].Value, dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray[k]["Answers"].AsArray[l]["IsTrue"].AsBool); adTab[l] = ad; } switch (dataJson["Rounds"].AsArray[i]["Type"].Value) { case "Blind test": MusicQuestion mq = new MusicQuestion(dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray[k]["MusicPath"].Value, adTab); mq.StartTrack = dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray[k]["StartTrack"].AsFloat; mq.Volume = dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray[k]["Volume"].AsFloat; mq.Fade = dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray[k]["Fade"].AsBool; qdList.Add((QuestionData)mq); break; case "Musique": MusicQuestion mq2 = new MusicQuestion(dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray[k]["MusicPath"].Value, adTab); mq2.StartTrack = dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray[k]["StartTrack"].AsFloat; mq2.Volume = dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray[k]["Volume"].AsFloat; mq2.Fade = dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray[k]["Fade"].AsBool; qdList.Add((QuestionData)mq2); break; case "Image": ImageQuestion iq = new ImageQuestion(dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray[k]["ImagePath"].Value, adTab); qdList.Add((QuestionData)iq); break; case "QCM": TextQuestion tq = new TextQuestion(dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray[k]["Question"].Value, adTab); qdList.Add((QuestionData)tq); break; case "MCQ": TextQuestion tq2 = new TextQuestion(dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray[k]["Question"].Value, adTab); qdList.Add((QuestionData)tq2); break; case "TrueFalse": TrueFalseQuestion tf = new TrueFalseQuestion(dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray[k]["Question"].Value, adTab); qdList.Add((QuestionData)tf); break; case "VraiFaux": TrueFalseQuestion tf2 = new TrueFalseQuestion(dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Questions"].AsArray[k]["Question"].Value, adTab); qdList.Add((QuestionData)tf2); break; default: Debug.LogError("Type de question non-reconnu"); break; } } TopicData td = new TopicData(dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["Name"].Value, qdList); td.IsAvailable = dataJson["Rounds"].AsArray[i]["Topics"].AsArray[j]["IsAvailable"].AsBool; tdList.Add(td); } RoundData rd = new RoundData(dataJson["Rounds"].AsArray[i]["Type"].Value, tdList, dataJson["Rounds"].AsArray[i]["IsBuzzActivate"].AsBool); rdList.Add(rd); } Rounds = rdList; }
/// <summary> /// Update the matrix column in the database /// </summary> /// <param name="updatedAnswer">Answer to update, must specify the answer id</param> public void UpdateMatrixAnswer(AnswerData updatedAnswer, string languageCode) { AnswerFactory.Create().UpdateMatrixAnswer(updatedAnswer, languageCode); }
public void Setup(AnswerData answerData) { _answerData = answerData; answerText.text = _answerData.answerText; }
/// <summary> /// Get a list of answers to which the answer has subscribed to /// </summary> public AnswerData GetSubscriptionList(int answerId) { ArrayList sqlParams = new ArrayList(); { sqlParams.Add(new SqlParameter("@AnswerId", answerId).SqlValue); } AnswerData dataSet = new AnswerData(); DbConnection.db.LoadDataSet("vts_spAnswerGetSubscriptionList", dataSet, new string[] { "Answers" }, sqlParams.ToArray()); return dataSet; }
private int GetLongestAnswerLength(AnswerData questionAnswers) { int longestLength = 0; foreach (AnswerData.AnswersRow answer in questionAnswers.Answers.Rows) { if (answer.AnswerText.Length > longestLength) { longestLength = answer.AnswerText.Length; } } return longestLength; }
/// <summary> /// Update the matrix answer in the database /// </summary> /// <param name="updatedAnswer">Answer to update, must specify the answer id</param> public void UpdateMatrixAnswer(AnswerData updatedAnswer, string languageCode) { SqlConnection connection = new SqlConnection(DbConnection.NewDbConnectionString); SqlCommand insertCommand = new SqlCommand("vts_spAnswerMatrixUpdate", connection); insertCommand.CommandType = CommandType.StoredProcedure; insertCommand.Parameters.Add(new SqlParameter("@AnswerID", SqlDbType.Int, 4, "AnswerID")); insertCommand.Parameters.Add(new SqlParameter("@AnswerText", SqlDbType.NVarChar, 0xfa0, "AnswerText")); insertCommand.Parameters.Add(new SqlParameter("@ImageURL", SqlDbType.NVarChar, 0x3e8, "ImageURL")); insertCommand.Parameters.Add(new SqlParameter("@AnswerTypeID", SqlDbType.Int, 4, "AnswerTypeID")); insertCommand.Parameters.Add(new SqlParameter("@RatePart", SqlDbType.Bit, 1, "RatePart")); insertCommand.Parameters.Add(new SqlParameter("@Mandatory", SqlDbType.Bit, 1, "Mandatory")); insertCommand.Parameters.Add(new SqlParameter("@LanguageCode", languageCode)); DbConnection.db.UpdateDataSet(updatedAnswer, "Answers", insertCommand, new SqlCommand(), insertCommand, UpdateBehavior.Transactional); }
/// <summary> /// Adds a new answer to the question specified by the question id property in the database /// </summary> /// <param name="newAnswer">Answer object with information about what to add. Only Id must be ommited</param> public void AddAnswer(AnswerData newAnswer) { SqlConnection sqlConnection = new SqlConnection(DbConnection.NewDbConnectionString); // DbConnection.db.UpdateDataSet(this.GetInsertAnswerCommand(sqlConnection, null), new SqlCommand(), new SqlCommand(), newAnswer, "Answers", true); DbConnection.db.UpdateDataSet(newAnswer, "Answers", this.GetInsertAnswerCommand(sqlConnection, null), new SqlCommand(), new SqlCommand(), UpdateBehavior.Transactional); }
private void AddColumnButton_Click(object sender, System.EventArgs e) { if (AnswerTypeDropDownList.SelectedValue == "-1") { ((PageBase)Page).ShowErrorMessage(MessageLabel, ((PageBase)Page).GetPageResource("MissingTypeMessage")); MessageLabel.Visible = true; } else { AnswerData answer = new AnswerData(); AnswerData.AnswersRow newAnswer = answer.Answers.NewAnswersRow(); newAnswer.QuestionId = _parentQuestionId; newAnswer.AnswerText = NewColumnTextBox.Text; newAnswer.AnswerTypeId = int.Parse(AnswerTypeDropDownList.SelectedValue); answer.Answers.AddAnswersRow(newAnswer); new Answer().AddMatrixAnswer(answer); MessageLabel.Visible = true; ((PageBase)Page).ShowNormalMessage(MessageLabel, ((PageBase)Page).GetPageResource("MatrixColumnAddedMessage")); NewColumnTextBox.Text = string.Empty; BindAnswerOptions(); } }
/// <summary> /// Adds a new answer to the matrix question specified by the question id property in the database /// </summary> /// <param name="newAnswer">Answer object with information about what to add. Only Id must be ommited</param> public void AddMatrixAnswer(AnswerData newAnswer) { AnswerFactory.Create().AddMatrixAnswer(newAnswer); }
private void PageStart() { string strAnswer = "{" + "\"user\": [" + "{" + "\"group\": \"AA403.昭榮牧區-顯宗小組\"," + "\"name\": \"test\"," + "\"mobile\": \"test\"," + "\"eclass\": \"C1\"" + "}" + "]," + "\"exam\": [" + "{" + "\"id\": \"44\"," + "\"answer\": [" + "\"耶穌基督\"" + "]" + "}," + "{" + "\"id\": \"46\"," + "\"answer\": [" + "\"耶穌基督\"" + "]" + "}," + "{" + "\"id\": \"45\"," + "\"answer\": [" + "\"耶穌基督\"" + "]" + "}," + "{" + "\"id\": \"47\"," + "\"answer\": [" + "\"耶穌基督\"" + "]" + "}," + "{" + "\"id\": \"48\"," + "\"answer\": [" + "\"耶穌基督\"" + "]" + "}," + "{" + "\"id\": \"49\"," + "\"answer\": [" + "\"耶穌基督\"" + "]" + "}," + "{" + "\"id\": \"50\"," + "\"answer\": [" + "\"耶穌基督\"" + "]" + "}," + "{" + "\"id\": \"51\"," + "\"answer\": [" + "\"耶穌基督\"" + "]" + "}," + "{" + "\"id\": \"52\"," + "\"answer\": [" + "\"耶穌基督\"" + "]" + "}," + "{" + "\"id\": \"53\"," + "\"answer\": [" + "\"耶穌基督\"" + "]" + "}" + "]" + "}"; strAnswer = CheckStringByRequest("Answer"); PageData PageData = new PageData(); ScoreData ScoreData = new ScoreData(); AnswerData AnswerData = JsonConvert.DeserializeObject <AnswerData>(strAnswer); int _Score = 0; //分數 #region 分數計算 foreach (var i in AnswerData.exam) { DataTable dt = examq.QueryExamQuestionsByID(i.id); int _cntAns = 0; //計算答案格 bool _chkAns = false; //true:答對題目 string _anshtml = "<p>"; //HTML答案 string _AnsCopy = ""; //用於判斷一題當中是否有重覆的答案 for (int f = 1; f <= 10; f++) { #region DataTable Field if (bool.Parse(dt.Rows[0]["IsField" + f].ToString())) { //答案 _chkAns = false; foreach (string s in i.answer) { //檢查所有答案 #region answer if (s == dt.Rows[0]["Field" + f].ToString() && _AnsCopy != dt.Rows[0]["Field" + f].ToString()) { //答對 _AnsCopy = dt.Rows[0]["Field" + f].ToString(); //_Score = _Score + 10; //答對+10分 _Score++; //_anshtml += "<del class='text - danger'>"; //_anshtml += s; //寫的答案 //_anshtml += "</del>"; _chkAns = true; } #endregion } if (!_chkAns) { //答錯 _anshtml += "<del class='text - danger'>"; _anshtml += i.answer[_cntAns]; //寫的答案 _anshtml += "</del>"; _cntAns++; } _anshtml += "<ins class='text - success'>"; _anshtml += dt.Rows[0]["Field" + f].ToString(); //正確答案 _anshtml += "</ins>"; } else { //題目 _anshtml += dt.Rows[0]["Field" + f].ToString(); } #endregion } _anshtml += "</p>"; ScoreData.answer.Add(HttpUtility.HtmlEncode(_anshtml)); } #endregion if (_Score != 0) { //計算總題數 int _FieldCnt = 0; foreach (var i in AnswerData.exam) { foreach (string s in i.answer) { _FieldCnt++; } } //答錯每格扣幾分 //100分 - [(總題數 - 答對題數) * (每題幾分)] _Score = 100 - ((_FieldCnt - _Score) * (100 / _FieldCnt)); } ScoreData.score = _Score; //分數小於70表示不通過 if (_Score < 70) { PageData.IsPass = false; } PageData.DataInfo.Add(ScoreData); #region 分數登記 //Access DataBase uscore.InsUserScore(AnswerData.user[0].eclass, AnswerData.user[0].group, AnswerData.user[0].name, AnswerData.user[0].mobile, _Score.ToString()); //小組 string[] arrg = AnswerData.user[0].group.Split('.'); string GroupCName = arrg[1].Split('-')[0]; string GroupName = arrg[1].Split('-')[1]; DataTable dtMem = chcmem.QueryMemDataByChcMember(GroupCName, GroupName, AnswerData.user[0].name); if (dtMem != null && dtMem.Rows.Count > 0) { bool ChkUpd = false; switch (AnswerData.user[0].eclass) { case "C1": if (_Score > int.Parse(dtMem.Rows[0]["C1_Score"].ToString())) { ChkUpd = true; } break; case "C212": if (_Score > int.Parse(dtMem.Rows[0]["C212_Score"].ToString())) { ChkUpd = true; } break; case "C234": if (_Score > int.Parse(dtMem.Rows[0]["C234_Score"].ToString())) { ChkUpd = true; } break; } if (ChkUpd) { //寫入Log memlog.InsChcMember2ByChcMember_Log(GroupCName, GroupName, AnswerData.user[0].name); //更新成績 chcmem.UpdScoreByChcMember(AnswerData.user[0].eclass, AnswerData.user[0].mobile, GroupCName, GroupName, AnswerData.user[0].name, _Score); //通過判定我寫在Admin/SystemSet.aspx //當考卷開啓或關閉時更新通過狀態 } } //Google Excel SendGoogleExcel(AnswerData, _Score.ToString()); #endregion //查詢接下來可以考哪些科目(全部三科) DataTable dtScore = uscore.QueryUserScoreNoneExamCategory(AnswerData.user[0].group, AnswerData.user[0].name, DateTime.UtcNow.AddHours(8).ToString("yyyy/MM/dd")); if (dtScore.Rows.Count > 0) { int _c1 = 0; int _c212 = 0; int _c234 = 0; foreach (DataRow drECD in dtScore.Rows) { switch (drECD["ExamCategory"].ToString()) { case "C1": _c1++; break; case "C212": _c212++; break; case "C234": _c234++; break; } } if (_c1 == 0) { PageData.EClassData.Add("C1 測驗卷"); } if (_c212 == 0) { PageData.EClassData.Add("C2 一、二課測驗卷"); } if (_c234 == 0) { PageData.EClassData.Add("C2 三、四課測驗卷"); } } else { PageData.EClassData.Add("C1 測驗卷"); PageData.EClassData.Add("C2 一、二課測驗卷"); PageData.EClassData.Add("C2 三、四課測驗卷"); } Response.Write(JsonConvert.SerializeObject(PageData)); }
/// <summary> /// Update the answer in the database /// </summary> /// <param name="updatedAnswer">Answer to update, must specify the answer id</param> public void UpdateAnswer(AnswerData updatedAnswer, string languageCode) { SqlConnection connection = new SqlConnection(DbConnection.NewDbConnectionString); SqlCommand insertCommand = new SqlCommand("vts_spAnswerUpdate", connection); insertCommand.CommandType = CommandType.StoredProcedure; insertCommand.Parameters.Add(new SqlParameter("@LanguageCode", languageCode)); insertCommand.Parameters.Add(new SqlParameter("@AnswerID", SqlDbType.Int, 4, "AnswerID")); insertCommand.Parameters.Add(new SqlParameter("@AnswerText", SqlDbType.NVarChar, 0xfa0, "AnswerText")); insertCommand.Parameters.Add(new SqlParameter("@DefaultText", SqlDbType.NVarChar, 0xfa0, "DefaultText")); insertCommand.Parameters.Add(new SqlParameter("@AnswerPipeAlias", SqlDbType.NVarChar, 0xff, "AnswerPipeAlias")); insertCommand.Parameters.Add(new SqlParameter("@ImageURL", SqlDbType.NVarChar, 0x3e8, "ImageURL")); insertCommand.Parameters.Add(new SqlParameter("@AnswerTypeID", SqlDbType.Int, 4, "AnswerTypeID")); insertCommand.Parameters.Add(new SqlParameter("@RatePart", SqlDbType.Bit, 1, "RatePart")); insertCommand.Parameters.Add(new SqlParameter("@Selected", SqlDbType.Bit, 1, "Selected")); insertCommand.Parameters.Add(new SqlParameter("@ScorePoint", SqlDbType.Int, 4, "ScorePoint")); insertCommand.Parameters.Add(new SqlParameter("@RegularExpressionId", SqlDbType.Int, 4, "RegularExpressionId")); insertCommand.Parameters.Add(new SqlParameter("@Mandatory", SqlDbType.Bit, 1, "Mandatory")); insertCommand.Parameters.Add(new SqlParameter("@AnswerIDText", SqlDbType.NVarChar, 255, "AnswerIDText")); insertCommand.Parameters.Add(new SqlParameter("@AnswerAlias", SqlDbType.NVarChar, 255, "AnswerAlias")); insertCommand.Parameters.Add(new SqlParameter("@SliderRange", SqlDbType.NVarChar, 3, "SliderRange")); insertCommand.Parameters.Add(new SqlParameter("@SliderValue", SqlDbType.Int, 6, "SliderValue")); insertCommand.Parameters.Add(new SqlParameter("@SliderMin", SqlDbType.Int, 6, "SliderMin")); insertCommand.Parameters.Add(new SqlParameter("@SliderMax", SqlDbType.Int, 6, "SliderMax")); insertCommand.Parameters.Add(new SqlParameter("@SliderAnimate", SqlDbType.Bit, 1, "SliderAnimate")); insertCommand.Parameters.Add(new SqlParameter("@SliderStep", SqlDbType.Int, 6, "SliderStep")); DbConnection.db.UpdateDataSet(updatedAnswer, "Answers", insertCommand, new SqlCommand(), insertCommand, UpdateBehavior.Transactional); }
/// <summary> /// Parse an AnswerDataCollection, converts the data and /// returns an AnswerItemCollection filled with the correct /// child controls /// </summary> /// <param name="answers">A collection of answerdata entities</param> /// <param name="defaultSelectionMode">The default selection mode for the /// item (Radio, checkbox etc...)</param> /// <param name="parentcontrolUniqueID"> /// Unique ID required to identify global groups /// like radiobutton groups /// </param> /// <param name="showAnswerText"> /// Assigns the text to the answeritem control ? /// </param> /// <param name="voterAnswersState"> /// Current state of answers, used for piping. If not available /// leave it to null /// </param> /// <param name="enableDefaults"> /// Does the answer set the user default values of fields to the answer web controls /// </param> /// <returns>A collection of answeritem web controls</returns> public static AnswerItemCollection CreateAnswerItemCollection(AnswerData answers, QuestionItem question, Section section, AnswerSelectionMode defaultSelectionMode, Style answerStyle, ControlRenderMode renderMode, string languageCode, string parentControlUniqueID, bool showAnswerText, VoterAnswersData.VotersAnswersDataTable voterAnswersState, bool enableDefaults) { AnswerItemCollection items = new AnswerItemCollection(); foreach (AnswerData.AnswersRow row in answers.Answers.Rows) { items.Add(Create(row, question, section, defaultSelectionMode, answerStyle, renderMode, languageCode, parentControlUniqueID, showAnswerText, voterAnswersState, enableDefaults)); } return items; }
public void Setup(AnswerData data) { m_AnswerData = data; m_AnswerText.text = m_AnswerData.Answer; }
/// <summary> /// Creates a new answer item instance from the db answer data /// </summary> /// <param name="answer">The data source to create the instance from</param> /// <param name="question">The question container</param> /// <param name="defaultSelectionMode">The default selection mode for the /// item (Radio, checkbox etc...)</param> /// <param name="parentControlUniqueID"> /// Unique ID required to identify global selection groups /// like radiobutton groups /// </param> /// <param name="showAnswerText"> /// Assigns the text to the answeritem control ? /// </param> /// <param name="enableDefaults"> /// Does the answer set the user default values of fields to the answer web controls /// </param> public static AnswerItem Create(AnswerData.AnswersRow answer, QuestionItem question, Section section, AnswerSelectionMode defaultSelectionMode, Style answerStyle, ControlRenderMode renderMode, string languageCode, string parentControlUniqueID, bool showAnswerText, VoterAnswersData.VotersAnswersDataTable voterAnswersState, bool enableDefaults) { AnswerItem item = null; try { if (answer.TypeAssembly != null) { item = (AnswerItem) Assembly.Load(answer.TypeAssembly).CreateInstance(answer.TypeNameSpace); item.AnswerId = answer.AnswerId; item.ImageUrl = answer.IsImageURLNull() ? null : answer.ImageURL; item.ID = (section == null) ? (GlobalConfig.AnswerItemName + answer.AnswerId) : string.Concat(new object[] { GlobalConfig.AnswerItemName, answer.AnswerId, GlobalConfig.AnswerSectionName, section.SectionUid }); item.AnswerStyle = answerStyle; item.Question = question; item.QuestionId = answer.QuestionId; item.RenderMode = renderMode; item.Text = new PipeManager().PipeValuesInText(answer.QuestionId, answer.AnswerText, voterAnswersState, languageCode); item.ShowAnswerText = showAnswerText; item.SectionContainer = section; item.LanguageCode = languageCode; } } catch (FileNotFoundException) { item = new AnswerTextItem(); item.AnswerId = -1; item.Text = string.Format(ResourceManager.GetString("AnswerTypeAssemblyNotFoundMessage"), answer.TypeAssembly); return item; } catch (NullReferenceException) { item = new AnswerTextItem(); item.AnswerId = -1; item.Text = string.Format(ResourceManager.GetString("AnswerTypeNotFoundMessage"), answer.TypeNameSpace, answer.TypeAssembly); return item; } catch (InvalidCastException) { item = new AnswerTextItem(); item.AnswerId = -1; item.Text = string.Format(ResourceManager.GetString("AnswerTypeInvalidMessage"), answer.TypeNameSpace, answer.TypeAssembly); return item; } if (item is IClientScriptValidator) { IClientScriptValidator validator = (IClientScriptValidator) item; validator.JavascriptCode = answer.JavascriptCode; validator.JavascriptFunctionName = answer.JavascriptFunctionName; if (answer.JavascriptErrorMessage != null) { validator.JavascriptErrorMessage = (ResourceManager.GetString(answer.JavascriptErrorMessage, languageCode) == null) ? answer.JavascriptErrorMessage : ResourceManager.GetString(answer.JavascriptErrorMessage, languageCode); } else { validator.JavascriptErrorMessage = null; } validator.EnableValidation = true; } if (item is IMandatoryAnswer) { ((IMandatoryAnswer) item).Mandatory = answer.Mandatory; } if ((item is IRegExValidator) && (answer.RegExpression != null)) { ((IRegExValidator) item).RegExpression = answer.RegExpression; ((IRegExValidator) item).RegExpressionErrorMessage = answer.RegExMessage; } AnswerSelectionItem item2 = item as AnswerSelectionItem; if (item2 != null) { item2.UniqueGroupId = parentControlUniqueID; item2.AnswerId = answer.AnswerId; item2.TypeMode = (AnswerTypeMode) answer.TypeMode; item2.SelectionMode = defaultSelectionMode; bool flag = (section == null) ? IsUserSelected(answer.AnswerId, 0, voterAnswersState) : IsUserSelected(answer.AnswerId, section.SectionNumber, voterAnswersState); if (flag) { item2.Selected = flag; } else { item2.Selected = enableDefaults ? answer.Selected : false; } } if (item is IFieldItem) { IFieldItem item3 = (IFieldItem) item; item3.FieldHeight = answer.FieldHeight; item3.FieldWidth = answer.FieldWidth; item3.FieldLength = answer.FieldLength; } else if (item is AnswerDataSourceItem) { AnswerDataSourceItem item4 = (AnswerDataSourceItem) item; item4.QuestionId = answer.QuestionId; item4.AnswerId = answer.AnswerId; if (item4 is AnswerXmlItem) { item4.DataSource = answer.XmlDatasource; } else if (answer.DataSource != null) { item4.DataSource = ParseDefaultAnswerText(answer.QuestionId, answer.DataSource, voterAnswersState, languageCode); } item4.ImageUrl = answer.IsImageURLNull() ? null : answer.ImageURL; } string str = (section == null) ? GetUserText(answer.AnswerId, 0, voterAnswersState) : GetUserText(answer.AnswerId, section.SectionNumber, voterAnswersState); if (str != null) { item.DefaultText = str; } else if ((enableDefaults && !answer.IsDefaultTextNull()) && (answer.DefaultText.Length > 0)) { item.DefaultText = ParseDefaultAnswerText(answer.QuestionId, answer.DefaultText, voterAnswersState, languageCode); } if (item is ExtendedAnswerItem) { ((ExtendedAnswerItem) item).RestoreProperties(); } return item; }
/// <summary> /// Updates the columns /// </summary> private void ColsDataGrid_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { DataGridItem gridItem = (DataGridItem)e.Item; AnswerData answer = new AnswerData(); AnswerData.AnswersRow updatedAnswer = answer.Answers.NewAnswersRow(); updatedAnswer.AnswerText = ((TextBox)gridItem.Cells[0].Controls[0]).Text; updatedAnswer.AnswerTypeId = int.Parse(((DropDownList)gridItem.Cells[1].Controls[1]).SelectedValue); updatedAnswer.AnswerId = int.Parse(ColsDataGrid.DataKeys[gridItem.ItemIndex].ToString()); updatedAnswer.RatePart = ((CheckBox)gridItem.Cells[2].FindControl("RatingPartCheckBox")).Checked; updatedAnswer.Mandatory = ((CheckBox)gridItem.Cells[3].FindControl("MandatoryCheckBox")).Checked; answer.Answers.AddAnswersRow(updatedAnswer); new Answer().UpdateMatrixAnswer(answer, ChildsLanguageDropdownlist.SelectedValue); ColsDataGrid.EditItemIndex = -1; BindAnswerOptions(); MessageLabel.Visible = true; ((PageBase)Page).ShowNormalMessage(MessageLabel, ((PageBase)Page).GetPageResource("MatrixColumnUpdatedMessage")); }
public void Setup(AnswerData data) { answerData = data; answerText.text = answerData.answerText; Debug.Log(answerData.answerText); }
public void Setup(AnswerData data) { answerData = data; textoDaResposta.text = answerData.textoResposta; }
public void ShowAnswer(AnswerData result) { Clear(); StartCoroutine(Animate(result)); }
public void SetUp(AnswerData Data) { answerData = Data; // Manage Text answer; answerText.text = answerData.answerText; }
// Kill me now! IEnumerator Animate(AnswerData result) { Result.GetOrAddComponent <CanvasGroup>().Fade(0f, 1f, 0.5f); yield return(new WaitForSeconds(TimeBeforeShowAnswer)); Answer.gameObject.SetActive(true); Answer.text = string.Format("{0}", result.Answer); yield return(new WaitForSeconds(TimeBeforeShowChosenBy)); Divider.gameObject.SetActive(true); Divider.Fade(0f, 1f, 0.1f); ChosenBy.gameObject.SetActive(true); ChosenBy.gameObject.GetOrAddComponent <CanvasGroup>().Fade(0f, 1f, 0.1f); yield return(new WaitForSeconds(TimeBeforePlayersReveal)); float revealTime = TimeToRevealPlayers / result.Choosers.Count; foreach (var player in result.Choosers) { yield return(new WaitForSeconds(revealTime)); var instance = UiUtility.AddChild(Rows, RowPrototype, true); instance.PlayerName.text = player.Name; instance.gameObject.GetOrAddComponent <CanvasGroup>().Scale(Vector3.one * 5, Vector3.one, 0.2f); resultViews.Add(instance.gameObject); } if (result.Type != GameAnswerType.ActualAnswer) { yield return(new WaitForSeconds(TimeBeforeAuthorReveal)); } else { yield return(new WaitForSeconds(TimeBeforeActualAnswerReveal)); } Author.gameObject.SetActive(true); Author.gameObject.GetOrAddComponent <CanvasGroup>().Fade(0f, 1f, TimeAuthorFade); Author.gameObject.GetOrAddComponent <CanvasGroup>().Scale(new Vector3(5f, 5f, 1f), Vector3.one, TimeAuthorScale); if (result.Type == GameAnswerType.Player) { Author.text = string.Format(Strings.Result.PlayerAnswer, result.Author.Name); yield return(new WaitForSeconds(TimeBeforeScoreReveal)); Points.gameObject.SetActive(true); Points.text = string.Format("+{0}", result.Points.ToString()); Points.gameObject.GetOrAddComponent <CanvasGroup>().Fade(0f, 1f, TimeScoreFade); Points.gameObject.GetOrAddComponent <CanvasGroup>().Scale(new Vector3(5f, 5f, 1f), Vector3.one, TimeScoreScale); } else if (result.Type == GameAnswerType.Decoy) { Author.text = Strings.Result.Decoy; yield return(new WaitForSeconds(TimeBeforeScoreReveal)); } else { Author.text = string.Format(Strings.Result.ActualAnswer); yield return(new WaitForSeconds(TimeBeforeScoreReveal)); } if (result.Type != GameAnswerType.ActualAnswer) { yield return(new WaitForSeconds(TimeBeforeShowNextResult)); } else { yield return(new WaitForSeconds(TimeAfterActualAnswerReveal)); } Result.GetOrAddComponent <CanvasGroup>().Fade(1f, 0f, TimeFadeAfterResult); yield return(new WaitForSeconds(TimeFadeAfterResult)); if (OnFinishedShowingResult != null) { OnFinishedShowingResult(); } yield return(0); }
/// <summary> /// Parse an AnswerDataCollection, converts the data /// to webcontrols and returns a filled answer section /// </summary> protected abstract AnswerSection GetAnswerSection(AnswerData answers, int sectionNumber, int sectionUid);
static List <int> GetGrayClueIndexes(int fixedRowOrColIndex, bool isFixedRow, List <ColorableClueNumber> scaningClues, bool isAsc) { List <int> result = new List <int>(); int lastValue = -1; int chainedCount = 0; int selectClueIndex = isAsc ? 0 : scaningClues.Count - 1; int maxRowOrColIndex = (isFixedRow ? (MainGame.maxColumns + 1) : (MainGame.maxRows + 1)); for ( int tempColOrRowIndex = isAsc ? 1 : maxRowOrColIndex - 1; isAsc ? (tempColOrRowIndex < maxRowOrColIndex) : (tempColOrRowIndex >= 1); tempColOrRowIndex = isAsc ? tempColOrRowIndex + 1 : tempColOrRowIndex - 1) { int gridId = -1; if (isFixedRow) { gridId = MainGame.ConvertToGridID(tempColOrRowIndex, fixedRowOrColIndex, MainGame.maxColumns); } else { gridId = MainGame.ConvertToGridID(fixedRowOrColIndex, tempColOrRowIndex, MainGame.maxColumns); } if (myPuzzleAnswers.ContainsKey(gridId)) { if (isAsc ? (selectClueIndex > scaningClues.Count - 1) : (selectClueIndex < 0)) { break; } AnswerData ad = myPuzzleAnswers[gridId]; //Debug.Log(string.Format("AD id={0},isAnswered={1},isBlocked={2}", gridId, ad.currentAnswer, ad.isBlocked)); if (ad.currentAnswer) { chainedCount++; if ((isAsc && tempColOrRowIndex == (maxRowOrColIndex - 1)) || (!isAsc && tempColOrRowIndex == 1)) { if (chainedCount == scaningClues[selectClueIndex].number) { result.Add(selectClueIndex); } else { } } } else if (ad.isBlocked) { if (lastValue == 1) { if (chainedCount == scaningClues[selectClueIndex].number) { result.Add(selectClueIndex); } chainedCount = 0; selectClueIndex = isAsc ? selectClueIndex + 1 : selectClueIndex - 1; } } else if (!ad.currentAnswer) { if (lastValue == 1 && (chainedCount == scaningClues[selectClueIndex].number)) { result.Add(selectClueIndex); selectClueIndex = isAsc ? selectClueIndex + 1 : selectClueIndex - 1; chainedCount = 0; } break; } lastValue = (ad.isBlocked) ? 2 : ad.currentAnswer ? 1 : 0; } } return(result); }