mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Merge pull request #98 from ets-cfuhrman-pfe/fuhrmanator/issue57
Quiz exporté n'est pas du GIFT valide
This commit is contained in:
commit
8cca95d269
1 changed files with 8 additions and 3 deletions
|
|
@ -229,21 +229,26 @@ const Dashboard: React.FC = () => {
|
||||||
console.log(selectedQuiz.content);
|
console.log(selectedQuiz.content);
|
||||||
selectedQuiz.content.forEach((question, qIndex) => {
|
selectedQuiz.content.forEach((question, qIndex) => {
|
||||||
const formattedQuestion = question.trim();
|
const formattedQuestion = question.trim();
|
||||||
console.log(formattedQuestion);
|
// console.log(formattedQuestion);
|
||||||
if (formattedQuestion !== '') {
|
if (formattedQuestion !== '') {
|
||||||
quizContent += formattedQuestion;
|
quizContent += formattedQuestion + '\n';
|
||||||
if (qIndex !== selectedQuiz.content.length - 1) {
|
if (qIndex !== selectedQuiz.content.length - 1) {
|
||||||
quizContent += '\n';
|
quizContent += '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!validateQuiz(selectedQuiz.content)) {
|
||||||
|
window.alert('Attention! Ce quiz contient des questions invalides selon le format GIFT.');
|
||||||
|
}
|
||||||
const blob = new Blob([quizContent], { type: 'text/plain' });
|
const blob = new Blob([quizContent], { type: 'text/plain' });
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
const filename = title;
|
const filename = title;
|
||||||
a.download = `${filename}.txt`;
|
a.download = `${filename}.gift`;
|
||||||
a.href = window.URL.createObjectURL(blob);
|
a.href = window.URL.createObjectURL(blob);
|
||||||
a.click();
|
a.click();
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error exporting selected quiz:', error);
|
console.error('Error exporting selected quiz:', error);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue