|
Script for a Short-Answer Question that Returns the Correct Part of the Student's Guess
I've got my teaching cap on this evening and I'm going to show you a simplish JavaScript function that can be invoked for any short-answer question that gets input from a textbox. Rather than just telling the student whether their effort was right or wrong and giving them the solution, it erases the incorrect section from the end of the string and waits for them to try again - much better than just giving it to them on a plate. For example, suppose the word was "spectacular" (we've got Moulin Rouge playing on the video at the moment and Ewan McGregor just bashed it into his typewriter) and the student guessed "SPECIAL". The script will return "spec" to the textbox because " I " is the first incorrect letter. It doesn't matter that the guess was entered in capitals because the script converts it to lowercase before doing any comparisons. When the student gets it right, an alert box pops up saying "You got it!". I'm sure I don't need to tell you, but this is a great way to get students to focus on spelling. Anyway, there's an example below. Have a play around with it until you get the feel of it. Clue: The word is a popular scripting language!
|