XML - Quiz

Get help using Construct 2

Post » Wed Feb 11, 2015 1:47 pm

This almost works

BUT simply cant figure out how to trigger the next Q in xml

screendump.jpg



Here is the capx
XML-Quiz.zip


Cheers
You do not have the required permissions to view the files attached to this post.
B
33
S
17
G
11
Posts: 350
Reputation: 8,695

Post » Thu Feb 12, 2015 6:07 am

Hi, please try it now. note that I added the function object to the project


Also it might be better to restructure your xml

<correct>paris</correct>
<answer="lyon">Lyon</answer>
<answer="marseille">Marseille</answer>
<answer="paris">Paris</answer>

Then it is more reliable to compare the string rather than indexes as all the nodes don't have unique identifiers.

Then you can check answer with:
if (XML.StringValue("//question[@no='" & questionno & "']//correct/text()") == "paris")

And try to use both ' and "... i don't think this is nested correctly: "/questions/question[@no="""&questionno&"""]"
You do not have the required permissions to view the files attached to this post.
B
32
S
6
G
2
Posts: 317
Reputation: 2,801

Post » Thu Feb 12, 2015 9:40 am

JUST - GREAT ... thanks

I see that your function easy gives me the possiblity to add
more answers :-)


I would like to optimize the xml as you suggest, and Ive done
the xml as you show - but cant figure out when to use the

Then you can check answer with:
if (XML.StringValue("//question[@no='" & questionno & "']//correct/text()") == "paris")


hope you get time to give it a look
You do not have the required permissions to view the files attached to this post.
B
33
S
17
G
11
Posts: 350
Reputation: 8,695

Post » Thu Feb 12, 2015 11:13 am

I haven't looked at the capx yet.

<answer="paris">Paris</answer>
<correct>paris</correct>

the "correct" value = paris
you set one answer button's text to paris

So when the user clicks on a button, you read the button's text value and compare it to the "correct" tag's contents so if they are both == paris, then it is true, else false

hope that makes sense... its getting late :)
B
32
S
6
G
2
Posts: 317
Reputation: 2,801

Post » Thu Feb 12, 2015 11:35 am

OKAY .. See our point, just cant get it work

Ohhh --- another timezone :-)
B
33
S
17
G
11
Posts: 350
Reputation: 8,695


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 11 guests