refactor: stdLearning and report model
This commit is contained in:
parent
ee4f1814e4
commit
11bd20565f
|
|
@ -3,7 +3,7 @@ APP_PORT = 3001
|
||||||
DB_HOST = localhost
|
DB_HOST = localhost
|
||||||
DB_USER = root
|
DB_USER = root
|
||||||
DB_PASSWORD =
|
DB_PASSWORD =
|
||||||
DB_NAME = project_siswa
|
DB_NAME = adaptive_learning
|
||||||
|
|
||||||
ACCESS_TOKEN_SECRET =
|
ACCESS_TOKEN_SECRET =
|
||||||
RESET_PASSWORD_SECRET =
|
RESET_PASSWORD_SECRET =
|
||||||
|
|
|
||||||
|
|
@ -169,9 +169,15 @@ export const learningScoreByStdLearningId = async (req, res) => {
|
||||||
ID: ID,
|
ID: ID,
|
||||||
},
|
},
|
||||||
include: [
|
include: [
|
||||||
|
{
|
||||||
|
model: models.Level,
|
||||||
|
as: "level",
|
||||||
|
attributes: ["ID_LEVEL", "NAME_LEVEL"],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
model: models.Level,
|
model: models.Level,
|
||||||
as: "nextLevel",
|
as: "nextLevel",
|
||||||
|
attributes: ["NAME_LEVEL"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: models.User,
|
model: models.User,
|
||||||
|
|
@ -207,9 +213,12 @@ export const learningScoreByStdLearningId = async (req, res) => {
|
||||||
NISN: stdLearning.learningUser.students
|
NISN: stdLearning.learningUser.students
|
||||||
? stdLearning.learningUser.students.NISN
|
? stdLearning.learningUser.students.NISN
|
||||||
: null,
|
: null,
|
||||||
|
ID_LEVEL: stdLearning.level ? stdLearning.level.ID_LEVEL : null,
|
||||||
|
CURRENT_LEVEL_NAME: stdLearning.level ? stdLearning.level.NAME_LEVEL : null,
|
||||||
SCORE: stdLearning.SCORE,
|
SCORE: stdLearning.SCORE,
|
||||||
NEXT_LEARNING: stdLearning.NEXT_LEARNING,
|
NEXT_LEARNING: stdLearning.NEXT_LEARNING,
|
||||||
NEXT_LEARNING_NAME: stdLearning.nextLevel.NAME_LEVEL,
|
NEXT_LEARNING_NAME: stdLearning.nextLevel.NAME_LEVEL,
|
||||||
|
IS_PASS: stdLearning.IS_PASS,
|
||||||
};
|
};
|
||||||
|
|
||||||
return response(200, nextLearningData, "Success", res);
|
return response(200, nextLearningData, "Success", res);
|
||||||
|
|
|
||||||
|
|
@ -137,3 +137,22 @@ export const userReport = async (req, res) => {
|
||||||
response(500, null, "Internal Server Error", res);
|
response(500, null, "Internal Server Error", res);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const deleteReportById = async (req, res) => {
|
||||||
|
const { id } = req.params;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const report = await models.Report.findByPk(id);
|
||||||
|
|
||||||
|
if (!report) {
|
||||||
|
return response(404, null, "Report not found", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
await report.destroy();
|
||||||
|
|
||||||
|
response(200, null, "Report deleted successfully", res);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
response(500, null, "Internal Server Error", res);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user