Skip to content
Snippets Groups Projects
Commit c958c300 authored by Mariani Giacomo's avatar Mariani Giacomo
Browse files

remove_element updated

parent 01defcde
No related branches found
No related tags found
No related merge requests found
...@@ -495,10 +495,10 @@ let Content = { ...@@ -495,10 +495,10 @@ let Content = {
 <body>  <body>
  <div id="piano-keyboard">   <div id="piano-keyboard">
   <button type="button" value="C" style="width: 50px; height: 120px; padding: 2px;">C</button>    <button type="button" value="C" style="width: 50px; height: 120px; padding: 2px;">C</button>
   <button type="button" value="C#" style="width: 50px; height: 100px; background-color: #000;color: #FFFFFF; padding: 2px; line-height: 10;">C#</button>    <button type="button" value="C#" style="width: 50px; height: 100px; background-color: #000; color: #8C8A93; padding: 2px; line-height: 10;">C#</button>
   <button type="button" value="D♭" style="width: 50px; height: 100px; background-color: #000;color: #FFFFFF; padding: 2px; line-height: 10;">D♭</button>    <button type="button" value="D♭" style="width: 50px; height: 100px; background-color: #000; color: #8C8A93; padding: 2px; line-height: 10;">D♭</button>
   <button type="button" value="D" style="width: 50px; height: 120px; padding: 2px;">D</button>    <button type="button" value="D" style="width: 50px; height: 120px; padding: 2px;">D</button>
   <button type="button" value="D#" style="width: 50px; height: 100px; background-color: #000;color: #FFFFFF; padding: 2px; line-height: 10;">D#</button>    <button type="button" value="D#" style="width: 50px; height: 100px; background-color: #000; color: #8C8A93; padding: 2px; line-height: 10;">D#</button>
   <button type="button" value="E" style="width: 50px; height: 120px; padding: 2px;">E</button>    <button type="button" value="E" style="width: 50px; height: 120px; padding: 2px;">E</button>
  </div>   </div>
 </body>  </body>
...@@ -527,19 +527,34 @@ let Content = { ...@@ -527,19 +527,34 @@ let Content = {
}); });
document.body.appendChild(pianoDivInConf); document.body.appendChild(pianoDivInConf);
let returnedKeyboard = removePianoKey('D♭'); let returnedKeyBoard = removePianoKey('D♭');
let correctKeyRemoved = Object.values(returnedKeyBoard.childNodes).every(key => key.value !== 'D♭');
if (typeof(returnedKeyboard) === 'object') { const checkWithAllKeys = () => {
let returnedKeys = Object.values(returnedKeyboard.childNodes).map(item => item.value) ; display.cmd("Testing with other keys...");
display.res("Checking the keyboard keys...", returnedKeys); keys.splice(keys.findIndex(item => item === 'D♭'), 1);
return keys.map(item => {
return Object.values(removePianoKey(item).childNodes).map(key => key.value)
});
}
if (correctKeyRemoved) {
display.cmd("Correct key removed");
display.res("Checking the keyboard keys... Open the developer tools console to see the logs", checkWithAllKeys());
display.cmd("Hups, did we remove a bit too many keys... No problem");
} else { } else {
display.cmd("Did yuu return the keyboard div?") display.cmd("Did yuu remove the key using the keyValue parameter and returned the keyboard div?");
}`, }`,
executeAtStart: true, executeAtStart: true,
points: function ($element, config, accessor) { points: function ($element, config, accessor) {
let p = accessor.testResults(10, function(i , args, res) { let p = accessor.testResults(10, function(i , args, res) {
let correctKeys = ['C', 'C#', 'D', 'D#', 'E']; let correctKeys = ['C', 'C#', 'D', 'D#', 'E'];
let points = args.some((key, i) => key !== correctKeys[i])? 0 : config.maxPoints; console.log('Checking that the correct keys have been removed');
let points = args.every((item, i) => item.every(key => key !== correctKeys[i]))? 10 : 0;
if(points === 0) {
let wrongKeyboards = args.filter((item, i) => item.some(key => key === correctKeys[i]));
console.log('Some of the keyboards returned the wrong keys', wrongKeyboards);
}
return points; return points;
}); });
return { points: p }; return { points: p };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment