Follow

Try Again - Knowledge Base

A guide to setting up the Try Again functionality for Questions API and Assess API.

What is the Try Again functionality?

Try Again allows students to ask for another set of data for the Question they are attempting. In this case, they can click the Try Again button, and they will be given the same format of Question again, but with different values, which requires a different answer (it could be any part of the Question). The dataset of Question variations uses the existing Dynamic Content functionality.

 

Animation showing different question values after pressing the Try Again button

Figure 1: How selecting Try Again changes data in the current Question

Integration overview

Try Again can be added to Questions with Dynamic Content.

The integration steps will generally run as follows:

  1. Content authors will add Question variations as data to a dataset in the Item. Then, they will add the relevant variables to the Question content.
  2. Developers will add the Try Again functionality to the interface and set the initialization parameters to gain the desired behaviour.

Note Try Again can be used out of the box as a button, or it can be configured as a custom button using the Try Again public method.

 

Setting initialization options

You need to use Items API, as it will generate the dynamic data and add it to the Question JSON of each Question.

Items API initialization

initObj: {
    "dynamic_items": {
        "data_table_seed" => "SOME_SEED", // optional
        "try_again": {
            "max_attempts" => 5, // required, max 10
            "random" => true // optional, false default
        }
    }
}

Code example: Items API initialization

 

For the initObj object, we have two variables of interest, dynamic_items and try_again.

For the try_again variable, max_attempts is a required variable that sets the number of times the user can click Try Again. The maximum number of tries that can be specified is ten.

For the dynamic_items element, we can set the sub-element try_again: random element to to true. This will cause to the user to be given a randomised sequence of data rows when clicking Try Again.

 

Variable Type Default Required? Description
try_again: max_attempts integer If the number of dataset rows is less than the defined max_attempts, then that Item will will use the number of rows available. Yes Sets the number of times the user can click Try Again. Dataset rows are processed sequentially by default.
try_again: random boolean false No Changes the initial loading of data rows from the original author dataset to be random (when true). This controls how the data from the dataset is captured and brought down to the page.
data_table_seed string If not defined, the random seed will use the value of the current session_id. No A randomising seed that will be used to generate a sequence of data rows given to students clicking Try Again.
Table: variables specified in the Items API initialization object

 

Note When using Try Again random: if you have 50 rows in your data set and you have random: false you have, for example, max_attempts set to 7, then only the first 7 of the 50 rows of the data set are captured and rendered for the users. If random is set to false, there is no reason to add any more rows to the data set at authoring time. If random is set to true, then any user can get any seven rows from the dataset and not necessarily the same rows. A seed of the rows in each session is stored, so that they can be restored in resume mode.

Public methods

Some public methods are provided to allow creation of custom navigation buttons for Try Again.

Assess API public methods

These public methods for Assess API can be used to create custom navigation to work with the Try Again button.

 

assessApp.item('ITEM_REF').dynamic.previousAttempt();
assessApp.item('ITEM_REF').dynamic.nextAttempt();
assessApp.item('ITEM_REF').dynamic.currentAttemptIndex();
assessApp.item('ITEM_REF').dynamic.totalAttempts(); 

Code example: Assess API public methods for Try Again

 

In the example above, ITEM_REF refers to the unique reference for the Item in context, with the Question that the student is answering.

 

Method Description
previousAttempt() Load the previous attempt data row.
nextAttempt() Load the next attempt data row.
currentAttemptIndex() Returns the index of the current attempt.
totalAttempts() Count the total number of attempts so far.
Table: public methods for building custom navigation with Try Again in Assess API

 

Assess API event listener

An event listener is provided that can be used to trigger your own functions.

assessApp.on('dynamic:item:changed', function () { // Do something });

Code example: listening for an event when a dynamic Item is changed

 

Choosing a region for the Try Again button

To show the Try Again button on screen, it has to be added to a region in Assess API. See the Assess API documentation for more information on region configuration.

Questions API public methods

These public methods for Questions API can be used to create custom navigation to work with the Try Again button.

 

questionApp.question('QUESTION_REF').dynamic.previousAttempt();
questionApp.question('QUESTION_REF').dynamic.nextAttempt();
questionApp.question('QUESTION_REF').dynamic.currentAttemptIndex();
questionApp.question('QUESTION_REF').dynamic.totalAttempts();

Code example: Questions API public methods

 

In the example above, QUESTION_REF refers to the unique reference for the Question in context that the student is answering.

 

Method Description
previousAttempt() Load the previous attempt data row.
nextAttempt() Load the next attempt data row.
currentAttemptIndex() Returns the index of the current attempt.
totalAttempts() Count the total number of attempts so far.
Table: public methods for building custom navigation with Try Again in Questions API

 

Next Steps

The above example demonstrates how to set up the Try Again button for Items and assessments with Dynamic Content. For more information, see the documentation for Items API initialization options and public methods, and the Author Site documentation for Dynamic Content.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments