Пример #1
0
        public void LoadQuiz(int quiz_id, int user_id)
        {
            desc.Children.Clear();
            Results results = new Results();

            QuestionResult[] res;
            Question[]       questions;
            DB.LoadResult(quiz_id, user_id, out results);
            DB.LoadQuestionResults(results.ID, out res);
            DB.LoadQuestions(quiz_id, out questions);
            Answer[] answers = new Answer[res.Length];
            for (int i = 0; i < questions.Length; i++)
            {
                Answer[] a;
                AddLine(questions[i].Description);
                DB.LoadAnswers(questions[i].ID, out a);
                int    total       = 100;
                int    totalCount  = 0;
                int[]  percentages = new int[a.Length];
                bool[] boldText    = new bool[a.Length];
                for (int j = 0; j < a.Length; j++)
                {
                    DB.LoadQuestionResultsByAnswer(a[j].ID, out res);
                    totalCount    += res.Length;
                    percentages[j] = res.Length;
                    boldText[j]    = false;
                    for (int k = 0; k < res.Length; k++)
                    {
                        if (results.ID == res[k].Results_ID)
                        {
                            boldText[j] = true;
                            break;
                        }
                    }
                }
                for (int j = 0; j < a.Length; j++)
                {
                    int perc = (int)Math.Round(100.0f * ((float)percentages[j] / (float)totalCount));
                    total -= perc;
                    if (j == a.Length - 1 && total != 0 && total != 100)
                    {
                        perc += total;
                    }
                    AddLine(a[j].Description, boldText[j], perc, a[j].Correctness > 0 ? Colors.Green : Colors.Red);
                }
            }
        }
Пример #2
0
 public MainWindow()
 {
     InitializeComponent();
     fadeout            = Resources["titleFadeOut"] as Storyboard;
     fadeout.Completed += sb_Completed;
     fadein             = Resources["titleFadeIn"] as Storyboard;
     DB.InitializeConnection();
     Quiz[] quizes;
     DB.LoadQuizes(out quizes);
     foreach (Quiz q in quizes)
     {
         List.Items.Add(new ListBoxItem()
         {
             Content = q.Description, Tag = q,
         });
         DB.LoadQuestions(q.ID, out currentQuizQuestions);
     }
     curMode = UIMode.Login;
     sb_Completed(this, new EventArgs());
 }