Example #1
0
        public static string GetDescription(QuestionType enumerationValue)
        {
            Type type = enumerationValue.GetType();

            if (!type.IsEnum)
            {
                throw new ArgumentException("EnumerationValue must be of Enum type", "enumerationValue");
            }

            //Tries to find a DescriptionAttribute for a potential friendly name
            //for the enum
            MemberInfo[] memberInfo = type.GetMember(enumerationValue.ToString());
            if (memberInfo != null && memberInfo.Length > 0)
            {
                object[] attrs = memberInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);

                if (attrs != null && attrs.Length > 0)
                {
                    //Pull out the description value
                    return(((DescriptionAttribute)attrs[0]).Description);
                }
            }
            //If we have no description attribute, just return the ToString of the enum
            return(enumerationValue.ToString());
        }
Example #2
0
    public static int GetLessonBestScore(QuestionType Category, int lessonNumber)
    {
        int lesson = 0;

        P2DSecurety.SecureLocalLoad(lessonOfLevelKey + Category.ToString() + lessonNumber.ToString(), out lesson);
        return(lesson);
    }
Example #3
0
        public static void InitData(QuestionType questionType)
        {
            var xmlDataDocument = new XmlDocument();

            xmlDataDocument.Load(@"C:\\Users\\Ion Ml\\source\\repos\\Quiz\\Quiz\\Models\\Questions.xml");
            foreach (XmlNode questionNode in xmlDataDocument.DocumentElement)
            {
                if (string.Equals(questionNode.Name, questionType.ToString(), StringComparison.OrdinalIgnoreCase))
                {
                    var questionName = questionNode.Attributes[0].InnerText;

                    var answerNodeList = questionNode.ChildNodes;
                    var answerList     = new List <Answer>();
                    foreach (XmlElement answerNode in answerNodeList)
                    {
                        var answerName = answerNode.InnerText;
                        var isValid    = bool.Parse(answerNode.Attributes[0].InnerText);
                        var answer     = new Answer(answerName, isValid);
                        answerList.Add(answer);
                    }

                    var questionsAndAnswer = new QuestionAndAnswer(questionName, answerList);
                    _quizQuestions.Add(questionsAndAnswer);
                }
            }
        }
Example #4
0
    public static int GetLastOpenLesson(QuestionType category)
    {
        int lesson = 0;

        P2DSecurety.SecureLocalLoad(lessonOfLevelKey + category.ToString(), out lesson);
        return(lesson);
    }
Example #5
0
        public BaseView(string name, Grid currentGrid)
        {
            InitializeComponent();
            NameTest.Text = name;
            QuestionType questionType = EnR();

            if (questionType == QuestionType.Deffoult)
            {
                questionType = RuR();

                if (questionType == QuestionType.Deffoult)
                {
                    questionType = UaR();
                }
            }
            var temp = MainHistoryEntity.CodingHistorys?.FirstOrDefault(p => p.NameTest ==
                                                                        questionType.ToString());

            DateTest.Text += temp?.TestHistorys?.Last()?.CreateTiem.Date;
            BestMark.Text += temp?.TestHistorys?.Max(p => p.Mark) ?? 0;
            Try.Text      += temp?
                             .TestHistorys?.Count() ?? 0;
            _currentGrid      = currentGrid;
            StaertTest.Click += StaertTest_Click;
        }
Example #6
0
 public static Question Map(string result, QuestionType requestedQuestionType)
 {
     return(new Question
     {
         QuestionType = requestedQuestionType.ToString(),
         Title = result
     });
 }
Example #7
0
    public static void SetLastOpenLesson(QuestionType category, int value)
    {
        P2DSecurety.SecureLocalSave(lessonOfLevelKey + category.ToString(), value);

        if (onScoreChangeEvent != null)
        {
            onScoreChangeEvent(category);
        }
    }
Example #8
0
    public static void SetLessonBestScore(QuestionType Category, int lessonNumber, int value)
    {
        P2DSecurety.SecureLocalSave(lessonOfLevelKey + Category.ToString() + lessonNumber.ToString(), value);

        if (onScoreChangeEvent != null)
        {
            onScoreChangeEvent(Category);
        }
    }
        public Dictionary <string, string> BaseExportDict()
        {
            Dictionary <string, string> dict = new Dictionary <string, string>()
            {
                { id + "_questiontype", questiontype.ToString() },
                { id + "_required", required.ToString() },
                { id + "_answerCounter", answerCounter.ToString() },
                { id + "_isAnswered", isAnswered.ToString() },
                { id + "_answerUtcTime", answerUtcTime.ToString() },
                { id + "_showUtcTime", showUtcTime.ToString() },
                { id + "_hideUtcTime", showUtcTime.ToString() }
            };

            return(dict);
        }
Example #10
0
        public GameObject CreateQuestion(QuestionType questionType)
        {
            var name = questionType.ToString();

            try
            {
                var question = (GameObject)UnityEngine.Object.Instantiate(Resources.Load(name));
                question.transform.SetParent(this._parentObject.transform, false);
                question.name = name;

                return(question);
            }
            catch (ArgumentException)
            {
                throw new ArgumentException($@"Could not find prefab named {name} in Resources directory. Check your spelling or create this prefab.");
            }
        }
        /// <summary>
        /// 新增選擇問題
        /// </summary>
        /// <param name="Qtype"></param>
        /// <param name="name"></param>
        /// <param name="label"></param>
        /// <param name="width"></param>
        /// <param name="rows"></param>
        /// <param name="GridColXml"></param>
        /// <param name="GridDefaultXml"></param>
        public void AddQuestionSelect(QuestionType Qtype, string name, string label, string width, int rows,XElement  GridColXml,XElement GridDefaultXml)
        {
            if (_QGroup.Element("Qs") == null)
                _QGroup.SetElementValue("Qs", "");

            XElement elm = new XElement("Q");
            elm.SetAttributeValue("type", Qtype.ToString());
            elm.SetAttributeValue("name", name);
            elm.SetAttributeValue("label", label);
            elm.SetAttributeValue("width", width);

            // 解析使用 Grid 型態
            if (Qtype == QuestionType.grid)
            {
                elm.SetAttributeValue("rows", rows.ToString());
                elm.Add(GridColXml);
                elm.Add(GridDefaultXml);
            }
        }
Example #12
0
        public ListItemValue(QuestionType questionType, object theValue)
        {
            switch (questionType)
            {
            case QuestionType.Text:
                ValueText = (string)theValue;
                break;

            case QuestionType.Numeric:
                ValueNumeric = (decimal?)theValue;
                break;

            case QuestionType.Bool:
                ValueBool = (bool?)theValue;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(questionType), questionType.ToString());
            }
        }
Example #13
0
        public static string GenerateApiUrl(uint amount,
                                            QuestionCategory category     = QuestionCategory.Any,
                                            QuestionDifficulty difficulty = QuestionDifficulty.Any,
                                            QuestionType type             = QuestionType.Any,
                                            ResponseEncoding encoding     = ResponseEncoding.Default,
                                            string sessionToken           = "")
        {
            if (amount < 1 || amount > 50)
            {
                throw new ArgumentOutOfRangeException(nameof(amount), amount, "Amount must be between 1 and 50.");
            }

            string query = $"amount={amount}";

            if (category != QuestionCategory.Any)
            {
                query += $"&category={category:D}";
            }

            if (difficulty != QuestionDifficulty.Any)
            {
                query += $"&difficulty={difficulty.ToString().ToLowerInvariant()}";
            }

            if (type != QuestionType.Any)
            {
                query += $"&type={type.ToString().ToLowerInvariant()}";
            }

            if (encoding != ResponseEncoding.Default)
            {
                query += $"&encode={encoding}";
            }

            if (!string.IsNullOrEmpty(sessionToken))
            {
                query += $"&token={sessionToken}";
            }

            return($"{ApiEndpoint}?{query}");
        }
        /** Public methods **/
        public QuestionsResponse RequestQuestions(uint amount,
                                                  QuestionDifficulty difficulty = QuestionDifficulty.Undefined,
                                                  QuestionType type             = QuestionType.Undefined,
                                                  ResponseEncoding encoding     = ResponseEncoding.Undefined,
                                                  uint categoryID     = 0,
                                                  string sessionToken = "")
        {
            string Url = "https://opentdb.com/api.php?amount=" + amount;

            if (categoryID != 0)
            {
                Url += "&category=" + categoryID;
            }

            if (difficulty != QuestionDifficulty.Undefined)
            {
                Url += "&difficulty=" + difficulty.ToString().ToLower();
            }

            if (type != QuestionType.Undefined)
            {
                Url += "&type=" + type.ToString().ToLower();
            }

            if (encoding != ResponseEncoding.Undefined)
            {
                Url += "&encode=" + encoding.ToString();
            }

            if (sessionToken != "")
            {
                Url += "&token=" + sessionToken;
            }

            string JsonString = SendAPIRequest(Url);

            return(JsonConvert.DeserializeObject <QuestionsResponse>(JsonString));
        }
