Interactive Quiz using ppt

2019-08-30 08:08发布

I posted a rubbish question about this before and have gone away and done some work on it to re-ask. Basically I've made a ppt quiz that counts how many correct and incorrect answers a person has given. It then feeds this information back to the user at the end. However what I want to happen now is I want the results to be stored so that I can go back in and see how each user has performed in the quiz. Ideally I would like it to work over 6 networked computers storing all the quiz results in one place. But if need be I can just take a file from each of the 6 computers.

My code so far looks like this:

Dim username As String
Dim numberCorrect As Integer
Dim numberWrong As Integer

Sub YourName()
username = InputBox(prompt:="Type your Name")
MsgBox " Get Ready to begin " + username, vbApplicationModal, " Orange 1C Book 7"
End Sub

Sub correct()
numberCorrect = numberCorrect + 1
ActivePresentation.SlideShowWindow.View.Next
End Sub

Sub incorrect()
numberWrong = numberWrong + 1
ActivePresentation.SlideShowWindow.View.Next
End Sub

Sub Start()
numberCorrect = 0
numberWrong = 0
YourName
ActivePresentation.SlideShowWindow.View.Next
End Sub

Sub Results()
MsgBox "Well done " & username & " You got " & numberCorrect & " out of " & numberCorrect + numberWrong, vbApplicationModal, "Orange 1C Book 7"

End Sub'

Any help would be greatly appreciated. Not sure where to begin with the next step.

1条回答
放荡不羁爱自由
2楼-- · 2019-08-30 08:34

Here goes one option for you... But some explanation first. This code will create TXT file. Each time someone will reach Results macro it will add results to the file. So, one file will keep all the results until you don't delete them (or the file). Therefore I've added separation line and date/time information for you to easily find appropriate results.

Sub Save_Results_To_Txt()

    'set file results location to activepresentation path
    'or could be changed to any path string
    Dim strWhere As String
        strWhere = ActivePresentation.Path
    'let's set name of the file separately
    Dim strName As String
        strName = "\results.txt"

    Dim ff As Long
    ff = FreeFile

    Open strWhere & strName For Append As #ff

    Write #ff, Now & vbTab & username
    Write #ff, numberCorrect & vbTab & vbTab & numberWrong
    Write #ff, String(30, "-")

    Close #ff

End Sub

You need to add Save_Results_To_Txt to your Results sub, possibly before MsgBox line.

Your results.txt file will look like:

"2013-04-25 16:11:05    Tom"
"10     11"
"------------------------------"
"2013-04-25 16:11:23    Mark"
"11     10"
"------------------------------"
查看更多
登录 后发表回答