can you please clarify my doubt?

Posted by Tejamanimala under ASP.NET on 5/13/2013 | Points: 10 | Views : 1600 | Status : [Member] | Replies : 9
HI,
I have one online exam paper page,in this when students select the answer,and submit the button,result will be calculated and stores hat results into database.My problem is,when i selecting the questions,when i missed to select one question and click's on the submit button i got a message as please select 3rd question like this,after selecting the 3rd question,i clicked on submit button,then result is storing into database.result in the scense question,correct option,selected option.so here result is stored into database multiple times,beacause,after submit,3rd question missing,selection of 3rd question ,after submiting answers i am getting the multiple times data(i mean if i have 30 questions,it stores 30 questions 2times,i'e,am getting 60 questions,ansers,seelcted options)
what should i do for this?

manimala


Responses

Posted by: Kmandapalli on: 5/13/2013 [Member] Silver | Points: 25

Up
0
Down
Hi,

Before inserting only, you have to check whether all the values are present or not.
If anyone is getting null value, then you need to throw an exception and stop the insertion process.

Mark as Answer if satisfied..........

Regards,
Shree M.

Kavya Shree Mandapalli

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tejamanimala on: 5/14/2013 [Member] Starter | Points: 25

Up
0
Down
hi shree,
can you please tell me hoe to write exceptions.and i have an idea that is,if i doesn't select the answer option,if i go to the next question immediately i want to display the message as please select the answer,if we do like this i don't get the multiple storing of data isn't it?


manimala

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kmandapalli on: 5/14/2013 [Member] Silver | Points: 25

Up
0
Down
Hi,

Ya you can also do like this infact but i guess it becomes little complex..
And i guess you are doing an online exam model application.
So,
if the user doesn't know the answer of any question he will leave that right.
We should not force him to attempt all the questions and you cannot find this model of exam anywhere in real time i hope...

Mark as Answer if satisfied.....

Regards,
Shree M.

Kavya Shree Mandapalli

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tejamanimala on: 5/14/2013 [Member] Starter | Points: 25

Up
0
Down
hi shree,
yes you are right,but,this for company online examination,so student must attempt the all answer so,can you please tell me how it is possible?and i don't about exceptions,and how to write the code and how to use it?

manimala

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tejamanimala on: 5/14/2013 [Member] Starter | Points: 25

Up
0
Down
hi shree, i wrote like this,but i don't know how to give Immediate message as "please select the answer",i mean i dont know the code for it,can you please tell me how it is possible?

hi,i have online exam paper,in that i have 30 questions with multiple options,each question have 4 multiple choice answers.My doubt is,if i didn't select any of one of the question,and i am going to the next question,then immediately,i want to display the error message as please select the 3rd question or 4th question,near question only,how it is possible to display the message?(i have 30 questions in a page)
my code is...........
if ((RadioButtonList1.SelectedValue) == dsCurrent.Tables[0].Rows[0]["CorrectOption"].ToString())
{
if (RadioButtonList1.SelectedValue == "")
{
sb.Append("1");
sb.Append(",");
}
i++;
SqlCommand cmd1 = new SqlCommand("insert into StudentExamFullResult (UserID,Question,SelectedOption,CorrectOption) values('"+Label32.Text+"','" + dsCurrent.Tables[0].Rows[0]["Question"].ToString() + "','" + RadioButtonList1.SelectedValue + "','" + dsCurrent.Tables[0].Rows[0]["CorrectOption"].ToString() + "')", con);
cmd1.ExecuteNonQuery();
}

else
{
f (RadioButtonList1.SelectedValue == "")
{
sb.Append("1");
sb.Append(",");
}
SqlCommand cmd1 = new SqlCommand("insert into StudentExamFullResult (UserID,Question,SelectedOption,CorrectOption) values('" +Label32.Text + "','" + dsCurrent.Tables[0].Rows[0]["Question"].ToString() + "','" + RadioButtonList1.SelectedValue + "','" + dsCurrent.Tables[0].Rows[0]["CorrectOption"].ToString() + "')", con);
cmd1.ExecuteNonQuery();
}

if ((RadioButtonList2.SelectedValue) == dsCurrent.Tables[0].Rows[1]["CorrectOption"].ToString())
{
if (RadioButtonList2.SelectedValue == "")
{
sb.Append("2");
sb.Append(",");
}
i++;
SqlCommand cmd2 = new SqlCommand("insert into StudentExamFullResult (UserID,Question,SelectedOption,CorrectOption) values('" + Label32.Text + "','" + dsCurrent.Tables[0].Rows[1]["Question"].ToString() + "','" + RadioButtonList2.SelectedValue + "','" + dsCurrent.Tables[0].Rows[1]["CorrectOption"].ToString() + "')", con);
cmd2.ExecuteNonQuery();
}
else
{
if (RadioButtonList2.SelectedValue == "")
{
sb.Append("2");
sb.Append(",");
}
SqlCommand cmd2 = new SqlCommand("insert into StudentExamFullResult (UserID,Question,SelectedOption,CorrectOption) values('" + Label32.Text + "','" + dsCurrent.Tables[0].Rows[1]["Question"].ToString() + "','" + RadioButtonList2.SelectedValue + "','" + dsCurrent.Tables[0].Rows[1]["CorrectOption"].ToString() + "')", con);
cmd2.ExecuteNonQuery();
}

manimala



manimala

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tejamanimala on: 5/14/2013 [Member] Starter | Points: 25

Up
0
Down

and for not selecting all questions i wrote like
string bulider = sb.ToString();
if (bulider != "")
{
ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Please select " + bulider + " question(s)')", true);
}
else
{
ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Congratulations " + Label32.Text + " answers successfully submited ')", true);
string x = System.Web.HttpContext.Current.Session["Domain"].ToString();
SqlCommand cmd1 = new SqlCommand("insert into Resultsforstudents (UserID,UserName,Domain,Date,Marks) values('" + Label32.Text + "','" + Label33.Text + "','" + x + "','" + DateTime.Now.ToString() + "','" + i + "')", con);
cmd1.ExecuteNonQuery();
Response.Redirect("LogOut.aspx");
}



manimala

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kmandapalli on: 5/14/2013 [Member] Silver | Points: 25

Up
0
Down
Hi,

I have already done a sample application on this, I am attaching the zip file.
You download it and go through it....
If you have any doubts you can query me...

LoginPage.aspx:
UserName: shaanu
I did not give any Password so leave it as empty as click on SignIn.

Then you will get two links like
Add Question
View Questions

When you click on Add Question, you can add a question.
Question Type: Means your question has only a single answer or multiple answers.

When you click on view question, you can view the questions only of that particular user.

If you want to view all the questions of all the users, then give the UserName as Admin.

Mark as answer if satisfied...........

Regards,
Shree M.
 Download source file

Kavya Shree Mandapalli

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raja_89 on: 5/15/2013 [Member] Starter | Points: 25

Up
0
Down
Hai
You can check with distinct property

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 5/21/2013 [Member] Starter | Points: 25

Up
0
Down
Use
if(!IsPostBack)
{
// method name
}



ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response