skydiet-lib-node
Advanced tools
Comparing version 1.0.15 to 1.0.16
@@ -27,2 +27,3 @@ "use strict"; | ||
const childsDisableds = getChildsDisableds(questionsChilds, questionsAnswereds, options.bankQuestions); | ||
const questionsAutoAnswereds = getQuestionsAutoAnswereds(question.codeAnswer, questionsAnswereds, options.bankQuestions, options.attendanceMetActivities ?? []); | ||
let currentAttendenceQuestionsNew = options.currentAttendenceQuestions.filter((q) => !childsDisableds.map((disabled) => disabled._id).includes(q._id)); | ||
@@ -34,13 +35,9 @@ currentAttendenceQuestionsNew = [...currentAttendenceQuestionsNew, ...childsReleaseds]; | ||
} | ||
let questionsAutoAnswereds = []; | ||
if (options.disableAutoAnswers === false) { | ||
questionsAutoAnswereds = getQuestionsAutoAnswereds(question.codeAnswer, questionsAnswereds, options.bankQuestions, options.attendanceMetActivities ?? []); | ||
currentAttendenceQuestionsNew.forEach((aq) => { | ||
const autoAnswered = questionsAutoAnswereds.find((aaq) => aaq._id === aq._id); | ||
if (autoAnswered) { | ||
aq.answer = autoAnswered.answer ?? aq.defaultAnswer; | ||
} | ||
}); | ||
} | ||
return { questions: currentAttendenceQuestionsNew, autoAnswers: questionsAutoAnswereds }; | ||
currentAttendenceQuestionsNew.forEach((aq) => { | ||
const autoAnswered = questionsAutoAnswereds.find((aaq) => aaq._id === aq._id); | ||
if (autoAnswered) { | ||
aq.answer = autoAnswered.answer ?? aq.defaultAnswer; | ||
} | ||
}); | ||
return { questions: currentAttendenceQuestionsNew, autoAnswers: options.disableAutoAnswers ? [] : questionsAutoAnswereds }; | ||
}; | ||
@@ -47,0 +44,0 @@ exports.processAnswer = processAnswer; |
{ | ||
"name": "skydiet-lib-node", | ||
"version": "1.0.15", | ||
"version": "1.0.16", | ||
"description": "Biblioteca para funções skydiet", | ||
@@ -5,0 +5,0 @@ "author": "Daniel Cabral <cabralconsultoriaemsoftware@gmail.com>", |
@@ -35,9 +35,7 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ | ||
const childsDisableds = getChildsDisableds(questionsChilds, questionsAnswereds, options.bankQuestions) | ||
const questionsAutoAnswereds = getQuestionsAutoAnswereds(question.codeAnswer, questionsAnswereds, options.bankQuestions, options.attendanceMetActivities ?? []) | ||
let currentAttendenceQuestionsNew = options.currentAttendenceQuestions.filter((q: IAttendanceQuestion) => !childsDisableds.map((disabled: IAttendanceQuestion) => disabled._id).includes(q._id)); | ||
currentAttendenceQuestionsNew = [...currentAttendenceQuestionsNew, ...childsReleaseds] | ||
const currentQuestionNew = currentAttendenceQuestionsNew.find((q: IAttendanceQuestion) => q._id === options.currentQuestion._id) | ||
@@ -47,16 +45,11 @@ if (currentQuestionNew) { | ||
} | ||
let questionsAutoAnswereds: IAttendanceQuestion[] = [] | ||
if (options.disableAutoAnswers === false) { | ||
questionsAutoAnswereds = getQuestionsAutoAnswereds(question.codeAnswer, questionsAnswereds, options.bankQuestions, options.attendanceMetActivities ?? []) | ||
currentAttendenceQuestionsNew.forEach((aq: IAttendanceQuestion) => { | ||
const autoAnswered = questionsAutoAnswereds.find((aaq: IAttendanceQuestion) => aaq._id === aq._id) | ||
if (autoAnswered) { | ||
aq.answer = autoAnswered.answer ?? aq.defaultAnswer | ||
} | ||
}) | ||
} | ||
return { questions: currentAttendenceQuestionsNew, autoAnswers: questionsAutoAnswereds } | ||
currentAttendenceQuestionsNew.forEach((aq: IAttendanceQuestion) => { | ||
const autoAnswered = questionsAutoAnswereds.find((aaq: IAttendanceQuestion) => aaq._id === aq._id) | ||
if (autoAnswered) { | ||
aq.answer = autoAnswered.answer ?? aq.defaultAnswer | ||
} | ||
}) | ||
return { questions: currentAttendenceQuestionsNew, autoAnswers: options.disableAutoAnswers ? [] : questionsAutoAnswereds} | ||
} | ||
@@ -63,0 +56,0 @@ |
57926
1265