Scoring in Task Builder 2 and Game Builder allows you to control whether a response should be considered correct or incorrect. The built-in scoring components Scorer and Scorer Multi work on the basis of simply matching the given response with a particular string (or one of a list of strings).
But what if you wanted to write your own scoring logic? Perhaps you're collecting numeric responses, and want to mark something as correct if it's above or below a certain value, or within a certain range. Or maybe you want to tie the correct answer to the time of day - some responses are correct in the morning but incorrect in the afternoon. For any of these types of scenarios, you can create your own scorer.
Start by creating a new component with the Screen Component template:
You can now implement your logic in the scoreResponse()
lifecycle method:
The response
object that is passed in contains lots of information about the response that is being processed. You can find a full reference of all the properties here:
For a worked example of a new scoring component see our Custom Scoring Example.