@programisto/edrm-exams 0.3.2 → 0.3.4
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.
|
@@ -95,7 +95,7 @@ async function correctTest(options) {
|
|
|
95
95
|
await TestResult.findByIdAndUpdate(result._id, {
|
|
96
96
|
$set: {
|
|
97
97
|
responses: result.responses,
|
|
98
|
-
score:
|
|
98
|
+
score: finalscore,
|
|
99
99
|
state: result.state
|
|
100
100
|
}
|
|
101
101
|
});
|
|
@@ -111,7 +111,7 @@ async function correctTest(options) {
|
|
|
111
111
|
data: {
|
|
112
112
|
firstname: contact.firstname,
|
|
113
113
|
lastname: contact.lastname,
|
|
114
|
-
score:
|
|
114
|
+
score: scorePercentage,
|
|
115
115
|
testName: test?.title || '',
|
|
116
116
|
testLink
|
|
117
117
|
}
|
|
@@ -250,7 +250,7 @@ class ExamsRouter extends EnduranceRouter {
|
|
|
250
250
|
// Modifier un test
|
|
251
251
|
this.put('/test/:id', authenticatedOptions, async (req, res) => {
|
|
252
252
|
const { id } = req.params;
|
|
253
|
-
const { title, description, targetJob, seniorityLevel, categories, state } = req.body;
|
|
253
|
+
const { title, description, targetJob, seniorityLevel, categories, state, questions } = req.body;
|
|
254
254
|
try {
|
|
255
255
|
const test = await Test.findById(id);
|
|
256
256
|
if (!test) {
|
|
@@ -291,6 +291,23 @@ class ExamsRouter extends EnduranceRouter {
|
|
|
291
291
|
}));
|
|
292
292
|
test.categories = processedCategories;
|
|
293
293
|
}
|
|
294
|
+
if (questions) {
|
|
295
|
+
// Vérifier que toutes les questions existent
|
|
296
|
+
const questionIds = questions.map((q) => q.questionId);
|
|
297
|
+
const existingQuestions = await TestQuestion.find({ _id: { $in: questionIds } });
|
|
298
|
+
if (existingQuestions.length !== questionIds.length) {
|
|
299
|
+
return res.status(400).json({
|
|
300
|
+
message: 'Certaines questions spécifiées n\'existent pas',
|
|
301
|
+
providedQuestions: questionIds.length,
|
|
302
|
+
foundQuestions: existingQuestions.length
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
// Mettre à jour les questions avec leur ordre
|
|
306
|
+
test.questions = questions.map((q) => ({
|
|
307
|
+
questionId: q.questionId,
|
|
308
|
+
order: q.order || 0
|
|
309
|
+
}));
|
|
310
|
+
}
|
|
294
311
|
await test.save();
|
|
295
312
|
res.status(200).json({ message: 'Test modifié avec succès', data: test });
|
|
296
313
|
}
|