Example #1
0
 private void SystemFeedback_Loaded(object sender, RoutedEventArgs e)
 {
     Q2.Labels = new List <string>()
     {
         "非常不流畅", "不流畅", "一般", "流畅", "非常流畅"
     };
     for (int i = 3; i <= 18; i++)
     {
         EvaluationControl ec = QContent.FindName("Q" + i.ToString()) as EvaluationControl;
         ec.Labels = new List <string>()
         {
             "非常弱", "比较弱", "一般", "比较强", "非常强"
         };
     }
     Q19.Labels = new List <string>()
     {
         "非常不准确", "不准确", "一般", "准确", "非常准确"
     };
     for (int i = 21; i <= 35; i += 2)
     {
         TextBlock tb = QContent.FindName("R" + i.ToString()) as TextBlock;
         tb.Visibility = Visibility.Hidden;
         TextBox tbox = QContent.FindName("Q" + i.ToString()) as TextBox;
         tbox.Visibility = Visibility.Hidden;
     }
 }
Example #2
0
        private void UnCheckEvent(object sender, RoutedEventArgs e)
        {
            CheckBox checkBox = sender as CheckBox;
            int      no       = int.Parse(checkBox.Name.Substring(1)) + 1;

            TextBlock tb = QContent.FindName("R" + no.ToString()) as TextBlock;

            tb.Visibility = Visibility.Hidden;
            TextBox tbox = QContent.FindName("Q" + no.ToString()) as TextBox;

            tbox.Visibility = Visibility.Hidden;
        }
Example #3
0
        private string FormatQuestionaire()
        {
            String ques = "";

            ques += Q1.Text + @"|";
            for (int i = 3; i <= 19; i++)
            {
                EvaluationControl ec = QContent.FindName("Q" + i.ToString()) as EvaluationControl;
                ques += ec.GetSelectionValue() + @"|";
            }
            for (int i = 20; i <= 34; i += 2)
            {
                CheckBox cb   = QContent.FindName("Q" + i.ToString()) as CheckBox;
                TextBox  tbox = QContent.FindName("Q" + (i + 1).ToString()) as TextBox;
                if (cb.IsChecked.HasValue && cb.IsChecked.Value)
                {
                    ques += cb.Tag + tbox.Text + @"|";
                }
            }
            ques += Q36.Text + @"|";
            ques += Q37.Text + @"|";
            return(ques);
        }
        public PartialViewResult CreateQuizQues(MultipieChoiceViewModel TheQuiz)
        {
            int TeacherID           = int.Parse(Request.Cookies["TeacherID"].Value);
            ApplicationDbContext db = new ApplicationDbContext();
            string myAnswerContent;

            if (TheQuiz.Content != null && TheQuiz.Quiz.Quiz1 != null && TheQuiz.Quiz.Quiz2 != null && TheQuiz.Quiz.Quiz3 != null && TheQuiz.Quiz.Quiz4 != null)
            {
                try
                {
                    try
                    {
                        QContent qcontent = new QContent();
                        Answer   qAnswer  = new Answer();
                        qcontent.Content = TheQuiz.Content;
                        switch (TheQuiz.EAnswer)
                        {
                        case Answer_input.A:
                            TheQuiz.Quiz.Answer = 1;
                            break;

                        case Answer_input.B:
                            TheQuiz.Quiz.Answer = 2;
                            break;

                        case Answer_input.C:
                            TheQuiz.Quiz.Answer = 3;
                            break;

                        case Answer_input.D:
                            TheQuiz.Quiz.Answer = 4;
                            break;
                        }
                        qAnswer.Content = JsonConvert.SerializeObject(TheQuiz.Quiz);
                        myAnswerContent = JsonConvert.SerializeObject(TheQuiz.Quiz);
                        db.Answers.Add(qAnswer);
                        db.QContents.Add(qcontent);
                        db.SaveChanges();
                    }
                    catch
                    {
                        return(PartialView("_CreateQuesFailed"));
                    }
                    Question QuizQues = new Question
                    {
                        Level   = 2,
                        Type    = (from t in db.QTypes where t.id == 2 select t).First(),
                        Content = (from ct in db.QContents where ct.Content == TheQuiz.Content select ct).First(),
                        Answer  = (from a in db.Answers where a.Content == myAnswerContent select a).First(),
                        Creator = (from tea in db.Teachers where tea.id == TeacherID select tea).First()
                    };
                    db.Questions.Add(QuizQues);
                    db.SaveChanges();
                    //đưa object về partial view để JS lấy đc id của object, từ đó gọi ajax về 1 action khác
                    return(PartialView("_QuizCreateSuccess", QuizQues));
                    //đưa object về partial view để JS lấy đc id của object, từ đó gọi ajax về 1 action khác
                }
                catch
                {
                    return(PartialView("_CreateQuesFailed"));
                }
            }
            else
            {
                return(PartialView("_CreateQuesFailed"));
            }
        }