Skip to content

Instantly share code, notes, and snippets.

@gusaiani

gusaiani/cga.js

Created Nov 18, 2020
Embed
What would you like to do?
Randomize and open url for simulated preparation exercises for CGA certification. Run with `node ./cga.js`
const { exec } = require("child_process")
const romans = [null, 'i', 'ii', 'iii', 'iv', 'v', 'vi', 'vii', 'viii', 'ix', 'x', 'xi']
const totalNumberOfQuestions = 60
const numberOfQuestions = 15
const moduleNumber = Math.round(Math.random()) + 1
const maxTests = moduleNumber === 1 ? 11 : 9
const testNumber = Math.floor(Math.random() * maxTests) + 1
const romanModule = romans[moduleNumber]
const romanTest = romans[testNumber]
const url = `https://proeducacional.com/ead/curso-cga-modulo-${romanModule}/capitulos/simulados-cga-modulo-${romanModule}/exercicios/simulado-cga-${romanModule}-${romanTest}/`
console.log({moduleNumber, testNumber})
exec(`open ${url}`)
exec("shuf -i 1-60 -n 15 | sort -n", (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`)
return
}
if (stderr) {
console.log(`stderr: ${stderr}`)
return
}
console.log(stdout)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment