Using the shared action for tracking states, the check action for the Submit button is explained step-by-step in this post. Two situations: formula with 3 and formula with 4 terms.

# Intro

Review the output tutorial published in this post. The two first use cases were about a knowledge check question where the learner needs to create physics formulas, by clicking the terms in the formula. Those terms are multistate objects, used as buttons. In a previous post you created one shared action to get the ‘State number’ which is stored in an associated variable for each multistate object. That same post also explained how to choose the sequence of the states.

The first use case has 3 terms in the formula, the second one has 4 terms. The terms are identical multistate objects, at the start of the exercise they show the same Normal state.

In this article youi’ll see how to create the action for the Submit button, and the On Enter action which is needed to reset the slide and thus allow multiple visits to the slides.

# Submit actions

Those are advanced action triggered by the Success event of the Submit buttons.

## Formula with 3 terms

To the left of the equal sign the term should be ‘Force’, which is state 3 in the multistate object.

To the right of the equal sign we need ‘Pressure’ and ‘Area’, sequence is not important. Those are states 1 and 2. The easiest way is to calculate the sum of the two state numbers, which should be 3. To avoid confusion, create another user variable **v_right** to calculate the sum. The condition will be very simple: v_1 (state number to the left of the equal sign) needs to be equal to v_right. To show the result, another multistate object **SS_Feedback** was created with these three states:

This feedback shape is on the slide (not hidden) but the Normal state is invisible to the learner. I used the same feedback for the next slide (4 term formula) by timing it for the rest of the project. It will be hidden after the two formula slides.

The Submit action doesn’t need much explanation; I used the Delay command to mimick the default time a feedback is shown, allowing a new attempt:

## Formula with 4 terms

Due to the sequence of the states, a correct formula will also have the same sum to the left and to the right of the equal sign. Of course we need another user variable **v_left ** to store the sum to the left. However, checking the sums will not be sufficient in this case. If the learner chooses exactly the same states on both sides, the sums will also be the same. Example: if only the states for the ‘oval ‘are chose on both sides. To exclude that situation, I use another expression with a multiplication of the state numbers. For the result of the multiplication two extra user variables a; re defined: **v_leftM** and **v_rightM**

Example: if only ‘oval’ states are used sum will be: **5 = 2 + 3.** However the multiplication will result in **6 = 2 * 3**. Whereas for the drum the sum is **5 = 1 + 4 **but the multiplcation will result in **4 = 1 * 4. ** Look at the Submit action in this case:

# Enter actions (reset)

Those are advanced actions triggered by the On Enter event of the slides, to reset the situation.

## Formula with 3 terms

The 3 variables storing the state numbers need to be reset to their default value (1: corresponding with the Normal state). That is not necessary for the **v_right**, because it is always calculated. The option ‘Retain state on revisit slide’ is **not** activated, which means that on revisiting the slide the Normal state is reset automatically. The variable **v_states** needs to be redefined.

Since the multistate object SS_Feedback is timed for more than one slide, and can be hidden by actions on later slides, it is important to show this object and put it back in the Normal state. The automatic reset to the Normal state is not happening due to the timing. The Next button needs to be hidden.

## Formula with 4 terms

The 4 variables storing the state numbers need to be reset to their default value (1: corresponding with the Normal state). That is not necessary for **v_right**, **v_left, v_leftM** and **v_rightM **because they will be calculated. The option ‘Retain state on revisit slide’ is **not** activated, which means that on revisiting the slide the Normal state is reset automatically. The variable **v_states** needs to be redefined.

The resetting for the feedback object is for the same reason as in the other Formula slide.

# More?

The same workflow can be used in many different situations. I’ll post another sample project meant for maths exercises for primary school. Or what about language tests: grammar, vocabulary…

You must be logged in to post a comment.