Powerful PowerPoint for Educators: Using Visual Basic for Applications to Make PowerPoint Interactive


Try Again: Answer Until It’s Right


Download 1.37 Mb.
Pdf ko'rish
bet152/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   148   149   150   151   152   153   154   155   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

Try Again: Answer Until It’s Right
Next, we can try to force the student to answer un til the ques tion is right,
only count ing the first try. This time, start with the code from “Try Again: An-
swer Un til It’s Right” in Chapter 7. Make the ex act same changes as above, ex-
cept use this 
RandomQuestion
pro ce dure:
Sub RandomQuestion()
Dim first As In 
teger
Dim sec 
ond As In 
teger
Dim done As Boolean
done = False
first = Int(10 * Rnd)
sec 
ond = Int(10 * Rnd)
While Not done
an 
swer = InputBox("What is " & first & " + " & sec 
ond & "?")
If an 
swer = first + sec 
ond Then
RightAnswer
done = True
Else
WrongAnswer
End If
Wend
End Sub
This uses a 
While
loop similar to what is used for short-answer questions. The
ran dom num bers are gen er ated be fore the
While
loop so that the same ques tion
is asked over and over again un til it is answered correctly.
If you want to try to create a printable page with the re sults, you can try that
on your own. Start with the ver sion of that from this chap ter in “Arrays.” Keep in 
mind that simply listing the answers might not be help ful be cause the ques tions
are ran domly generated. You might want to add another array to keep track of
the questions so you can add the questions and an swers to your slide.
Choose Questions Ran domly from a Pool
My daugh ter is learning to read. Although I am gen erally op posed to com -
puter use by five-year-olds, my daughter is fascinated with the computer, and I
thought I could use it with her to help her read. I took the words she was working
with in school and the read ing sen tences her teach ers sent home and cre ated a
pre sen ta tion. The pre sen ta tion con tains a few sen tences and a mul ti ple-choice
question on each slide. Throughout the year, I added to the slides, but I did not
want her to go through each slide every time. I wanted to limit her time on the
computer, so I wanted the computer to ran domly select five ques tions for her to
answer. The pre sentation uses an array to keep track of which questions have
been answered (so no ques tion is re peated in each set of five) and ran dom num-
bers to pick which question to present next. The code for this presentation can be
found in Figure 8.2.
146 More Tricks for Your Scripting Bag



Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   148   149   150   151   152   153   154   155   ...   191




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling