mirror of
https://github.com/resendecode/nuitdelinfo.git
synced 2026-07-09 07:07:50 +00:00
liaison_back_front
This commit is contained in:
+25
-9
@@ -1,6 +1,6 @@
|
||||
|
||||
function getTitre (categorie ,indice){// Charger le contenu du fichier JSON
|
||||
fetch(`./resources/${categorie}.json`)
|
||||
fetch(`/back/resources/${categorie}.json`)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur de chargement du fichier JSON : ${response.status}`);
|
||||
@@ -12,6 +12,7 @@ function getTitre (categorie ,indice){// Charger le contenu du fichier JSON
|
||||
if (indice >= 0 && indice < questions.length) {
|
||||
const question = questions[indice].question;
|
||||
console.log(`Question à l'indice ${indice}: ${question}`);
|
||||
document.getElementById('qid').innerHTML = question;
|
||||
} else {
|
||||
console.error(`Indice ${indice} hors de portée.`);
|
||||
}
|
||||
@@ -21,7 +22,7 @@ function getTitre (categorie ,indice){// Charger le contenu du fichier JSON
|
||||
});
|
||||
}
|
||||
function getRep1(categorie, indice){// Charger le contenu du fichier JSON
|
||||
fetch(`./resources/${categorie}.json`)
|
||||
fetch(`/back/resources/${categorie}.json`)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur de chargement du fichier JSON : ${response.status}`);
|
||||
@@ -33,6 +34,7 @@ function getRep1(categorie, indice){// Charger le contenu du fichier JSON
|
||||
if (indice >= 0 && indice < questions.length) {
|
||||
const rep = questions[indice].options[0].text;
|
||||
console.log(`Reponse à l'indice ${indice}: ${rep}`);
|
||||
document.getElementById('lefttext').innerHTML = rep;
|
||||
return rep;
|
||||
} else {
|
||||
console.error(`Indice ${indice} hors de portée.`);
|
||||
@@ -43,7 +45,7 @@ function getRep1(categorie, indice){// Charger le contenu du fichier JSON
|
||||
});
|
||||
}
|
||||
function getRep2(categorie, indice){// Charger le contenu du fichier JSON
|
||||
fetch(`./resources/${categorie}.json`)
|
||||
fetch(`/back/resources/${categorie}.json`)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur de chargement du fichier JSON : ${response.status}`);
|
||||
@@ -55,6 +57,7 @@ function getRep2(categorie, indice){// Charger le contenu du fichier JSON
|
||||
if (indice >= 0 && indice < questions.length) {
|
||||
const rep = questions[indice].options[1].text;
|
||||
console.log(`Reponse à l'indice ${indice}: ${rep}`);
|
||||
document.getElementById('righttext').innerHTML = rep;
|
||||
return rep;
|
||||
} else {
|
||||
console.error(`Indice ${indice} hors de portée.`);
|
||||
@@ -64,8 +67,8 @@ function getRep2(categorie, indice){// Charger le contenu du fichier JSON
|
||||
console.error('Erreur lors du chargement du fichier JSON :', erreur.message);
|
||||
});
|
||||
}
|
||||
function getVrai(categorie, indice){
|
||||
fetch(`./resources/${categorie}.json`)
|
||||
function getVrai(categorie, indice,id){
|
||||
fetch(`/back/resources/${categorie}.json`)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur de chargement du fichier JSON : ${response.status}`);
|
||||
@@ -77,6 +80,7 @@ function getVrai(categorie, indice){
|
||||
if (indice >= 0 && indice < questions.length) {
|
||||
const vrai = questions[indice].reponse;
|
||||
console.log(`vraie reponse ${indice}: ${vrai}`);
|
||||
document.getElementById('qtype').innerHTML = vrai == id ? "Correct" : "Incorrect";
|
||||
return vrai;
|
||||
} else {
|
||||
console.error(`Indice ${indice} hors de portée.`);
|
||||
@@ -87,7 +91,7 @@ function getVrai(categorie, indice){
|
||||
});
|
||||
}
|
||||
function getDescription(categorie, indice){
|
||||
fetch(`./resources/${categorie}.json`)
|
||||
fetch(`/back/resources/${categorie}.json`)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur de chargement du fichier JSON : ${response.status}`);
|
||||
@@ -99,6 +103,7 @@ function getDescription(categorie, indice){
|
||||
if (indice >= 0 && indice < questions.length) {
|
||||
const description = questions[indice].description;
|
||||
console.log(`description ${indice}: ${description}`);
|
||||
document.getElementById('qid').innerHTML = description;
|
||||
return description;
|
||||
} else {
|
||||
console.error(`Indice ${indice} hors de portée.`);
|
||||
@@ -109,7 +114,7 @@ function getDescription(categorie, indice){
|
||||
});
|
||||
}
|
||||
function getImg1(categorie, indice){
|
||||
fetch(`./resources/${categorie}.json`)
|
||||
fetch(`/back/resources/${categorie}.json`)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur de chargement du fichier JSON : ${response.status}`);
|
||||
@@ -121,6 +126,8 @@ function getImg1(categorie, indice){
|
||||
if (indice >= 0 && indice < questions.length) {
|
||||
const img = questions[indice].options[0].img;
|
||||
console.log(`vraie reponse ${indice}: ${img}`);
|
||||
document.getElementById('imgleft').src = img;
|
||||
|
||||
return img;
|
||||
} else {
|
||||
console.error(`Indice ${indice} hors de portée.`);
|
||||
@@ -131,7 +138,7 @@ function getImg1(categorie, indice){
|
||||
});
|
||||
}
|
||||
function getImg2(categorie, indice){
|
||||
fetch(`./resources/${categorie}.json`)
|
||||
fetch(`/back/resources/${categorie}.json`)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur de chargement du fichier JSON : ${response.status}`);
|
||||
@@ -143,6 +150,7 @@ function getImg2(categorie, indice){
|
||||
if (indice >= 0 && indice < questions.length) {
|
||||
const img = questions[indice].options[1].img;
|
||||
console.log(`vraie reponse ${indice}: ${img}`);
|
||||
document.getElementById('imgright').src = img;
|
||||
return img;
|
||||
} else {
|
||||
console.error(`Indice ${indice} hors de portée.`);
|
||||
@@ -167,8 +175,16 @@ function getImg2(categorie, indice){
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', ()=>
|
||||
{
|
||||
const tableauDentiers = [1, 2, 3, 4, 5];
|
||||
const tableauIndex = [0, 1, 2, 3, 4];
|
||||
index = getIndex(tableauIndex);
|
||||
|
||||
|
||||
// Assuming you want the first question
|
||||
}
|
||||
)
|
||||
|
||||
function next(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user