refactor: monitoring student function
This commit is contained in:
parent
2245c8440d
commit
b6885b4e89
|
|
@ -119,11 +119,23 @@ export const updateStdLearningById = async (req, res) => {
|
|||
) {
|
||||
req.body.ID_STUDENT_LEARNING = id;
|
||||
|
||||
const existingMonitoring = await models.Monitoring.findOne({
|
||||
where: { ID_STUDENT_LEARNING: id },
|
||||
const existingMonitoringForTopic = await models.Monitoring.findOne({
|
||||
include: [
|
||||
{
|
||||
model: models.StdLearning,
|
||||
as: "stdLearningMonitoring",
|
||||
include: [
|
||||
{
|
||||
model: models.Level,
|
||||
as: "level",
|
||||
where: { ID_TOPIC: stdLearning.level.ID_TOPIC },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
if (!existingMonitoring) {
|
||||
if (!existingMonitoringForTopic) {
|
||||
const newMonitoring = await createMonitoring(req);
|
||||
|
||||
const { level, ...responseData } = stdLearning.toJSON();
|
||||
|
|
|
|||
|
|
@ -361,6 +361,7 @@ export const monitoringStudentProgressById = async (req, res) => {
|
|||
"STUDENT_START",
|
||||
"STUDENT_FINISH",
|
||||
],
|
||||
order: [["STUDENT_FINISH", "DESC"]],
|
||||
distinct: true,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user