Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Quiz myQuiz = new Quiz(new List <Question>());

            List <string> possAns1 = new List <string>()
            {
                "Garfield", "Salem", "Cheshire", "Tom"
            };
            List <int> correctAns1 = new List <int>()
            {
                2, 3
            };
            Checkbox newQuestion1 = new Checkbox(2, "Who is the best cat in the world?", possAns1, correctAns1);

            myQuiz.AddQuestion(newQuestion1);

            List <string> possAns2 = new List <string>()
            {
                "Doc", "Tillie", "Gizmo", "Benji", "Nala"
            };
            MultipleChoice newQuestion2 = new MultipleChoice(1, "Who won the Halloween Costume Contest?", 3, possAns2);

            myQuiz.AddQuestion(newQuestion2);

            TrueOrFalse newQuestion3 = new TrueOrFalse(1, "Are all dogs the best?", true);

            myQuiz.AddQuestion(newQuestion3);

            myQuiz.RunQuiz();

            myQuiz.GradeQuiz();
        }
Ejemplo n.º 2
0
        //TESTING MULTIPLE CHOICE
        public static void Question1()
        {
            MultipleChoice McTestQuestion = new MultipleChoice("What is my name?", options, 'a');

            Console.WriteLine(McTestQuestion.ToString());
            char[] MCchoice = { Console.ReadKey().KeyChar };

            Console.WriteLine("\n" + McTestQuestion.GradeAnswer(MCchoice) + "\n");
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Quiz   myQuiz = new Quiz();
            string userInput;

            MultipleChoice myQuestion = new MultipleChoice("MC 1", new Dictionary <string, string> {
                { "a", "wrong" }, { "b", "correct" }, { "c", "wrong" }, { "d", "wrong" }
            }, "b");
            MultipleChoice myQuestion2 = new MultipleChoice("MC 2", new Dictionary <string, string> {
                { "a", "wrong" }, { "b", "wrong" }, { "c", "correct" }, { "d", "wrong" }
            }, "c");
            TrueFalse myQuestion3 = new TrueFalse("TF 1", new Dictionary <string, string> {
                { "a", "true" }, { "b", "false" }
            }, "a");
            Checkbox myQuestion4 = new Checkbox("CB 1", new Dictionary <string, string> {
                { "a", "correct" }, { "b", "correct" }, { "c", "wrong" }, { "d", "correct" }
            }, "abd");
            ShortAnswer myQuestion5 = new ShortAnswer("SA 1");


            myQuiz.AddQuestion(myQuestion);
            myQuiz.AddQuestion(myQuestion2);
            myQuiz.AddQuestion(myQuestion3);
            myQuiz.AddQuestion(myQuestion4);
            myQuiz.AddQuestion(myQuestion5);

            while (true)
            {
                Console.WriteLine("1 - Add questions\n2 - Run quiz\n3 - Grade the quiz");
                userInput = Console.ReadLine();
                if (Equals(userInput, "1"))
                {
                    myQuiz.AddQuestion();
                }
                else if (Equals(userInput, "2"))
                {
                    myQuiz.RunQuiz();
                }
                else if (Equals(userInput, "3"))
                {
                    Console.WriteLine($"\nYou answered {myQuiz.GradeQuiz():P1} correctly.\n");
                }
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Quiz     quiz = new Quiz();
            Question q1   = new MultipleChoice("What is 1+1?", new List <string> {
                "1", "2", "3", "4"
            }, "2");

            quiz.Add(q1);
            Question q2 = new TrueOrFalse("Is 1+1 is 2?", "true");

            quiz.Add(q2);
            Question q3 = new Checkbox("What is 1+1?", new List <string> {
                "1", "2", "Two", "3"
            }, new List <string> {
                "2", "3"
            });

            quiz.Add(q3);
            quiz.Run();
            quiz.Grade();

            /*string option;
             *
             * do
             * {
             *  Console.WriteLine("It's Quiz time.What do you want(Press ENTER to quit)?\n1.Add Question\n2.Run the Quiz\n3.Grade the Quiz");
             *
             *  option = Console.ReadLine();
             *  switch (option)
             *  {
             *      case "1":
             *          Console.WriteLine("Which type of question you want to enter?\n1.Multiple Choice\n2.True/false\n3.Checkbox.");
             *          string questionType = Console.ReadLine();
             *          Console.WriteLine("Enter the QuestionText to add.");
             *          string questionText = Console.ReadLine();
             *          switch (questionType)
             *          {
             *              case "1":
             *                  Console.WriteLine("Enter 4 options seperated by comma");
             *                  List<string> options = Console.ReadLine().Split(",").ToList();
             *                  for (int i = 0; i < 4; i++)
             *                      Console.WriteLine("{0}.{1}", i + 1, options[i]);
             *                  Console.WriteLine("Choose the correct answer option");
             *                  string answer = Console.ReadLine();
             *                  Question q = new MultipleChoice(questionText, options, answer);
             *                  quiz.Add(q);
             *                  break;
             *              case "2":
             *                  Console.WriteLine("enter true/false.");
             *                  break;
             *              case "3":
             *                  break;
             *          }
             *
             *          break;
             *      case "2":
             *          quiz.Run();
             *          break;
             *      case "3":
             *          quiz.Grade();
             *          break;
             *      default:
             *          Console.WriteLine("Choose a valid option.");
             *          break;
             *
             *  }
             * } while (option != "");*/
        }
 public static Question CreateSubQuestion(String line)
 {
     Question temp = new OneChoice(Constants.MathCourse, 1, Constants.OneChoiceQuestionType, String.Empty, String.Empty);
     String[] properties = line.Split(Constants.SemiColon);
     char course = Convert.ToChar(properties[0]);
     int difficulty = Convert.ToInt32(properties[1]);
     char questionType = Convert.ToChar(properties[2]);
     String question = properties[3];
     switch (questionType)
     {
         case Constants.OneChoiceQuestionType:
             temp = new OneChoice(course, difficulty, questionType, question, properties[4]);
             break;
         case Constants.MultipleChoiceQuestionType:
             String[] possibleAnswers = new String[5];
             bool[] correctAnswers = new bool[5];
             for (int i = 0; i <= 4; i++)
             {
                 possibleAnswers[i] = properties[i + 4];
                 correctAnswers[i] = Convert.ToBoolean(properties[i + 9]);
             }
             temp = new MultipleChoice(course, difficulty, questionType, question, possibleAnswers, correctAnswers);
             break;
         case Constants.DragDropQuestionType:
             String[] dragAnswers = new String[5];
             String[] dropAnswers = new String[5];
             for (int i = 0; i <= 4; i++)
             {
                 dragAnswers[i] = properties[i + 4];
                 dropAnswers[i] = properties[i + 9];
             }
             temp = new DragNDrop(course, difficulty, questionType, question, dragAnswers, dropAnswers);
             break;
         case Constants.TableQuestionType:
             temp = new TableQuestion(course, difficulty, questionType, question, Convert.ToInt32(properties[4]));
             break;
     }
     return temp;
 }
 public MultipleChoice(MultipleChoice o) //Copy Constructor
     : base(o.GetCourse, o.GetDifficulty, o.GetQuestionType, o.GetQuestion)
 {
     this.possibleAnswers = o.GetPossibleAnswers();
     this.correctAnswers = o.GetCorrectAnswers();
 }
Ejemplo n.º 7
0
        public void AddQuestion()
        {
            Question newQuestion = new Question();

            do
            {
                int    userSelection;
                string userInput;
                Console.Write("What type of question to add:\n 1 - Multiple Choice\n 2 - Checkbox\n 3 - True/False\n> ");
                while (!int.TryParse(Console.ReadLine(), out userSelection))
                {
                    Console.Write("Invalid entry, choose question type by number: ");
                }
                if (userSelection == 1)
                {
                    newQuestion = new MultipleChoice();
                }
                else if (userSelection == 2)
                {
                    newQuestion = new Checkbox();
                }
                else if (userSelection == 3)
                {
                    newQuestion = new TrueFalse();
                }

                do
                {
                    Console.WriteLine("Enter the question prompt: ");
                    userInput = Console.ReadLine();
                    Console.Write($"\tYou entered the question prompt:\n\t{userInput}\n\tIs that correct (y/n)?: ");
                } while (!Equals(Console.ReadLine().ToLower(), "y"));
                newQuestion.Prompt = userInput;

                if (!newQuestion.GetType().Equals(typeof(TrueFalse)))
                {
                    do
                    {
                        Console.WriteLine("Enter the possible answers:\n(Hit \"Enter\" when done)");
                        userInput = Console.ReadLine();
                        char choice = 'a';
                        while (!Equals(userInput.ToLower(), ""))
                        {
                            newQuestion.possibleAnswers[choice.ToString()] = userInput;
                            choice++;
                            userInput = Console.ReadLine();
                        }
                        Console.WriteLine("\tYou entered the possible answers: ");
                        foreach (KeyValuePair <string, string> a in newQuestion.possibleAnswers)
                        {
                            Console.WriteLine($"\t{a.Key} - {a.Value}");
                        }
                        Console.Write("\tIs that correct(y / n) ? ");
                    } while (!Equals(Console.ReadLine().ToLower(), "y"));
                }
                else
                {
                    Console.WriteLine("\tPossible answers: ");
                    newQuestion.possibleAnswers["a"] = "true";
                    newQuestion.possibleAnswers["b"] = "false";
                    foreach (KeyValuePair <string, string> a in newQuestion.possibleAnswers)
                    {
                        Console.WriteLine($"\t{a.Key} - {a.Value}");
                    }
                }

                do
                {
                    Console.WriteLine("Enter the letters that correspond to the correct choice(s)");
                    userInput = Console.ReadLine();
                    char[] userArr = userInput.ToCharArray();
                    Array.Sort(userArr);
                    newQuestion.CorrectAnswer = new string(userArr);
                    Console.WriteLine("\tYou entered the correct answer(s) as: {0}", newQuestion.CorrectAnswer);
                    Console.Write("\tIs that correct(y / n) ? ");
                } while (!Equals(Console.ReadLine().ToLower(), "y"));
                Console.Clear();
                Console.Write($"Your {newQuestion.GetType()} question will appear as follows:\n\n{newQuestion.Display()}\nWith correct answer(s) marked as: {newQuestion.CorrectAnswer}\n\nIs that correct (y to accept, n to start over): ");
            } while (!Equals(Console.ReadLine().ToLower(), "y"));
            questions.Add(newQuestion);
        }