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