Elements Choose

Choose is used for the conditional execution of actions.

The example is a Block that contains a multiple choice question. If the user clicks the Option button during the playback of correct choice (between 45 and 53 seconds in the audio track), the "CorrectChoice" flag will record that they answered correctly. The OnFinish event handler will tell them whether they answered correctly.

<File Href="question23.mp3" Class="Question">
     <OnFinish>
         <ActionSet>
             <Choose>
                 <When>
                     <ValueTest>
                         <Eq>
                             <GetValue Name="CorrectChoice"/>
                             <Value>1</Value>
                          </Eq>
                      </ValueTest>
                      <PushStack>
                          <Location Class="Question" Target="Next"/>
                       </PushStack>
                      <Goto>
                           <Location Ref="YouAreCorrect"/>
                      </Goto>
                 </When>
                 <Otherwise>
                     <PushStack>
                          <Location Class="Question" Target="Next"/>
                      </PushStack>
                      <Goto>
                          <Location Ref="ImSorryThatIsNotCorrect"/>
                       </Goto>
                   </Otherwise>
               </Choose>
           </ActionSet>
     </OnFinish>
     <Block Offset="45000" Length="8000">
          <OnButton Button="Option1" Action="Release">
                <ActionSet>
                     <SetValue Name="CorrectChoice">
                         <Value>1</Value>
                     </SetValue>
                </ActionSet>
          <OnButton>
     </Block>
</File>