Example #15
0
 public string GetTemplateName()
 {
     return(QuestionType.ToString());
 }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            QuestionType type = (QuestionType)value;

            return(Application.Current.Resources[type.ToString()]);
        }
Example #17
0
 public static void SetQuestionType(this MyFirstAlexaSkill.Application.AlexaServiceResponse response, QuestionType type)
 {
     response.sessionAttributes.Add("questionType", type.ToString());
 }
Example #18
0
 private static ClientModels.QuestionType ToQuestionType(this QuestionType questionType)
 {
     return((ClientModels.QuestionType)Enum.Parse(typeof(QuestionType), questionType.ToString()));
 }
Example #19
0
        private void updateRightPanel()
        {
            if (this.contentTreeView.SelectedItem == null)
            {
                return;
            }

            if (this.contentTreeView.SelectedItem == this.rootTreeViewItem)
            {
                this.contentTreeView.ContextMenu = this.contentTreeView.Resources["eidtAppContextMenu"] as ContextMenu;
            }
            else if (this.contentTreeView.SelectedItem is KnowledgeTreeNode)
            {
                this.contentTreeView.ContextMenu = this.contentTreeView.Resources["knowledgeContextMenu"] as ContextMenu;

                this.rightContentDockPanel.Children.Clear();
                this.rightContentDockPanel.Children.Add(this.KnowledgeUserControl);
                this.KnowledgeUserControl.ShowKnowledge();
            }
            else if (this.contentTreeView.SelectedItem is QuestionBankTreeNode)
            {
                this.contentTreeView.ContextMenu = this.contentTreeView.Resources["questionBankContextMenu"] as ContextMenu;

                this.rightContentDockPanel.Children.Clear();
                this.rightContentDockPanel.Children.Add(this.QuestionListUserControl);
                this.QuestionListUserControl.ShowQuestion(QuestionType.None);
            }
            else if (this.contentTreeView.SelectedItem is QuestionTypeTreeNode)
            {
                this.contentTreeView.ContextMenu = this.contentTreeView.Resources["questionTypeContextMenu"] as ContextMenu;
                QuestionType type = ((QuestionTypeTreeNode)this.contentTreeView.SelectedItem).Type;
                ((MenuItem)(this.contentTreeView.ContextMenu.Items[0])).CommandParameter = type.ToString();

                this.rightContentDockPanel.Children.Clear();
                this.rightContentDockPanel.Children.Add(this.QuestionListUserControl);
                this.QuestionListUserControl.ShowQuestion(type);
            }
        }
Example #20
0
        private void PopulateControls()
        {
            if (survey != null)
            {
                lnkPages.Text = string.Format(CultureInfo.InvariantCulture,
                                              SurveyResources.SurveyPagesLabelFormatString,
                                              survey.SurveyName);

                litHeading.Text = string.Format(CultureInfo.InvariantCulture,
                                                SurveyResources.QuestionEditFormatString,
                                                survey.SurveyName);
            }

            if (currentModule != null)
            {
                lnkSurveys.Text = string.Format(CultureInfo.InvariantCulture,
                                                SurveyResources.ChooseActiveSurveyFormatString,
                                                currentModule.ModuleTitle);
            }

            if (surveyPage != null)
            {
                lnkQuestions.Text = string.Format(CultureInfo.InvariantCulture,
                                                  SurveyResources.QuestionsPageFormatString,
                                                  surveyPage.PageTitle);
            }



            if (Page.IsPostBack)
            {
                return;
            }

            if (questionGuid == Guid.Empty)
            {
                lblQuestionType.Text = questionType.ToString();

                if (questionType == QuestionType.TextBox || questionType == QuestionType.Date)
                {
                    addOptionRow.Visible = false;
                    itemsRow.Visible     = false;
                }
                return;
            }

            lblQuestionType.Text      = ((QuestionType)question.QuestionTypeId).ToString();
            edMessage.Text            = question.QuestionText;
            chkAnswerRequired.Checked = question.AnswerIsRequired;
            txtValidationMessage.Text = question.ValidationMessage;

            if ((QuestionType)question.QuestionTypeId == QuestionType.TextBox || questionType == QuestionType.Date)
            {
                addOptionRow.Visible = false;
                itemsRow.Visible     = false;
            }

            foreach (QuestionOption option in QuestionOption.GetAll(questionGuid))
            {
                lbOptions.Items.Add(new ListItem(option.Answer, option.QuestionOptionGuid.ToString()));
            }
        }