示例#1
0
        public static Question createByJToken(JToken data)
        {
            Question question = new Question() {
                Id = Convert.ToInt32(data["id"]),
                Text = data["text"].ToString(),
                CorectAnswerId = Convert.ToInt32(data["corectAnswerId"])
            };
            question.Answers = Answer.createByJToken(data["answers"], question);

            return question;
        }
示例#2
0
文件: Answer.cs 项目: JKord/BoikoQuiz
        //[ManyToOne(CascadeOperations = CascadeOperation.CascadeRead)]
        //public Question Question { get; set; }
        public static List<Answer> createByJToken(JToken data, Question question)
        {
            List<Answer> answers = new List<Answer>();
            foreach (var answer in data)
                answers.Add(new Answer() {
                    Id = Convert.ToInt32(answer["id"]),
                    Text = answer["text"].ToString(),
                    QuestionId = question.Id,
                   // Question = question
                });

            return answers;
        }
示例#3
0
        public Question getQuestion()
        {
            List<Answer> answers = new List<Answer>();
            answers.Add(getCorrectAnswer());
            answers.Add(new Answer() { Id = 2, Text = "a2" });
            answers.Add(new Answer() { Id = 3, Text = "a3" });

            foreach (Answer answer in answers)
                answer.QuestionId = 1;

            Question question = new Question()
            {
                Id = 1,
                Text = "Text",
                CorectAnswerId = 1,
                Answers = answers
            };

            return question;
        }
示例#4
0
 public QuizeItemControl(Question _question, EventHandler _clickNext)
 {
     InitializeComponent();
     LayoutRoot.DataContext = question = _question;
     clickNext = _clickNext;
 }