refactor: get exercise by level id function
This commit is contained in:
parent
4ced73bca2
commit
f4a3e6d02d
|
|
@ -347,7 +347,7 @@ export const refreshToken = async (req, res) => {
|
|||
res.cookie("refreshToken", newRefreshToken, {
|
||||
httpOnly: true,
|
||||
secure: process.env.NODE_ENV === "production",
|
||||
sameSite: "Strict",
|
||||
// sameSite: "Strict",
|
||||
maxAge: 7 * 24 * 60 * 60 * 1000
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -308,6 +308,13 @@ export const getExerciseByLevelId = async (req, res) => {
|
|||
model: models.Topic,
|
||||
as: "levelTopic",
|
||||
attributes: ["NAME_TOPIC"],
|
||||
include: [
|
||||
{
|
||||
model: models.Section,
|
||||
as: "topicSection",
|
||||
attributes: ["NAME_SECTION"],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
attributes: ["NAME_LEVEL"],
|
||||
|
|
@ -320,18 +327,9 @@ export const getExerciseByLevelId = async (req, res) => {
|
|||
const exercises = await models.Exercise.findAll({
|
||||
where: { ID_LEVEL: idLevel, IS_DELETED: 0 },
|
||||
include: [
|
||||
{
|
||||
model: models.MultipleChoices,
|
||||
as: "multipleChoices",
|
||||
},
|
||||
{
|
||||
model: models.MatchingPairs,
|
||||
as: "matchingPairs",
|
||||
},
|
||||
{
|
||||
model: models.TrueFalse,
|
||||
as: "trueFalse",
|
||||
},
|
||||
{ model: models.MultipleChoices, as: "multipleChoices" },
|
||||
{ model: models.MatchingPairs, as: "matchingPairs" },
|
||||
{ model: models.TrueFalse, as: "trueFalse" },
|
||||
],
|
||||
});
|
||||
|
||||
|
|
@ -381,6 +379,7 @@ export const getExerciseByLevelId = async (req, res) => {
|
|||
});
|
||||
|
||||
const responsePayload = {
|
||||
NAME_SECTION: levelExists.levelTopic.topicSection.NAME_SECTION,
|
||||
NAME_TOPIC: levelExists.levelTopic.NAME_TOPIC,
|
||||
NAME_LEVEL: levelExists.NAME_LEVEL,
|
||||
EXERCISES: formattedExercises,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user