//private String addQuestion;

        public QuestionsDeckJSON_IO()
        {
            Deck         = new QuestionsDeck();
            QuizSettings = new QuizSettings();
            DeckList     = new List <QuestionsDeck>();
            ser          = new JavaScriptSerializer();
        }
Example #2
0
 /// <summary>
 /// CreateQuiz Constructor
 /// </summary>
 public CreateQuiz()
 {
     InitializeComponent();
     Height1 = Application.Current.MainWindow.ActualHeight;
     Width1  = Application.Current.MainWindow.ActualWidth;
     CreateQuizTabControl.Width        = Width1;
     CreateQuizTabControl.Height       = Height1 * (0.85);
     NumberOfMinutesTextBox.Visibility = Visibility.Hidden;
     SetTabTemplate();
     PopulateListBox();
     QuizSettings = new QuizSettings();
 }
        public void WriteQuizSettings(QuizSettings setQuizSettings)
        {
            if (setQuizSettings == null || setQuizSettings.QuizName == "")
            {
                MessageBox.Show("You have to name your quiz");
                return;
            }
            QuizSettings = setQuizSettings;
            JavaScriptSerializer ser = new JavaScriptSerializer();
            String outputJSON        = ser.Serialize(QuizSettings);

            // Get the rootpath, locate the quiz directory and then the QuestionsDeck subfolder.
            // Once that is located, write the JSON file to the destination.
            String RootPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

            RootPath += @"\QuizApp\";
            String QuizSettingsPath = RootPath + @"\QuizSettings\";

            File.WriteAllText(QuizSettingsPath + setQuizSettings.QuizName + ".QuizSettings.json", outputJSON);
            MessageBox.Show("file: " + FileName + " written.");
        }