Quiz (beta)
This subobject enables the Stagecast quizzes in your Moment
Introduction
If you are implementing a Quiz, you can take advantage of the quiz API:s. These offer a set of utilities to create users, fetch and answer questions and see the top results. You can also hand out prizes (see Prize (beta)).
To enable the quiz in your WebApp you have to add the quiz
plugin to the list of plugins in your manifest.json
.
API Docs
setContext(quizId:string): Promise<Quiz>
setContext(quizId:string): Promise<Quiz>
This is the first function you should call in order to initialize the quiz service. All the following calls will not require the quizId.
Params
quizId
: the id of the quiz to be fetched; You will find the quizId in the SDK config params.
getQuiz(): Promise<Quiz>
getQuiz(): Promise<Quiz>
getQuestion(id): Promise<Question>
(id): Promise<Question>
Params
id
: the question id;
Make sure to load the question when you need it. This is important as the backend computes the points based on the question fetch timestamp.
answerQuestion(questionHash, answer): Promise<AnswerScore>
(questionHash, answer): Promise<AnswerScore>
Params
questionHash: string
: the id of the content to be fetched;answer: number
: if the content should be compressed or full size.
getTopScores(offset?, limit?): Promise<
TopScores>
(offset?, limit?): Promise<
TopScores>
Params
offset
: the starting position;limit
: the number of positions to be fetched.
getUserScores(): Promise<LeaderboardEntry>
(): Promise<LeaderboardEntry>
getUserProfile(): Promise<Profile>
(): Promise<Profile>
It fetches the user profile information
setUserProfile(profile): Promise<Profile>
(profile): Promise<Profile>
Allow to set the user display information. Generally used to set the user name.
playNewRound(): Promise<Profile>
(): Promise<Profile>
This function allows a user to play another round of a quiz. It's points
are set to 0.
This call should be made BEFORE the round gets played. This call will unlock the n questions a round allows.
Last updated