Trouble with a quiz
Bluebolts
05 Jun 2014, 05:52I seem to be having trouble creating a quiz, when the wrong answer is selected, the quiz is failed, and the player has to start over. However the link to the correct answer seems to be dead and when I click it, the message is not displayed and they next question does not come. I am godawful at this and i'm a bit over my head but i need to finish a project and would be ecstatic if i could get some help with this.
candidates = NewStringList()
list add (candidates, "Never. It's better to perish than survive by war.")
list add (candidates, "Very rarely, but sometimes violent resistance is better than cowardice or no resistance at all.")
list add (candidates, "Sometimes. Violent resistance is an acceptable option for freedom fighters and the oppressed who have not succeeded otherwise.")
list add (candidates, "Violence and war can be redemptive and can lead to peace.")
ShowMenu (" Besides ending war, what do you consider the most important cause of a peacemaker?", candidates, true) {
if (result = "Never. It's better to perish than survive by war.") {
msg ("I can agree.")
ShowMenu ("The concept of nonviolence is?", , true) {
candidates = NewStringList()
list add (candidates, "Cowardice")
list add (candidates, "Bravery")
list add (candidates, "Impossible")
list add (candidates, "Violence")
ShowMenu ("The concept of nonviolence is:", candidates, false) {
if (result = "Bravery") {
msg ("This rings true.")
ShowMenu ("When you have a problem with an acquaintance like a neighbor or coworker, what do you do?", , true) {
candidates = NewStringList()
list add (candidates, "Talk to others about it but not the person who is bothering me")
list add (candidates, "Keep it to myself because I don't want to cause a conflict")
list add (candidates, "Keep it to myself until it gets unbearable and then confront the person angrily")
list add (candidates, "Speak to the person calmly and tell him/her what is bothering me")
ShowMenu ("When you have a problem with an acquaintance like a neighbor or coworker, what do you do?", candidates, false) {
if (result = "Speak to the person calmly and tell him/her what is bothering me") {
msg ("An appropriate answer.")
ShowMenu (" Is it ever OK to break the law or sacrifice moral principles in the name of peace?", , true) {
candidates = NewStringList()
list add (candidates, "It's never acceptable")
list add (candidates, "It's an acceptable position but I wouldn't do it")
list add (candidates, "It's acceptable only in dire situations like life or death")
list add (candidates, "It's necessary to do so to achieve peace")
ShowMenu ("Is it ever OK to break the law or sacrifice moral principles in the name of peace?", candidates, false) {
if (result = "It's necessary to do so to achieve peace") {
msg ("You sir, have proven to me and my peers, that with the help of your leadership and your peoples community, we can all function as one, equal, loving society.")
ClearScreen
msg ("<b>Congratulations, I hope you have enjoyed this short game created by Tristan and Clint. We have worked to ensure that the game is able to help you develop a view on non-violence in a painless way, thank you for playing.</b>")
finish
}
else {
msg ("Get out.")
}
}
}
}
else {
msg ("Your not a freedom fighter, Your not even a man.")
}
}
}
}
else {
msg ("A vile warmonger is what you are.")
}
}
}
}
else {
msg ("You are no peacemaker.")
}
}

jaynabonne
05 Jun 2014, 06:50There are two problems, one in Quest and one yours.
The Quest problem is what's keeping you from clicking on some items. (Note that you can still type in the number.) Not to get too deep, but the Quest generates the command link, it doesn't like embedded single quotes/apostrophes (like what you see in "It's"). This causes a Javascript syntax error when you click on the link.
I tried various ways to escape the quote, but nothing worked. So... two options:
1) Change things like "It's" to "It is" (and "wouldn't" to "would not", etc).
2) Switch to using a dictionary for ShowMenu. This let's you use key/value pairs for the candidates. You can keep the key strings clean and display whatever you like in the values. For example, instead of:
you would do this:
Now the other problem: you're doubling up your ShowMenu's in a way I don't understand. Something like this is useless and won't run properly, since you're not passing a second parameter:
You don't need those extra lines in there. After you get a correct answer, just build the new candidate responses and invoke the new menu. There's no need to do a showmenu with no candidates before you do the real code you need of building the candidates and calling the menu the right way.
The Quest problem is what's keeping you from clicking on some items. (Note that you can still type in the number.) Not to get too deep, but the Quest generates the command link, it doesn't like embedded single quotes/apostrophes (like what you see in "It's"). This causes a Javascript syntax error when you click on the link.
I tried various ways to escape the quote, but nothing worked. So... two options:
1) Change things like "It's" to "It is" (and "wouldn't" to "would not", etc).
2) Switch to using a dictionary for ShowMenu. This let's you use key/value pairs for the candidates. You can keep the key strings clean and display whatever you like in the values. For example, instead of:
candidates = NewStringList()
list add (candidates, "Never. It's better to perish than survive by war.")
list add (candidates, "Very rarely, but sometimes violent resistance is better than cowardice or no resistance at all.")
list add (candidates, "Sometimes. Violent resistance is an acceptable option for freedom fighters and the oppressed who have not succeeded otherwise.")
list add (candidates, "Violence and war can be redemptive and can lead to peace.")
ShowMenu (" Besides ending war, what do you consider the most important cause of a peacemaker?", candidates, true) {
if (result = "Never. It's better to perish than survive by war.") {
you would do this:
candidates = NewStringDictionary()
dictionary add (candidates, "choice1", "Never. It's better to perish than survive by war.")
dictionary add (candidates, "choice2", "Very rarely, but sometimes violent resistance is better than cowardice or no resistance at all.")
dictionary add (candidates, "choice3", "Sometimes. Violent resistance is an acceptable option for freedom fighters and the oppressed who have not succeeded otherwise.")
dictionary add (candidates, "choice4", "Violence and war can be redemptive and can lead to peace.")
ShowMenu (" Besides ending war, what do you consider the most important cause of a peacemaker?", candidates, true) {
if (result = "choice1") {
Now the other problem: you're doubling up your ShowMenu's in a way I don't understand. Something like this is useless and won't run properly, since you're not passing a second parameter:
ShowMenu ("The concept of nonviolence is?", , true) {
You don't need those extra lines in there. After you get a correct answer, just build the new candidate responses and invoke the new menu. There's no need to do a showmenu with no candidates before you do the real code you need of building the candidates and calling the menu the right way.
Bluebolts
06 Jun 2014, 02:39\
Wow man that was a speedy response, works like a charm, thanks for the help I truly appreciate that you took the time to do this. -Clint
jaynabonne wrote:
1) Change things like "It's" to "It is" (and "wouldn't" to "would not", etc).
2) Switch to using a dictionary for ShowMenu. This let's you use key/value pairs for the candidates. You can keep the key strings clean and display whatever you like in the values. .
Wow man that was a speedy response, works like a charm, thanks for the help I truly appreciate that you took the time to do this. -Clint