//This method is called within the question object. It receives the old object and the new questionType in order to replace the old object with a new one.

        public void OnReplaceRequested(Question oldQuestionObject, char questionType)
        {
            Question old = (Question)questionsListBox.SelectedItem;                                                                         //Select the old question object from the listbox
            int index = allQuestions.IndexOf(old);                                                                                          //Lookup the position of the old object
            Question newQuestionObject;                                                                                                     //Declare new object
            String restOfString = String.Empty;                                                                                             //Create empty string
            switch (questionType)
            {
                case Constants.OneChoiceQuestionType:
                    restOfString = String.Empty;                                                                                            //OneChoice = empty answer
                    break;
                case Constants.MultipleChoiceQuestionType:                                                                                  //MultipleChoice = 5 empty answers, 5 false bools        
                    restOfString = Constants.RestOfStringMultipleChoice;
                    break;
                case Constants.DragDropQuestionType:
                    restOfString = Constants.RestOfStringDragDrop;                                                                          //DragDrop = 5 empty drag answers, 5 empty drop answers
                    break;
                case Constants.TableQuestionType:
                    restOfString = Constants.RestOfStringTableQ;                                                                            //TableQuestions = Default multiplier 1
                    break;
            }
            newQuestionObject = FileManager.CreateSubQuestion(String.Format("{0};{1};{2};{3};{4}",                                          //Create new object with old question parameters and default answers.
            oldQuestionObject.GetCourse, oldQuestionObject.GetDifficulty, questionType, oldQuestionObject.GetQuestion, restOfString));
            allQuestions[index] = newQuestionObject;                                                                                        //Replace the old object with the new one
            questionsListBox.ItemsSource = UpdateCourseList(newQuestionObject.GetCourse);                                                   //Update the listbox
            FileManager.WriteCourseFile(newQuestionObject.GetPath(), UpdateCourseList(newQuestionObject.GetCourse));                               //Update the txt file
            questionsListBox.SelectedItem = newQuestionObject;                                                                              //Select the new question object in the listbox
            SetIReplacePropertyOnQuestions();                                                                                               //Set instance to all question objects in the list
        }
Beispiel #2
0
        public QuizMaster(string filename)
        {
            // Complete file string
            string raw_quiz_data = System.IO.File.ReadAllText(filename);
            // Remove breaklines
            raw_quiz_data = raw_quiz_data.Replace (Environment.NewLine, "");

            // Split questions
            string[] question_data_list = raw_quiz_data.Split('~');
            questions = new Question[question_data_list.Length + 1]; // Last question is filled with empty data

            int i = 0;
            foreach (string question_data in question_data_list) {
                // Parse the question+options (question_answer[0]) and the question answer (question_answer[1])
                string[] question_options_answer = question_data.Split('`');
                int answer = (int) char.GetNumericValue(question_options_answer[1][0]);
                // Split the options
                string[] question_options = question_options_answer[0].Split ('.');

                string[] options = new string[question_options.Length - 1];
                for (int option = 0; option < options.Length; option++) {
                    options[option] = question_options[option + 1];
                }
                questions[i] = new Question(question_options[0], options, answer);

                i++;
            }

            questions[questions.Length - 1] = new Question("No more questions", new string[]{}, -1);

            current_question = -1;
            total_questions_count = questions.Length;
        }
 public Form1()
 {
     InitializeComponent();
     string[] awss = {"1","2","3","4"};
     Question question = new Question("Pergunta ", "isso é um pergunta", awss, 1);
     question.Aswered += aswered;
     this.Enabled = false;
     question.ShowDialog();
     this.Enabled = true;
 }
		public void AddQuestionDataItem (Question question)
		{
			if (!has_question_been_asked) {
				WearableClass.DataApi.PutDataItem (google_api_client, question.ToPutDataRequest ());
				SetHasQuestionBeenAsked (true);
			} else {
				future_questions.Add (question);
			}
		}
			public int CompareTo (Question that)
			{
				return this.questionIndex - that.questionIndex;
			}
Beispiel #6
0
 public Question NextQuestion()
 {
     CurrentQuestion = Questions[random.Next(Questions.Count)];
     return(CurrentQuestion);
 }
Beispiel #7
0
 public int CompareTo(Question that)
 {
     return(this.questionIndex - that.questionIndex);
 }
Beispiel #8
0
 public void AddQuestion(Question question)
 {
     QuestionDict.Add(question, false);
 }
Beispiel #9
0
 public Quiz(Question question, bool correct = false)
 {
     QuestionDict = new Dictionary <Question, bool> {
         { question, false }
     };
 }