Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with turing quiz please
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic
Author Message
user23




PostPosted: Sun Dec 12, 2010 2:14 pm   Post subject: Help with turing quiz please

How can I show the question number and total score of someone doing my turing quiz? At the end of each question I clear the screen, but I'd want the bottom of the slide (or top...somewhere) to have the question number and number of questions right.

For example,
Question: 4 of 10
Total Correct: 2/4

And that should update with each question that it goes through.

Anyone know how I could do that?

Thanks

EDIT: Also, how can I use an image as a background? When I add text over an image it just clears the part of the image where the text is, and only half is shown. I want the image to cover the whole background, with the text on top of it. Another problem I have is that my images are too large and go outside of the run window, is the only way to solve this to resize the image (how would I know to what size?)
 
Sponsor
Sponsor
Sponsor
sponsor
ProgrammingFun




PostPosted: Sun Dec 12, 2010 3:04 pm   Post subject: RE:Help with turing quiz please

I am not sure about the background image (it always does that for images but can be fixed for a solid colour)...
You can show the total questions and the total correct by using variables for each which increase according to the situation (use the case or if-else structure)...if these are contained in a loop, your job is even easier...
 
user23




PostPosted: Sun Dec 12, 2010 3:39 pm   Post subject: Re: RE:Help with turing quiz please

ProgrammingFun @ Sun Dec 12, 2010 3:04 pm wrote:
I am not sure about the background image (it always does that for images but can be fixed for a solid colour)...
You can show the total questions and the total correct by using variables for each which increase according to the situation (use the case or if-else structure)...if these are contained in a loop, your job is even easier...


Hmm, im not sure how I would do that actually.
Right now my questions are set up to be answered by letter, and then if the answer is a, its like
IF response1 = a then
put your right
else
put your wrong

Obviously its formatted properly though and works in turing lol. At the moment, each answer has a variable, (from variable1-variable10)

But i don't see how I would be able to put that into a setup to show the information I'd like.
 
TokenHerbz




PostPosted: Sun Dec 12, 2010 3:51 pm   Post subject: Re: Help with turing quiz please

Turing:

proc draw_score
    put "Question X / X"
    put "Correct: X / X @ X%"
    put ""
end draw_score

draw_score
put "Qeustion 1: BOO YA"
Input.Pause %as get answer
cls
draw_score
put "Question 2: LETS LOOP THE QUESTIONS THO"
Input.Pause
cls
draw_score
put "Question 3: MAKE THIS EFFICIANT!"
Input.Pause
cls

put "gives you an idea, try to do this using just 1 cls / 1 get / 1 draw_score."


Extra TIP, you don't need 10 variables!
 
user23




PostPosted: Sun Dec 12, 2010 4:03 pm   Post subject: Re: Help with turing quiz please

Quote:
var answer : string
put "Question?"
put "a"
put "b"
put "c"
put "d"
get answer
if answer = "c" then
put "You are correct."
elsif answer = "C" then
put "You are correct."
else
put "You are wrong, the correct answer is c."
end if
delay(1500)
cls


Hmm, right now my questions look like that, repeated 10x. Are you saying my questions shouldn't some how be implemented into the above? I'm new to turing, so I don't really know much about it.

I'd prefer to keep the above format for my questions though, as I'd like to keep this simple right now.

Thanks
 
TokenHerbz




PostPosted: Sun Dec 12, 2010 4:18 pm   Post subject: RE:Help with turing quiz please

Well being me, i would do this a way where you probly wouldn't get it.

but take a look into arrays. even tho its not as usefull as say something more complex its still going to cut your code down and make your block so much better... Heres another TIP...

You could assign an array of questions easily,

what does this line output?
code:
put "question 1: How does this happen? \n omg A? \n omgB? \nZOMGS \n CRAZY!"
 
TokenHerbz




PostPosted: Sun Dec 12, 2010 4:25 pm   Post subject: RE:Help with turing quiz please

using an array is simple to, just in the loop you have it call each question, get the answer, match answers, display results, and whallah! bingo!
 
user23




PostPosted: Sun Dec 12, 2010 4:27 pm   Post subject: RE:Help with turing quiz please

Thanks,
Another question though, could I make images fit the the space required below the text atleast, rather than resizing it?
And theres no way at all to have an image behind text?

Thanks

And is counting results at all possible with the way I had my questions setup as well? I think Im supposed to keep it in that format.
 
Sponsor
Sponsor
Sponsor
sponsor
TokenHerbz




PostPosted: Sun Dec 12, 2010 5:27 pm   Post subject: RE:Help with turing quiz please

yeah you can count even with your format, like if answer is right count goes up 1.

as for pictures you can have images as a background i don't like it tho sometimes its really really sluggish. You can write ontop of that to without having that white space there, however... you can do that with "put".

so that will be a little project in itself but check it out in the turing F9 or maybe its F10 key.
 
TerranceN




PostPosted: Sun Dec 12, 2010 6:02 pm   Post subject: RE:Help with turing quiz please

In order to keep score, you need to create a score variable at the top of your program. Every time the user gets a correct answer, you increment the score by 1, using: score := score + 1, or the shorthand equivalent: score += 1. Likewise, you need to create a questionNumber variable, and increment it when you move to the next question. Then outputting score is as easy as
Turing:

put "Question: " + questionNumber + "/10"
put "Total Correct: " + score + "/" + questionNumber


You can use Draw.Text to draw text without messing up the background, but getting input using get will still mess up the background. As far as I know, there is no way of doing this without getting the input using Input.KeyDown or getch and making your own method of getting input.

You should take this chance to learn functions. Functions would allow you to write the block of code that asks the question and processes the response, once, then give it different questions. This would be much clearer then copying and pasting that block of code 10 times with different questions, and if you want to make a change, you would only have to change one spot compared to 10.
 
user23




PostPosted: Wed Dec 15, 2010 9:36 pm   Post subject: Re: Help with turing quiz please

So I have everything done now, including score and everything, and I set it up within a loop to allow the user to replay when they're done, by pressing yes or no. If they press yes, the quiz restarts but the score count from before continues on. How can I reset the value of my score variable to 0 when the user plays again?
 
DemonWasp




PostPosted: Wed Dec 15, 2010 10:37 pm   Post subject: RE:Help with turing quiz please

At the top of your "replay" loop, you should initialize (not declare!) all your variables again (such as score).
 
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: