Page 2 of 2

Re: pgSoundLoader() for dummies

PostPosted: Wed Oct 08, 2014 5:06 pm
by Robert Stevenson
Any way of having a different .mp3 for "correct" and "incorrect"? I presume you would have to move to "on question scored"?

Re: pgSoundLoader() for dummies

PostPosted: Wed Oct 08, 2014 5:21 pm
by Clifton
For the on question scored event you would just have a "correct.mp3" or an "incorrect.mp3" for each question type. May have to append a page id or something if they vary from page to page. That way they can all be kept in a single folder to make referencing them easy.

On question scored
use pgSoundLoader() to play the file ...
score & "_" & name of this page & ".mp3"

The above string would resolve to something like:
"correct_question_1.mp3"
or
"incorrect_question_1.mp3"
(Note: avoid spaces in your page names if you do it like this)

Then for the url_playList parameter: "../sounds/" & score & "_" & name of this page & ".mp3"
This makes the selection of the sound file to play dynamic based on the value of score (either "correct" or "incorrect").

Re: pgSoundLoader() for dummies

PostPosted: Wed Oct 08, 2014 6:22 pm
by Robert Stevenson
I really do appreciate the time you spend educating us but that one just seems way over my head. There was a reason I titled this post "pgSoundLoader() for dummies ... Sure miss the good old days when you could just assign a clip.

Re: pgSoundLoader() for dummies

PostPosted: Wed Oct 08, 2014 6:37 pm
by Clifton
Let's take a look at this more closely.
First suppose we have variable called score and we have an action editor expression (name of this page).

If the name of a page is "page_1" then (name of this page) in the actions editor = "page_1"
In the actions editor the ampersand (&) symbol allows us to concatenate strings together to form new ones based on variables.
So for example:
(name of this page) & ".mp3" will equal the new string "page_1.mp3"

In your situation, you are trying to leverage the score variable to have your course decide which sound to play:
score & "_" & (name of this page) & ".mp3" will equal the new string (if a student answers correctly) "correct_page_1.mp3"

Once your wrap your head around concatenation, it is one of the most powerful ways to extend the actions editor to make intelligient decisions about what to do based on the interaction of users with your courses.

Re: pgSoundLoader() for dummies

PostPosted: Thu Oct 09, 2014 3:37 pm
by Robert Stevenson
Say what? I'm thinking you should re-design the old clip-editor so that it works to simply select an .mp3 from a list. Getting my head around the rest ... the school year would be done before I got the book to work. Such is the nature of education that I usually need these things working within 48 hours. Can't imagine having to apply audio feedback to 120 multiple choice questions.

Re: pgSoundLoader() for dummies

PostPosted: Thu Oct 09, 2014 4:19 pm
by Clifton
If you look closely at the method, you can use the exact same code for every page and every question in your book. Never make a modification, just let the code decide which clip to play. Your only concern would be to create the clips. If you only have a correct and incorrect clip, then skip the (name of page) part of the concatenation and just use ...

url_playList = score & ".mp3"
Depending on the score of the question, this concatenation will resolve to either:
url_playList = "correct.mp3"
url_playList = "incorrect.mp3"

Just extend the code to include your path to the sounds folder and you've got everything you need to million questions.
url_playList = "../sounds/" & score & ".mp3"

The actions editor has permitted concatenation for a long time so we are not really doing anything new, just taking what's been around for a while and making it do some very productive things. If you send a single page of your quiz, I will mock it up so you can see how incredibly easy this is.

Think of the ampersand as glue that is used to stick together multiple strings or variables that contain strings.