Keeping score

M

MoWoL

Many thanks to everyone who has helped me so far. I was hoping to once again
get pointed in the right direction. I have a power point for user practice
that gives the slides in random order, and when the question is answered
incorrectly, the slide will come up again, once correct, it no longer comes
up. This code was adapted from Mr. Marcovitz's web site and works beautifuly.
I have tried to incorporate scoring on the power point, and want it to only
count the answer the first time it comes up. (If they get it wrong once, it's
counted as wrong even though they will face the question again.) I have tried
using the qAnswered array found on the site, but it won't work. I think maybe
because I already have the visited array keeping the randomization working
properly. (Can you have two arrays in code?) I am new to VBA, but love
playing with it. The following code works but counts incorrect every time
they may get it wrong, not just the first. Thanks again for any input you may
have.

Dim visited() As Boolean
Dim numSlides As Long
Dim numRead As Integer
Dim NumCorrect As Integer
Dim NumIncorrect As Integer

Sub GetStarted()

Initialize
MakeAllNotVisible
RandomNext

End Sub

Sub Initialize()

Randomize
numRead = 0
NumCorrect = 0
NumIncorrect = 0
numSlides = ActivePresentation.Slides.Count
ReDim visited(numSlides)
For i = 2 To numSlides - 1
visited(i) = False
Next i
End Sub

Sub MakeAllNotVisible()

Dim oSld As Slide
Dim oShp As Shape
For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.Name = "Missed" Then
oShp.Visible = False
End If
Next oShp
Next oSld

End Sub
Sub RightAnswer()

NumCorrect = NumCorrect + 1
visited(ActivePresentation.SlideShowWindow.View.Slide.SlideIndex) = True
numRead = numRead + 1
RandomNext

End Sub
Sub WrongAnswer()

NumIncorrect = NumIncorrect + 1
ActivePresentation.SlideShowWindow.View.Slide.Shapes("Missed").Visible =
True
ActivePresentation.SlideShowWindow.View.GotoSlide (2)

End Sub
Sub RandomNext()
Dim nextSlide As Long

If numRead >= numSlides - 3 Then
ActivePresentation.SlideShowWindow.View.Last
Else
nextSlide = Int((numSlides - 2) * Rnd + 2)
While visited(nextSlide) = True Or nextSlide = 2
nextSlide = Int((numSlides - 2) * Rnd + 2)
Wend
ActivePresentation.SlideShowWindow.View.GotoSlide (nextSlide)
End If
End Sub
 
D

David M. Marcovitz

Within reason, you can have as many arrays as you want. Without testing
it out, I believe that what you want to do is VERY easy. Right now, you
are adding one to numCorrect or numIncorrect no matter what. All you need
to do is put those statements inside an If block to ask if that question
has been visited previously. It should be something like this (in
RightAnswer):

If visited(ActivePresentation.SlideShowWindow.View.Slide.SlideIndex) _
= False Then
numCorrect = numCorrect + 1
End If

Do the same for WrongAnswer (obviously using numIncorrect). The If
statement simply asks if the slide has not been visited. If it has, it
does nothing with the score. If it has not, it adds one to the count of
correct or incorrect answers.

--David
--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
M

MoWoL

Thank you for getting back to me so quickly. I have tried this and the
problem lies in WrongAnswer. When the user gets the question wrong the first
time it will count NumIncorrect. But in order to make the slide come up again
in the RandomNext, I can not then mark the slide as visited. So the next time
it comes up, if they again answer incorrectly, visited is still false so it
counts another incorrect. It also will then count one for correct the next
time because visited will be false until the correct answer is reached. Once
answered correctly, the slide doesn't come up anymore, so the issue ends, but
in this situation, it would have counted twice incorrect and once correct.
 
D

David M. Marcovitz

Aha. Now I get your issue. Sorry for misunderstanding the first time. In
this case, you need another array (that is why you were asking about the
number of arrays). Call it visited2 or something that makes sense to you.
Copy just about every line of code where you have visited and add one
just like it for visited2. Then use visited2 in my If statements and the
original visited in the Random statements. Make sure that you set
visited2 to True in WrongAnswer (and not visited) and both visited and
visited2 to True in Right Answer.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
M

MoWoL

Well thanks for the help. I had tried to do that before but it wasn't
working. Thats why I thought maybe you couldn't have more than one array. Now
I know, it was probably just something I missed in code. Like a stinking
comma or something. (Picky VBA) I will give it another shot. Thanks again for
all your help.
 

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