Skip to content

Instantly share code, notes, and snippets.

@doxyf
Created December 21, 2022 20:40
Show Gist options
  • Save doxyf/018451cf14d08c70781fea9599c50332 to your computer and use it in GitHub Desktop.
Save doxyf/018451cf14d08c70781fea9599c50332 to your computer and use it in GitHub Desktop.
Without error handling!
const axios = require('axios');
const process = require('process');
var kahid = process.argv[2];
if(!kahid) throw new Error('Please enter valid Kahoot ID (not room ID)')
async function main(){
let r = await axios.get(`https://create.kahoot.it/rest/kahoots/${kahid}/card/?includeKahoot=true`);
let parsed = parseQuestions(r.data.kahoot.questions);
parsed.forEach(res => {
console.log(`[${res.qpos}] Q: ${res.question} | A: ${res.answ} | (That's position ${res.pos})`);
});
};
main();
function parseQuestions(qJson){
let answ = [];
qJson.forEach((partial, i) => {
if(partial.type == 'content') return;
partial.choices.forEach((val, j) => {
if(val.correct) answ.push({qpos: i, question: partial.question, pos: j, answ: val.answer});
});
});
return answ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment