helper.getSquizQuestion
Prototype
function getSquizQuestion(category, difficulty)
Input parameters
category - the category of the question (0-4)
difficulty - the difficulty of the question (0-2)
Return value
An object with a random question
Description
Used to retrieve a random question from the Squiz database. Squiz contains many thousands of trivia questions created and moderated by Spogg.com members.
Possible question categories are SQUIZ_CATEGORY_SCIENCE, SQUIZ_CATEGORY_CULTURE, SQUIZ_CATEGORY_SPORTS, SQUIZ_CATEGORY_GEOGRAPHY and SQUIZ_CATEGORY_HISTORY. You can use a random integer value between 0 and 4 to select a random question category. Questions are sorted automatically by difficulty depending on how players have answered the questions. You can select three different levels; SQUIZ_QUESTION_EASY, SQUIZ_QUESTION_MEDIUM, SQUIZ_QUESTION_HARD. If you want a random leveled question, use a random integer between 0 and 2.
The Squiz API will return an associative array with a random question and answer options:
question.question - a random question from the Squiz database
question.answers[0] - answer option 0
question.answers[1] - answer option 1
question.answers[2] - answer option 2
question.answers[3] - answer option 3
question.correctAnswer - number of correct answer
question.category - question category
question.difficulty - difficulty of question
question.added_by - user name of member who added the question
question.id - id of question (normally not used)
Example code
var question = getSquizQuestion(SQUIZ_CATEGORY_SCIENCE,
SQUIZ_QUESTION_MEDIUM);
trace("Random question: "+question.question);
