Hi
Could I have vbdotnet's collective thoughts please?
I am about to write a sub in my gameshow program (multiple choice questions A-D, eight contestants). I currently find myself paralysed by the number of ways of doing a simple task.
The sub will take some well-formed xml contestant response data, identify a particular node (a group of responses), put its child elements (responses) into a structure of some kind, sort the responses according to who gave the response most quickly, filter the responses for a duff choice (E and above) and then perform a calculation (the % who got the question correct).
What is the best combination of elegance and me being able to work out the details?
The xml's structure, in pseudo-code, is this:
-quiz_session
--questionsgroup
----question
-----responsesgroup
-------response
-------response
-------response
-------(more responses)
----question
-----responsesgroup
-------response
-------response
-------response
Below are some sample data consisting of two questions being answered by eight contestants.
Thanks for any contributions!
<session id="56805FDEA6">
<questionsgroup count="2">
<question id="1">
<topic id="Countries">
</topic>
<text>What is the capital of France</text>
<date>15/05/2010</date>
<time>17:48:56</time>
<answers count="4">
<answer><text>Paris</text>
</answer>
<answer><text>Berlin</text>
</answer>
<answer><text>Cassablanca</text>
</answer>
<answer><text>Cardiff</text>
</answer>
</answers>
<responsesgroup starttime="634095425252343750" endtime="634095425361093750">
<response id="1" time="634095425289687500">2</response>
<response id="2" time="634095425289687501">2</response>
<response id="3" time="634095425289687502">2</response>
<response id="4" time="634095425289687503">2</response>
<response id="5" time="634095425289687504">2</response>
<response id="6" time="634095425289687505">2</response>
<response id="7" time="634095425289687506">9</response>
<response id="8" time="634095425289687507">3</response>
</responsesgroup>
</question>
<question id="2">
<topic id="Sayings">
</topic>
<text>What might you find in a poke?</text>
<date>15/05/2010</date>
<time>18:28:53</time>
<answers count="4">
<answer><text>Pig</text>
</answer>
<answer><text>Calf</text>
</answer>
<answer><text>Horse</text>
</answer>
<answer><text>Donkey</text>
</answer>
</answers>
<responsesgroup starttime="634095425414687500" endtime="634095449334843750">
<response id="1" time="634095425444531250">1</response>
<response id="2" time="634095425444531251">1</response>
<response id="3" time="634095425444687502">1</response>
<response id="4" time="634095425444687503">1</response>
<response id="5" time="634095425444687504">1</response>
<response id="6" time="634095425444687505">1</response>
<response id="7" time="634095425444687506">9</response>
<response id="8" time="634095425444687507">4</response>
</responsesgroup>
</question>
</questionsgroup>
</session>
Could I have vbdotnet's collective thoughts please?
I am about to write a sub in my gameshow program (multiple choice questions A-D, eight contestants). I currently find myself paralysed by the number of ways of doing a simple task.
The sub will take some well-formed xml contestant response data, identify a particular node (a group of responses), put its child elements (responses) into a structure of some kind, sort the responses according to who gave the response most quickly, filter the responses for a duff choice (E and above) and then perform a calculation (the % who got the question correct).
What is the best combination of elegance and me being able to work out the details?
- Should I parse the xml data in its natural format with the xPath class? I am new to this and there is a learning curve for me.
- Ditto with the XmlDocument class
- (With thanks to Matt, LINQ
- I am more familiar with databases. Should I create a disconnected recordset? If so, must I loop through each response or is there a more elegant way to populate the recordset?
- Should I use an array?
- Or a collection?
The xml's structure, in pseudo-code, is this:
-quiz_session
--questionsgroup
----question
-----responsesgroup
-------response
-------response
-------response
-------(more responses)
----question
-----responsesgroup
-------response
-------response
-------response
Below are some sample data consisting of two questions being answered by eight contestants.
Thanks for any contributions!
<session id="56805FDEA6">
<questionsgroup count="2">
<question id="1">
<topic id="Countries">
</topic>
<text>What is the capital of France</text>
<date>15/05/2010</date>
<time>17:48:56</time>
<answers count="4">
<answer><text>Paris</text>
</answer>
<answer><text>Berlin</text>
</answer>
<answer><text>Cassablanca</text>
</answer>
<answer><text>Cardiff</text>
</answer>
</answers>
<responsesgroup starttime="634095425252343750" endtime="634095425361093750">
<response id="1" time="634095425289687500">2</response>
<response id="2" time="634095425289687501">2</response>
<response id="3" time="634095425289687502">2</response>
<response id="4" time="634095425289687503">2</response>
<response id="5" time="634095425289687504">2</response>
<response id="6" time="634095425289687505">2</response>
<response id="7" time="634095425289687506">9</response>
<response id="8" time="634095425289687507">3</response>
</responsesgroup>
</question>
<question id="2">
<topic id="Sayings">
</topic>
<text>What might you find in a poke?</text>
<date>15/05/2010</date>
<time>18:28:53</time>
<answers count="4">
<answer><text>Pig</text>
</answer>
<answer><text>Calf</text>
</answer>
<answer><text>Horse</text>
</answer>
<answer><text>Donkey</text>
</answer>
</answers>
<responsesgroup starttime="634095425414687500" endtime="634095449334843750">
<response id="1" time="634095425444531250">1</response>
<response id="2" time="634095425444531251">1</response>
<response id="3" time="634095425444687502">1</response>
<response id="4" time="634095425444687503">1</response>
<response id="5" time="634095425444687504">1</response>
<response id="6" time="634095425444687505">1</response>
<response id="7" time="634095425444687506">9</response>
<response id="8" time="634095425444687507">4</response>
</responsesgroup>
</question>
</questionsgroup>
</session>
Last edited: