コード例 #1
0
        //
        //Function call to getPictureID(), gets Question_ID, adds question and picture
        //
        public String addPictureQuestion(Questions q, Picture p)
        {
            p.picture_ID = this.getPictureID();
            q.question_ID = this.getNext();
            try
            {
                conn.Open();
                cmd = new SqlCommand("Insert into Questions(Question_ID, Exam_Type, Format, Question, Option1, Option2, Option3, Option4, Solution, Marks, Section,Picture_ID) values('" + q.question_ID + "','" + q.exam_Type + "','" + q.format + "','" + q.question + "','" + q.option1 + "','" + q.option2 + "','" + q.option3 + "','" + q.option4 + "','" + q.solution + "'," + q.marks + ",'" + q.section + "','" + p.picture_ID + "')", conn);
                int result1 = cmd.ExecuteNonQuery();

                cmd = new SqlCommand();
                cmd.CommandText = "Insert into Pictures(Picture_ID,Picture)" + " values(@Picture_ID, @Picture)";
                cmd.Parameters.Add("@Picture_ID", System.Data.SqlDbType.VarChar, 50);
                cmd.Parameters.Add("@Picture", System.Data.SqlDbType.Image);
                cmd.Parameters["@Picture_ID"].Value = p.picture_ID;
                cmd.Parameters["@Picture"].Value = p.image;
                cmd.Connection = conn;
                int result = cmd.ExecuteNonQuery();
                conn.Close();
                if (result == 1 && result1 == 1)
                    return "Question was successfully added & assigned Question ID " + q.question_ID + ".";
                else
                    return "Sorry. There was some error.";

            }
            catch (Exception ex)
            {
                conn.Close();
                return ex.Message;
            }
        }
コード例 #2
0
        //
        //On changing the Format ComboBox: Resets & Disables controls, Loads No Of Question ComboBox, gets and sets the value of No of Questions
        //
        private void formatCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Resets & Disables controls
            noOfQuestionsCombo.Items.Clear();
            noOfQuestionsCombo.ResetText();

            //Loads No Of Question ComboBox
            Questions q = new Questions();
            q.exam_Type = examTypeText.Text;
            q.section = sectionCombo.SelectedItem.ToString();
            q.format = formatCombo.SelectedItem.ToString();
            int i = qb.getQuestionNoCount(q);
            for (int j = 0; j <= i; j++)
            {
                noOfQuestionsCombo.Items.Add(j);
            }
            noOfQuestionsCombo.Enabled = true;
            update.Enabled = true;

            //Gets and sets the value of No of Questions
            Paper s = new Paper();
            s.exam_ID = ed.exam_ID;
            s.section = sectionCombo.SelectedItem.ToString();
            s.format = formatCombo.SelectedItem.ToString();
            int no = p.getNoOfQuestions(s);
            noOfQuestionsCombo.SelectedItem = no;
        }
コード例 #3
0
        //
        //On click of Go button
        //
        private void go_Click(object sender, EventArgs e)
        {
            if (questionIDCombo.SelectedIndex != -1)
            {
                //Assigns the selected Question ID & gets the other fields
                Questions ed = new Questions();
                string temp = questionIDCombo.SelectedItem.ToString();
                int pos = temp.IndexOf(":");
                ed.question_ID = temp.Substring(0, pos);
                ed = bs.getQuestion(ed);
                string format = ed.format;

                //Loads the net form as per the format of the selected queseion
                switch (format)
                {
                    case "MCQ (Single Answer)":
                        UpdateSingleChoice f = new UpdateSingleChoice(ed);
                        f.MdiParent = this.MdiParent;
                        f.Dock = DockStyle.Fill;
                        this.Close();
                        f.Show();
                        break;

                    case "MCQ (Multiple Answers)":
                        UpdateMultipleChoiceQuestions f1 = new UpdateMultipleChoiceQuestions(ed);
                        f1.MdiParent = this.MdiParent;
                        f1.Dock = DockStyle.Fill;
                        this.Close();
                        f1.Show();
                        break;

                    case "Match The Column":
                        UpdateMatchTheColumn f2 = new UpdateMatchTheColumn(ed);
                        f2.MdiParent = this.MdiParent;
                        f2.Dock = DockStyle.Fill;
                        this.Close();
                        f2.Show();
                        break;

                    case "Picture Question: Single Answer":
                        UpdatePictureQuestionSingleAnswer f3 = new UpdatePictureQuestionSingleAnswer(ed);
                        f3.MdiParent = this.MdiParent;
                        f3.Dock = DockStyle.Fill;
                        this.Close();
                        f3.Show();
                        break;

                    case "Picture Question: Multiple Answer":
                        UpdatePictureQuestionMultipleAnswer f4 = new UpdatePictureQuestionMultipleAnswer(ed);
                        f4.MdiParent = this.MdiParent;
                        f4.Dock = DockStyle.Fill;
                        this.Close();
                        f4.Show();
                        break;
                 }
            }
            else
                MessageBox.Show("Please select a valid Question ID.", "Error");
        }
コード例 #4
0
 public CheckSolution(Questions[] q1, Answers[] a1, Employee e1, Exam_Details ed1)
 {
     InitializeComponent();
     q = q1;
     a = a1;
     emp = e1;
     ed = ed1;
 }
コード例 #5
0
 public Result(Employee e1, Exam_Details e2,Questions[] q1, Answers[] a1)
 {
     InitializeComponent();
     emp = e1;
     ed = e2;
     a = a1;
     q = q1;
 }
        //
        //On click of Add button: Validates, adds question and picture, displays assigned Question ID & Picture ID
        //
        protected void add_Click(object sender, EventArgs e)
        {
            if ((marksCombo.SelectedIndex == -1) || (examTypeCombo.SelectedIndex == -1))
                System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Please select a valid entry')</SCRIPT>");
            else
            {
                Questions que = new Questions();
                que.exam_Type = examTypeCombo.Text.ToString();
                que.question = questionText.Text.ToString();
                que.format = formatText.Text.ToString();
                que.option1 = option1Text.Text.ToString();
                que.option2 = option2Text.Text.ToString();
                que.option3 = option3Text.Text.ToString();
                que.option4 = option4Text.Text.ToString();
                string t = marksCombo.Text.ToString();
                if (t == "")
                    que.marks = 0;
                else
                    que.marks = Convert.ToInt32(t);

                if (sectioncomboBox.SelectedIndex != -1)
                    que.section = sectioncomboBox.SelectedItem.ToString();
                else if (sectioncomboBox.Text != "")
                    que.section = sectioncomboBox.Text.ToString();
                else
                    System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Enter Section.')</SCRIPT>");

                string sol = "";
                if (option1Radio.Checked)
                    sol = "1";
                if (option2Radio.Checked)
                    sol = "2";
                if (option3Radio.Checked)
                    sol = "3";
                if (option4Radio.Checked)
                    sol = "4";
                que.solution = sol;
                this.btnUpload_Click(sender, e);

                string feedback = ed.addPictureQuestion(que, p);
                if (feedback.Contains("successfully"))
                {
                    System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Successfully.')</SCRIPT>");
                    option1Radio.Checked = option2Radio.Checked = option3Radio.Checked = option4Radio.Checked = false;
                    examTypeCombo.SelectedIndex = marksCombo.SelectedIndex = 0;
                    questionText.Text = option1Text.Text = option2Text.Text = option3Text.Text = option4Text.Text = "";
                    Image1.ImageUrl = null;
                    //pictureBox1.Image = null;
                }
                else
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + feedback + "');", true);
                    ///System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('UnSuccessfully.')</SCRIPT>");
                //MessageBox.Show(feedback, "Add Question");
            }
        }
コード例 #7
0
 //
 //Accepts and assigns Question, Answers, Bookmark array, index, time left, Employee and Exam Details
 //
 public PictureQuestionSingleAns(Questions[] que, Answers[] ans, Bookmark[] b1, int ind, int timeleft1, Employee e, Exam_Details exd)
 {
     InitializeComponent();
     q = que;
     a = ans;
     b = b1;
     index = ind;
     timeLeft = timeleft1;
     emp = e;
     ed = exd;
 }
コード例 #8
0
 //
 //Accepts and assigns Question, Answers, Bookmark array, index, time left, Employee and Exam Details
 //
 public MatchTheColumnTest(Questions[] que, Answers[] ans, Bookmark[] b1, int ind, int timeleft1, Employee e, Exam_Details exd)
 {
     InitializeComponent();
     q = que;
     a = ans;
     index = ind;
     b = b1;
     timeLeft = timeleft1;
     emp = e;
     ed = exd;
 }
コード例 #9
0
 //
 //Initializes the fields of Answers array including answers
 //
 public Answers[] initializeAnswersArray(Answers[] a, Questions[] q, Exam_Details ed, Employee emp)
 {
     for (int i = 0; i < q.Length; i++)
     {
         a[i] = new Answers();
         a[i].exam_ID = ed.exam_ID;
         a[i].employee_Id = emp.employee_Id;
         a[i].question_ID = q[i].question_ID;
         a = this.storeAnswer(a, i, "");
     }
     return a;
 }
コード例 #10
0
        //
        //Calculates marks for each question and the total, stores them in Answers array, DAL call to store the answers in the Answers table, and final results in the Result table
        //
        public bool submit(Answers[] a, Questions[] q, Employee emp, Exam_Details ed)
        {
            //Calculates marks for each question (stores them in Answers array), total and percentage
            int score = 0;
            int outOf = 0;
            float per = 0;
            for (int i = 0; i < q.Length; i++)
            {
                if (a[i].answer.Equals(q[i].solution))
                    a[i].marks = q[i].marks;
                else
                    a[i].marks = 0;
                score += a[i].marks;
                outOf += q[i].marks;
            }
            per = (score *100) / outOf;

            //DAL call to store the answers in the Answers table
            bool feed = d.submitAnswers(a);

            //DAL call to store final result in the Result table
            if (feed)
            {
                Results re = new Results();
                re.employee_ID = emp.employee_Id;
                re.exam_ID = ed.exam_ID;
                re.score = score;
                re.percentage = per;
                ResultsDAL rb = new ResultsDAL();
                bool feed1 = rb.addScore(re);
                if (feed1)
                {
                    ResultStatusDAL rsd = new ResultStatusDAL();
                    ResultStatus rs = new ResultStatus();
                    rs.employee_ID = emp.employee_Id;
                    rs.exam_Type = ed.exam_Type;
                    if (re.percentage >= 50.0)
                        rs.status = "Passed";
                    else
                        rs.status = "Failed";
                    bool feed2 = rsd.updateStatus(rs);
                    if (feed2)
                        return true;
                    else
                        return false;
                }
                else
                    return false;
            }
            else
                return false;
        }
        protected void add_Click(object sender, EventArgs e)
        {
            if ((marksCombo.SelectedIndex == -1) || (examTypeCombo.SelectedIndex == -1))
                System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Please select a valid entry')</SCRIPT>");
                //MessageBox.Show("Please select a valid entry","Error");
            else
            {
                Questions que = new Questions();
                que.exam_Type = examTypeCombo.Text.ToString();
                que.question = questionText.Text.ToString();
                que.format = formatText.Text.ToString();
                que.option1 = option1Text.Text.ToString();
                que.option2 = option2Text.Text.ToString();
                que.option3 = option3Text.Text.ToString();
                que.option4 = option4Text.Text.ToString();
                string t = marksCombo.Text.ToString();
                if (t == "")
                    que.marks = 0;
                else
                    que.marks = Convert.ToInt32(t);
                if (sectioncomboBox.SelectedIndex != -1)
                    que.section = sectioncomboBox.SelectedItem.ToString();
                else if (sectioncomboBox.Text != "")
                    que.section = sectioncomboBox.Text.ToString();
                else
                    System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Enter Section')</SCRIPT>");
                    //MessageBox.Show("Enter Section");

                string sol = "";
                if (option1Radio.Checked)
                    sol = "1";
                if (option2Radio.Checked)
                    sol = "2";
                if (option3Radio.Checked)
                    sol = "3";
                if (option4Radio.Checked)
                    sol = "4";
                que.solution = sol;

                string feedback = ed.addQuestion(que);
                if (feedback.Contains("successfully"))
                {
                    option1Radio.Checked = option2Radio.Checked = option3Radio.Checked = option4Radio.Checked = false;
                    examTypeCombo.SelectedIndex = marksCombo.SelectedIndex = 0;
                    questionText.Text = option1Text.Text = option2Text.Text = option3Text.Text = option4Text.Text = "";

                }
                System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert(feedback)</SCRIPT>");
                //MessageBox.Show(feedback, "Add Question");
            }
        }
コード例 #12
0
        //Calculate Detailed Result
        public bool calculateResult(Answers[] a, Questions[] q, Results r, Employee emp)
        {
            bool flag = true;
            int count = q.Length;
            int total = 0;
            string[] abc;
            ResultsDAL d = new ResultsDAL();

            int i = d.getSectionCount(r);
            DetailedReports[] re = new DetailedReports[i];
            abc = new string[i];
            int[] section = new int[i];
            abc = d.loadSection(r, i);

            int[] totalQuestions = d.totalSectionQuestions(abc, r);

            for (int j = 0; j < count; j++)
            {

                //total = total + q[j].marks;
                if (a[j].answer.Equals(q[j].solution))
                {
                    string click = q[j].section;
                    for (int k = 0; k < i; k++)
                    {
                        if (click == abc[k])
                            section[k]++;
                    }
                }
            }

            for (int k = 0; k < i; k++)
            {
                re[k] = new DetailedReports();
                re[k].employee_ID = emp.employee_Id;
                re[k].exam_ID = r.exam_ID;
                re[k].section = abc[k];
                re[k].percentage = (section[k] * 100) / totalQuestions[k];
                flag = d.addDetailedResult(re[k]);
            }
            return flag;
        }
コード例 #13
0
 //
 //Adds Question and returns assigned Question ID (or Error Message)
 //
 public string addQuestion(Questions q)
 {
     try
     {
         q.question_ID = this.getNext();
         conn.Open();
         cmd = new SqlCommand("Insert into Questions(Question_ID, Exam_Type, Format, Question, Option1, Option2, Option3, Option4, Solution, Marks, Section) values('" + q.question_ID + "','" + q.exam_Type + "','" + q.format + "','" + q.question + "','" + q.option1 + "','" + q.option2 + "','" + q.option3 + "','" + q.option4 + "','" + q.solution + "'," + q.marks + ",'" + q.section + "')", conn);
         int i= cmd.ExecuteNonQuery();
         conn.Close();
         if(i==1)
             return "Question was successfully added & assigned Question ID " + q.question_ID + ".";
         else
             return "Some error occured. Sorry for the inconvenience.";
     }
     catch (Exception ex)
     {
         conn.Close();
         return "Some error occured. Sorry for the inconvenience.";
     }
 }
コード例 #14
0
        //
        //On changing the Format ComboBox: Resets & Disables controls, Loads No Of Question ComboBox
        //
        protected void formatCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Resets & Disables controls
            noOfQuestionsCombo.Items.Clear();
            noOfQuestionsCombo.SelectedIndex = -1;
            //noOfQuestionsCombo.ResetText();

            //Loads No Of Question ComboBox
            Questions q = new Questions();
            q.exam_Type = examTypeText.Text;
            q.section = sectionCombo.SelectedItem.ToString();
            q.format = formatCombo.SelectedItem.ToString();
            int i = qb.getQuestionNoCount(q);
            for (int j = 1; j <= i; j++)
            {
                noOfQuestionsCombo.Items.Add(j+"");
            }
            noOfQuestionsCombo.SelectedIndex = 0;
            noOfQuestionsCombo.Enabled = true;
            add.Enabled = true;
        }
コード例 #15
0
        //
        //Deletes the selected Exam & pops up a Success or Error message
        //
        protected void delete_Click(object sender, EventArgs e)
        {
            if (questionIDCombo.SelectedIndex != -1)
            {
                //DialogResult result = MessageBox.Show("Are you sure you want delete " + questionIDCombo.SelectedItem.ToString() + "?", "Delete Question", MessageBoxButtons.YesNo);
                //if (result == DialogResult.Yes)

                    Questions q = new Questions();
                    string temp = questionIDCombo.SelectedItem.ToString();
                    int index = temp.IndexOf(":");
                    q.question_ID = temp.Substring(0, index - 1);
                    string feed = ed.deleteQuestion(q);
                    System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Succesfully deleted.')</SCRIPT>");
                    //MessageBox.Show(feed);

            }
            else
                System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('SPlease select a valid Question ID.')</SCRIPT>");
                //MessageBox.Show("Please select a valid Question ID.");

            this.Page_Load(sender, e);
        }
 public UpdatePictureQuestionMultipleAnswer(Questions que)
 {
     InitializeComponent();
     q = que;
 }
コード例 #17
0
 //
 //Gets count of Questions for a given Exam Type, Section & Format
 //
 public int getQuestionNoCount(Questions q)
 {
     conn.Open();
     cmd = new SqlCommand("select count(Question_ID) from Questions where Exam_Type='" + q.exam_Type + "' and Section='" + q.section + "' and Format ='" + q.format + "'",conn);
     int i = (int)cmd.ExecuteScalar();
     conn.Close();
     return i;
 }
        //
        //On click of Add button: Validates, adds question and picture, displays assigned Question ID & Picture ID
        //
        private void add_Click(object sender, EventArgs e)
        {
            if ((marksCombo.SelectedIndex == -1) || (examTypeCombo.SelectedIndex == -1))
                MessageBox.Show("Please select a valid entry", "Error");
            else
            {
                Questions que = new Questions();
                que.exam_Type = examTypeCombo.Text.ToString();
                que.question = questionText.Text.ToString();
                que.format = formatText.Text.ToString();
                que.option1 = option1Text.Text.ToString();
                que.option2 = option2Text.Text.ToString();
                que.option3 = option3Text.Text.ToString();
                que.option4 = option4Text.Text.ToString();
                string t = marksCombo.Text.ToString();
                if (t == "")
                    que.marks = 0;
                else
                    que.marks = Convert.ToInt32(t);
                if (sectioncomboBox.SelectedIndex != -1)
                    que.section = sectioncomboBox.SelectedItem.ToString();
                else if (sectioncomboBox.Text != "")
                    que.section = sectioncomboBox.Text.ToString();
                else
                    MessageBox.Show("Enter Section");

                string sol = "";
                if (option1Check.Checked)
                    sol = sol + "1";
                if (option2Check.Checked)
                    sol = sol + "2";
                if (option3Check.Checked)
                    sol = sol + "3";
                if (option4Check.Checked)
                    sol = sol + "4";
                que.solution = sol;

                string feedback = ed.addPictureQuestion(que, p);

                if (feedback.Contains("successfully"))
                {
                    option1Check.Checked = option2Check.Checked = option3Check.Checked = option4Check.Checked = false;
                    examTypeCombo.SelectedIndex = marksCombo.SelectedIndex = 0;
                    questionText.Text = formatText.Text = option1Text.Text = option2Text.Text = option3Text.Text = option4Text.Text = "";
                    pictureBox1.Image = null;
                }

                MessageBox.Show(feedback, "Add Question");
            }
        }
コード例 #19
0
        //
        //Randomly selects questions for each Format-Section specification of the Paper as per the No Of Questions
        //
        public Questions[] getQuestionPaper(Paper[] arr, Questions[] q, Exam_Details ed)
        {
            int maxcount = 0, mincount = 0;
            DataRow dr;
            int index = 0;
            Object[] abc = new Object[11];
            string temp;
            bool[] rand;
            int no = 0;
            int m;
            int param = arr.Length;
            DataTable dt;
            conn.Open();

            for (int l = 0; l < param; l++)
            {
                //Selects questions for each Format-Section specification of the Paper
                cmd = new SqlCommand("Select * from Questions where Exam_Type ='" + ed.exam_Type + "' and Section ='" + arr[l].section + "' and Format ='" + arr[l].format + "'",conn);
                dread = cmd.ExecuteReader();
                dt = new DataTable();
                dt.Load(dread);

                //Random Selection of questions
                maxcount = dt.Rows.Count;
                mincount = arr[l].no_Of_Questions;
                rand = new bool[maxcount];
                no = 0;
                while (no < mincount)
                {
                    Random r = new Random();
                    m = r.Next(maxcount);

                    if (rand[m] == false)
                    {
                        rand[m] = true;
                        no++;
                    }
                }

                //Loads the randomly selected question into Question Array
                for (int i = 0; i < maxcount; i++)
                {
                    if (rand[i] == true)
                    {
                        q[index] = new Questions();
                        dr = dt.Rows[i];
                        abc = dr.ItemArray;

                        q[index].question_ID = (string)abc.ElementAt(0);
                        q[index].exam_Type = (string)abc.ElementAt(1);
                        q[index].format = (string)abc.ElementAt(2);
                        q[index].question = (string)abc.ElementAt(3);
                        q[index].option1 = (string)abc.ElementAt(4);
                        q[index].option2 = (string)abc.ElementAt(5);
                        q[index].option3 = (string)abc.ElementAt(6);
                        q[index].option4 = (string)abc.ElementAt(7);
                        q[index].solution = (string)abc.ElementAt(8);
                        temp = abc.ElementAt(9).ToString();
                        q[index].marks = Convert.ToInt32(temp);
                        q[index].section = (string)abc.ElementAt(10);
                        if((q[index].format.Equals("Picture Question: Single Answer") )|| (q[index].format.Equals("Picture Question: Multiple Answer")))
                            q[index].picture_ID = (string)abc.ElementAt(11);
                        index++;
                    }
                }

            }
            dread.Close();
            conn.Close();
            return q;
        }
コード例 #20
0
 //
 //Gets count of Sections for a given Exam Type
 //
 public int getSectionCount(Questions q)
 {
     conn.Open();
     cmd = new SqlCommand("select count(distinct Section) from Questions where Exam_Type='"+q.exam_Type+"'", conn);
     int i = (int)cmd.ExecuteScalar();
     conn.Close();
     return i;
 }
        //
        //On click of Add button, validates, adds question, displays assigned Quesetion ID
        //
        private void add_Click(object sender, EventArgs e)
        {
            if ((marksCombo.SelectedIndex == -1) || (examTypeCombo.SelectedIndex == -1))
                MessageBox.Show("Please select a valid entry", "Error");
            else
            {
                Questions que = new Questions();
                que.exam_Type = examTypeCombo.Text.ToString();
                que.question = "." + aText.Text.ToString() + "." + bText.Text.ToString() + "." + cText.Text.ToString() + "." + dText.Text.ToString() + ".";
                que.format = formatText.Text.ToString();
                que.marks = Convert.ToInt32(marksCombo.Text);
                if (sectioncomboBox.SelectedIndex != -1)
                    que.section = sectioncomboBox.SelectedItem.ToString();
                else if (sectioncomboBox.Text != "")
                    que.section = sectioncomboBox.Text.ToString();
                else
                    MessageBox.Show("Enter Section");
                que.solution = solutionText.Text.ToString();
                que.option1 = oneText.Text.ToString();
                que.option2 = twoText.Text.ToString();
                que.option3 = threeText.Text.ToString();
                que.option4 = fourText.Text.ToString();

                string feedback = ed.addQuestion(que);
                MessageBox.Show(feedback);
                if(feedback.Contains("successfully"))
                {
                    examTypeCombo.SelectedIndex = sectioncomboBox.SelectedIndex = marksCombo.SelectedIndex = 0;
                    aText.Text = bText.Text = cText.Text = dText.Text = formatText.Text = solutionText.Text = oneText.Text = twoText.Text = threeText.Text = fourText.Text = "";
                }
            }
        }
コード例 #22
0
 //
 //Loads Sections for a given Exam Type
 //
 public string[] loadSection(Questions q, int k)
 {
     conn.Open();
     cmd = new SqlCommand("select distinct Section from Questions where Exam_Type = '"+q.exam_Type+"'",conn);
     dread = cmd.ExecuteReader();
     string[] abc = new string[k];
     int i =0;
     while (i<k)
     {
         dread.Read();
         abc[i] = dread.GetString(0);
         i++;
     }
     dread.Close();
     conn.Close();
     return abc;
 }
コード例 #23
0
 //
 //Function call to getPictureID(), Updates fields of Question, returns Success or Error Message
 //
 public string updatePictureQuestion(Questions q, Picture p)
 {
     try
     {
         p.picture_ID = this.getPictureID();
         conn.Open();
         cmd = new SqlCommand("Update Questions SET Question_ID='" + q.question_ID + "', Exam_Type='" + q.exam_Type + "', Format ='" + q.format + "', Question = '" + q.question + "', Option1 = '" + q.option1 + "', Option2 = '" + q.option2 + "', Option3 = '" + q.option3 + "', Option4 = '" + q.option4 + "', Solution = '" + q.solution + "', Marks = " + q.marks + ", Section = '" + q.section + "', Picture_ID = '"+ p.picture_ID +"' Where Question_ID='" + q.question_ID + "'", conn);
         int i = cmd.ExecuteNonQuery();
         cmd = new SqlCommand();
         cmd.CommandText = "Insert into Pictures(Picture_ID,Picture)" + " values(@Picture_ID, @Picture)";
         cmd.Parameters.Add("@Picture_ID", System.Data.SqlDbType.VarChar, 50);
         cmd.Parameters.Add("@Picture", System.Data.SqlDbType.Image);
         cmd.Parameters["@Picture_ID"].Value = p.picture_ID;
         cmd.Parameters["@Picture"].Value = p.image;
         cmd.Connection = conn;
         int j = cmd.ExecuteNonQuery();
         conn.Close();
         if (i == 1 && j==1)
             return "Question was successfully updated.";
         else
             return"Some error occured. Sorry for the inconvenience.";
     }
     catch (Exception ex)
     {
         conn.Close();
         return "Some error occured. Sorry for the inconvenience.";
     }
 }
コード例 #24
0
 //
 //Updates fields of Question, returns Success or Error Message
 //
 public string updateQuestion(Questions q)
 {
     try
     {
         conn.Open();
         cmd = new SqlCommand("Update Questions SET Question_ID='" +q.question_ID + "', Exam_Type='" +q.exam_Type+ "', Format ='"+q.format+"', Question = '"+ q.question +"', Option1 = '"+q.option1 +"', Option2 = '"+q.option2 +"', Option3 = '"+q.option3 +"', Option4 = '"+q.option4 +"', Solution = '"+q.solution +"', Marks = "+q.marks +", Section = '"+q.section + "' Where Question_ID='" + q.question_ID + "'", conn);
         int i = cmd.ExecuteNonQuery();
         conn.Close();
         if(i==1)
             return "Question was successfully updated";
         else
             return "Some error occured. Sorry for the inconvenience.";
     }
     catch (Exception ex)
     {
         conn.Close();
         return "Some error occured. Sorry for the inconvenience.";
     }
 }
コード例 #25
0
        //
        //On changing the Section ComboBox: Resets & Disables controls, Loads Format ComboBox
        //
        private void sectionCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Resets & Disables controls
            formatCombo.Items.Clear();
            formatCombo.ResetText();
            noOfQuestionsCombo.Items.Clear();
            noOfQuestionsCombo.ResetText();
            noOfQuestionsCombo.Enabled = false;
            add.Enabled = false;

            //Loads Format ComboBox
            Questions q = new Questions();
            q.exam_Type = ed.exam_Type;
            q.section = sectionCombo.SelectedItem.ToString();
            int i = qb.getFormatCount(q);
            string[] abc = new string[i];
            abc = qb.loadFormat(q, i);
            for (int j = 0; j < i; j++)
            {
                formatCombo.Items.Add(abc[j]);
            }
            formatCombo.Enabled = true;
        }
コード例 #26
0
        //
        //On Form Load: Displays No of Added Question, Disables controls & Loads Section ComboBox
        //
        private void SetPaper_Load(object sender, EventArgs e)
        {
            // to allign the Legend(Group Box) to
            // the center of form
            int centerForm;
            int centerGroup;
            int groupStartPosition;

            centerForm = this.Width / 2;
            centerGroup = setPaperRegion.Width / 2;
            groupStartPosition = centerForm - centerGroup;
            setPaperRegion.Left = groupStartPosition;

            // Displays No of Added Questions
            Paper pq = new Paper();
            pq.exam_ID = ed.exam_ID;
            noOfQuestionsText.Text = p.getAddedQuestionCount(pq) + "";

            //Diables controls
            sectionCombo.Enabled = false;
            formatCombo.Enabled = false;
            noOfQuestionsCombo.Enabled = false;
            add.Enabled = false;

            //Loads Section ComboBox
            Questions q = new Questions();
            q.exam_Type = ed.exam_Type;
            int i = qb.getSectionCount(q);
            if (i > 0)
            {
                string[] abc = new string[i];
                abc = qb.loadSection(q, i);
                for (int j = 0; j < i; j++)
                {
                   sectionCombo.Items.Add(abc[j]);
                }
                sectionCombo.Enabled = true;
            }
            else
                MessageBox.Show("No Questions present in the database for the Exam Type of the selected Exam.", "Error");
        }
コード例 #27
0
        public Questions getQuestion(int index)
        {
            string constr = @"Server=NIKKHIL-HP\sqlexpress;Integrated Security=true; database=OnlineExamination";
            SqlDataAdapter da = new SqlDataAdapter();
            SqlCommandBuilder sb = new SqlCommandBuilder(da);
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            SqlTransaction tran = conn.BeginTransaction();
            String sql = "Select * from Questions";
            da.SelectCommand = new SqlCommand(sql, conn, tran);
            DataSet ds = new DataSet();
            da.Fill(ds, "Questions");
            DataTable dt = ds.Tables["Questions"];

            Questions et = new Questions();

            DataRow dr = dt.Rows[index];
            dr = dt.Rows[index];
            Object[] abc = new Object[11];
            abc = dr.ItemArray;
            et.question_ID = (string)abc.ElementAt(0);
            et.exam_Type = (string)abc.ElementAt(1);
            et.format = (string)abc.ElementAt(2);
            et.question = (string)abc.ElementAt(3);
            et.option1 = (string)abc.ElementAt(4);
            et.option2 = (string)abc.ElementAt(5);
            et.option3 = (string)abc.ElementAt(6);
            et.option4 = (string)abc.ElementAt(7);
            et.solution = (string)abc.ElementAt(8);
            string abcde = abc.ElementAt(9).ToString();
            et.marks = Convert.ToInt32(abcde);
            et.section = (string)abc.ElementAt(10);
            conn.Close();
            return et;
        }
 public UpdateSingleChoice(Questions que)
 {
     InitializeComponent();
     q = que;
 }
コード例 #29
0
 public int getFormatCount(Questions q, string a)
 {
     String constr = @"Server=NIKKHIL-HP\sqlexpress;Integrated Security=true; database=OnlineExamination";
     SqlConnection conn = new SqlConnection(constr);
     conn.Open();
     String query = string.Format("select Question_ID from TempPaper where Format='" + a + "' and  Section ='" + q.section + "'");
     SqlCommand cmd = new SqlCommand();
     cmd.Connection = conn;
     cmd.CommandText = query;
     SqlDataReader rdr = cmd.ExecuteReader();
     int i = 0;
     while (rdr.Read())
     {
         i++;
     }
     conn.Close();
     return i;
 }
コード例 #30
0
 public UpdateMatchTheColumn(Questions que)
 {
     InitializeComponent();
      q = que;
 }