Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bazzil29 committed Dec 27, 2018
1 parent 1ca3dfa commit 44ac3b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
10 changes: 3 additions & 7 deletions controller/admin.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,11 @@ module.exports = {

let count = 0;

studentSurveys.forEach(e => {
if (surveyChecker.verify(e)) {
count++;
}
})


if (studentSurveys) {
studentSurveys.forEach(e => {
if (surveyChecker.verify(e)) {
count++;
}
if (!!e.comment) {
comments.push(e.comment);
}
Expand Down
11 changes: 9 additions & 2 deletions controller/teacher.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const ClassSurvey = require('../models/classSurvey.model');
const Class = require('../models/class.model');
const StudentSurvey = require('../models/studentSurvey.model');

const surveyChecker = require('../common/validateSurvey');
const response = require('../common/response');

module.exports = {
Expand Down Expand Up @@ -41,15 +42,21 @@ module.exports = {
const isHaveClass = teacherClasses.find(e => e.id === classId);
const studentSurveys = await StudentSurvey.find({ class: classId });
const comments = [];
let count = 0;

if (studentSurveys) {
studentSurveys.forEach(e => {
if (surveyChecker.verify(e)) {
count++;
}

if (!!e.comment) {
comments.push(e.comment);
}
})
}


if (isHaveClass) {
const classSurvey = await ClassSurvey.findById(classId);
console.log(classSurvey);
Expand All @@ -61,7 +68,7 @@ module.exports = {
last_modify: classSurvey.last_modify,
deadline: classSurvey.deadline,
comments: comments,
count_of_students: studentSurveys.length
count_of_students: count
}
response.success(res, classSurveyTmp);
}
Expand All @@ -86,7 +93,7 @@ module.exports = {
id: classId,
name: isExistClass.name
});
teachers.findEach(e => {
teachers.forEach(e => {
if (e.id !== userId) {
for (let i = 0; i < e.class.length; i++) {
if (e.class[i].id === classId) {
Expand Down

0 comments on commit 44ac3b4

Please sign in to comment.