Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 68 additions & 3 deletions actions/creerExamen.js

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La fonction permet d'afficher les différents question pré-sélectionnées pour composer l'examen, tout en les numérotant pour simplifier la sélection (on va avoir des numéros + le nom de la question qui suit)

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ export async function saveExamToDir(content, filename = null, dirName = 'examens
return outPath;
}

function displayQuestionsForDeletion(selectedBlocks) {
console.log(`\n${'='.repeat(60)}`);
console.log(`Questions sélectionnées (${selectedBlocks.length} au total)`);
console.log('='.repeat(60));

selectedBlocks.forEach((block, index) => {
try {
const parsed = parseGiftQuestion(block);
console.log(`${index + 1}) ${parsed.title}`);
} catch (e) {
console.log(`${index + 1}) [Question non parsable]`);
}
});

console.log('='.repeat(60));
}

export default async function creerExamen(rl = null) {
console.log('\n[actions] Création d\'un examen — sélection interactive (Spec_F2)');

Expand Down Expand Up @@ -211,11 +228,59 @@ export default async function creerExamen(rl = null) {
selectedSet.add(raw);
}
}


//Ajout de la possibilité de supprimer des questions avant de terminer
console.log(`\nNombre de questions sélectionnées : ${selectedBlocks.length}`);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ici ça reprends le moment de l'exécution de fin de sélection de question, avec la 3e proposition, celle de supprimer des questions.

on va afficher les questions de l'examen, puis demander de sélectionner la question à supprimer, qu'on va venir analyser pour récupérer le vrai numéro (j'ai fait commencer le compteur à 1 au lieu de 0) et ainsi delete la question du block et du set, pour que la suite de l'exécution se passe sans problème.

On peut donc continuer l'exécution (+ message de confirmation)

const finish = await rl.question(`Terminer la création maintenant ? (y=oui, n=continuer, s=supprimer des questions déjà ajoutées) : \n${blue}votre examen doit avoir entre 15 et 20 questions uniques pour être valide${reset} `);

const choice = finish.trim().toLowerCase();

if (choice === 'y') {
break;
} else if (choice === 's') {
if (selectedBlocks.length === 0) {
console.log(`${colors.yellow}Aucune question à supprimer.${colors.reset}`);
continue;
}

displayQuestionsForDeletion(selectedBlocks);

const delChoice = await rl.question(
'\nNuméro de la question à supprimer (0 pour annuler) : '
);

if (delChoice.trim() === '0') {
console.log('Suppression annulée.');
continue;
}

const delIdx = parseInt(delChoice, 10) - 1;

if (delIdx >= 0 && delIdx < selectedBlocks.length) {
const removed = selectedBlocks[delIdx];
selectedBlocks.splice(delIdx, 1);
selectedSet.delete(removed);

try {
const parsed = parseGiftQuestion(removed);
console.log(`${colors.green}Question "${parsed.title}" supprimée avec succès.${colors.reset}`);
} catch (e) {
console.log(`${colors.green}Question supprimée avec succès.${colors.reset}`);
}

console.log(`Nombre de questions restantes : ${selectedBlocks.length}`);
} else {
console.log(`${colors.red}Numéro invalide.${colors.reset}`);
}

continue;
} else if (choice === 'n') {
continue;
} else {
console.log(`${colors.yellow}Choix non reconnu, continuation...${colors.reset}`);
continue;
}

const finish = await rl.question(`Terminer la création maintenant ? (y=oui, n=continuer) : \n${blue}votre examen doit avoir entre 15 et 20 questions uniques pour être valide${reset} `);
if (finish.trim().toLowerCase() === 'y') break;
}

try {
Expand Down
76 changes: 76 additions & 0 deletions examens/Test suppression.gift

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test fonctionnel de la fonctionnalité de suppression de question durant la création d'examen, ce qui donne juste un examen classique

Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
::U1 p10 GR2.1 Present tenses & habits::I usually {=go} to the gym on Sundays. (<i>go</i>)

::U1 p10 GR2.2 Present tenses & habits::The children {=are growing up} very quickly. (<i>grow up</i>)

::U1 p10 GR2.3 Present tenses & habits::I think she {=is being ='s being} a bit unfair – he didn't mean to upset her. (<i>be</i>)

::U1 p8-9 Reading "Coachella" 2 reading for gist::[html]<p><em>You are going to read a newspaper article about an American music festival, Coachella. Read the article quickly for gist and choose the phrase which best summarises each paragraph.</em></p>{
=<p>A. When the American 90s rock band Pearl Jam put on a concert in the dried-up, baking-hot Coachella Valley in California, it was an attempt to prove that they could break away from the monopoly of the concert giant TicketMaster, who, they believed, was using its considerable power to exploit music fans by continually increasing prices. Their concert was well attended and inspired the idea for a future, more ambitious event. Naturally, nobody could have predicted quite how important Coachella would eventually become.</p> -> 4. The original inspiration of Coachella
=<p>B. Six years later, in 1999, the same venue hosted its first weekend-long music festival. Although initially making a loss, this was blamed on the unbearably high temperatures and the lack of available campsite facilities. What's more, it took only a few more years until its quality line-ups, from small bands to headliners, were attracting worldwide attention.</p> -> 7. Overcoming problematic beginnings
=<p>C. If one band is responsible for confirming Coachella's arrival on the world stage, it is Daft Punk's iconic appearance there in 2006.  As a direct result of the festival's success, promoters expanded it to a three-day event, and in 2009, Coachella presented its most mainstream line-up, including Paul McCartney, the Killers, and The Cure. The following year Jay-Z became the first rap headliner and by 2012 such was the popularity of Coachella that it had developed into two weekends of three-day shows.</p> -> 2. Getting bigger and better
=<p>D. In an effort to attract America's impoverished younger generation to an expensive annual visit to the desert, the promoters made two clever decisions. One smart move was to get a much-missed band or singer such as Rage Against the Machine to reform every year. Most notable was a holographic representation of the late rapper 2Pac in 2012. ln a stroke of genius, they decided to cater for the section of the audience who adored the music that used to be labelled electronic and who flocked to dance in big tents to their favourite DJs.</p> -> 1. Appealing to the target market
=<p>E. By keeping its cool musical reputation, the festival would go from strength to strength. In 2016, half a million fans bought their tickets in under 20 minutes, and each year around 100,000 attendees a day now splash out around $375 on admission. Of course, the costs don't stop there. It is now the most profitable festival in the world.</p> -> 6. A money-making success
=<p> F. Just two hours from Los Angeles, Coachella swiftly became the place to see and be seen. The presence of models and other celebrities soon began to attract style bloggers, drawn by the fashion rather than the music. Which, in turn, has made Coachella irresistible to fashion houses, beauty companies and other lifestyle labels.</p> -> 5. A fashionable destination
=<p>G. Although for several years luxury brands have been hosting free concerts and pool parties for invited guests and photographing Instagram stars modelling designer clothes, this has until recently been outside festival hours. As a result, they are now effectively separate events, to the point that 'No-chella' as it has become known, is, in the opinion of some, in danger of overshadowing the 'real' festival.</p>\n<p>Coachella has certainly come a long way from the original anti-establishment Pearl Jam gig.</p> -> 3. Choosing between two attractions
}


// question: 25402755 name: U1 p8-9 #9 Vocabulary

::U1 p10 GR2.4 Present tenses & habits::She {=isn't getting =is not getting} any better at maths even though she has a private tutor. (<i>not get</i>)

::U1 p10 GR2.5 Present tenses & habits::Sally {=appears} to be enjoying the course. (<i>appear</i>)

::U1 p10 GR2.6 Present tenses & habits::Even when I have a bad headache I {=don't take =do not take} painkillers. (<i>not take</i>)

::U1 p10 GR2.7 Present tenses & habits::Colin {=is} used to walking to school – he's always done it. (<i>be</i>)

::U1 p10 GR2.8 Present tenses & habits::It seemed very cold at first but now we {=are getting ='re getting} used to the weather. (<i>get</i>)

::U1 p7 Adverbs GR 1.1::[html]Does she come by car? (<i>generally</i>) {
=Does she generally come by car?}

::U1 p7 Adverbs GR 1.2::[html]Take care when using this machinery. (<i>always</i>) {
=Always take care when using this machinery.
=Always take care when using this machinery}

::U1 p7 Adverbs GR 1.3::[html]They're a little nervous at the beginning. (<i>sometimes</i>) {
=They're sometimes a little nervous at the beginning.
=They are sometimes a little nervous at the beginning.
=They're sometimes a little nervous at the beginning
=They are sometimes a little nervous at the beginning
=They’re sometimes a little nervous at the beginning
=They’re sometimes a little nervous at the beginning.}

::U1 p7 Adverbs GR 1.4::[html]I don't go to the gym on Fridays. (<i>usually</i>) {
=I don't usually go to the gym on Fridays.
=I do not usually go to the gym on Fridays.
=I don't usually go to the gym on Fridays
=I do not usually go to the gym on Fridays
=I don’t usually go to the gym on Fridays
=I don’t usually go to the gym on Fridays.}

::U1 p7 Adverbs GR 1.5::[html]They've been told that. (<i>often</i>) {
=They've often been told that.
=They have often been told that.
=They've often been told that
=They have often been told that
=They’ve often been told that
=They’ve often been told that.}

::U1 p8-9 9 Vocabulary::[html]<em>Look at the following words and phrases from the article and at the meaning options. Try to work out the meaning from the context or from the word itself. Then match each one to a definition.</em>{
=Spend a lot of money -> Splash out
=Show something is definitely true -> Confirming
=Find a solution (to a problem) -> Resolved
=Go large in numbers -> Flocked
=Try to get as much as possible (sometimes unfairly) -> Exploit
=Consider facts when making a decision -> Taken into account
=Make something seem less important -> Overshadowing
=Provide people with what they want -> Cater for
=Give the idea for -> Inspired
=Good but difficult -> Ambitious
=Someone or something famous and important -> Iconic
=Impossible to refuse -> Irresistible
=Makes a lot of money -> Profitable
=Very poor -> Impoverished
}
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.