Online examination in ASP - Shalu - 10-04-2017
[attachment=14265]
Result.aspx.cs
Code: using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Result : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string s = Convert.ToString(Session["abc"]);
try
{
if (s == " ")
{
// int a = 0;
ltrlResult.Text = "<h2>Sorry Your Score =0";
}
else
{
//int a = Convert.ToInt32(s);
//if (a >= 6)
//{
//
Image1.ImageUrl = " /images/img2.jpg";
ltrlResult.Text = "<h2>Your Score Good= " + Session["abc"] + "</h2>";
}
//else
//{
// Image1.ImageUrl = " /images/img1.jpg";
// ltrlResult.Text = "<h2>Your Score Poor= " + a.ToString() + "</h2>";
//}
//}
}
catch (Exception ee)
{
Response.Write(ee);
}
finally
{
}
}
}
Registration.aspx.cs
Code: using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class Registration : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["abc"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("insert into login values(@name,@uid,@pwd,@sque,@sans,@email,@loc,@dob)",con);
con.Open();
string s = TextBox1.Text + "-" + TextBox2.Text;
cmd.Parameters.AddWithValue("@name",s);
cmd.Parameters.AddWithValue("@uid",TextBox3.Text);
cmd.Parameters.AddWithValue("@pwd", TextBox4.Text);
cmd.Parameters.AddWithValue("@sque", DropDownList1.SelectedItem.Text);
cmd.Parameters.AddWithValue("@sans", TextBox6.Text);
cmd.Parameters.AddWithValue("@email", TextBox7.Text);
cmd.Parameters.AddWithValue("@loc", DropDownList2.SelectedItem.Text);
cmd.Parameters.AddWithValue("@dob", TextBox8.Text);
cmd.ExecuteNonQuery();
con.Close();
Label1.Text = "You Have Sucessfully Registerd Please Go to Login For Exam";
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
Home.aspx.cs
Code: using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class Home : System.Web.UI.Page
{
public static SqlConnection sqlconn;
protected string PostBackStr;
protected void Page_Load(object sender, EventArgs e)
{
sqlconn = new SqlConnection(ConfigurationManager.AppSettings["abc"].ToString());
PostBackStr = Page.ClientScript.GetPostBackEventReference(this, "time");
if (IsPostBack)
{
string eventArg = Request["__EVENTARGUMENT"];
if (eventArg == "time")
{
getNextQuestion();
}
}
}
protected void btnStart_Click(object sender, EventArgs e)
{
if (DropDownList1.SelectedItem.Text == "Select Paper")
{
PanelMain.Visible = false;
Panel1.Visible = true;
lblName.Text = "Name : " + txtName.Text;
//int score = Convert.ToInt32(txtScore.Text);
lblScore.Text = "Please Select Paper : ";// +Convert.ToString(score);
btnNext.Text = "Logout";
}
if (DropDownList1.SelectedItem.Text == "Math")
{
PanelMain.Visible = false;
Panel1.Visible = true;
lblName.Text = "Name : " + txtName.Text;
int score = Convert.ToInt32(txtScore.Text);
lblScore.Text = "Score : " + Convert.ToString(score);
Session["counter"] = "1";
Random rnd = new Random();
int i = rnd.Next(1, 10);//Here specify your starting slno of question table and ending no.
//lblQuestion.Text = i.ToString();
getQuestion_math(i);
}
if (DropDownList1.SelectedItem.Text == "English")
{
PanelMain.Visible = false;
Panel1.Visible = true;
lblName.Text = "Name : " + txtName.Text;
int score = Convert.ToInt32(txtScore.Text);
lblScore.Text = "Score : " + Convert.ToString(score);
Session["counter"] = "1";
Random rnd = new Random();
int i = rnd.Next(1, 10);//Here specify your starting slno of question table and ending no.
//lblQuestion.Text = i.ToString();
getQuestion_English(i);
}
if (DropDownList1.SelectedItem.Text == "Computer")
{
PanelMain.Visible = false;
Panel1.Visible = true;
lblName.Text = "Name : " + txtName.Text;
int score = Convert.ToInt32(txtScore.Text);
lblScore.Text = "Score : " + Convert.ToString(score);
Session["counter"] = "1";
Random rnd = new Random();
int i = rnd.Next(1, 10);//Here specify your starting slno of question table and ending no.
//lblQuestion.Text = i.ToString();
getQuestion(i);
}
if (DropDownList1.SelectedItem.Text == "Science")
{
PanelMain.Visible = false;
Panel1.Visible = true;
lblName.Text = "Name : " + txtName.Text;
int score = Convert.ToInt32(txtScore.Text);
lblScore.Text = "Score : " + Convert.ToString(score);
Session["counter"] = "1";
Random rnd = new Random();
int i = rnd.Next(1, 10);//Here specify your starting slno of question table and ending no.
//lblQuestion.Text = i.ToString();
getQuestion_science(i);
}
}
protected void btnNext_Click(object sender, EventArgs e)
{
if (DropDownList1.SelectedItem.Text == "Select Paper")
{
Response.Redirect("Default.aspx");
}
if (DropDownList1.SelectedItem.Text == "Computer")
{
getNextQuestion();
}
if (DropDownList1.SelectedItem.Text == "Science")
{
getNextQuestion_science();
}
if (DropDownList1.SelectedItem.Text == "English")
{
getNextQuestion_English();
}
if (DropDownList1.SelectedItem.Text == "Math")
{
getNextQuestion_math();
}
}
public void getQuestion(int no)
{
string str = "select * from Question where slNo=" + no + "";
SqlDataAdapter da2 = new SqlDataAdapter(str, sqlconn);
DataSet ds2 = new DataSet();
da2.Fill(ds2, "Question");
if (ds2.Tables[0].Rows.Count > 0)
{
DataRow dtr;
int i = 0;
while (i < ds2.Tables[0].Rows.Count)
{
dtr = ds2.Tables[0].Rows[i];
Session["Answer"] = Convert.ToString(Convert.ToInt32(dtr["Correct"].ToString()) - 1);
lblQuestion.Text = "Q." + Session["counter"].ToString() + " " + dtr["Question"].ToString();
RblOption.ClearSelection();
RblOption.Items.Clear();
RblOption.Items.Add(dtr["Option1"].ToString());
RblOption.Items.Add(dtr["Option2"].ToString());
RblOption.Items.Add(dtr["Option3"].ToString());
RblOption.Items.Add(dtr["Option4"].ToString());
i++;
}
}
}
public void getNextQuestion()
{
if (Convert.ToInt32(Session["counter"].ToString()) < 10)//10 is a counter which is used for 10 questions
{
string s;
if (RblOption.SelectedIndex >= 0)
{
if (Session["Answer"].ToString() == RblOption.SelectedIndex.ToString())
{
int score = Convert.ToInt32(txtScore.Text) + 1;// 1 for mark for each question
txtScore.Text = score.ToString();
s = "Score : " + Convert.ToString(score);
Session["abc"] = s.ToString();
lblScore.Text = Convert.ToString(score);
}
}
Random rnd = new Random();
int i = rnd.Next(1, 10);
//lblQuestion.Text = i.ToString();
getQuestion(i);
Session["counter"] = Convert.ToString(Convert.ToInt32(Session["counter"].ToString()) + 1);
}
else
{
Response.Redirect("Result.aspx");
Panel2.Visible = false;
//code for displaying after completting the exam, if you want to show the result then you can code here.
}
}
//math
public void getQuestion_math(int no)
{
string str = "select * from Question_math where slNo=" + no + "";
SqlDataAdapter da2 = new SqlDataAdapter(str, sqlconn);
DataSet ds2 = new DataSet();
da2.Fill(ds2, "Question_math");
if (ds2.Tables[0].Rows.Count > 0)
{
DataRow dtr;
int i = 0;
while (i < ds2.Tables[0].Rows.Count)
{
dtr = ds2.Tables[0].Rows[i];
Session["Answer"] = Convert.ToString(Convert.ToInt32(dtr["Correct"].ToString()) - 1);
lblQuestion.Text = "Q." + Session["counter"].ToString() + " " + dtr["Question"].ToString();
RblOption.ClearSelection();
RblOption.Items.Clear();
RblOption.Items.Add(dtr["Option1"].ToString());
RblOption.Items.Add(dtr["Option2"].ToString());
RblOption.Items.Add(dtr["Option3"].ToString());
RblOption.Items.Add(dtr["Option4"].ToString());
i++;
}
}
}
public void getNextQuestion_math()
{
if (Convert.ToInt32(Session["counter"].ToString()) < 10)//10 is a counter which is used for 10 questions
{
string s;
if (RblOption.SelectedIndex >= 0)
{
if (Session["Answer"].ToString() == RblOption.SelectedIndex.ToString())
{
int score = Convert.ToInt32(txtScore.Text) + 1;// 1 for mark for each question
txtScore.Text = score.ToString();
s = "Score : " + Convert.ToString(score);
Session["abc"] = s.ToString();
lblScore.Text = Convert.ToString(score);
}
}
Random rnd = new Random();
int i = rnd.Next(1, 10);
//lblQuestion.Text = i.ToString();
getQuestion_math(i);
Session["counter"] = Convert.ToString(Convert.ToInt32(Session["counter"].ToString()) + 1);
}
else
{
Response.Redirect("Result.aspx");
Panel2.Visible = false;
//code for displaying after completting the exam, if you want to show the result then you can code here.
}
}
// Science
public void getQuestion_science(int no)
{
string str = "select * from Question_science where slNo=" + no + "";
SqlDataAdapter da2 = new SqlDataAdapter(str, sqlconn);
DataSet ds2 = new DataSet();
da2.Fill(ds2, "Question_science");
if (ds2.Tables[0].Rows.Count > 0)
{
DataRow dtr;
int i = 0;
while (i < ds2.Tables[0].Rows.Count)
{
dtr = ds2.Tables[0].Rows[i];
Session["Answer"] = Convert.ToString(Convert.ToInt32(dtr["Correct"].ToString()) - 1);
lblQuestion.Text = "Q." + Session["counter"].ToString() + " " + dtr["Question"].ToString();
RblOption.ClearSelection();
RblOption.Items.Clear();
RblOption.Items.Add(dtr["Option1"].ToString());
RblOption.Items.Add(dtr["Option2"].ToString());
RblOption.Items.Add(dtr["Option3"].ToString());
RblOption.Items.Add(dtr["Option4"].ToString());
i++;
}
}
}
public void getNextQuestion_science()
{
if (Convert.ToInt32(Session["counter"].ToString()) < 10)//10 is a counter which is used for 10 questions
{
string s;
if (RblOption.SelectedIndex >= 0)
{
if (Session["Answer"].ToString() == RblOption.SelectedIndex.ToString())
{
int score = Convert.ToInt32(txtScore.Text) + 1;// 1 for mark for each question
txtScore.Text = score.ToString();
s = "Score : " + Convert.ToString(score);
Session["abc"] = s.ToString();
lblScore.Text = Convert.ToString(score);
}
}
Random rnd = new Random();
int i = rnd.Next(1, 10);
//lblQuestion.Text = i.ToString();
getQuestion_science(i);
Session["counter"] = Convert.ToString(Convert.ToInt32(Session["counter"].ToString()) + 1);
}
else
{
Response.Redirect("Result.aspx");
Panel2.Visible = false;
//code for displaying after completting the exam, if you want to show the result then you can code here.
}
}
// English
public void getQuestion_English(int no)
{
string str = "select * from Question_English where slNo=" + no + "";
SqlDataAdapter da2 = new SqlDataAdapter(str, sqlconn);
DataSet ds2 = new DataSet();
da2.Fill(ds2, "Question_English");
if (ds2.Tables[0].Rows.Count > 0)
{
DataRow dtr;
int i = 0;
while (i < ds2.Tables[0].Rows.Count)
{
dtr = ds2.Tables[0].Rows[i];
Session["Answer"] = Convert.ToString(Convert.ToInt32(dtr["Correct"].ToString()) - 1);
lblQuestion.Text = "Q." + Session["counter"].ToString() + " " + dtr["Question"].ToString();
RblOption.ClearSelection();
RblOption.Items.Clear();
RblOption.Items.Add(dtr["Option1"].ToString());
RblOption.Items.Add(dtr["Option2"].ToString());
RblOption.Items.Add(dtr["Option3"].ToString());
RblOption.Items.Add(dtr["Option4"].ToString());
i++;
}
}
}
public void getNextQuestion_English()
{
if (Convert.ToInt32(Session["counter"].ToString()) < 10)//10 is a counter which is used for 10 questions
{
string s;
if (RblOption.SelectedIndex >= 0)
{
if (Session["Answer"].ToString() == RblOption.SelectedIndex.ToString())
{
int score = Convert.ToInt32(txtScore.Text) + 1;// 1 for mark for each question
txtScore.Text = score.ToString();
s = "Score : " + Convert.ToString(score);
Session["abc"] = s.ToString();
lblScore.Text = Convert.ToString(score);
}
}
Random rnd = new Random();
int i = rnd.Next(1, 10);
//lblQuestion.Text = i.ToString();
getQuestion_English(i);
Session["counter"] = Convert.ToString(Convert.ToInt32(Session["counter"].ToString()) + 1);
}
else
{
Response.Redirect("Result.aspx");
Panel2.Visible = false;
//code for displaying after completting the exam, if you want to show the result then you can code here.
}
}
#region Connection Open
public void ConnectionOpen()
{
try
{
if (sqlconn.State == ConnectionState.Closed) { sqlconn.Open(); }
}
catch (SqlException ex)
{
}
catch (SystemException sex)
{
}
}
#endregion
#region Connection Close
public void ConnectionClose()
{
try
{
if (sqlconn.State != ConnectionState.Closed) { sqlconn.Close(); }
}
catch (SqlException ex)
{
}
catch (SystemException sex)
{
}
}
#endregion
}
Online examination in ASP - sreejith.george - 10-04-2017
to get information about the topic Online Examination full report,ppt and related topic refer the page link bellow
http://seminarsprojects.net/Thread-online-examination-full-report
http://seminarsprojects.net/Thread-online-examination-project
http://seminarsprojects.net/Thread-eexam-online-examination-system
http://seminarsprojects.net/Thread-online-examination-full-report?pid=53124#pid53124
http://seminarsprojects.net/Thread-online-examination-full-report?page=2
http://seminarsprojects.net/Thread-eexam-online-examination-system?page=2
http://seminarsprojects.net/Thread-eexam-the-online-examination-system
http://seminarsprojects.net/Thread-online-examination-in-asp
http://seminarsprojects.net/Thread-online-examination
http://seminarsprojects.net/Thread-online-examination-system
|