Whops! Keeping score 1 more time

P

Preschool Mike

I thought I had it all worked out, but I was wrong. I'm having trouble with
my keeping score. As I said the student has to arrange 3 shapes (stars) in
the order of largest to smallest. If they do so correctly I only want it to
score it a 1 correct (e.g., question/problem 1). Presently it scores it as 3
correct. Wasn't sure if I needed to change my RightAnswer procedure or
something in the MoveStarsTo procedure, which I've tried with no luck.

Here the code I'm using:

Dim MyAnswers As Shape
Dim numCorrect As Integer
Dim numIncorrect As Integer

Sub Initialize()
MoveStarsHome
numCorrect = 0
numIncorrect = 0
ActivePresentation.SlideShowWindow.View.Next
End Sub


Sub MoveShape(theShape As Shape)
theShape.Fill.ForeColor.RGB = vbBlue
Set MyAnswers = theShape

End Sub

Sub MoveStarsTo(theAnswerBox As Shape)
MyAnswers.Fill.ForeColor.RGB = vbYellow
MyAnswers.Top = theAnswerBox.Top + 15
MyAnswers.Left = theAnswerBox.Left + 15
If MyAnswers.Name = "LargeStar" And theAnswerBox.Name = "LargeStarBox" Then
RightAnswer
ElseIf MyAnswers.Name = "MediumStar" And theAnswerBox.Name = "MediumStarBox"
Then
RightAnswer
ElseIf MyAnswers.Name = "SmallStar" And theAnswerBox.Name = "SmallStarBox"
Then
RightAnswer
Else
WrongAnswer
End If

End Sub
Sub RightAnswer()
numCorrect = numCorrect + 1
End Sub

Sub WrongAnswer()
numIncorrect = numIncorrect + 1
End Sub

Sub MoveStarsHome()
ActivePresentation.Slides(2).Shapes("LargeStar").Fill.ForeColor.RGB =
vbYellow
ActivePresentation.Slides(2).Shapes("LargeStar").Top = 50
ActivePresentation.Slides(2).Shapes("LargeStar").Left = 320
ActivePresentation.Slides(2).Shapes("MediumStar").Fill.ForeColor.RGB =
vbYellow
ActivePresentation.Slides(2).Shapes("MediumStar").Top = 75
ActivePresentation.Slides(2).Shapes("MediumStar").Left = 150
ActivePresentation.Slides(2).Shapes("SmallStar").Fill.ForeColor.RGB =
vbYellow
ActivePresentation.Slides(2).Shapes("SmallStar").Top = 90
ActivePresentation.Slides(2).Shapes("SmallStar").Left = 500
End Sub
Sub CheckAnswer()
MsgBox ("You got " & numCorrect & " correct")
End Sub

Thanks,

Mike
 
D

David Marcovitz

Yes, yes, yes. I now see the problem. I think what you want is the judging
to happen when they are all done rather than when they actually put the
right thing in the right box. This is going to add a bit of complexity, but
it is doable. But first, a simpler solution that might be good enough:

You could have a a separate variable to keep track of the "score" for this
slide (so you are not adding 1 to numCorrect or 1 to numIncorrect).

Dim numRightOrder As Integer

Wherever you have numcorrect = numcorrect + 1, substitute, numRightOrder =
numRightOrder + 1.

Finally, adjust your CheckAnswer procedure to:

CheckAnswer()
If numRightOrder = 3 Then
numCorrect = numCorrect + 1
Else
numIncorrect = numIncorrect + 1
End If
End Sub

Now, for the slightly more complex solution:

Dim largeCorrect As Boolean
Dim mediumCorrect As Boolean
Dim smallCorrect As Boolean

Sub MoveStarsTo(theAnswerBox As Shape)
MyAnswers.Fill.ForeColor.RGB = vbYellow
MyAnswers.Top = theAnswerBox.Top + 15
MyAnswers.Left = theAnswerBox.Left + 15
If MyAnswers.Name = "LargeStar" Then
If theAnswerBox.Name = "LargeStarBox" Then
largeStarCorrect = True
Else
largeStarCorrect = False
End If
ElseIf MyAnswers.Name = "MediumStar" Then
If theAnswerBox.Name = "MediumStarBox" Then
mediumStarCorrect = True
Else
mediumStarCorrect = False
End If
ElseIf MyAnswers.Name = "SmallStar" Then
If theAnswerBox.Name = "SmallStarBox" Then
smallStarCorrect = True
Else
smallStarCorrect = False
End If
Else
MsgBox "You must first click on a star before clicking on a box."
End If
End Sub

Sub CheckAnswer()
If smallStarCorrect And mediumStarCorrect And largeStarCorrect Then
numCorrect = numCorrect + 1
Else
numIncorrect = numIncorrect + 1
End If
End Sub

This is all air code, but this is the idea. We're setting a True/False value
for each shape. When the answers are checked, it adds one to the score if
and only if all the shapes are in the right box.

--David


I thought I had it all worked out, but I was wrong. I'm having trouble with
my keeping score. As I said the student has to arrange 3 shapes (stars) in
the order of largest to smallest. If they do so correctly I only want it to
score it a 1 correct (e.g., question/problem 1). Presently it scores it as 3
correct. Wasn't sure if I needed to change my RightAnswer procedure or
something in the MoveStarsTo procedure, which I've tried with no luck.

Here the code I'm using:

Dim MyAnswers As Shape
Dim numCorrect As Integer
Dim numIncorrect As Integer

Sub Initialize()
MoveStarsHome
numCorrect = 0
numIncorrect = 0
ActivePresentation.SlideShowWindow.View.Next
End Sub


Sub MoveShape(theShape As Shape)
theShape.Fill.ForeColor.RGB = vbBlue
Set MyAnswers = theShape

End Sub

Sub MoveStarsTo(theAnswerBox As Shape)
MyAnswers.Fill.ForeColor.RGB = vbYellow
MyAnswers.Top = theAnswerBox.Top + 15
MyAnswers.Left = theAnswerBox.Left + 15
If MyAnswers.Name = "LargeStar" And theAnswerBox.Name = "LargeStarBox" Then
RightAnswer
ElseIf MyAnswers.Name = "MediumStar" And theAnswerBox.Name = "MediumStarBox"
Then
RightAnswer
ElseIf MyAnswers.Name = "SmallStar" And theAnswerBox.Name = "SmallStarBox"
Then
RightAnswer
Else
WrongAnswer
End If

End Sub
Sub RightAnswer()
numCorrect = numCorrect + 1
End Sub

Sub WrongAnswer()
numIncorrect = numIncorrect + 1
End Sub

Sub MoveStarsHome()
ActivePresentation.Slides(2).Shapes("LargeStar").Fill.ForeColor.RGB =
vbYellow
ActivePresentation.Slides(2).Shapes("LargeStar").Top = 50
ActivePresentation.Slides(2).Shapes("LargeStar").Left = 320
ActivePresentation.Slides(2).Shapes("MediumStar").Fill.ForeColor.RGB =
vbYellow
ActivePresentation.Slides(2).Shapes("MediumStar").Top = 75
ActivePresentation.Slides(2).Shapes("MediumStar").Left = 150
ActivePresentation.Slides(2).Shapes("SmallStar").Fill.ForeColor.RGB =
vbYellow
ActivePresentation.Slides(2).Shapes("SmallStar").Top = 90
ActivePresentation.Slides(2).Shapes("SmallStar").Left = 500
End Sub
Sub CheckAnswer()
MsgBox ("You got " & numCorrect & " correct")
End Sub

Thanks,

Mike

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

Preschool Mike

This code worked great. The only thing I had to add, because I have more
than one slide (e.g., problem/question) was some code to reset the
numRightOrder back to 0 after each slide. Thanks again for you help. Just
wish I knew enough so I wouldn't have to ask and could also help others.

Mike
 

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