I can´t figure out how this is implemented in existing components.
This is implemented in the .hbs file:
{{> audio-controls this}}
but how and were?
D
I can´t figure out how this is implemented in existing components.
This is implemented in the .hbs file:
{{> audio-controls this}}
but how and were?
D
You need to add that to the handlebars template (.hbs) of any component you need to be able to implement audio.
You will also need to modify the JavaScript code of each component that you want to implement audio.
This is NOT a simple extension to implement... here be dragons, as the saying goes.
I would strongly suggest you carefully read through the README first and make a decision based on how well you understand that as to whether this is something you proceed with or not...
Hi Dan
Check out and tell me if this example works for you, and i will try to help you explaining my solution
Hi I now got it all to work on the component level.
But now the problems with the feedbackpart starts.
The desciption on how to use the feedbackaudiopart isn´t relevant anymore!
I think that it had a major structure change. For instance there isn´t any tutor.hbs,
I think it has been replaced by the notify.hbs. Is there any here that got it all to work?
I have tried several way to go but with no luck.
D
I think it has been replaced by the notify.hbs
Yes it has. You should be able to modify notify.hbs in the same way you would have done for tutor.hbs
I have tried several way to go but with no luck.
What exactly did you try?
To the best of my knowledge we haven't used this extension in a couple of years so apologies for the documentation not being up to date.
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
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.
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
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...
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
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.
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/