diff --git a/.envexample b/.envexample index 3d1a8c1..b34c63c 100644 --- a/.envexample +++ b/.envexample @@ -3,7 +3,7 @@ APP_PORT = 3001 DB_HOST = localhost DB_USER = root DB_PASSWORD = -DB_NAME = project_siswa +DB_NAME = adaptive_learning ACCESS_TOKEN_SECRET = RESET_PASSWORD_SECRET = diff --git a/controllers/learningControllers/stdLearning.js b/controllers/learningControllers/stdLearning.js index 6ae2830..7c57d4f 100644 --- a/controllers/learningControllers/stdLearning.js +++ b/controllers/learningControllers/stdLearning.js @@ -169,9 +169,15 @@ export const learningScoreByStdLearningId = async (req, res) => { ID: ID, }, include: [ + { + model: models.Level, + as: "level", + attributes: ["ID_LEVEL", "NAME_LEVEL"], + }, { model: models.Level, as: "nextLevel", + attributes: ["NAME_LEVEL"], }, { model: models.User, @@ -207,9 +213,12 @@ export const learningScoreByStdLearningId = async (req, res) => { NISN: stdLearning.learningUser.students ? stdLearning.learningUser.students.NISN : null, + ID_LEVEL: stdLearning.level ? stdLearning.level.ID_LEVEL : null, + CURRENT_LEVEL_NAME: stdLearning.level ? stdLearning.level.NAME_LEVEL : null, SCORE: stdLearning.SCORE, NEXT_LEARNING: stdLearning.NEXT_LEARNING, NEXT_LEARNING_NAME: stdLearning.nextLevel.NAME_LEVEL, + IS_PASS: stdLearning.IS_PASS, }; return response(200, nextLearningData, "Success", res); diff --git a/controllers/usersControllers/report.js b/controllers/usersControllers/report.js index 957db88..2e2e760 100644 --- a/controllers/usersControllers/report.js +++ b/controllers/usersControllers/report.js @@ -137,3 +137,22 @@ export const userReport = async (req, 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); + } +};