23 lines
763 B
JavaScript
23 lines
763 B
JavaScript
|
const models = require("../../models");
|
||
|
|
||
|
module.exports = socket => {
|
||
|
return async (data) => {
|
||
|
const options = {where: {},
|
||
|
include: [models.UE, {model: models.User},
|
||
|
{
|
||
|
model: models.Grade,
|
||
|
include: [{model: models.User, as: "TeacherGrade"}, {model: models.User, as: "StudentGrade"}]
|
||
|
}]
|
||
|
};
|
||
|
|
||
|
if (data && data.id)
|
||
|
options.where.id = data.id;
|
||
|
|
||
|
if (socket.request.session.user.permissions === 2) {
|
||
|
options.include[1].where = {email: socket.request.session.user.email};
|
||
|
options.include[1].required = true;
|
||
|
}
|
||
|
socket.emit("evaluationGet", await models.Evaluation.findAll(options));
|
||
|
}
|
||
|
};
|