Computer Science Canada

Making multiple choise questions

Author:  animeanime [ Mon May 25, 2009 8:24 am ]
Post subject:  Making multiple choise questions

What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>


What is the problem you are having?
<Answer Here>


Describe what you have tried to solve this problem
<Answer Here>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


<Add your code here>



Please specify what version of Turing you are using
<Answer Here>

Author:  Tallguy [ Mon May 25, 2009 8:25 am ]
Post subject:  RE:Making multiple choise questions

we still need to know what exactly you need help with . . .

Author:  animeanime [ Mon May 25, 2009 8:26 am ]
Post subject:  Re: Making multiple choise questions

Cant edit the post. So here....

What is it you are trying to achieve?
Making a multiple choise exam in turing


What is the problem you are having?
Cannot start the program and cant make it work


Describe what you have tried to solve this problem
I have tried using different ways of using " if " and " elsif " and it dident work


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing:

% The multiple choise exam
% User choose one of the 4 possiable answers for each question

var answer: char
var point: real
var a, b, c, d: char
point := 0


put "This is a science exam consisting of 20 questions. Please select the most correct answer for each question."
put "Question Number #1"
put "What is the last planet in the solor system"
put "a) Venus"
put "b) Pluto"
put "c) Mars"
put "d) Jupiter"
get answer

if answer= a
then
put "WRONG!"
if answer= b
then
put "WRONG!"
if answer= c
then
put "WRONG!"
else
put "CORRECT!"
end if
end if
end if



Please specify what version of Turing you are using
4.0.3

Author:  Tallguy [ Mon May 25, 2009 8:36 am ]
Post subject:  Re: Making multiple choise questions

Turing:



if answer= "a"
 



forgot the " " for when the user chooses an answer

Author:  animeanime [ Mon May 25, 2009 8:42 am ]
Post subject:  Re: Making multiple choise questions

Ok, what if I want it to be something like this?

Turing:

% The multiple choise exam
% User choose one of the 4 possiable answers for each question

var answer: char
var point: real
var a, b, c, d: char
point := 0


put "This is a science exam consisting of 20 questions. Please select the most correct answer for each question."
put "Question Number #1"
put "What is the last planet in the solor system"
put "a) Venus"
put "b) Pluto"
put "c) Mars"
put "d) Jupiter"
get answer

if answer= 'a', 'c', 'd'
then point=point+0
else
then point=point+1
end if


So it counts how much right questions I did, and how much incorrect questions I did. How can I do that?

Author:  octopi [ Mon May 25, 2009 8:45 am ]
Post subject:  Re: Making multiple choise questions

Although this is incorrect, you can replace it with something that is correct...
code:

if answer= 'a', 'c', 'd'
then point=point+0
else
then point=point+1
end if


Could be changed to
code:

if answer= "b"
then point=point+1
else
then point=point+0
end if


But please keep in mind that point=point+0, is the same as point=point, which is the same as not even having that line there to begin with.
If you have 5 apples, and you add 0 apples, you still have 5 apples.

Author:  animeanime [ Mon May 25, 2009 8:50 am ]
Post subject:  Re: Making multiple choise questions

I put it, and I get a syntax error at " then "

Turing:
var answer: char
var point: real
var a, b, c, d: char
point := 0


put "This is a science exam consisting of 20 questions. Please select the most correct answer for each question."
put "Question Number #1"
put "What is the last planet in the solor system"
put "a) Venus"
put "b) Pluto"
put "c) Mars"
put "d) Jupiter"
get answer

if answer= "b"
then point:=point+1
else
then point=point+0
end if

Author:  animeanime [ Mon May 25, 2009 9:08 am ]
Post subject:  Re: Making multiple choise questions

I got it to start. But now, its not WORKING properly, why?

Turing:
% The multiple choise exam
% User choose one of the 4 possiable answers for each question

var answer: char
var point: real
var a, b, c, d: char
point := 0


put "This is a science exam consisting of 20 questions. Please select the most correct answer for each question."
put "Question Number #1"
put "What is the last planet in the solor system"
put "a) Venus"
put "b) Pluto"
put "c) Mars"
put "d) Jupiter"
get answer
if answer= "b"
then point:=point+1
else
point:=point+0
end if

put "Question Number #2"
put "What is photosynthesis?"
put "a) When plants absorb water from the sun"
put "b) When plants absorb water from their roots"
put "c) When the sun absorbs energy from the plant"
put "d) When plants absorbs energy from the sun"
get answer
if answer= "d"
then point:=point+1
else
point:=point+0
end if

put "Question Number #3"
put "What are the 3 primary colors?"
put "a) Red, Yellow, Green"
put "b) Yellow, Red, Blue"
put "c) Yellow, Blue, Green"
put "d) Green, Yellow, Purple"
get answer
if answer= "b"
then point:=point+1
else
point:=point+0
end if

put "Question Number #4"
put "What is the biggest country in the world?"
put "a) Russia"
put "b) USA"
put "c) Canada"
put "d) China"
get answer
if answer= "a"
then point:=point+1
else
point:=point+0
end if

put "Question Number #5"
put "What is a mouse on a computer?"
put "a) Input Device"
put "b) Output Device"
put "c) Internet Device"
put "d) Moving Device"
get answer
if answer= "a"
then point:=point+1
else
point:=point+0
end if

put point

Author:  octopi [ Mon May 25, 2009 9:15 am ]
Post subject:  Re: Making multiple choise questions

What isn't working with it?, you need to be descriptive with your questions.

Perhaps it isn't working, since Pluto isn't a planet let alone the the largest in the solar system.

Author:  michaelp [ Mon May 25, 2009 2:26 pm ]
Post subject:  Re: Making multiple choise questions

Turing:
get answer
if answer= "b"
then point:=point+1
else
point:=point+0
end if

That 'point := point + 0' is unnecessary.
Also, instead of "answer = "b"" try doing it with single quotes. Single quotes are for single characters, double quotes are for strings, and the answer variable is a character.
So, your new code would be:
Turing:
get answer
if answer= 'b' then
  point:=point+1
end if

You should put then on the same line as the if, it looks better. (IMO anyways)

Author:  corriep [ Mon May 25, 2009 2:42 pm ]
Post subject:  Re: Making multiple choise questions

Ok 3 things:
#1 The variables a, b, c, d : char are un-needed and you should get rid of them
#2 answer should be a string not a char
#3
octopi wrote:
Perhaps it isn't working, since Pluto isn't a planet
Evil or Very Mad Don't you dare say that!

Author:  Kharybdis [ Tue May 26, 2009 7:51 am ]
Post subject:  RE:Making multiple choise questions

Pluto owns. The scientists who spewed that scientific mumbo-jumbo saying its not a planet ultimately fail.

Anyways, animeanime, please read the tutorials on if and elsif statements and strings.

Link: http://compsci.ca/v3/viewtopic.php?t=8808

Author:  BigBear [ Tue May 26, 2009 9:32 am ]
Post subject:  RE:Making multiple choise questions

When pluto was de planeted my science teacher read an article about how a group in the 80's thought the mass of pluto was too great considering the mass formations of ice

I forget the details but it just shows how long it takes to get the technology and prove something

Author:  animeanime [ Tue May 26, 2009 9:33 am ]
Post subject:  Re: Making multiple choise questions

Thanks guys. Its working so far.

Author:  animeanime [ Tue May 26, 2009 10:06 am ]
Post subject:  Re: Making multiple choise questions

Is it possible to make it like a real test? So for example after you did questions 1 and 2, and as your doing number 3. You want to change the answer for number 2. So you change it and then go back to number 3 and continue the test...... Is that possible?

Author:  Siavash [ Tue May 26, 2009 12:07 pm ]
Post subject:  RE:Making multiple choise questions

I think your program will be much better if you use turing GUI.CreatePictureRadioButton
look it up in http://compsci.ca/holtsoft/doc/ to learn how to use it

Author:  animeanime [ Wed May 27, 2009 8:14 am ]
Post subject:  RE:Making multiple choise questions

The code itself that is there, if I put it in turing, I get errors. And its not working for me


: