forked from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into newstatsservice
- Loading branch information
Showing
25 changed files
with
568 additions
and
491 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,70 @@ | ||
const GenericGenerator = require('./GenericGenerator') | ||
const fs = require('fs'); | ||
|
||
class GeneratorChooser{ | ||
constructor(){ | ||
this.generators = new Map(); | ||
this.tematicas = []; | ||
this.leer_json("./data/tematicas.json"); | ||
} | ||
const GenericGenerator = require("./GenericGenerator"); | ||
const fs = require("fs"); | ||
|
||
class GeneratorChooser { | ||
constructor() { | ||
this.generators = new Map(); | ||
this.tematicas = []; | ||
this.leer_json("./data/tematicas.json"); | ||
} | ||
|
||
leer_json(ruta){ | ||
const datos = fs.readFileSync(ruta); | ||
var tematicas = JSON.parse(datos); | ||
|
||
for(let i in tematicas){ | ||
var tematica = tematicas[i]; | ||
this.tematicas.push(i); | ||
this.generators.set(i, | ||
new GenericGenerator(tematica.entity, tematica.props, tematica.types, tematica.preguntas) | ||
); | ||
} | ||
leer_json(ruta) { | ||
const datos = fs.readFileSync(ruta); | ||
var tematicas = JSON.parse(datos); | ||
|
||
for (let i in tematicas) { | ||
var tematica = tematicas[i]; | ||
this.tematicas.push(i); | ||
this.generators.set( | ||
i, | ||
new GenericGenerator( | ||
tematica.entity, | ||
tematica.props, | ||
tematica.types, | ||
tematica.preguntas | ||
) | ||
); | ||
} | ||
} | ||
|
||
getQuestions(tematica, n){ | ||
if(tematica === "all"){ | ||
var questions = []; | ||
for(let i = 0 ; i < n ; i++){ | ||
let rand = Math.floor(Math.random() * this.tematicas.length) | ||
let randTematica =this.tematicas[rand]; | ||
let q = this.generators.get(randTematica).generateRandomQuestions(1); | ||
questions.push(q); | ||
} | ||
return questions.flat(); | ||
}else{ | ||
return this.generators.get(tematica).generateRandomQuestions(n); | ||
} | ||
getQuestions(tematica, n) { | ||
if (tematica === "all") { | ||
var questions = []; | ||
for (let i = 0; i < n; i++) { | ||
let rand = Math.floor(Math.random() * this.tematicas.length); | ||
let randTematica = this.tematicas[rand]; | ||
let q = this.generators.get(randTematica).generateRandomQuestions(1); | ||
questions.push(q); | ||
} | ||
return questions.flat(); | ||
} else { | ||
return this.generators.get(tematica).generateRandomQuestions(n); | ||
} | ||
} | ||
|
||
async loadGenerators(){ | ||
for(let i = 0 ; i < this.tematicas.length ; i++){ | ||
var gen = this.generators.get(this.tematicas[i]); | ||
console.log("Cargando temática: " + this.tematicas[i]); | ||
await gen.getData(); | ||
await this.#sleep(10000); | ||
} | ||
getQuestionsPost(tematicas, n) { | ||
var questions = []; | ||
for (let i = 0; i < n; i++) { | ||
let rand = Math.floor(Math.random() * tematicas.length); | ||
let randTematica = tematicas[rand]; | ||
let q = this.generators.get(randTematica).generateRandomQuestions(1); | ||
questions.push(q); | ||
} | ||
return questions.flat(); | ||
} | ||
|
||
#sleep(ms) { | ||
return new Promise(resolve => setTimeout(resolve, ms)); | ||
async loadGenerators() { | ||
for (let i = 0; i < this.tematicas.length; i++) { | ||
var gen = this.generators.get(this.tematicas[i]); | ||
console.log("Cargando temática: " + this.tematicas[i]); | ||
await gen.getData(); | ||
await this.#sleep(10000); | ||
} | ||
} | ||
|
||
#sleep(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
} | ||
|
||
module.exports = GeneratorChooser; | ||
module.exports = GeneratorChooser; |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.footer{ | ||
border-top: 3px solid var(--borders); | ||
width: 100%; | ||
} |
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
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
Oops, something went wrong.