Search the Community
Showing results for tags 'quiz'.
-
I want to save some tests (about one thousand tests totally) from a quiz website to a text file. The test page is a simple one, it contains: 1) The questions; they are inside the <p class="qw">...</p> 2) 5 choices; they are radio buttons id ="a1", "b1" ... When I click a radio for a choice, if correct, the background of it will turn green, if wrong, it will turn red, and the correct answer will turn green. What I need to get is the correct answer. So when I click an answer, no matter right or wrong, the test will automatically go to the next question in about 3 or 4 seconds (I don't know exactly how many seconds). So what I want to save is: Questions choice 1; choice 2; choice 3; choice 4; choice 5; correct answer Then next question... I have limited knowledge of AutoIt, I have check the IE UDFs, but I don't know where to start. Especially I don't know how to do since the test will to go next item automatically. Please give me some hints. Thank you very much.
-
hello everybody I'm working on a quiz depending on "ini" files: DB.ini : to get the questions ans.ini : to save the answers the quiz I'm working can save the previous answers but I'm facing a problem when back and forward this is the main code #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <Date.au3> #include <StaticConstants.au3> #include <Array.au3> #include <MsgBoxConstants.au3> #NoTrayIcon Opt("TrayIconHide", 1) Opt("MustDeclareVars", 1) Opt("GUICloseOnESC", 0) ;1=ESC closes, 0=ESC won't close ;~ ---------------------------------------------------------------------- Local $qui_width,$qui_hight,$GUIMsg,$var_qs,$Key_qs,$xi,$TXTxLen,$data_ans,$ans_ini Local $QSTN,$A,$B,$C,$D,$Aopt,$Bopt,$Copt,$Dopt Local $var_ini,$Key_ans,$sData0 Local $File = "DB.ini", $font = "Lucida Console" Global $i = 1 $ans_ini = "ans.ini" $sData0 = "ans=1" If FileExists($ans_ini) = 0 Then FileOpen($ans_ini, 1) FileClose($ans_ini) IniWriteSection($ans_ini, "1", $sData0) EndIf $qui_width = 1250 $qui_hight = 675 local $hGUI = GUICreate("Quiz" , $qui_width, $qui_hight) GUISetBkColor(0xFFFFD4) ;~ --------------------------------------------------------- guictrlcreategroup("question", 20, 35, $qui_width-40, 75 ) ;~ --------------------------------------------------------- guictrlcreategroup("answers", 20, 125, 500, 424 ) ;~ --------------------------------------------------------- guictrlcreategroup("A", 40, 145, 460, 90 ) GUICtrlSetFont(-1, 10, 650, $font) guictrlcreategroup("B", 40, 243, 460, 90 ) GUICtrlSetFont(-1, 10, 650, $font) guictrlcreategroup("C", 40, 341, 460, 90 ) GUICtrlSetFont(-1, 10, 650, $font) guictrlcreategroup("D", 40, 439, 460, 90 ) GUICtrlSetFont(-1, 10, 650, $font) ;~ --------------------------------------------------------- ;~ A $A = GUICtrlCreateLabel("",75 ,185,420,45,$GUI_ONTOP) ; Question text GUICtrlSetFont(-1, 12,650, $font) GUICtrlSetColor(-1, 0x008fd7) ;~ --------------------------------- $Aopt = GUICtrlCreateRadio("", 57,170,15,50) GUICtrlSetFont(-1, 12,650, $font) ;~ --------------------------------------------------------- ;~ B $B = GUICtrlCreateLabel("",75 ,283,420,45) ; Question text GUICtrlSetFont(-1, 12,650, $font) GUICtrlSetColor(-1, 0x008fd7) ;~ --------------------------------- $Bopt = GUICtrlCreateRadio("", 57,268,15,50) GUICtrlSetFont(-1, 12,650, $font) ;~ --------------------------------------------------------- ;~ C $C = GUICtrlCreateLabel("",75 ,381,420,45) ; Question text GUICtrlSetFont(-1, 12,650, $font) GUICtrlSetColor(-1, 0x008fd7) ;~ --------------------------------- $Copt = GUICtrlCreateRadio("", 57,366,15,50) GUICtrlSetFont(-1, 12,650, $font) ;~ --------------------------------------------------------- ;~ D $D = GUICtrlCreateLabel("",75 ,479,420,45) ; Question text GUICtrlSetFont(-1, 12,650, $font) GUICtrlSetColor(-1, 0x008fd7) ;~ --------------------------------- $Dopt = GUICtrlCreateRadio("", 57,464,15,50) GUICtrlSetFont(-1, 12,650, $font) ;~ --------------------------------------------------------- Local $count = GUICtrlCreateLabel("",500 ,575,420,45) ; Question text GUICtrlSetFont(-1, 12,650, $font) GUICtrlSetColor(-1, 0x008fd7) ;~ Buttons Local $next = GUICtrlCreateButton("next",300,600,100,50) Local $prev = GUICtrlCreateButton("prev",100,600,100,50) ;~ --------------------------------------------------------- guictrlcreategroup("img", 540, 125, 690, 424 ) ;~ --------------------------------------------------------- NextData() GUISetState(@SW_SHOW) GUICtrlSetState($prev,$GUI_DISABLE) While 1 $GUIMsg = GUIGetMsg() Select Case $GUIMsg = $GUI_EVENT_CLOSE;, $nExititem FileDelete($ans_ini) Exit ;~ --------------------------------------------$unchk Case $GUIMsg = $next DetectChkOpt() ;~ -------------------------------------------- Case $GUIMsg = $prev prevData() EndSelect WEnd Func NextData() $var_ini = IniReadSectionNames($ans_ini) $var_qs = IniReadSectionNames($File) ;MsgBox(0,"", "$i=" & $i & " - lav[0]=" & $var_ini[0]) If $i <= $var_qs[0] Then If $i > $var_ini[0] Then GUICtrlSetState($Bopt,$GUI_UNCHECKED) GUICtrlSetState($Aopt,$GUI_UNCHECKED) GUICtrlSetState($Copt,$GUI_UNCHECKED) GUICtrlSetState($Dopt,$GUI_UNCHECKED) $Key_qs = IniReadSection($File, $var_qs[$i]) ;~ --------------------------------------------------------- $QSTN = GUICtrlCreateLabel($Key_qs[1][1] ,75,64,500,45) ; Question text GUICtrlSetFont(-1, 12,650, $font) GUICtrlSetColor(-1, 0x008fd7) ;~ ---------------------------------------------------------- GUICtrlSetData($A,$Key_qs[2][1]) GUICtrlSetData($B,$Key_qs[3][1]) GUICtrlSetData($C,$Key_qs[4][1]) If $Key_qs[5][1] = "-" Then GUICtrlSetState($Dopt,$GUI_HIDE) GUICtrlSetData($D,"") Else GUICtrlSetState($Dopt,$GUI_SHOW) GUICtrlSetData($D,$Key_qs[5][1]) EndIf $i=$i+1 Else $Key_ans = IniReadSection($ans_ini, $var_ini[$i]) If $Key_ans[1][1] = "A" Then GUICtrlSetState($Aopt,$GUI_CHECKED) GUICtrlSetState($Bopt,$GUI_UNCHECKED) GUICtrlSetState($Copt,$GUI_UNCHECKED) GUICtrlSetState($Dopt,$GUI_UNCHECKED) ElseIf $Key_ans[1][1] = "B" Then GUICtrlSetState($Bopt,$GUI_CHECKED) GUICtrlSetState($Aopt,$GUI_UNCHECKED) GUICtrlSetState($Copt,$GUI_UNCHECKED) GUICtrlSetState($Dopt,$GUI_UNCHECKED) ElseIf $Key_ans[1][1] = "C" Then GUICtrlSetState($Copt,$GUI_CHECKED) GUICtrlSetState($Aopt,$GUI_UNCHECKED) GUICtrlSetState($Bopt,$GUI_UNCHECKED) GUICtrlSetState($Dopt,$GUI_UNCHECKED) ElseIf $Key_ans[1][1] = "D" Then GUICtrlSetState($Dopt,$GUI_CHECKED) GUICtrlSetState($Aopt,$GUI_UNCHECKED) GUICtrlSetState($Bopt,$GUI_UNCHECKED) GUICtrlSetState($Copt,$GUI_UNCHECKED) EndIf $Key_qs = IniReadSection($File, $var_qs[$i]) ;~ --------------------------------------------------------- $QSTN = GUICtrlCreateLabel($Key_qs[1][1] ,75 ,64,500,45) ; Question text GUICtrlSetFont(-1, 12,650, $font) GUICtrlSetColor(-1, 0x008fd7) ;~ ---------------------------------------------------------- GUICtrlSetData($A,$Key_qs[2][1]) GUICtrlSetData($B,$Key_qs[3][1]) GUICtrlSetData($C,$Key_qs[4][1]) If $Key_qs[5][1] = "-" Then GUICtrlSetState($Dopt,$GUI_HIDE) GUICtrlSetData($D,"") Else GUICtrlSetState($Dopt,$GUI_SHOW) GUICtrlSetData($D,$Key_qs[5][1]) EndIf $i=$i+1 EndIf Else Result() EndIf GUICtrlSetData($count,$i) EndFunc Func prevData() $var_ini = IniReadSectionNames($ans_ini) $var_qs = IniReadSectionNames($File) If $var_ini[0] = 1 Then $i=$var_ini[0] Else $i=$var_ini[0]-1 EndIf MsgBox(0,"",$var_ini[0]) $Key_ans = IniReadSection($ans_ini, $var_ini[$i]) If $var_qs[$i] = $var_qs[1] Then GUICtrlSetState($prev,$GUI_DISABLE) If $Key_ans[1][1] = "A" Then GUICtrlSetState($Aopt,$GUI_CHECKED) GUICtrlSetState($Bopt,$GUI_UNCHECKED) GUICtrlSetState($Copt,$GUI_UNCHECKED) GUICtrlSetState($Dopt,$GUI_UNCHECKED) ElseIf $Key_ans[1][1] = "B" Then GUICtrlSetState($Bopt,$GUI_CHECKED) GUICtrlSetState($Aopt,$GUI_UNCHECKED) GUICtrlSetState($Copt,$GUI_UNCHECKED) GUICtrlSetState($Dopt,$GUI_UNCHECKED) ElseIf $Key_ans[1][1] = "C" Then GUICtrlSetState($Copt,$GUI_CHECKED) GUICtrlSetState($Aopt,$GUI_UNCHECKED) GUICtrlSetState($Bopt,$GUI_UNCHECKED) GUICtrlSetState($Dopt,$GUI_UNCHECKED) ElseIf $Key_ans[1][1] = "D" Then GUICtrlSetState($Dopt,$GUI_CHECKED) GUICtrlSetState($Aopt,$GUI_UNCHECKED) GUICtrlSetState($Bopt,$GUI_UNCHECKED) GUICtrlSetState($Copt,$GUI_UNCHECKED) EndIf $Key_qs = IniReadSection($File, $var_qs[$i]) $QSTN = GUICtrlCreateLabel($Key_qs[1][1] ,75 ,64,500,45) ; Question text GUICtrlSetFont(-1, 12,650, $font) GUICtrlSetColor(-1, 0x008fd7) ;~ ---------------------------------------------------------- GUICtrlSetData($A,$Key_qs[2][1]) GUICtrlSetData($B,$Key_qs[3][1]) GUICtrlSetData($C,$Key_qs[4][1]) If $Key_qs[5][1] = "-" Then GUICtrlSetState($Dopt,$GUI_HIDE) GUICtrlSetData($D,"") Else GUICtrlSetState($Dopt,$GUI_SHOW) GUICtrlSetData($D,$Key_qs[5][1]) EndIf Else If $Key_ans[1][1] = "A" Then GUICtrlSetState($Aopt,$GUI_CHECKED) GUICtrlSetState($Bopt,$GUI_UNCHECKED) GUICtrlSetState($Copt,$GUI_UNCHECKED) GUICtrlSetState($Dopt,$GUI_UNCHECKED) ElseIf $Key_ans[1][1] = "B" Then GUICtrlSetState($Bopt,$GUI_CHECKED) GUICtrlSetState($Aopt,$GUI_UNCHECKED) GUICtrlSetState($Copt,$GUI_UNCHECKED) GUICtrlSetState($Dopt,$GUI_UNCHECKED) ElseIf $Key_ans[1][1] = "C" Then GUICtrlSetState($Copt,$GUI_CHECKED) GUICtrlSetState($Aopt,$GUI_UNCHECKED) GUICtrlSetState($Bopt,$GUI_UNCHECKED) GUICtrlSetState($Dopt,$GUI_UNCHECKED) ElseIf $Key_ans[1][1] = "D" Then GUICtrlSetState($Dopt,$GUI_CHECKED) GUICtrlSetState($Aopt,$GUI_UNCHECKED) GUICtrlSetState($Bopt,$GUI_UNCHECKED) GUICtrlSetState($Copt,$GUI_UNCHECKED) EndIf $Key_qs = IniReadSection($File, $var_qs[$i]) $QSTN = GUICtrlCreateLabel($Key_qs[1][1] ,75 ,64,500,45) ; Question text GUICtrlSetFont(-1, 12,650, $font) GUICtrlSetColor(-1, 0x008fd7) ;~ ---------------------------------------------------------- GUICtrlSetData($A,$Key_qs[2][1]) GUICtrlSetData($B,$Key_qs[3][1]) GUICtrlSetData($C,$Key_qs[4][1]) If $Key_qs[5][1] = "-" Then GUICtrlSetState($Dopt,$GUI_HIDE) GUICtrlSetData($D,"") Else GUICtrlSetState($Dopt,$GUI_SHOW) GUICtrlSetData($D,$Key_qs[5][1]) EndIf EndIf EndFunc Func DetectChkOpt() Select Case GUICtrlRead($Aopt) = 1 $data_ans = "ans[" & $i-1 & "]=A" IniWriteSection($ans_ini, $i-1, $data_ans) MsgBox(0,""," $i=" & $i) GUICtrlSetData($QSTN,"") GUICtrlSetState($prev,$GUI_ENABLE) NextData() ;~ ======================= Case GUICtrlRead($Bopt) = 1 $data_ans = "ans[" & $i-1 & "]=B" IniWriteSection($ans_ini, $i-1, $data_ans) MsgBox(0,""," $i=" & $i) GUICtrlSetData($QSTN,"") GUICtrlSetState($prev,$GUI_ENABLE) NextData() ;~ ======================= Case GUICtrlRead($Copt) = 1 $data_ans = "ans[" & $i-1 & "]=C" IniWriteSection($ans_ini, $i-1, $data_ans) MsgBox(0,""," $i=" & $i) GUICtrlSetData($QSTN,"") GUICtrlSetState($prev,$GUI_ENABLE) NextData() ;~ ======================= Case GUICtrlRead($Dopt) = 1 $data_ans = "ans[" & $i-1 & "]=D" IniWriteSection($ans_ini, $i-1, $data_ans) MsgBox(0,""," $i=" & $i) GUICtrlSetData($QSTN,"") GUICtrlSetState($prev,$GUI_ENABLE) NextData() ;~ ======================= Case Else MsgBox(0,"attention","please choose one of these options") EndSelect EndFunc Func Result() Local $rslt = 0 $var_qs = IniReadSectionNames($File) $var_ini = IniReadSectionNames($ans_ini) ;~ --------------------------------------------------- For $l = 1 To $var_ini[0] $Key_qs = IniReadSection($File, $var_qs[$l]) $Key_ans = IniReadSection($ans_ini, $var_ini[$l]) If $Key_ans[1][1] = $Key_qs[6][1] Then $rslt = $rslt + 1 EndIf Next ;~ --------------------------------------------------- GUICtrlSetData($QSTN,$Key_qs[1][1]) ;MsgBox(0,"",Ubound($ansr) & " " & $ai) MsgBox(0,"Result", $rslt & " of " & $var_qs[0] ) $i = $var_ini[0] MsgBox(0,"$i = $var_ini[0]-1", $i ) EndFunc and this is example of the questions file: DB.ini [1] QS = What is the biggest planet in our solar system? ans1 = Earth ans2 = Jupiter ans3 = Pluto ans4 = - true = B img = [2] QS = What is the name of the element with the chemical symbol ‘He’? ans1 = Helium ans2 = Hydrogen ans3 = Oxygen ans4 = nitrogen true = A img = [3] QS = How many bones do sharks have in their bodies? ans1 = 20 ans2 = 50 ans3 = 0 ans4 = 10 true = C img = may be the code is long or has many errors but that what I can please help me I have to finish soon please