예제 #1
0
    protected void populatePanel()
    {
        QuestionLista q = new QuestionLista();

        Serialisointi.DeSerialisoiKysymyksetXml(HttpContext.Current.Server.MapPath("~/App_Data/SavedQuestions.xml"), ref q);

        btnVastaa.Visible = true;

        if (q.kysymykset.Count > 0)
        {
            foreach (Question item in q.kysymykset)
            {
                TextBox kysymys = new TextBox();
                kysymys.Text    = item.question;
                kysymys.Enabled = false;

                studentPane.Controls.Add(kysymys);
                studentPane.Controls.Add(new LiteralControl("<br />"));

                foreach (string item1 in item.answers)
                {
                    Label    ehto    = new Label();
                    CheckBox vastaus = new CheckBox();
                    ehto.Text = item1;

                    studentPane.Controls.Add(ehto);
                    studentPane.Controls.Add(vastaus);
                    studentPane.Controls.Add(new LiteralControl("<br />"));
                }
            }
        }
    }
예제 #2
0
    protected void endSurvey(object sender, EventArgs e)
    {
        QuestionLista a = new QuestionLista();

        Timer1.Enabled = false;
        Serialisointi.SerialisoiXmlKysymykset(HttpContext.Current.Server.MapPath("~/App_Data/SavedQuestions.xml"), a);
        showresults = true;
    }
예제 #3
0
    protected void btnAddQuestion_Click(object sender, EventArgs e)
    {
        List <string> answers      = new List <string>();
        List <int>    rightanswers = new List <int>();
        QuestionLista q            = new QuestionLista();
        int           j            = 0;

        if (int.Parse(cmbNumberofAnswers.SelectedValue) > 2)
        {
            foreach (Control item in pane.Controls)
            {
                if (item is TextBox)
                {
                    TextBox txtInstance = (TextBox)item;
                    answers.Add(txtInstance.Text);
                }
                if (item is CheckBox)
                {
                    CheckBox chkInstance = (CheckBox)item;
                    if (chkInstance.Checked)
                    {
                        rightanswers.Add(j);
                    }
                    j++;
                }
            }

            Question o = new Question();
            o.question     = txtQuetion.Text;
            o.answers      = answers;
            o.rightanswers = rightanswers;
            q.kysymykset.Add(o);
        }
        else
        {
            answers.Add("Kyllä");
            answers.Add("Ei");

            if (CheckBox1.Checked)
            {
                rightanswers.Add(0);
            }
            else
            {
                rightanswers.Add(1);
            }

            Question o = new Question();
            o.question     = txtQuetion.Text;
            o.answers      = answers;
            o.rightanswers = rightanswers;
            q.kysymykset.Add(o);
        }

        Serialisointi.SerialisoiXmlKysymykset(HttpContext.Current.Server.MapPath("~/App_Data/SavedQuestions.xml"), q);
        lblInfo.Text = "Kysymys lisätty!";
    }
예제 #4
0
    protected void btnAddQuestion_Click(object sender, EventArgs e)
    {
        List<string> answers = new List<string>();
        List<int> rightanswers = new List<int>();
        QuestionLista q = new QuestionLista();
        int j = 0;

        if (int.Parse(cmbNumberofAnswers.SelectedValue) > 2)
        {
            foreach (Control item in pane.Controls)
            {
                if (item is TextBox)
                {
                    TextBox txtInstance = (TextBox)item;
                    answers.Add(txtInstance.Text);
                }
                if (item is CheckBox)
                {
                    CheckBox chkInstance = (CheckBox)item;
                    if (chkInstance.Checked)
                    {
                        rightanswers.Add(j);
                    }
                    j++;
                }
            }

            Question o = new Question();
            o.question = txtQuetion.Text;
            o.answers = answers;
            o.rightanswers = rightanswers;
            q.kysymykset.Add(o);
        }
        else
        {
            answers.Add("Kyllä");
            answers.Add("Ei");

            if (CheckBox1.Checked)
            {
                rightanswers.Add(0);
            }
            else
            {
                rightanswers.Add(1);
            }

            Question o = new Question();
            o.question = txtQuetion.Text;
            o.answers = answers;
            o.rightanswers = rightanswers;
            q.kysymykset.Add(o);
        }

        Serialisointi.SerialisoiXmlKysymykset(HttpContext.Current.Server.MapPath("~/App_Data/SavedQuestions.xml"), q);
        lblInfo.Text = "Kysymys lisätty!";
    }
예제 #5
0
    public static void DeSerialisoiKysymyksetXml(string filePath, ref QuestionLista kysymykset)
    {
        XmlSerializer deserializer = new XmlSerializer(typeof(QuestionLista));

        try
        {
            FileStream xmlFile = new FileStream(filePath, FileMode.Open);
            kysymykset = (QuestionLista)deserializer.Deserialize(xmlFile);
            xmlFile.Close();
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
        }
    }
예제 #6
0
    public static void SerialisoiXmlKysymykset(string tiedosto, QuestionLista kysymykset)
    {
        XmlSerializer xs = new XmlSerializer(kysymykset.GetType());
        TextWriter    tw = new StreamWriter(tiedosto);

        try
        {
            xs.Serialize(tw, kysymykset);
        }
        catch (Exception e)
        {
            throw e;
        }
        finally
        {
            tw.Close();
        }
    }
예제 #7
0
    public static void DeSerialisoiKysymyksetXml(string filePath, ref QuestionLista kysymykset)
    {
        XmlSerializer deserializer = new XmlSerializer(typeof(QuestionLista));
            try
            {
                FileStream xmlFile = new FileStream(filePath, FileMode.Open);
                kysymykset = (QuestionLista)deserializer.Deserialize(xmlFile);
                xmlFile.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

            }
    }
예제 #8
0
 public static void SerialisoiXmlKysymykset(string tiedosto, QuestionLista kysymykset)
 {
     XmlSerializer xs = new XmlSerializer(kysymykset.GetType());
         TextWriter tw = new StreamWriter(tiedosto);
         try
         {
             xs.Serialize(tw, kysymykset);
         }
         catch (Exception e)
         {
             throw e;
         }
         finally
         {
             tw.Close();
         }
 }
예제 #9
0
    protected void populatePanel()
    {
        QuestionLista q = new QuestionLista();

        Serialisointi.DeSerialisoiKysymyksetXml(HttpContext.Current.Server.MapPath("~/App_Data/SavedQuestions.xml"), ref q);

        btnVastaa.Visible = true;

        if (q.kysymykset.Count > 0)
        {
            foreach (Question item in q.kysymykset)
            {
                TextBox kysymys = new TextBox();
                kysymys.Text = item.question;
                kysymys.Enabled = false;

                studentPane.Controls.Add(kysymys);
                studentPane.Controls.Add(new LiteralControl("<br />"));

                foreach (string item1 in item.answers)
                {
                    Label ehto = new Label();
                    CheckBox vastaus = new CheckBox();
                    ehto.Text = item1;

                    studentPane.Controls.Add(ehto);
                    studentPane.Controls.Add(vastaus);
                    studentPane.Controls.Add(new LiteralControl("<br />"));
                }
            }
        }
    }
예제 #10
0
 protected void endSurvey(object sender, EventArgs e)
 {
     QuestionLista a = new QuestionLista();
     Timer1.Enabled = false;
     Serialisointi.SerialisoiXmlKysymykset(HttpContext.Current.Server.MapPath("~/App_Data/SavedQuestions.xml"), a);
     showresults = true;
 }