Picture of Dan Jonsson
Re: Audio Extension
by Dan Jonsson - Monday, 29 May 2017, 8:19 AM
 

There are two different notify handlebar files. One in the core and one in themes.
And could you help with were to place the "{{> audio-controls feedbackAudio}}" in the notify.hbs

 

I have modifyed QuestionView.js file with this:

setupCorrectFeedback: function() {
this.model.set({
feedbackAudio: this.model.get("_feedbackAudio") ? this.model.get("_feedbackAudio").correct : {}
});
return this.model.setupCorrectFeedback();
},

setupPartlyCorrectFeedback: function() {
if (this.model.get('_attemptsLeft') === 0 || !this.model.get('_feedback')._partlyCorrect.notFinal) {
this.model.set({
feedbackAudio: this.model.get("_feedbackAudio") ? this.model.get("_feedbackAudio")._partlyCorrect.final : {}
});
} else {
this.model.set({
feedbackAudio: this.model.get("_feedbackAudio") ? this.model.get("_feedbackAudio")._partlyCorrect.notFinal : {}
});
}
return this.model.setupPartlyCorrectFeedback();
},

setupIncorrectFeedback: function() {
if (this.model.get('_attemptsLeft') === 0 || !this.model.get('_feedback')._incorrect.notFinal) {
this.model.set({
feedbackAudio: this.model.get("_feedbackAudio") ? this.model.get("_feedbackAudio")._incorrect.final : {}
});
} else {
this.model.set({
feedbackAudio: this.model.get("_feedbackAudio") ? this.model.get("_feedbackAudio")._incorrect.notFinal : {}
});
}
return this.model.setupIncorrectFeedback();
},

 

Modifyed the components json with this:

"_items": [
{
"text": "1. Ämnen och föremål som är bristfälligt förpackade.",
"_shouldBeSelected": false
},
{
"text": "X. Ämnen och föremål som kan orsaka skador på liv, hälsa och egendom om de hanteras fel under transport.",
"_shouldBeSelected": true
},
{
"text": "2. Gods som är explosivt i kontakt med syre.",
"_shouldBeSelected": false
}
],
"_feedback": {
"correct": "Rätt svar!",
"_incorrect": {
"final": "Fel svar, Försök igen!"
}
},
"_feedbackAudio":{
"correct":{
"_audio": {
"mp3": "course/en/audio/01_02_05_00_Ovning_2_Farligt_gods_RATT.mp3"
}
},
"_incorrect": {
"final": {
"_audio": {
"mp3": "course/en/audio/01_02_05_00_Ovning_2_Farligt_gods_FEL.mp3"
}
}
},
"_partlyCorrect": {
"final": {
"_audio": {
"mp3": "course/en/audio/01_02_05_00_Ovning_2_Farligt_gods_FEL.mp3"
}
}
}
},
"_pageLevelProgress": {
"_isEnabled": true
}
},

 

What do you think!

 

D

Picture of Matt Leathes
Re: Audio Extension
by Matt Leathes - Monday, 5 June 2017, 3:11 PM
 

Hi Dan

You need to modify the one in the theme.

Sorry for the confusion from having two sets of handlebars templates. It's something we are aware of and have fixed with the release of vanilla v2.1.0 - now they only exist in core - but if you want to modify one it's still good practice to copy it to the theme first as this is a good way of indicating that it has been modified.

As to where in the notify.hbs you should put that code snippet - it really depends on where you want the audio control within the HTML order of notify. For example, if you'd like the audio control to be before the title, insert that snippet before the {{#if title}} expression.

Looking at your changes to questionView... I'm not 100% they will work, it's hard to know without actually setting all this up for myself. I think you'd actually be better off modifying the same functions in questionModel.js (I'm assuming you're using Adapt 2.0.10 or better) as that's where they now live (the functions that remain in questionView are there mainly for backwards compatibility I think)... you just to make sure you change this.model.set to just this.set... I've updated the relevant part of the README in line with this.

Picture of Dan Jonsson
Re: Audio Extension
by Dan Jonsson - Wednesday, 7 June 2017, 8:24 AM
 

Hi Matt

I´m using the 2.0.5 version of Adapt perhaps this is the reason I can´t get this to work!

I mean I have followed your new instructions with no success!

I made modifications to components.json, notify.hbs and questionModel.js

I got the {{> audio-controls this}} to work but not {{> audio-controls feedbackAudio}}.

 

D

Picture of Matt Leathes
Re: Audio Extension
by Matt Leathes - Wednesday, 7 June 2017, 10:23 AM
 

Hi Dan

I'm confused - you say you're using Adapt v2.0.5 but then go on to say you modified questionModel.js - which doesn't exist in that version of Adapt...

Picture of Dan Jonsson
Re: Audio Extension
by Dan Jonsson - Wednesday, 7 June 2017, 1:04 PM
 

It does in my version! 

D

 

Picture of Dan Jonsson
Re: Audio Extension
by Dan Jonsson - Wednesday, 7 June 2017, 1:19 PM
 

I downloaded the zip framework version and reinstalled.

Now I got a clean version of adapt and there is the questionModel.js!

The only new file is the itemsModel.js

 

D

Picture of Dan Jonsson
Re: Audio Extension
by Dan Jonsson - Thursday, 22 June 2017, 12:45 PM
 

Hi Matt hope you get some time in the near future to test this out. 

Please let me know when you done and if you got it to work.

It´s the feedback section I have trouble with!

Best Dan

Picture of Matt Leathes
Re: Audio Extension
by Matt Leathes - Saturday, 24 June 2017, 9:23 PM
 

Yeah OK not surprising you struggled with this, the instructions were still very out of date - there were some modifications that needed to be made to notifyView.js and adapt-contrib-tutor.js in order to make it all work.

Try the attached where I've amended the first MCQ in the questions component topic to have feedback audio. Note that I haven't actually included any mp3 files so you'll just get a 404 error when you try to play the audio.

If you want to see what I changed use a tool like WinMerge to compare the src folder to that of a fresh copy of Adapt.

I've updated the instructions as well.

Quite frankly the whole thing needs a re-write but, like I say, it's not something we've have any need to use since Adapt v2 was released so it's not a high (or even medium!) priority for us.

Picture of Dan Jonsson
Re: Audio Extension
by Dan Jonsson - Monday, 26 June 2017, 9:21 AM
 

Great! Thanks for the help!

It works as expected, so far!

What do you mean by " it's not something we've have any need to use since Adapt v2 was released "?

I can´t find any good way to handel audio in Adapt v2 or have I missed something?

 

Thanks!

Dan/

 

 

Picture of Matt Leathes
Re: Audio Extension
by Matt Leathes - Monday, 26 June 2017, 10:17 AM
 
What do you mean by " it's not something we've have any need to use since Adapt v2 was released "?

I mean that 'we' (as in Kineo, the company who created the adapt-audio extension) have not used this extension since sometime in 2014 which was when Adapt was still at v1 stage.

Picture of Dan Jonsson
Re: Audio Extension
by Dan Jonsson - Monday, 26 June 2017, 11:49 AM
 

Ok, then I get it!

Thanks!

D