Example #1
0
        private void editLessonButton_Click(object sender, EventArgs e)
        {
            using (NewLessonPrompt prompt = new NewLessonPrompt(ClassName, CurrentLessonName, (string)CurrentLesson["description"], (int)CurrentLesson["timeLimit"]))
            {
                this.Enabled = false;
                prompt.ShowDialog();
                this.Enabled = true;

                //if (prompt.getLessonTimeLimit() <= 0) { return; }

                // update data name to reflect any potential changes
                System.IO.File.Move(getLessonPath(CurrentLessonName), getLessonPath(prompt.getLessonName()));

                CurrentLessonName            = prompt.getLessonName();
                CurrentLesson["description"] = prompt.getLessonDescription();
                CurrentLesson["timeLimit"]   = prompt.getLessonTimeLimit();

                saveCurrentLessonData();

                updateDropDownFields();

                adjustDropDown(prompt.getLessonName());

                //lessonName = prompt.getLessonName();
                //lessonTimeLimit = prompt.getLessonTimeLimit();
            }
        }
Example #2
0
        private void newLessonButton_Click(object sender, EventArgs e)
        {
            string lessonName;
            string lessonDescription;
            int    lessonTimeLimit;

            using (NewLessonPrompt prompt = new NewLessonPrompt(ClassName, "", "", 0))
            {
                this.Enabled = false;
                prompt.ShowDialog();
                this.Enabled = true;

                // escape (do nothing) if user X'd out of Lesson Creation prompt (lessonTimeLimit returned 0)
                if (prompt.getLessonTimeLimit() <= 0)
                {
                    return;
                }

                lessonName        = prompt.getLessonName();
                lessonDescription = prompt.getLessonDescription();
                lessonTimeLimit   = prompt.getLessonTimeLimit();
            }

            JObject lessonObj = new JObject(
                new JProperty("description", (string)lessonDescription),
                new JProperty("timeLimit", (int)lessonTimeLimit),
                new JProperty("activities", new JArray())
                );

            File.WriteAllText(@"Classes\\" + ClassName + "\\Lessons\\" + lessonName + ".json", lessonObj.ToString());

            updateDropDownFields();

            CurrentLessonName = lessonName;
            loadCurrentLessonData();

            adjustDropDown(lessonName);

            MessageBox.Show("Your new lesson '" + lessonName + "' has been created!\n\n" +
                            "Use the tools provided to modify and add to it!");
        }