1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
letu/sockets/get/gradeGet.js

23 lines
949 B
JavaScript
Raw Permalink Normal View History

const models = require("../../models");
module.exports = socket => {
return async (data) => {
2021-01-17 11:48:14 +01:00
const options = {where: {}, include: [{model: models.Evaluation, include: {model: models.UE}},
2021-01-20 17:14:33 +01:00
{attributes: ["email", "firstName", "lastName"], model: models.User, as: "TeacherGrade"},
{attributes: ["email", "firstName", "lastName"], model: models.User, as: "StudentGrade", include: {model: models.Group, include: models.Semester}}]};
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));
}
};