Computer Science Canada Help with turing quiz please |
Author: | user23 [ 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?) |
Author: | ProgrammingFun [ 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... |
Author: | user23 [ 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. |
Author: | TokenHerbz [ Sun Dec 12, 2010 3:51 pm ] | ||
Post subject: | Re: Help with turing quiz please | ||
Extra TIP, you don't need 10 variables! |
Author: | user23 [ 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 |
Author: | TokenHerbz [ 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?
|
Author: | TokenHerbz [ 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! |
Author: | user23 [ 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. |
Author: | TokenHerbz [ 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. |
Author: | TerranceN [ 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
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 <a href="http://compsci.ca/v3/viewtopic.php?t=14665">functions</a>. 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. |
Author: | user23 [ 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? |
Author: | DemonWasp [ 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). |