diff --git a/actions/creerExamen.js b/actions/creerExamen.js index 9c06c67..e783816 100644 --- a/actions/creerExamen.js +++ b/actions/creerExamen.js @@ -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)'); @@ -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}`); + 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 { diff --git a/examens/Test suppression.gift b/examens/Test suppression.gift new file mode 100644 index 0000000..14d6d44 --- /dev/null +++ b/examens/Test suppression.gift @@ -0,0 +1,76 @@ +::U1 p10 GR2.1 Present tenses & habits::I usually {=go} to the gym on Sundays. (go) + +::U1 p10 GR2.2 Present tenses & habits::The children {=are growing up} very quickly. (grow up) + +::U1 p10 GR2.3 Present tenses & habits::I think she {=is being ='s being} a bit unfair – he didn't mean to upset her. (be) + +::U1 p8-9 Reading "Coachella" 2 reading for gist::[html]
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.
{ + =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.
-> 4. The original inspiration of Coachella + =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.
-> 7. Overcoming problematic beginnings + =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.
-> 2. Getting bigger and better + =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.
-> 1. Appealing to the target market + =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.
-> 6. A money-making success + =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.
-> 5. A fashionable destination + =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.
\nCoachella has certainly come a long way from the original anti-establishment Pearl Jam gig.
-> 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. (not get) + +::U1 p10 GR2.5 Present tenses & habits::Sally {=appears} to be enjoying the course. (appear) + +::U1 p10 GR2.6 Present tenses & habits::Even when I have a bad headache I {=don't take =do not take} painkillers. (not take) + +::U1 p10 GR2.7 Present tenses & habits::Colin {=is} used to walking to school – he's always done it. (be) + +::U1 p10 GR2.8 Present tenses & habits::It seemed very cold at first but now we {=are getting ='re getting} used to the weather. (get) + +::U1 p7 Adverbs GR 1.1::[html]Does she come by car? (generally) { + =Does she generally come by car?} + +::U1 p7 Adverbs GR 1.2::[html]Take care when using this machinery. (always) { + =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. (sometimes) { + =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. (usually) { + =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. (often) { + =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]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.{ + =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 +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8acb842..875a655 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2107,6 +2107,7 @@ "resolved": "https://registry.npmjs.org/vega/-/vega-6.2.0.tgz", "integrity": "sha512-BIwalIcEGysJdQDjeVUmMWB3e50jPDNAMfLJscjEvpunU9bSt7X1OYnQxkg3uBwuRRI4nWfFZO9uIW910nLeGw==", "license": "BSD-3-Clause", + "peer": true, "dependencies": { "vega-crossfilter": "~5.1.0", "vega-dataflow": "~6.1.0",