@programisto/edrm-exams 0.2.11 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -346,7 +346,12 @@ class ExamsRouter extends EnduranceRouter {
346
346
  if (!test) {
347
347
  return res.status(404).json({ message: 'no test founded with this id' });
348
348
  }
349
- test.questions = test.questions.filter(id => id.toString() !== questionId);
349
+ // Supprimer la question du tableau questions en filtrant par questionId
350
+ test.questions = test.questions.filter(q => q.questionId.toString() !== questionId);
351
+ // Recalculer les ordres pour que ça se suive
352
+ test.questions.forEach((q, index) => {
353
+ q.order = index + 1;
354
+ });
350
355
  await test.save();
351
356
  res.status(200).json({ message: 'question deleted with sucess' });
352
357
  });
@@ -827,7 +832,7 @@ class ExamsRouter extends EnduranceRouter {
827
832
  const otherQuestions = await TestQuestion.find({ _id: { $in: otherQuestionsIds } });
828
833
  // Calculer combien de questions générer pour cette catégorie
829
834
  const remainingQuestions = numberOfQuestions - questionsGenerated;
830
- const questionsForThisCategory = Math.min(remainingQuestions, 1); // Au maximum 1 question par catégorie
835
+ const questionsForThisCategory = Math.min(remainingQuestions, Math.ceil(numberOfQuestions / categoriesToUse.length));
831
836
  for (let i = 0; i < questionsForThisCategory; i++) {
832
837
  const generatedQuestion = await generateLiveMessage('createQuestion', {
833
838
  job: test.targetJob,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@programisto/edrm-exams",
4
- "version": "0.2.11",
4
+ "version": "0.2.12",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },