public void TrueFalseQuestionTest1()
        {
            TrueFalseQuestion q = new TrueFalseQuestion("Titre", "Texte", "FeedBack", true, "Feedback Vrai", "Feedback Faux");

            //
            Assert.AreEqual(QuestionType.TrueFalse, q.Type);
            Assert.AreEqual("Titre", q.Name);
            Assert.AreEqual("Texte", q.QuestionText);
            Assert.AreEqual("FeedBack", q.GeneralFeedback);
            Assert.AreEqual("Feedback Vrai", q.FeedbackTrue);
            Assert.AreEqual("Feedback Faux", q.FeedbackFalse);
            Assert.AreEqual(true, q.Correct);
            //
            Action    action = () => q.AddAnswer("true", "aucune", 100);
            Exception exc    = Assert.ThrowsException <OverflowException>(action);

            //
            Trace.WriteLine(q.MoodleXML.OuterXml);
        }
    public void SaveQuestion()
    {
        int            QuestionNumber = EventSystem.current.currentSelectedGameObject.GetComponentInParent <PanelModel>().PanelNumber;
        TMP_InputField questionInput  = EventSystem.current.currentSelectedGameObject.GetComponentInChildren <TMP_InputField>(); //get the question

        TMP_InputField[]  answersInput     = questionInput.GetComponentsInChildren <TMP_InputField>();                           //get the answers
        Toggle[]          answersIsCorrect = new Toggle[answersInput.Length];
        List <AnswerData> answers          = new List <AnswerData>();

        for (int i = 1; i < answersInput.Length; i++)
        {
            answersIsCorrect[i] = answersInput[i].GetComponentInChildren <Toggle>(); //get the correct statement of the answer
            answers.Add(new AnswerData(answersInput[i].text, answersIsCorrect[i].isOn));
        }

        TrueFalseQuestion question = new TrueFalseQuestion(questionInput.text, answers.ToArray());                  //create a new TextQuestion

        DataModel.Rounds[DataModel.IroundCur].Topics[DataModel.ItopicCur].Questions[QuestionNumber - 1] = question; //add the question to the current topic in the DataModel
    }
    /**
     * Create a new question in the DataModel and fill it with default value
     **/
    public void NewQuestionPanelData()
    {
        nbQ++;
        questionPrefab      = Instantiate(Resources.Load <RectTransform>("Prefabs/TFSample"), GameObject.Find("QGrid").transform);
        questionPrefab.name = "TFSample" + nbQ;
        questionPrefab.GetComponent <PanelModel>().PanelNumber = nbQ;
        questionPrefab.Find("Delete").GetComponent <Button>().onClick.AddListener(() => RemoveQuestion());
        questionPrefab.Find("Delete").GetComponentInChildren <TextMeshProUGUI>().text = DataModel.TextToUse["menu_remove"];
        questionPrefab.Find("ValidateQuestion").GetComponent <Button>().onClick.AddListener(() => SaveQuestion());
        questionPrefab.Find("ValidateQuestion").Find("Validate").GetComponent <TextMeshProUGUI>().text = DataModel.TextToUse["menu_validate"];
        questionPrefab.Find("ValidateQuestion").Find("QField").Find("Text Area").Find("Placeholder").GetComponent <TextMeshProUGUI>().text = DataModel.TextToUse["enter_questiontext"];
        for (int i = 1; i < 3; i++)
        {
            questionPrefab.Find("ValidateQuestion").Find("QField").Find("AnswerField").Find("A" + i + "Field").Find("Text Area").GetComponentInChildren <TextMeshProUGUI>().text = DataModel.TextToUse["enter_answertext"];
            questionPrefab.Find("ValidateQuestion").Find("QField").Find("AnswerField").Find("A" + i + "Field").Find("TrueA" + i).GetComponentInChildren <TextMeshProUGUI>().text = DataModel.TextToUse["correct_answer"];
        }
        //add a neutral question when user press the AddQuestion button and add it to the DataModel
        AnswerData[]      ans      = { new AnswerData("a", false), new AnswerData("b", false) };
        TrueFalseQuestion question = new TrueFalseQuestion("question", ans);

        DataModel.Rounds[DataModel.IroundCur].Topics[DataModel.ItopicCur].Questions.Add(question);
    }
Beispiel #4
0
        public List <TestQuestion> GetQuestions()
        {
            List <TestQuestion> questions = null;
            string dir = System.IO.Path.Combine(AppDomain.CurrentDomain.GetData("DataDirectory").ToString(), "Midterm.json");

            using (StreamReader sr = new StreamReader(dir))
            {
                string jsonContent = sr.ReadToEnd();
                questions = new List <TestQuestion>(JsonConvert.DeserializeObject <List <TestQuestion> >(jsonContent));
            }

            for (int i = 0; i < questions.Count; i++)
            {
                switch (questions[i].Type)
                {
                case "TrueFalseQuestion":
                    questions[i] = new TrueFalseQuestion(questions[i]);
                    break;

                case "ShortAnswerQuestion":
                    questions[i] = new ShortAnswerQuestion(questions[i]);
                    break;

                case "LongAnswerQuestion":
                    questions[i] = new LongAnswerQuestion(questions[i]);
                    break;

                case "MultipleChoiceQuestion":
                    questions[i] = new MultipleChoiceQuestion(questions[i]);
                    break;

                default:
                    break;
                }
            }

            return(questions);
        }
Beispiel #5
0
        public IQuestion Build(string contents)
        {
            var match = _questionRegex.Match(contents);

            var num    = int.Parse(match.Groups[1].Value);
            var text   = match.Groups[2].Value.Trim();
            var answer = match.Groups[3].Value;

            var question = new TrueFalseQuestion(num, text);

            if (answer.Equals("true", StringComparison.CurrentCultureIgnoreCase))
            {
                question.Answer = true;
            }
            else if (answer.Equals("false", StringComparison.CurrentCultureIgnoreCase))
            {
                question.Answer = false;
            }

            _questionExtraFactory.InsertExtras(contents, question);

            return(question);
        }
Beispiel #6
0
        public void TrueFalseQuestionTest(string response, bool expectedIsValid, double expectedCorrectness)
        {
            Question question = new TrueFalseQuestion("A True Question", "true");

            // Question should be NOT complete
            Assert.IsFalse(question.IsComplete);

            bool isValid = question.ValidateAnswerAndSetResponse(response);

            Assert.AreEqual(expectedIsValid, isValid);

            if (isValid)
            {
                // Question should be correct (1.0) and Complete
                Assert.IsTrue(question.IsComplete);
                Assert.AreEqual(expectedCorrectness, question.Correctness);
            }
            else
            {
                // Question should not be Complete
                Assert.IsFalse(question.IsComplete);
            }
        }
        public ActionResult SaveTrueFalseQuestion(TrueFalseQuestion ques)
        {
            TeacherData teacherData = rsContext.getTeacher(User.Identity.Name);

            if (ques.expID == -1)
            {
                ques.RoomId = teacherData.RoomId;
                TrueFalseQuestionData tfqData = Adapting.getTrueFalseQuestionAsData(ques);
                rsContext.addActivity(tfqData);
                rsContext.SaveChanges();
                return(RedirectToDashboard());
            }
            else
            {
                ques.RoomId = 0;
                TrueFalseQuestionData tfqData = Adapting.getTrueFalseQuestionAsData(ques);
                rsContext.addActivity(tfqData);
                ExperimentData experimentData = (ExperimentData)rsContext.getActivity(ques.expID);
                tfqData.experimentOrder = experimentData.activities.Count;
                experimentData.addStep(tfqData);
                rsContext.SaveChanges();
                return(RedirectToAction("EditExperiment", new { ExpID = ques.expID }));
            }
        }
Beispiel #8
0
    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;
    }
Beispiel #9
0
    /**
     * @author David
     *
     * Saving the current state of DataModel in the data.json file
     **/
    public static void Save(string filepath)
    {
        JSONObject dataJson = new JSONObject();

        dataJson.Add("Quizname", QuizName);
        dataJson.Add("CurTopicName", CurTopicName);
        dataJson.Add("RoundNumber", RoundNumber);
        // indexes
        dataJson.Add("IroundCur", IroundCur);
        dataJson.Add("ItopicCur", ItopicCur);
        dataJson.Add("IquestionCur", IquestionCur);

        for (int i = 0; i < Scores.Length; i++)
        {
            dataJson.Add("Score" + i, Scores[i]);
            dataJson.Add("Joker" + i, Jokers[i]);
        }

        JSONArray roundsJsonArray = new JSONArray();

        foreach (RoundData rd in Rounds)
        {
            JSONObject roundJson = new JSONObject();
            roundJson.Add("Type", rd.Type);
            roundJson.Add("IsBuzzActivate", rd.IsBuzzRound);
            JSONArray topicsJsonArray = new JSONArray();
            foreach (TopicData td in rd.Topics)
            {
                JSONObject topicJson = new JSONObject();

                topicJson.Add("Name", td.Name);
                topicJson.Add("IsAvailable", td.IsAvailable);

                JSONArray questionsJsonArray = new JSONArray();
                foreach (QuestionData qd in td.Questions)
                {
                    JSONObject questionJson = new JSONObject();

                    switch (qd.GetType().ToString())
                    {
                    case "MusicQuestion":
                        MusicQuestion mq = (MusicQuestion)qd;
                        questionJson.Add("MusicPath", mq.MusicPath);
                        questionJson.Add("StartTrack", mq.StartTrack);
                        questionJson.Add("Volume", mq.Volume);
                        questionJson.Add("Fade", mq.Fade);
                        break;

                    case "ImageQuestion":
                        ImageQuestion iq = (ImageQuestion)qd;
                        questionJson.Add("ImagePath", iq.ImagePath);
                        break;

                    case "TextQuestion":
                        TextQuestion tq = (TextQuestion)qd;
                        questionJson.Add("Question", tq.Question);
                        break;

                    case "TrueFalseQuestion":
                        TrueFalseQuestion tfq = (TrueFalseQuestion)qd;
                        questionJson.Add("Question", tfq.Question);
                        break;

                    default: Debug.LogError("Type de question non-reconnu"); break;
                    }

                    JSONArray answersJsonArray = new JSONArray();

                    foreach (AnswerData ad in qd.Answers)
                    {
                        JSONObject answerJson = new JSONObject();

                        answerJson.Add("AnswerText", ad.AnswerText);
                        answerJson.Add("IsTrue", ad.IsTrue);

                        answersJsonArray.Add(answerJson);
                    }
                    questionJson.Add("Answers", answersJsonArray);

                    questionsJsonArray.Add(questionJson);
                }
                topicJson.Add("Questions", questionsJsonArray);

                topicsJsonArray.Add(topicJson);
            }

            roundJson.Add("Topics", topicsJsonArray);

            roundsJsonArray.Add(roundJson);
        }

        dataJson.Add("Rounds", roundsJsonArray);

        File.WriteAllText(filepath, dataJson.ToString());
    }
 private void ConvertTrueFalseFromXml(TrueFalseQuestion question, XElement element)
 {
     // Here you can populate specific attributes from the XElement
     // to the whole typed question instance!
 }
Beispiel #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="testFileName"></param>
        /// <returns></returns>
        private static List <Question> ReadFile(string testFileName)
        {
            List <Question> testQuestion = new List <Question>();

            try
            {
                using (StreamReader sr = new StreamReader(testFileName, Encoding.UTF8))
                {
                    TestTitle = sr.ReadLine();
                    string questionTypeFromFile;
                    while ((questionTypeFromFile = sr.ReadLine()) != null)
                    {
                        questionTypeFromFile = questionTypeFromFile.ToUpperInvariant();
                        if (questionTypeFromFile.Equals(Constants.QuestionType.K.ToString()))
                        {
                            KeyTermQuestion k = new KeyTermQuestion();
                            k.KeyTerm = sr.ReadLine();
                            k.ValidateAndSetMedia((Constants.MediaType)Enum.Parse(typeof(Constants.MediaType), sr.ReadLine()), sr.ReadLine());
                            k.Definition  = sr.ReadLine();
                            k.Explanation = k.KeyTerm + ": " + k.Definition;
                            testQuestion.Add(k);
                        }
                        else if (questionTypeFromFile.Equals(Constants.QuestionType.M.ToString()))
                        {
                            MultipleChoiceQuestion m = new MultipleChoiceQuestion();
                            m.Question = sr.ReadLine();
                            m.ValidateAndSetMedia((Constants.MediaType)Enum.Parse(typeof(Constants.MediaType), sr.ReadLine()), sr.ReadLine());
                            m.NumberOfChoices = Int32.Parse(sr.ReadLine());
                            for (int x = 0; x <= m.NumberOfChoices; x++)
                            {
                                m.Choices.Add(sr.ReadLine());
                            }
                            string tempExplanation = sr.ReadLine();
                            if (tempExplanation.ToLowerInvariant().Equals("null") || String.IsNullOrEmpty(tempExplanation))
                            {
                                m.Explanation = "The answer is: " + m.Choices[0];
                            }
                            else
                            {
                                m.Explanation = tempExplanation;
                            }
                            testQuestion.Add(m);
                        }
                        else if (questionTypeFromFile.Equals(Constants.QuestionType.T.ToString()))
                        {
                            TrueFalseQuestion t = new TrueFalseQuestion();
                            t.Question = sr.ReadLine();
                            t.ValidateAndSetMedia((Constants.MediaType)Enum.Parse(typeof(Constants.MediaType), sr.ReadLine()), sr.ReadLine());
                            t.Answer = Boolean.Parse(sr.ReadLine());
                            string tempExplanation = sr.ReadLine();
                            if (tempExplanation.ToLowerInvariant().Equals("null") || String.IsNullOrEmpty(tempExplanation))
                            {
                                t.Explanation = "The answer is: " + t.Answer;
                            }
                            else
                            {
                                t.Explanation = tempExplanation;
                            }
                            testQuestion.Add(t);
                        }
                        else
                        {
                            throw new ArgumentException("Corrupt data file. Check structure and values.");
                        }
                    }
                }
            }
            catch (FileNotFoundException ex)
            {
                throw new FileNotFoundException("Cannot find test file: " + ex.ToString());
            }
            catch (IOException ex)
            {
                throw new IOException("Cannot open test file: " + ex.ToString());
            }
            return(testQuestion);
        }
Beispiel #12
0
        /// <summary>
        /// Creates an array list of test questions.
        /// </summary>
        /// <param name="testFileName">The name of the test data file</param>
        /// <param name="questionOrder">Question order setting: Default to display questions as read from the file, Random to randomize the order.</param>
        /// <param name="termDisplay">Term display settings: TermAsQuestion to display terms as question (Default); DefinitionAsQuestion to display definitions as question; Mixed to mix it up.</param>
        /// <returns>A formatted list of test questions created from test data objects.</returns>
        public static List <TestQuestion> GetTest(string testFileName, Constants.QuestionOrder questionOrder, Constants.TermDisplay termDisplay)
        {
            List <TestQuestion> testQuestions = new List <TestQuestion>();
            List <Question>     testData      = ReadFile(testFileName);
            List <int>          ktIndex       = new List <int>();

            for (int x = 0; x < testData.Count; x++)
            {
                if (testData[x].QuestionType == Constants.QuestionType.K)
                {
                    ktIndex.Add(x);
                }
            }
            int ktCount = 0;

            for (int x = 0; x < testData.Count; x++)
            {
                Constants.QuestionType qt = testData[x].QuestionType;
                RandomNumbers          rn;
                switch (qt)
                {
                case Constants.QuestionType.K:
                    KeyTermQuestion kt = (KeyTermQuestion)testData[x];
                    int             ktNumberOfChoices = ((ktIndex.Count - 1) < 3 ? (ktIndex.Count - 1) : 3);
                    List <string>   ktTempChoices     = new List <string>();
                    rn = new RandomNumbers((ktIndex.Count - 1), ktCount, ktNumberOfChoices);
                    bool displayTermAsQuestion = true;
                    switch (termDisplay)
                    {
                    case Constants.TermDisplay.DefinitionAsQuestion:
                        displayTermAsQuestion = false;
                        break;

                    case Constants.TermDisplay.Mixed:
                        displayTermAsQuestion = (Random.Next(2) == 0 ? false : true);
                        break;

                    case Constants.TermDisplay.TermAsQuestion:
                    default:
                        break;
                    }
                    if (displayTermAsQuestion)
                    {
                        for (int y = 0; y <= ktNumberOfChoices; y++)
                        {
                            ktTempChoices.Add(((KeyTermQuestion)testData[ktIndex[rn.UniqueArray[y]]]).Definition);
                        }
                        testQuestions.Add(new TestQuestion(qt, kt.KeyTerm, kt.MediaType, kt.MediaFileName, ktNumberOfChoices, ktTempChoices, rn.IndexLocation, kt.Explanation));
                    }
                    else
                    {
                        for (int y = 0; y <= ktNumberOfChoices; y++)
                        {
                            ktTempChoices.Add(((KeyTermQuestion)testData[ktIndex[rn.UniqueArray[y]]]).KeyTerm);
                        }
                        testQuestions.Add(new TestQuestion(qt, kt.Definition, kt.MediaType, kt.MediaFileName, ktNumberOfChoices, ktTempChoices, rn.IndexLocation, kt.Explanation));
                    }
                    ktCount++;
                    break;

                case Constants.QuestionType.M:
                    MultipleChoiceQuestion mc            = (MultipleChoiceQuestion)testData[x];
                    List <string>          mcTempChoices = new List <string>();
                    rn = new RandomNumbers(mc.NumberOfChoices, 0, mc.NumberOfChoices);
                    for (int i = 0; i <= mc.NumberOfChoices; i++)
                    {
                        mcTempChoices.Add(mc.Choices[rn.UniqueArray[i]]);
                    }
                    testQuestions.Add(new TestQuestion(qt, mc.Question, mc.MediaType, mc.MediaFileName, mc.NumberOfChoices, mcTempChoices, rn.IndexLocation, mc.Explanation));
                    break;

                case Constants.QuestionType.T:
                    TrueFalseQuestion tf            = (TrueFalseQuestion)testData[x];
                    List <string>     tfTempChoices = new List <string> {
                        "true",
                        "false"
                    };
                    testQuestions.Add(new TestQuestion(qt, tf.Question, tf.MediaType, tf.MediaFileName, 1, tfTempChoices, (tf.Answer ? 0 : 1), tf.Explanation));
                    break;

                default:
                    throw new ArgumentException("Corrupt data. Check structure and values.");
                }
            }
            if (questionOrder == Constants.QuestionOrder.Random)
            {
                RandomNumbers qoArray = new RandomNumbers(testQuestions.Count);
                for (int x = 0; x < testQuestions.Count; x++)
                {
                    TestQuestion temp = testQuestions[x];
                    testQuestions[x] = testQuestions[qoArray.UniqueArray[x]];
                    testQuestions[qoArray.UniqueArray[x]] = temp;
                }
            }
            return(testQuestions);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            questions[0] = new TrueFalseQuestion();
            (questions[0] as TrueFalseQuestion).QuestionText = "HTTP is a stateless protocol";
            questions[1] = new TrueFalseQuestion();
            (questions[1] as TrueFalseQuestion).QuestionText = "SessionState can be transferred between pages";
            questions[2] = new TrueFalseQuestion();
            (questions[2] as TrueFalseQuestion).QuestionText = "Sanitizing database inputs is only important for sites handling sensitive information";
            questions[3] = new TrueFalseQuestion();
            (questions[3] as TrueFalseQuestion).QuestionText = "ViewState can be transferred between pages";
            questions[4] = new TrueFalseQuestion();
            (questions[4] as TrueFalseQuestion).QuestionText = "Cookies can be transferred between pages";
            questions[5] = new TrueFalseQuestion();
            (questions[5] as TrueFalseQuestion).QuestionText = "It is a good practice to use inline CSS styles";
            questions[6] = new TrueFalseQuestion();
            (questions[6] as TrueFalseQuestion).QuestionText = "All controls in ASP.NET support DataBinding";
            questions[7] = new TrueFalseQuestion();
            (questions[7] as TrueFalseQuestion).QuestionText = "Browsers must support ASP.NET in order to display pages created with it";
            questions[8] = new TrueFalseQuestion();
            (questions[8] as TrueFalseQuestion).QuestionText = "When a MasterPage is used, a page wraps its own content with the MasterPages’s content";
            questions[9] = new TrueFalseQuestion();
            (questions[9] as TrueFalseQuestion).QuestionText = "&lt;deny&gt; authorization rules in the web.config are processed first regardless of the way the rules are ordered.";

            questions[10] = (EssayQuestion)LoadControl("~/Code/EssayQuestion.ascx");
            (questions[10] as EssayQuestion).QuestionText = "Place the following events in order of when they occur in the page lifecycle:<br />Load, Init, Request Arrives, PreRender, Load ViewState, Input Control Event Handling";
            questions[11] = (EssayQuestion)LoadControl("~/Code/EssayQuestion.ascx");
            (questions[11] as EssayQuestion).QuestionText = "What is the purpose of the doctype  declaration at the top of a web page?";
            questions[12] = (EssayQuestion)LoadControl("~/Code/EssayQuestion.ascx");
            (questions[12] as EssayQuestion).QuestionText = "What is the order of precedence for the same style defined in the following ways?<br />Style tag in document head, Extenal Style Sheet referenced by the link tag in document head";
            questions[13] = (EssayQuestion)LoadControl("~/Code/EssayQuestion.ascx");
            (questions[13] as EssayQuestion).QuestionText = "What is the order of precedence for CSS for referencing elements in the following ways<br />By Element Name, By ID, By CSS Class, Inline using the style=”” attribute";
            questions[14] = (EssayQuestion)LoadControl("~/Code/EssayQuestion.ascx");
            (questions[14] as EssayQuestion).QuestionText = "Explain why the alt attribute of the img tag is important";
            questions[15] = (EssayQuestion)LoadControl("~/Code/EssayQuestion.ascx");
            (questions[15] as EssayQuestion).QuestionText = "What is the purpose of name mangling?";
            questions[16] = (EssayQuestion)LoadControl("~/Code/EssayQuestion.ascx");
            (questions[16] as EssayQuestion).QuestionText = "Explain the difference between redirects that use a 301 HTTP status code and ones that use a 302 HTTP status code";

            questions[17] = (MultipleChoiceQuestion)LoadControl("~/Code/MultipleChoiceQuestion.ascx");
            (questions[17] as MultipleChoiceQuestion).QuestionText = "HTML Stands for:";
            (questions[17] as MultipleChoiceQuestion).Items.Add(new ListItem("HoTMaiL", "HoTMaiL"));
            (questions[17] as MultipleChoiceQuestion).Items.Add(new ListItem("Highly Transferable Modeling Language", "Highly Transferable Modeling Language"));
            (questions[17] as MultipleChoiceQuestion).Items.Add(new ListItem("HyperText Markup Language", "HyperText Markup Language"));
            (questions[17] as MultipleChoiceQuestion).Items.Add(new ListItem("High Traffic Masking Language", "High Traffic Masking Language"));

            questions[18] = (MultipleChoiceQuestion)LoadControl("~/Code/MultipleChoiceQuestion.ascx");
            (questions[18] as MultipleChoiceQuestion).QuestionText = "All controls that ask for user input should have an associated";
            (questions[18] as MultipleChoiceQuestion).Items.Add(new ListItem("Label", "Label"));
            (questions[18] as MultipleChoiceQuestion).Items.Add(new ListItem("Validator", "Validator"));
            (questions[18] as MultipleChoiceQuestion).Items.Add(new ListItem("Event Handler", "Event Handler"));
            (questions[18] as MultipleChoiceQuestion).Items.Add(new ListItem("Ferret", "Ferret"));

            questions[19] = (MultipleChoiceQuestion)LoadControl("~/Code/MultipleChoiceQuestion.ascx");
            (questions[19] as MultipleChoiceQuestion).QuestionText = "The living version of a page within the web browser is called the";
            (questions[19] as MultipleChoiceQuestion).Items.Add(new ListItem("Output Rendering Model", "Output Rendering Model"));
            (questions[19] as MultipleChoiceQuestion).Items.Add(new ListItem("Document Object Model", "Document Object Model"));
            (questions[19] as MultipleChoiceQuestion).Items.Add(new ListItem("Box Model", "Box Model"));
            (questions[19] as MultipleChoiceQuestion).Items.Add(new ListItem("Underwear Model", "Underwear Model"));

            questions[20] = (MultipleChoiceQuestion)LoadControl("~/Code/MultipleChoiceQuestion.ascx");
            (questions[20] as MultipleChoiceQuestion).QuestionText = "Which of the following elements is most appropriate for presenting the user with a list of items in no particular order?";
            (questions[20] as MultipleChoiceQuestion).Items.Add(new ListItem("ol", "ol"));
            (questions[20] as MultipleChoiceQuestion).Items.Add(new ListItem("ul", "ul"));
            (questions[20] as MultipleChoiceQuestion).Items.Add(new ListItem("dl", "dl"));
            (questions[20] as MultipleChoiceQuestion).Items.Add(new ListItem("dropdownliste", "dropdownliste"));

            questions[21] = (MultipleChoiceQuestion)LoadControl("~/Code/MultipleChoiceQuestion.ascx");
            (questions[21] as MultipleChoiceQuestion).QuestionText = "What is the difference between the ViewStateMode and EnableViewState properties in the <%@ Page %> declaration?";
            (questions[21] as MultipleChoiceQuestion).Items.Add(new ListItem("ViewStateMode was introduced in ASP.NET 4 to allow more than true/false values, but currently there is no distinguishable difference in functionality", "ViewStateMode was introduced in ASP.NET 4 to allow more than true/false values, but currently there is no distinguishable difference in functionality"));
            (questions[21] as MultipleChoiceQuestion).Items.Add(new ListItem("When ViewState is disabled via ViewStateMode, it can't be enabled at the control level", "When ViewState is disabled via ViewStateMode, it can't be enabled at the control level"));
            (questions[21] as MultipleChoiceQuestion).Items.Add(new ListItem("When ViewState is disabled via EnableViewState, it can't be enabled at the control level", "When ViewState is disabled via EnableViewState, it can't be enabled at the control level"));
            (questions[21] as MultipleChoiceQuestion).Items.Add(new ListItem("When ViewState is enabled via ViewStateMode, it can't be disabled at the control level", "When ViewState is enabled via ViewStateMode, it can't be disabled at the control level"));
            (questions[21] as MultipleChoiceQuestion).Items.Add(new ListItem("When ViewState is enabled via EnableViewState, it can't be disabled at the control level", "When ViewState is enabled via EnableViewState, it can't be disabled at the control level"));


            questions[22] = new ShortTextQuestion();
            (questions[22] as ShortTextQuestion).QuestionText = "The line of text that tells a SqlDataSource how to connect to the database is called a ";
            questions[23] = new ShortTextQuestion();
            (questions[23] as ShortTextQuestion).QuestionText = "When a WebForms page performs a POST operation to itself, it is referred to as a ";
            questions[24] = new ShortTextQuestion();
            (questions[24] as ShortTextQuestion).QuestionText = "The term for loading a controls data from a data source is ";
            questions[25] = new ShortTextQuestion();
            (questions[25] as ShortTextQuestion).QuestionText = "An example of a block element is ";
            questions[26] = new ShortTextQuestion();
            (questions[26] as ShortTextQuestion).QuestionText = "An example of an inline element is ";
            questions[27] = new ShortTextQuestion();
            (questions[27] as ShortTextQuestion).QuestionText = "What is the name of the file that stores configuration information for a web site? ";
            questions[28] = new ShortTextQuestion();
            (questions[28] as ShortTextQuestion).QuestionText = "A div with the following CSS will have what computed height and width? { margin: 0 0 5px; padding: 5px 10px; height: 100px; width: 50px;  border-left: solid 3px #0c0; } ";

            foreach (Control q in questions)
            {
                uxQuestions.Controls.Add(q);
            }
        }
Beispiel #14
0
        public static void Main(string[] args)
        {
            string theAnswer = "F";
            string x         = "Cheese is good?";

            TrueFalseQuestion cheesy = new TrueFalseQuestion(theAnswer, x);

            Console.WriteLine(cheesy.QuestionString);
            string usersAnswer = Console.ReadLine();

            if (usersAnswer != cheesy.AnswerString)
            {
                Console.WriteLine("You got it wrong");
            }
            else
            {
                Console.WriteLine("You got it right");
            }
            Console.ReadLine();


            string anotherAnswer   = "chalkboard";
            string anotherQuestion = "What is in front of us?";

            string[] thePossibleAnswers = { "chalkboard", "elephant", "Statue of Liberty" };

            MultipleChoiceQuestion chalky = new MultipleChoiceQuestion(anotherAnswer, anotherQuestion, thePossibleAnswers);

            //MultipleChoiceQuestion t = new MultipleChoiceQuestion(anotherAnswer, anotherQuestion, thePossibleAnswers);
            // these call down to MultipleChoiceQuestion : GeneralQuestion
            //t.PossibleAnswers
            Console.WriteLine(chalky.QuestionString);
            foreach (string aPossibleAnswer in chalky.PossibleAnswers)
            {
                Console.WriteLine(aPossibleAnswer);
            }
            string studentsAnswer = Console.ReadLine();

            if (studentsAnswer == chalky.AnswerString)
            {
                Console.WriteLine("You're smart");
            }
            else
            {
                Console.WriteLine("You're dumb");
            }
            Console.ReadLine();

            string moreAnswer   = "ab";
            string moreQuestion = "What's blue?";

            string[] morePossibleAnswers = { "a) ocean", "b) carpet", "c) tree" };

            CheckBoxQuestion bluey = new CheckBoxQuestion(moreAnswer, moreQuestion, morePossibleAnswers);

            Console.WriteLine(bluey.QuestionString);
            foreach (string thePossibleAnswersInBluey in bluey.PossibleAnswers)
            {
                Console.WriteLine(thePossibleAnswersInBluey);
            }
            string personsAnswer = Console.ReadLine();

            if (personsAnswer == bluey.AnswerString)
            {
                Console.WriteLine("Yessssssss");
            }
            else
            {
                Console.WriteLine("Nooooooo");
            }
            Console.ReadLine();
        }