Keeping score

P

Preschool Mike

I'm attempting, with very little success, to create an activity where my
students sort 3 objects/shapes by size from smallest to largest. I've only
been able to come up with the code to move the shapes into the 3 answer
boxes, but I need a way to keep score (e.g., see if they're answers are
correct). This is where I'm having all my difficulty. Here is an example of
how my quiz should work. There are three shapes of different sizes and three
answer boxes. The student clicks on the shape and then clicks on an answer
box where they want the shape to go. Here is the only code I can come up
with for placing the shapes and I'm not even sure if it's appropriate for
keeping score.

Dim MyAnswers As Shape

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

End Sub

Sub MoveTo(theAnswerBox As Shape)
MyAnswers.Fill.ForeColor.RGB = vbYellow
MyAnswers.Top = theAnswerBox.Top + 15
MyAnswers.Left = theAnswerBox.Left + 15
End Sub

Any help or suggestions is greatly appreciated.

Thanks,

Mike
 
D

David Marcovitz

OK. Here is some air code (untested and no guarantee that it will work), but
it should give you some ideas. First thing I might do is either name or tag
all the shapes and boxes (e.g., using the naming procedures in Example 8.7
on my site -- http://www.PowerfulPowerPoint.com ). Once you do that, the
problem is easy because MyAnswers contains a pointer to the shape that is
being moved, and theAnswerBox contains a pointer to the box it has been
moved to (inside the MoveTo procedure). So, in the MoveTo procedure, you can
do a simple If statement or Case statement (I'll use an If because I can
write that without looking it up, but for a large number of shapes, a Case
would probably be easier). In fact, there are probably lots of easier ways,
but none that I can write off the top of my head.

If MyAnswers.Name = "triangle" And theAnswerBox.Name = "triangle box" Then
RightAnswer
Else If MyAnswers.Name = "square" And theAnswerBox.Name = "square box" Then
RightAnswer
Else If MyAnswers.Name = "circle" And theAnswerBox.Name = "circle box" Then
RightAnswer
Else If MyAnswers.Name = "octagon" And theAnswerBox.Name = "octagon box"
Then
RightAnswer
Else
WrongAnswer
End If

Next, you need RightAnswer and WrongAnswer procedures that, in their
simplest form add one to the score:

Sub RightAnswer()
numCorrect = numCorrect + 1
End Sub

Sub WrongAnswer()
numIncorrect = numIncorrect + 1
End Sub

Of course, this gets trickier if you only want the score to be adjusted the
first time they do something. In that case it would use the same basic
strategy as above and the ideas from Example 7.7 on my site.

--David

I'm attempting, with very little success, to create an activity where my
students sort 3 objects/shapes by size from smallest to largest. I've only
been able to come up with the code to move the shapes into the 3 answer
boxes, but I need a way to keep score (e.g., see if they're answers are
correct). This is where I'm having all my difficulty. Here is an example of
how my quiz should work. There are three shapes of different sizes and three
answer boxes. The student clicks on the shape and then clicks on an answer
box where they want the shape to go. Here is the only code I can come up
with for placing the shapes and I'm not even sure if it's appropriate for
keeping score.

Dim MyAnswers As Shape

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

End Sub

Sub MoveTo(theAnswerBox As Shape)
MyAnswers.Fill.ForeColor.RGB = vbYellow
MyAnswers.Top = theAnswerBox.Top + 15
MyAnswers.Left = theAnswerBox.Left + 15
End Sub

Any help or suggestions is greatly appreciated.

Thanks,

Mike

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

David Marcovitz

While reading Steve's answer, I got another brainstorm. Given that you want
to add up the scores at the end (I'm guessing) and don't care how many times
they move them around, how about some variables to keep track of whether a
shape is in the right place:

Dim triangleScore As Long
Dim squareScore As Long
Dim circleScore As Long
Dim octagonScore As Long

These scores will be 0 or 1 (0 if that shape is wrong and 1 if it is right).
So, in the end, you can just add them up:

finalScore = triangleScore + squareScore + circleScore + octagonScore
MsgBox "You identified " & finalScore & " shapes correctly"

Now, to set the scores, the If expression gets more complicated:

If MyAnswers.Name = "triangle" Then
If theAnswerBox.Name = "triangle box" Then
triangleScore = 1
Else
triangleScore = 0
End If
Else If MyAnswers.Name = "square" Then
If theAnswerBox.Name = "square box" Then
squareScore = 1
Else
squareScore = 0
End If
Else If MyAnswers.Name = "circle" Then
If theAnswerBox.Name = "circle box" Then
circleScore = 1
Else
circleScore = 0
End If
Else If MyAnswers.Name = "octagon" Then
If theAnswerBox.Name = "octagon box" Then
octagonScore = 1
Else
octagonScore = 0
End If
Else
MsgBox "You didn't click on a shape first"
End If



OK. Here is some air code (untested and no guarantee that it will work), but
it should give you some ideas. First thing I might do is either name or tag
all the shapes and boxes (e.g., using the naming procedures in Example 8.7
on my site -- http://www.PowerfulPowerPoint.com ). Once you do that, the
problem is easy because MyAnswers contains a pointer to the shape that is
being moved, and theAnswerBox contains a pointer to the box it has been
moved to (inside the MoveTo procedure). So, in the MoveTo procedure, you can
do a simple If statement or Case statement (I'll use an If because I can
write that without looking it up, but for a large number of shapes, a Case
would probably be easier). In fact, there are probably lots of easier ways,
but none that I can write off the top of my head.

If MyAnswers.Name = "triangle" And theAnswerBox.Name = "triangle box" Then
RightAnswer
Else If MyAnswers.Name = "square" And theAnswerBox.Name = "square box" Then
RightAnswer
Else If MyAnswers.Name = "circle" And theAnswerBox.Name = "circle box" Then
RightAnswer
Else If MyAnswers.Name = "octagon" And theAnswerBox.Name = "octagon box"
Then
RightAnswer
Else
WrongAnswer
End If

Next, you need RightAnswer and WrongAnswer procedures that, in their
simplest form add one to the score:

Sub RightAnswer()
numCorrect = numCorrect + 1
End Sub

Sub WrongAnswer()
numIncorrect = numIncorrect + 1
End Sub

Of course, this gets trickier if you only want the score to be adjusted the
first time they do something. In that case it would use the same basic
strategy as above and the ideas from Example 7.7 on my site.

--David

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

Preschool Mike

Gentlemen thanks again for the help. You both are most resourceful. The
code works great for my activity. Again I ask where can I learn more? I
realize the only book out there is the one that David has written. Ever
consider a sequeal? I'll read a text book if you can think of a good one.
I'd even be interested in taking a class to learn more about VBA. Any
suggestions on where to start?

Mike
 
D

David Marcovitz

Thanks. I didn't want to write the book in the first place, but no one else
had written it, and I had a class to teach. After I created 70 pages worth
of handouts for my students, I decided to turn it into a book.
Unfortunately, the market for this book is a niche market. It was difficult
getting a publisher in the first place, and with this niche market, I doubt
that they would go for a sequel (or even a second edition to update for new
versions). I wish there were more, but there isn't much (other than what
Steve suggested). As for classes, I use this in my Multimedia Design for the
Classroom class (I am teaching it right now), and I know of another
professor who in Ohio (I think) who has used my book for her class, and I
know of a middle school teacher in Pennsylvania who uses my book with his
class (and they have won the state multimedia fair several times with it). I
wish I had a better answer for you (and for me), but I don't. Sorry.
--David

Gentlemen thanks again for the help. You both are most resourceful. The
code works great for my activity. Again I ask where can I learn more? I
realize the only book out there is the one that David has written. Ever
consider a sequeal? I'll read a text book if you can think of a good one.
I'd even be interested in taking a class to learn more about VBA. Any
suggestions on where to start?

Mike

--
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