using System;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Xml.Serialization;

namespace WizardInterface
{

    //    //RadMultiPage1.PageViews.Add(pvStartExam);
    //XmlSerializer serializer = new XmlSerializer(typeof(Exam));
    //XmlTextReader reader = new XmlTextReader("exam.xml");

    //Exam exam = (Exam)serializer.Deserialize(reader);
    //////lblTitle.Text = exam.Title;
    //////lblStartMessage.Text =
    //////    string.Format("The exam has {0} questions.  Press the start button to begin.",
    //////    exam.Questions.Length);
    ////foreach (Question question in exam.Questions)
    ////{
    ////    PageView pageView = new PageView();
    ////    Label lblQuestion = new Label();
    ////    lblQuestion.Text = question.Text;
    ////    pageView.Controls.Add(lblQuestion);
    ////    Button btnNext = new Button();
    ////    btnNext.Text = "Next";
    ////    btnNext.Click += new EventHandler(btnNext_Click);
    ////    pageView.Controls.Add(btnNext);
    ////    RadMultiPage1.PageViews.Add(pageView);
    ////}

    //RadMultiPage1.SelectedIndex = 0;
    //RadMultiPage1.PageViewItemCreated += new PageViewItemCreatedDelegate(RadMultiPage1_PageViewItemCreated);
    ////RadMultiPage1.PageViews.Add(pvEndExam);

    public enum QuestionType { SingleResponse, MultipleResponse };

    [Serializable]
    public class Exam
    {
        public Exam()
        {

        }

        public Exam(string title, Question[] questions)
        {
            _title = title;
            _questions = questions;
        }

        private string _title;

        public string Title
        {
            get { return _title; }
            set { _title = value; }
        }

        private Question[] _questions;

        [XmlArray()]
        public Question[] Questions
        {
            get { return _questions; }
            set { _questions = value; }
        }
    }

    [Serializable]
    public class Question
    {
        public Question()
        {
        }

        public Question(string text, QuestionType questionType, Response[] responses)
        {
            _text = text;
            _questionType = questionType;
            _responses = responses;
        }

        private string _text;

        public string Text
        {
            get { return _text; }
            set { _text = value; }
        }
        private QuestionType _questionType;

        public QuestionType QuestionType
        {
            get { return _questionType; }
            set { _questionType = value; }
        }

        private Response[] _responses;

        [XmlArray()]
        public Response[] Responses
        {
            get { return _responses; }
            set { _responses = value; }
        }
    }

    [Serializable]
    public class Response
    {
        public Response()
        {
        }

        public Response(string text, bool isCorrect)
        {
            _text = text;
            _isCorrect = IsCorrect;
        }

        private string _text;

        public string Text
        {
            get { return _text; }
            set { _text = value; }
        }

        private bool _isCorrect;

        public bool IsCorrect
        {
            get { return _isCorrect; }
            set { _isCorrect = value; }
        }
    }
}
