Last active
March 30, 2020 06:13
-
-
Save developerfromjokela/78f5e4ac2236f227c947d686a16370ab to your computer and use it in GitHub Desktop.
Skripti pöllii Otavan digitehtävistä oikean vastauksen ja printtaa sen consoleen. Käyttöohjeet alempana
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Jos ei pyöri tehtäväsivulla, se avataan. | |
if (document.getElementsByTagName("iframe").length > 0) { | |
var frame = document.getElementsByTagName("iframe")[0]; | |
var id = frame.id; | |
if (id.includes("UbilabsContentPortlet_frame")) { | |
alert("Sinulle avataan uusi välilehti, johon tämä tehtävä tehdään. Liitä tämä koodi uudelleen, jotta vastaukset tulevat esiin."); | |
window.open(frame.src, '_blank'); | |
} else { | |
runCheat(); | |
} | |
} else | |
runCheat(); | |
function runCheat() { | |
var source = _aikistaskgeneric_WAR_aikistaskportlet_INSTANCE_mkH2_structure; | |
var questions = source.questions; | |
questions.forEach(function(item) { | |
console.log("Tehtävä "+item.name); | |
console.log("Tyyppi: "+item.checkType); | |
if (item.checkType === "choice") { | |
var sections = item.sections; | |
sections.forEach(function(section) { | |
console.log("Kysymys "+section.id); | |
var choices = section.choices; | |
var found = false; | |
choices.forEach(function(choice) { | |
if (choice.points > 0) { | |
found = true; | |
console.log("Oikea vastaus: "+choice.name); | |
} | |
}); | |
if (!found) | |
console.log("Tälle kysymykselle ei löytynyt vastausta") | |
}); | |
} else { | |
console.log("Valitettavasti tätä tehtävää ei tueta."); | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(document.getElementsByTagName("iframe").length>0){var frame=document.getElementsByTagName("iframe")[0],id=frame.id;id.includes("UbilabsContentPortlet_frame")?(alert("Sinulle avataan uusi välilehti, johon tämä tehtävä tehdään. Liitä tämä koodi uudelleen, jotta vastaukset tulevat esiin."),window.open(frame.src,"_blank")):runCheat()}else runCheat();function runCheat(){_aikistaskgeneric_WAR_aikistaskportlet_INSTANCE_mkH2_structure.questions.forEach(function(e){(console.log("Tehtävä "+e.name),console.log("Tyyppi: "+e.checkType),"choice"===e.checkType)?e.sections.forEach(function(e){console.log("Kysymys "+e.id);var t=e.choices,a=!1;t.forEach(function(e){e.points>0&&(a=!0,console.log("Oikea vastaus: "+e.name))}),a||console.log("Tälle kysymykselle ei löytynyt vastausta")}):console.log("Valitettavasti tätä tehtävää ei tueta.")})} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Kopioi tiedoston
oikeavastaus_otava.min.js
kaikki koodi ja liitä selaimen komentoriviin.Otavan tehtäväsivu, mikä käsittelee tarkistuksen, on erillisellä sivulla. Skripti avaa tehtäväsivun, jos et ole tehtäväsivussa.
Kun liität, komentoriviin tulee oikeat vastaukset