示例#1
0
 public SendQuizInfo(StudentLogin student, List <StoredQuestions> sq, List <CompletedQuestion> cq, StoredQuizzes storedQuizzes)
 {
     //The student, storedquestions that they have answered, their completed question and the quiz are passed into the sub and then made global by this sub.
     InitializeComponent();
     Student       = student;
     SQ            = sq;
     CQ            = cq;
     storedquizzes = storedQuizzes;
 }
        public event Action <StartQuizForm, StudentLogin, StoredQuizzes, List <StoredQuestions>, List <StoredQuizQuestions>, List <CompletedQuestion> > CompletedQuiz; //This event is used to return the values of the completed quiz to the stats form when this form is closed

        public StartQuizForm(StudentLogin student, StoredQuizzes sQuiz, List <StoredQuestions> sQuestions, List <StoredQuizQuestions> storedQQuestions, CompletedQuiz cQuiz, List <CompletedQuestion> compQuestion)
        {
            InitializeComponent();
            //Parameters are assigned to the global variables
            Student             = student;
            SQuiz               = sQuiz;
            storedQuestions     = sQuestions;
            storedQuizQuestions = storedQQuestions;
            completedQuiz       = cQuiz;
            completedQuestion   = compQuestion;
        }
        private void QuizListBox_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            //Displays the quiz info
            QuizNameLabel.Show();
            InsertQuizNameLabel.Show();
            QuestionsLabel.Show();
            QuestionsListBox.Show();
            ExpandButton.Show();

            ChosenQuiz = (StoredQuizzes)QuizListBox.SelectedItem; //The chosen quiz is saved to be the selected item from the list view
            InsertQuizNameLabel.Text = ChosenQuiz.Name;           //The quiz name is displayed
            QuestionClass qc = new QuestionClass();

            SelectedQuestionsId            = qc.FindQuestionsId(ChosenQuiz);                 //Retrives the quiz`s questions ID`s from the database
            SelectedQuestions              = qc.GetStoredQuizQuestions(SelectedQuestionsId); //The ID`s related questions are then returned from the database
            QuestionsListBox.DataSource    = SelectedQuestions;                              //The data source for the list box displaying the questions is set to the questions
            QuestionsListBox.DisplayMember = "Question";                                     //The displayed item from the stored quizzes to be the name of the quiz
        }
示例#4
0
        private void ViewStatsCall(ViewStoredQuizzes VS, StoredQuizzes storedQuizzes, List <StoredQuestions> storedQuestions, List <StoredQuizQuestions> storedQuizQuestions)
        {
            //Launches the viewstats form
            ViewStats vs = new ViewStats(student, storedQuizzes, storedQuestions, storedQuizQuestions);

            vs.Show();

            vs.FormClosed += (source, EventArgs) =>
            {
                this.Show();
            };

            vs.OpenStoredQuizzes += (source, EventArgs) =>
            {
                //The user can specify to return to the storedquizzes, if they wish to do that this event is called
                button3_Click(null, EventArgs.Empty);
            };
        }
示例#5
0
        private void setup(StudentLogin student, StoredQuizzes SQuiz, List <StoredQuestions> storedQuestions, List <StoredQuizQuestions> storedQuizQuestions, List <CompletedQuestion> cquestion)
        {
            //In a seperate sub as the page may need to be refreshed when the student has answered the quiz again

            if (cquestion == null)
            {
                StudentInputNameLabel.Text = ($"{student.FirstName} {student.SecondName}");

                InputClassIdLabel.Text = student.ClassId.ToString();

                QuestionClass qc = new QuestionClass();
                //If the CompletedQuiz has not be loaded from the data base it will load it here
                if (CQuiz == null)
                {
                    CQuiz.Id        = SQuiz.QuizId;
                    CQuiz.StudentId = student.StudentId;
                    CQuiz.Length    = SQuiz.Length;
                    CQuiz           = qc.CreateCompletedQuiz(CQuiz);
                }

                completedQuestion = qc.GetCompletedQuestion(CQuiz, storedQuizQuestions);
            }
            else
            {
                //If the questions have already been answered and the user wishes to return to their stats then the page needs to be refreshed but we don`t need to
                //query the database again
                listView1.Items.Clear();
                listView1.Refresh();
                completedQuestion = cquestion;
            }

            foreach (StoredQuestions sq in storedQuestions)
            {
                //Assigns the relevant stats the the rows for each question on the table
                ListViewItem b = new ListViewItem(sq.Question);
                if (sq.Area == 1)
                {
                    b.SubItems.Add("Recall");
                }
                else
                {
                    b.SubItems.Add("Calculations");
                }

                if (sq.TopicId == 1)
                {
                    b.SubItems.Add("Particles");
                }
                else if (sq.TopicId == 2)
                {
                    b.SubItems.Add("Waves");
                }
                else if (sq.TopicId == 3)
                {
                    b.SubItems.Add("Mechanics");
                }
                else if (sq.TopicId == 4)
                {
                    b.SubItems.Add("Materials");
                }
                else if (sq.TopicId == 5)
                {
                    b.SubItems.Add("Electricity");
                }

                //For each question answered in completed questions, the loop checks to see if it is equal to the current stored question ID.
                foreach (CompletedQuestion cq in completedQuestion)
                {
                    if (cq.QuestionId == sq.QuestionId)
                    {
                        //If the question is the same then the code adds the question`s stats to the table containing their scores (times answered, times correct, difficulty score, etc)
                        b.SubItems.Add(cq.XCompleted.ToString());
                        b.SubItems.Add(cq.XCorrect.ToString());
                        string score = DifficultyScore(cq.CalculatedDifficulty);
                        b.SubItems.Add(score);
                        b.SubItems.Add(cq.CalculatedDifficulty.ToString());
                        break; //braks the loop so that there is no more wasted loops
                    }
                }
                listView1.Items.Add(b);
            }


            Student = student;

            ListOfStoredQuestions = storedQuestions;

            SelectedQuiz = SQuiz;

            QuizQuestionsId = storedQuizQuestions;
            //saves varaibles to the program so that if the user starts a quiz then they don`t need to be retrived and are ready to be called
        }
示例#6
0
 public ViewStats(StudentLogin student, StoredQuizzes SQuiz, List <StoredQuestions> storedQuestions, List <StoredQuizQuestions> storedQuizQuestions)
 {
     InitializeComponent();
     setup(student, SQuiz, storedQuestions, storedQuizQuestions, null);
 }
示例#7
0
 private void NewViewStats(StartQuizForm SQF, StudentLogin student, StoredQuizzes SQuiz, List <StoredQuestions> storedQuestions, List <StoredQuizQuestions> storedQuizQuestions, List <CompletedQuestion> cq)
 {
     setup(student, SQuiz, storedQuestions, storedQuizQuestions, cq); //Refresehs the page to display any changes that may have been created when the student either deletes question info or completes a question
 }