Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Allow button to only play audio twice

New Here ,
Apr 05, 2016 Apr 05, 2016

I'm building a foreign language assessment with audio passages that the user must listen to then answer two questions about it. The user can only play the audio twice. But even if I put 2 in the No. of Attempts, when I tested it I was able to play the audio unlimited times. What's the trick?

play audio only twice.jpg

682
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Apr 06, 2016 Apr 06, 2016

You seem to misunderstand 'attempts' for an interactive object, will try to clarify. It is not limiting the number of clicks ON the interactive object (here a button) but telling how many attempts can be 'failed', which means clicking OUTSIDE of the object. For your use case the Failure action will never happen, because the user always clicks on the button, never outside of it. Same with the Continue project which you left for the Failure action: never happens.

For the Success action you use the

...
Translate
People's Champ ,
Apr 05, 2016 Apr 05, 2016

Create an advanced action to play audio and disable the button.

P.S. The first "question" is really a statement.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 06, 2016 Apr 06, 2016

You seem to misunderstand 'attempts' for an interactive object, will try to clarify. It is not limiting the number of clicks ON the interactive object (here a button) but telling how many attempts can be 'failed', which means clicking OUTSIDE of the object. For your use case the Failure action will never happen, because the user always clicks on the button, never outside of it. Same with the Continue project which you left for the Failure action: never happens.

For the Success action you use the Play Audio command, with Continue project unchecked: this means that the user can click multiple times, the playhead is never released and the audio can be played as many times as you want. The solution is indeed to use a conditional advanced action (not a standard action because you want to allow 2 attempts, sorry David - TLCMediaDesign) and a counter variable. These are the steps:

  • Define a user variable v_attempts with a default value of 2
  • Create an advanced action to be triggered by the button that will look like this:

TwiceAudio.png

It is always safer to disable the button before hiding it. Or you could just keep the Disable. This action also allows you to show the attempts left in a text container:

  1. Before first click: v_counter = 2
  2. After first click: v_counter = 1
  3. After second click: v_counter = 0   and since there is no longer possible to click, it will remain = 0; this is important because CP is not very maths minded, doesn't see the difference between a negative and a positive number.

It is also very easy to change the number of attempts by just editing the default value. Think this will be one of the (easy) scripts in my future actions cookbook. Tnx for the question.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 10, 2016 Apr 10, 2016

Thank you--it works great!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 11, 2016 Apr 11, 2016

Was pretty sure it worked, created a file to check the action.

You can find more use cases and tips for advanced/shared actions on my blog:

http://blog.lilybiri.com

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 12, 2016 Apr 12, 2016

Well, now I need it to play the audio in its entirety twice. Someone with a trigger finger could inadvertently click twice and not hear the full audio recording twice.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 13, 2016 Apr 13, 2016
LATEST

That will be more complicated, because you have to disable the button until the audio clip finishes. Have a look at this thread:

Can you add an event listener to triggered audio?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources