I’m having one problem. When I put in the real data in place of the mock data. For example:
var vStepAnswer = scoreData.staves[0].measures[0].noteSets[0].notes[0].step;
var wStepAnswer = scoreData.staves[1].measures[0].noteSets[0].notes[0].step;
var xStepAnswer = scoreData.staves[2].measures[0].noteSets[0].notes[0].step;
in place of the mock data:
var vStepAnswer = "2" /// mock of the step feed back
var wStepAnswer = "5" /// mock of the step feed back
var xStepAnswer = "6"/// mock of the step feed back
No matter what numbers the real data returns I’m always getting the “All wrong” response. I’ve tried plugging in the mock variable again and it works fine. I’ve tried editing the answer key to different correct responses but that hasn’t changed anything.
window.scoreView.getScore().done(function(scoreData) {
var vStepAnswer = scoreData.staves[0].measures[0].noteSets[0].notes[0].step;
var wStepAnswer = scoreData.staves[1].measures[0].noteSets[0].notes[0].step;
var xStepAnswer = scoreData.staves[2].measures[0].noteSets[0].notes[0].step;
var stepKeysAnswers = [['vAnswer',vStepAnswer,"E"],['wAnswer',wStepAnswer,"F"],['xAnswer',xStepAnswer,"D"]]// we put the feed back answers in arrays with the correct answer key name.
var correctAnswers = {vAnswer:["2" , "4", "0"],wAnswer:["3","5","1"],xAnswer:[ "1","3","6"] } //-- all correct answers
var answerCheckIncorrect = []; //-- final array to hold the false results below.
for (i = 0; i < stepKeysAnswers.length; i++) {
//-- we iterate over each setp answer array and work through each answer using the key and feed back answer for that key
var thisIsCorrect = correctAnswers[stepKeysAnswers[i][0]].includes(stepKeysAnswers[i][1]) //- i.e correctAnswers[wAnswer].includes(4)
// push the true or false result to the answerCheck array.
if (!thisIsCorrect){
answerCheckIncorrect.push(stepKeysAnswers[i]);
}
}
//console.log(answerCheckIncorrect);
//-- All Correct
if (answerCheckIncorrect.length == 0 ){
hypeDocument.getElementById("feedback6").innerHTML = "Great job! You have successfully entered a consonant note for each of the violin notes.";
hypeDocument.getElementById("feedback6").style.color = "#008F00";
hypeDocument.getElementById("feedback6").style.borderLeft = "6px solid green";
hypeDocument.getElementById("check4").innerHTML = "Play Again!";
return;
}
//-- One wrong
if (answerCheckIncorrect.length == 1 ){
hypeDocument.getElementById("feedback6").innerHTML = "The note you entered above '" + answerCheckIncorrect[0][2] + "' is incorrect. The other notes are all correct. Try again!";
hypeDocument.getElementById("feedback6").style.color = "red";
hypeDocument.getElementById("feedback6").style.borderLeft = "6px solid red";
hypeDocument.getElementById("check4").innerHTML = "Check Again!";
return;
}
//-- All wrong
if (answerCheckIncorrect.length == stepKeysAnswers.length ){
hypeDocument.getElementById("feedback6").innerHTML = "Try again! All of the notes you've entered are incorrect. ";
hypeDocument.getElementById("feedback6").style.color = "red";
hypeDocument.getElementById("feedback6").style.borderLeft = "6px solid red";
hypeDocument.getElementById("check4").innerHTML = "Check Again!";
return;
}
//-- some wrong.
var theNoticeString = ""
for (i = 0; i < answerCheckIncorrect.length; i++) {
theNoticeString += "'" + answerCheckIncorrect[i][2] + "' , " ;
}
theNoticeString = "The notes you entered above " + theNoticeString + " are wrong, The other notes are all correct. Try again!";
hypeDocument.getElementById("feedback6").innerHTML = theNoticeString;
hypeDocument.getElementById("feedback6").style.color = "red";
hypeDocument.getElementById("feedback6").style.borderLeft = "6px solid red";
hypeDocument.getElementById("check4").innerHTML = "Check Again!";
});
Though this latest one is not listed here, interested folks can see a preview of the way we are using Hype to build a progressive music composition curriculum used by teachers throughout the US and beyond here: YCIW Preview
@MarkHunte I’m having one issue with this that I can’t seem to figure out. As mentioned above the code is working wonderfully.
However, how can I implement a wrong answer if two of three or three of the same correct answers are entered. In other words let’s that we had var correctAnswers = {vAnswer:[1, 3, 5],wAnswer:[1,3,5],xAnswer:[1,3,5] } //-- all correct answers
If 1 were entered as the answer for vAnswer it could not be used as a correct answer for wAnswer or x Answer.
var vStepAnswer = 1 /// mock of the step feed back
var wStepAnswer = 1 /// mock of the step feed back
var xStepAnswer = 6/// mock of the step feed back
and
var correctAnswers = {vAnswer:[1, 3, 5],wAnswer:[1,3,5],xAnswer:[ 1,3,5] } //-- all correct answers
will give you
The note you entered above ‘D’ is incorrect. The other notes are all correct. Try again!
and for
var vStepAnswer = 1 /// mock of the step feed back
var wStepAnswer = 2 /// mock of the step feed back
var xStepAnswer = 6/// mock of the step feed bac
The notes you entered above ‘F’ , ‘D’ , are wrong, The other notes are all correct. Try again!
So a user could enter
var vStepAnswer = 1 /// mock of the step feed back
var wStepAnswer = 1 /// mock of the step feed back
var xStepAnswer = 1/// mock of the step feed back
… and currently the result would be: “Great job! You have entered all of the correct notes.” These answers are all possible correct answers. However, for the solution to be deemed correct the user must enter all 3 of the correct answers without repeating any. Like this:
var vStepAnswer = 1 /// mock of the step feed back
var wStepAnswer = 3 /// mock of the step feed back
var xStepAnswer = 5/// mock of the step feed back
It does not matter which answer holds the 1, 3 or 5 but they must all be entered.
So you mean that they must enter all 3 numbers for each answer rather than just get 1 number for each answer correct.
i.e
They need to enter 1,6 and 2 for the single correct answer [1,6 ,2] if they enter 1,6,4 then the answer is wrong.
If this is right I will assume you already have code to put the feedback into an array for each answer.
i.e feed back =
var vStepAnswer = [2 , 4, 0] /// mock of the step feed back
Not exactly. There are three different correct answers to be placed in 3 different places. It does not matter in which place they put a correct answer but they must include all 3 different correct answers and not repeat any of them.
Yes, I have put the feedback into an array for each answer, for example
var vStepAnswer = [1,3,5]
and there are 3 variables like:
var vStepAnswer = [1,3,5]
var wStepAnswer = [1,3,5]
var xStepAnswer = [1,3,5]
0I am hope it does then I would look at just concatenating the numbers into a single answer..
i.e [1,3,5] goes concatenated to 135, which would be easier to compare.
Like this.
var vStepAnswer = [2 , 4, 0].join("") /// mock of the step feed back
var wStepAnswer = [3,5 ,1].join("") /// mock of the step feed back
var xStepAnswer = [ 1,3,6].join("") /// mock of the step feed back
var stepKeysAnswers = [['vAnswer',vStepAnswer,"E"],['wAnswer',wStepAnswer,"F"],['xAnswer',xStepAnswer,"D"]]// we put the feed back answers in arrays with the correct answer key name.
var correctAnswers = {vAnswer:["240"],wAnswer:["351"],xAnswer:[ "136"] } //-- all correct answers
var vStepAnswer = [2 , 4, 1].sort().join("") /// mock of the step feed back
var wStepAnswer = [3,5 ,1].sort().join("") /// mock of the step feed back
var xStepAnswer = [ 1,3,6].sort().join("") /// mock of the step feed back
var stepKeysAnswers = [['vAnswer',vStepAnswer,"E"],['wAnswer',wStepAnswer,"F"],['xAnswer',xStepAnswer,"D"]]// we put the feed back answers in arrays with the correct answer key name.
var correctAnswers = {vAnswer:["124"],wAnswer:["135"],xAnswer:[ "136"] } //-- all correct answers
var answerCheckIncorrect = []; //-- final array to hold the false results below.
Would have to play with the sort if you wanted double digits and anything past 9,
The sort (in this case ) orders the numbers by greater value.
var vStepAnswer = [2 , 4, 1].sort().join("")
--> "124"
The ones in the correctAnswers would need to match that.
i.e 1 through 9 left to right.
Also you could have the code run on individual answer/feedback and store if correct or not for later when all answers are ready to be displayed
Thanks @MarkHunte I’m not able to get this to work and I think it might be because I’m placing the .sort().join in the wrong place or not doing the correct things with it.
My original code was this:
window.scoreView.getScore().done(function(scoreData) {
var vStepAnswer = scoreData.staves[0].measures[0].noteSets[0].notes[0].step;
var wStepAnswer = scoreData.staves[1].measures[0].noteSets[0].notes[0].step;
var xStepAnswer = scoreData.staves[2].measures[0].noteSets[0].notes[0].step;
var stepKeysAnswers = [['vAnswer',vStepAnswer,"Clarinet"],['wAnswer',wStepAnswer,"Trumpet"],['xAnswer',xStepAnswer,"Violin"]]// we put the feed back answers in arrays with the correct answer key name.
var correctAnswers = {vAnswer:[1,3,5],wAnswer:[1,3,5],xAnswer:[1,3,5] } //-- all correct answers
var answerCheckIncorrect = []; //-- final array to hold the false results below.
for (i = 0; i < stepKeysAnswers.length; i++) {
//-- we iterate over each setp answer array and work through each answer using the key and feed back answer for that key
var thisIsCorrect = correctAnswers[stepKeysAnswers[i][0]].includes(stepKeysAnswers[i][1]) //- i.e correctAnswers[wAnswer].includes(4)
// push the true or false result to the answerCheck array.
if (!thisIsCorrect){
answerCheckIncorrect.push(stepKeysAnswers[i]);
}
}
//console.log(answerCheckIncorrect);
//-- All Correct
if (answerCheckIncorrect.length == 0 ){
hypeDocument.getElementById("feedback6").innerHTML = "Great job! You have entered the notes D, F and A. These are the notes of D minor which is the ii chord.";
hypeDocument.getElementById("feedback6").style.color = "#008F00";
hypeDocument.getElementById("feedback6").style.borderLeft = "6px solid green";
hypeDocument.getElementById("check4").innerHTML = "Play Again!";
window.scoreView.playFromMeasure(0);
window.scoreView.addEventListener('playbackStop', function(event) {
hypeDocument.getElementById('next7').style.display="block";
});
return;
}
//-- One wrong
if (answerCheckIncorrect.length == 1 ){
hypeDocument.getElementById("feedback6").innerHTML = "The note in the " + answerCheckIncorrect[0][2] + " is incorrect. The other notes are all correct. Try again!";
hypeDocument.getElementById("feedback6").style.color = "red";
hypeDocument.getElementById("feedback6").style.borderLeft = "6px solid red";
hypeDocument.getElementById("check4").innerHTML = "Check Again!";
return;
}
//-- All wrong
if (answerCheckIncorrect.length == stepKeysAnswers.length ){
hypeDocument.getElementById("feedback6").innerHTML = "Try again! All of the notes you've entered are incorrect. ";
hypeDocument.getElementById("feedback6").style.color = "red";
hypeDocument.getElementById("feedback6").style.borderLeft = "6px solid red";
hypeDocument.getElementById("check4").innerHTML = "Check Again!";
return;
}
//-- some wrong.
var theNoticeString = ""
for (i = 0; i < answerCheckIncorrect.length; i++) {
theNoticeString += " " + answerCheckIncorrect[i][2] + ", " ;
}
theNoticeString = "The notes you've entered in the " + theNoticeString + " are wrong. The other note is correct. Try again!";
hypeDocument.getElementById("feedback6").innerHTML = theNoticeString;
hypeDocument.getElementById("feedback6").style.color = "red";
hypeDocument.getElementById("feedback6").style.borderLeft = "6px solid red";
hypeDocument.getElementById("check4").innerHTML = "Check Again!";
});
score5.focus();
I’ve tried to incorporate your suggestion as in below but it does not return any results.
var vStepAnswer = scoreData.staves[0].measures[0].noteSets[0].notes[0].step.join("");
var wStepAnswer = scoreData.staves[1].measures[0].noteSets[0].notes[0].step.join("");
var xStepAnswer = scoreData.staves[2].measures[0].noteSets[0].notes[0].step.join("");
var stepKeysAnswers = [['vAnswer',vStepAnswer,"E"],['wAnswer',wStepAnswer,"F"],['xAnswer',xStepAnswer,"D"]]// we put the feed back answers in arrays with the correct answer key name.
var correctAnswers = {vAnswer:["135"],wAnswer:["135"],xAnswer:[ "135"] } //-- all correct answers