The correct answer is

P

Preschool Mike

I'm trying to come up with a way for my printable page to display the correct
answers to the questions on my test that are answered wrong. Each question
has two wrong answer choices and on right answer choice button. Here is a
sample of my code. Currently all I can come up with is for it to just say
that "This is not the correct answer". I'd like for it to say what the
answer should have been. I did come up with a way by naming each slide the
correct answer but that won't work if more than question has the same answer
(e.g., question 1 & 2 the answer is 4 ). Is there a way I can tie it to the
..text or .name of the right answer button using the format I’m using below?
And also does anyone know why I (3 times out of 5) get error messages
(Service Temporarily Unavailable or An error occurred while sending your
post) when using this service?

Dim AnswerIs() As String

Sub Initialize()
Dim i As Long
MoveObjectsHome
TestName =
ActivePresentation.Slides(1).Shapes("TestNameBox").TextFrame.TextRange.Text
numCorrect = 0
numIncorrect = 0
printableSlideNum = ActivePresentation.Slides.Count + 1
numQuestions = ActivePresentation.Slides.Count - 2
ReDim qAnswered(numQuestions)
ReDim answer(numQuestions)
ReDim AnswerIs(numQuestions)
For i = 1 To numQuestions
qAnswered(i) = False
Next i

End Sub

Sub WrongAnswerButton(answerButton As Shape)
Dim thisQuestionNum As Long

thisQuestionNum = _
ActivePresentation.SlideShowWindow.View.Slide.SlideIndex - 1
answer(thisQuestionNum) = answerButton.TextFrame.TextRange.Text
WrongAnswer
End Sub

Sub WrongAnswer()
Dim thisQuestionNum As Long

thisQuestionNum = _
ActivePresentation.SlideShowWindow.View.Slide.SlideIndex - 1
If qAnswered(thisQuestionNum) = False Then
numIncorrect = numIncorrect + 1
End If
qAnswered(thisQuestionNum) = True
AnswerIs(thisQuestionNum) = "- This is not the right answer." 'instead
of saying this I want it to say what the correct answer is on my printable
slide.
ActivePresentation.SlideShowWindow.View.Next
End Sub

Thanks,
 
D

David Marcovitz

Mike,

The code you are using is not set up to do what you want, but we can work
with it. You are using code from Chapter 8 of my book, which really
simplifies things from the code in Chapter 7. However, you might find it
easier to use the code in Chapter 7. In that code, you have a procedure for
every possible answer so that you can assign the answer variable the answer
that was chosen. It would be trivial to adjust the feedback in those
procedures to give the right answer.

However, to do it with this code would require something harder. I'm
picturing something like this. You scroll through each of the shapes on the
current slide and check which one is assigned to the RightAnswerButton
shape, and use the text from that. Here is some air code to get you started
(totally untested, and I've never tried anything like this):

For Each oShp in ActivePresenation.SlideShowWindow.View.Slide
If oShp.ActionSettings(ppMouseClick).Action = ppActionRunMacro Then
If oShp.ActionSettings(ppMouseClick).Run = "RightAnswerButton" Then
MsgBox "I'm sorry. The right answer is " & _
oShp.TextFrame.TextRanage.Text
End If
End If
Next oShp

This should pop up a MsgBox for every shape on the current slide that is
assigned RightAnswerButton as the macro to run (assuming you will only have
one such shape on the slide). You could have a variable to keep track of the
right answer for later use instead of the MsgBox. I hope this gives the
basic idea.

--David


I'm trying to come up with a way for my printable page to display the correct
answers to the questions on my test that are answered wrong. Each question
has two wrong answer choices and on right answer choice button. Here is a
sample of my code. Currently all I can come up with is for it to just say
that "This is not the correct answer". I'd like for it to say what the
answer should have been. I did come up with a way by naming each slide the
correct answer but that won't work if more than question has the same answer
(e.g., question 1 & 2 the answer is 4 ). Is there a way I can tie it to the
.text or .name of the right answer button using the format I¹m using below?

And also does anyone know why I (3 times out of 5) get error messages
(Service Temporarily Unavailable or An error occurred while sending your
post) when using this service?

Dim AnswerIs() As String

Sub Initialize()
Dim i As Long
MoveObjectsHome
TestName =
ActivePresentation.Slides(1).Shapes("TestNameBox").TextFrame.TextRange.Text
numCorrect = 0
numIncorrect = 0
printableSlideNum = ActivePresentation.Slides.Count + 1
numQuestions = ActivePresentation.Slides.Count - 2
ReDim qAnswered(numQuestions)
ReDim answer(numQuestions)
ReDim AnswerIs(numQuestions)
For i = 1 To numQuestions
qAnswered(i) = False
Next i

End Sub

Sub WrongAnswerButton(answerButton As Shape)
Dim thisQuestionNum As Long

thisQuestionNum = _
ActivePresentation.SlideShowWindow.View.Slide.SlideIndex - 1
answer(thisQuestionNum) = answerButton.TextFrame.TextRange.Text
WrongAnswer
End Sub

Sub WrongAnswer()
Dim thisQuestionNum As Long

thisQuestionNum = _
ActivePresentation.SlideShowWindow.View.Slide.SlideIndex - 1
If qAnswered(thisQuestionNum) = False Then
numIncorrect = numIncorrect + 1
End If
qAnswered(thisQuestionNum) = True
AnswerIs(thisQuestionNum) = "- This is not the right answer." 'instead
of saying this I want it to say what the correct answer is on my printable
slide.
ActivePresentation.SlideShowWindow.View.Next
End Sub

Thanks,

--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 
P

Preschool Mike

Let me make sure I have this straight. I can't use the code I have below,
correct? So I should try the code from chap. 7? Which is what I ended up
doing. Where would I insert the below code you suggested? In the
WrongAnswerButton procedure? Is this correct?
 
D

David Marcovitz

Actually, you don't have this straight. The way I see it, you have two
choices:

(1) Work with the code in Chapter 7. Then you can modify all the separate
wrong answer procedures to give specific feedback (add or modify a MsgBox
line to say "The right answer is ..." with the ... replaced by the actual
right answer in each procedure), OR

(2) Insert the code below (or something like it that has actually been
tested and works) into the Chapter 8 version that you have been doing. If
you insert something like that into your WrongAnswerButton procedure it
should do what you want.

--David

Let me make sure I have this straight. I can't use the code I have below,
correct? So I should try the code from chap. 7? Which is what I ended up
doing. Where would I insert the below code you suggested? In the
WrongAnswerButton procedure? Is this correct?

--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top