Click here to Skip to main content
15,896,727 members
Please Sign up or sign in to vote.
1.00/5 (5 votes)
See more:
how can i design a multiple choice such all the questions and the answers to the questions in an xml file,using c#.please help me out.thanks in anticipation
Posted
Updated 28-Aug-12 6:55am
v2
Comments
[no name] 28-Aug-12 12:34pm    
You write your XML in XML no C# involved. Perhaps you can clarify what it is that you are trying to do so that it makes sense.
ridoy 28-Aug-12 12:50pm    
please clear your question..how you want to design your work that will need C#?
[no name] 28-Aug-12 12:51pm    
Where you kept your questions, in database or else?
Explain your question properly.
Your requirement is not proper

a) You do realize that tutors read these to see who can't do their assignments?
b) we don't do homework.
c) read this[^].
 
Share this answer
 
We can not give you the code here. You can still google to see if you can find similar example

But here is the pseudo code, go through it, you will find all the clues behind
1. Load the xml to XmlDocument. (namespace System.XML)
2. Parse the XML and get the answers in a IList or array string
3. Do a while loop on the collection object
4. Get each answer
5. Create a radio button dynamically and name it as radio_[counter] like radio_1, radio_2. This last number will be used to identify the answer when user checks a radio.
6. beside the radio, display the answer in a label.
7. There will be a button at the footer. Clicking the button will make a loop on radiobutton collection using forms.control
8. Get the checked radio button, parse the name of the radio button and get the last number.
9. Send the number to the database to get the answer. If matches, say "Right Answer", if no "Wrong Answer".

Try it yourself.
Best of luck.

cheers
 
Share this answer
 
Comments
Temidjoy 28-Aug-12 14:05pm    
am i going to include the correct anwser,wrongs options and the question as an element in the xml for each questions available in the xml
Sandip.Nascar 28-Aug-12 14:21pm    
Here is one sample xml which contains question, answers and right answer

<samplepaper>
<question id="1" description="What is the capital city of India?">
<answer id="1" description="Mumbai" flag="0">
<answer id="2" description="Kolkata" flag="0">
<answer id="3" description="New Delhi" flag="1">
<answer id="4" description="Chennai" flag="0">

<question id="1" description="XML can be parse using?">
<answer id="1" description="xmlparse" flag="0">
<answer id="2" description="XmlDoc" flag="0">
<answer id="3" description="XMLGrabber" flag="0">
<answer id="4" description="XMLDocument" flag="1">



Here flag represent the correct or incorrect answer.
Flag=1 is correct
Flag=0 is incorrect

Hope this helps.
cheers
Sandip.Nascar 28-Aug-12 14:21pm    
<pre>
<samplepaper>
<question id="1" description="What is the capital city of India?">
<answer id="1" description="Mumbai" flag="0">
<answer id="2" description="Kolkata" flag="0">
<answer id="3" description="New Delhi" flag="1">
<answer id="4" description="Chennai" flag="0">

<question id="1" description="XML can be parse using?">
<answer id="1" description="xmlparse" flag="0">
<answer id="2" description="XmlDoc" flag="0">
<answer id="3" description="XMLGrabber" flag="0">
<answer id="4" description="XMLDocument" flag="1">


</pre>
Sandip.Nascar 28-Aug-12 14:25pm    
sorry, somehow the xml is not allowed in comments. Som the blank lines... check in the solution section.
Sandip.Nascar 28-Aug-12 14:32pm    
I don't know who is the guy downvoted the solution. Can you please come here and give the reason. If you have better solution, post your solution instead don't make nuisance of your power of voting.
As per your comments on xml, I tried to post the xml in comment.
Somehow the xml is not considered as valid text (probably due to security).

So, here is the sample xml with question, answer and correct flag.

<samplepaper>
<question id="1" description="What is the capital city of India?">
<answer id="1" description="Mumbai" flag="0" />
<answer id="2" description="Kolkata" flag="0" />
<answer id="3" description="New Delhi" flag="1" />
<answer id="4" description="Chennai" flag="0" />
</question>
<question id="1" description="XML can be parse using?">
<answer id="1" description="xmlparse" flag="0" />
<answer id="2" description="XmlDoc" flag="0" />
<answer id="3" description="XMLGrabber" flag="0" />
<answer id="4" description="XMLDocument" flag="1" />
</question>
</samplepaper>


Flag=1 is correct answer
Flag=0 is incorrect answer

cheers
 
Share this answer
 
Comments
fjdiewornncalwe 28-Aug-12 15:45pm    
Please don't do people's homework for them. We want to help when they have issues, but providing something they can copy/paste as their own will teach them nothing.
Temidjoy 29-Aug-12 3:22am    
thanks 4 d idea

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900