Jump to content

Time worked on answers


Recommended Posts

I need to write a short little script that can track the amount of time a student spends on a question.  The only thing they will use the computer for is clicking a multiple choice answer, then they dont touch the computer until they select the next questions answer.  How can I place a timer between clicks.  This will give me an idea on which students are just selecting answers 1 second at a time, and others that actually sit down and work through the problem.  Hoping to get a consolewrite of question 1... x seconds... question 2... x seconds

 

Thanks,

JEnn

Edited by JennMaughan
Link to comment
Share on other sites

In another thread I started about Timers I created an example of turning a timer on and off with a toggle. There are some issues to know when using timers that are covered in that thread too.
 

If you look at the example I wrote it may give you some ideas on how to write your code and how to pass the timer info to console when the trigger is tripped.  Hope it helps you.

Edited by iAmNewbe
Link to comment
Share on other sites

You may be able to modify this example to suit your needs.

10 secs after this example is run, the duration between the start of the test and the first left mouse click, and subsequent left mouse clicks will be recorded.

#include <Misc.au3>
#include <Date.au3>
#include <Array.au3>

; This $StartTime is for testing purposes only. Waits 10sec before being able to answering questions (or record left mouse downs).
Local $StartTime = StringTrimLeft(_DateAdd("s", 10, _NowCalc()), 11) ; Time only needed (trim date - 11 characters).

;Local $StartTime = "13:05:00" ; <---- Set start time of test. A way to get time until first answer.
ConsoleWrite("$StartTime: " & $StartTime & @CRLF)
Local $TestLengthSecs = 10 * 60 ; <--- Set (In secs) eg. 10 * 60secs = 10 minutes. End program at end of test time.
Local $iNumOfQues = 10 ; <------------ Set number of questions.  When all question answered, program ends.

Local $hTimer, $iCoumt = 0, $iTimeDiff
Local $aData[$iNumOfQues + 1][2] = [["Question #", "Secs"]]
Local $TestEnd = _DateAdd("s", $TestLengthSecs, _NowCalcDate() & " " & $StartTime) ; Initial date in the format YYYY/MM/DD HH:MM:SS

While 1
    Sleep(10)
    If _DateDiff("s", _NowCalcDate() & " " & $StartTime, _NowCalc()) < 0 Then ContinueLoop ; Keep looping until start time of test.

    If IsNumber($hTimer) <> 1 Then ; First time through loop after Start Time.
        $hTimer = TimerInit() ; Start timer at start time of test to record time taken for first answer.
        MsgBox(0, "Start Now", "Start Now", 2) ; Show for 2 secs.
    EndIf
    If _IsPressed("01") Then ; Left mouse button.
        While _IsPressed("01") ; Wait for left mouse button to be released. (avoids multiple button presses)
            Sleep(10)
        WEnd
        $iCoumt += 1
        $aData[$iCoumt][0] = $iCoumt
        $aData[$iCoumt][1] = Round(TimerDiff($hTimer) / 1000, 2)
        ConsoleWrite("Question #" & $aData[$iCoumt][0] & @TAB & $aData[$iCoumt][1] & " secs" & @CRLF)
        $hTimer = TimerInit()
    EndIf
    If $iCoumt = $iNumOfQues Or _DateDiff("s", _NowCalc(), $TestEnd) < 0 Then ExitLoop
WEnd

_ArrayDisplay($aData) ; Using _FileWriteFromArray, array can be written to a file.

 

Link to comment
Share on other sites

19 hours ago, Malkey said:

You may be able to modify this example to suit your needs.

10 secs after this example is run, the duration between the start of the test and the first left mouse click, and subsequent left mouse clicks will be recorded.

#include <Misc.au3>
#include <Date.au3>
#include <Array.au3>

; This $StartTime is for testing purposes only. Waits 10sec before being able to answering questions (or record left mouse downs).
Local $StartTime = StringTrimLeft(_DateAdd("s", 10, _NowCalc()), 11) ; Time only needed (trim date - 11 characters).

;Local $StartTime = "13:05:00" ; <---- Set start time of test. A way to get time until first answer.
ConsoleWrite("$StartTime: " & $StartTime & @CRLF)
Local $TestLengthSecs = 10 * 60 ; <--- Set (In secs) eg. 10 * 60secs = 10 minutes. End program at end of test time.
Local $iNumOfQues = 10 ; <------------ Set number of questions.  When all question answered, program ends.

Local $hTimer, $iCoumt = 0, $iTimeDiff
Local $aData[$iNumOfQues + 1][2] = [["Question #", "Secs"]]
Local $TestEnd = _DateAdd("s", $TestLengthSecs, _NowCalcDate() & " " & $StartTime) ; Initial date in the format YYYY/MM/DD HH:MM:SS

While 1
    Sleep(10)
    If _DateDiff("s", _NowCalcDate() & " " & $StartTime, _NowCalc()) < 0 Then ContinueLoop ; Keep looping until start time of test.

    If IsNumber($hTimer) <> 1 Then ; First time through loop after Start Time.
        $hTimer = TimerInit() ; Start timer at start time of test to record time taken for first answer.
        MsgBox(0, "Start Now", "Start Now", 2) ; Show for 2 secs.
    EndIf
    If _IsPressed("01") Then ; Left mouse button.
        While _IsPressed("01") ; Wait for left mouse button to be released. (avoids multiple button presses)
            Sleep(10)
        WEnd
        $iCoumt += 1
        $aData[$iCoumt][0] = $iCoumt
        $aData[$iCoumt][1] = Round(TimerDiff($hTimer) / 1000, 2)
        ConsoleWrite("Question #" & $aData[$iCoumt][0] & @TAB & $aData[$iCoumt][1] & " secs" & @CRLF)
        $hTimer = TimerInit()
    EndIf
    If $iCoumt = $iNumOfQues Or _DateDiff("s", _NowCalc(), $TestEnd) < 0 Then ExitLoop
WEnd

_ArrayDisplay($aData) ; Using _FileWriteFromArray, array can be written to a file.

 

Malkey, This is perfect!!!!   Thank you.  Hoping to catch a few students that need to put more time into their work :P    Helps a lot.

 

Jenn

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...