Innen: Hungarian Scratch-Wiki

Icon translate.png Ez a szócikk még erősen fordítás alatt áll. Akadhatnak benne más nyelvű szövegek is.


A Scratch tartalmazza az erőforrásokat hogy létrehozzunk egy kérdés/válasz rendszert. Ez a rendszer használva lehet arra hogy valakit "kvizzelj", vagy ismételten válaszoljon automatizált kérdéseket. Ez az oktatóanyag megmutat külonböző módszereket hogy hogy kell készíteni egy kerdő rendszert. Mindegyik módszerhez, a kérdezz () és várj blokk van használva hogy kérdezzünk és bemenetet bevigyünk.

Egyszerű Módszer

Ez a módszer elégge hosszadalmassá válhat programozásban, ismétlődővé, és rendezetté, de mindig megvalósít egy egyszerű kérdő rendszert. A program megmondja a karakternek hogy tegyen fel egy kérdést, érzékelje hogy a jó vagy a rossz megoldás, és játszon le egy hangot az eredményhez képest. Ez az egyszerű módszer hogy programozzunk egy kvizjátékot.

when gf clicked
ask [Mennyi 1+1?] and wait
if <(megoldás) = [2]> then
  play sound [helyes! v] until done
  change [helyes v] by (1)
else
  play sound [hibás v] until done
end
. . . //ismételd meg a fenti programot külonböző kérdésekkel bármennyi megadott ideig

Lista Módszer

A következő módszer folyamatosan kiválaszt egy véletlenszerű kérdést hogy kérdezzen, with questions and answers added to certain lists. The list storage makes adding questions and answers quicker. Each item in the list "questions" must directly correspond to the same item in "answers". Further methods can be used to group questions and implement other functions for various purposes. For the following tutorial, assume the following:

  • "questions" is the list which contains each question
  • "answers" is the list which contains the corresponding answers to the questions in the list above
  • "item#" is a variable used to determine the current question one can answer
when gf clicked
forever
set [item# v] to (pick random (1) to (length of [questions v])) //picks a random question
ask (item (item#) of [questions v]) and wait //asks the question and waits for the response
if <(answer) = (item (item#) of [answers v])> then//if the answer is correct
play sound [correct! v] until done//notifies the viewer that the answer is correct
else
play sound [wrong v] until done//notifies the viewer that the answer is incorrect
say (item (item#) of [answers v]) for (1) secs //used to display what the correct answer was

Group Method

This method is much like the List Method of coding a quiz, but the Grouping Method can be used to group questions and repetitively ask the specified group of questions until a condition is reached. For example, if there are twenty questions, this method can be used to ask four of those questions in the group until they are known very well, and then the system will select a new group. For this method, assume the additional following:

  • "current questions" is the list which contains the current group of questions
  • "current answers" is the list which contains the current group of corresponding answers
  • "correct" is the variable used to determine how many questions of a specific group have been correct
when gf clicked
forever
delete (all v) of [current questions v] //clears the current group's questions
delete (all v) of [current answers v] //clears the current group's answers
set [correct v] to (0) //resets the amount if correct answers for the new group
repeat ([ceiling v] of ((length of [questions v]) / (5))) //each group contains 1/5 of the total questions
set [item# v] to (pick random (1) to (length of [questions v]))
add (item (item#) of [questions v]) to [current questions v] //adds a questions to a group
add (item (item#) of [answers v]) to [current answers v] //adds the corresponding answer
end
repeat until <(correct) = [15]> //"15" can be changed to the desired amount needed correct each group
set [item# v] to (pick random (1) to (length of [current questions v])) //picks a random question
ask (item (item#) of [current questions v]) and wait //asks the question and waits for the response
if <(answer) = (item (item#) of [current answers v])> then//if the answer is correct
play sound [correct! v] until done //notifies the viewer that the answer is correct
change [correct v] by (1)
else
play sound [wrong v] until done //notifies the viewer that the answer is incorrect
say (item (item#) of [current answers v]) for (1) secs //used to display what the correct answer was

Mathematical Method

This method is used in a math quiz in a way very much like the list method, but takes use of the Operators blocks to make several possibilities without needing to list them. Take, for example, randomly generated addition questions involving addends from 1 to 20. For this method, assume these variables:

  • "number1" is the first added to the question
  • "number2" is the second added in the question
  • "expect_answer" is the expected answer of the generated question
when gf clicked
hide variable [expect_answer v] // hides the answer
forever
    set [number1 v] to (pick random (1) to (20))
    set [number2 v] to (pick random (1) to (20)) // generates two random integers from 1 to 20
    set [expect_answer v] to ((number1) + (number2)) // calculates the result
    ask (join (number1) (join [ + ] (number2))) and wait // asks the question
    if <(answer) = (expect_answer)> then // if the answer is correct
        play sound [correct v] until done// notifies the viewer that the answer is correct
    else // if the answer isn't correct
        play sound [wrong v] // notifies the viewer that the answer is incorrect
        show variable [expect_answer v] // tells viewer what the correct answer was
        wait (4) secs // assures that the viewer has enough time to react before the variable is hidden again
        hide variable [expect_answer v] // hides the variable in preperation for the next loop
    end
end
Cookies help us deliver our services. By using our services, you agree to our use of cookies.