Skip to content
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@
"express": "^4.22.1",
"express-validator": "^7.0.1",
"express-ws": "^5.0.2",
"form-data": "^4.0.5",
"geoip-lite": "^1.4.10",
"googleapis": "^100.0.0",
"isomorphic-fetch": "^3.0.0",
"joi": "^18.0.1",
"joi": "^18.0.2",
"json2csv": "^6.0.0-alpha.2",
"jsonwebtoken": "^9.0.0",
"lodash": "^4.17.21",
Expand Down
26 changes: 13 additions & 13 deletions src/controllers/educationPortal/downloadReportController.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function buildTaskQuery(type, params) {

function calculateAverageGrade(taskList) {
const gradedTasks = taskList.filter(
t => t.grade && t.grade !== 'pending' && GRADE_MAP[t.grade] !== undefined,
(t) => t.grade && t.grade !== 'pending' && GRADE_MAP[t.grade] !== undefined,
);

if (gradedTasks.length === 0) return 'N/A';
Expand All @@ -99,7 +99,9 @@ async function fetchStudentReport(studentId, startDate, endDate) {
const [tasks, student] = await Promise.all([
EducationTask.find(query)
.populate('studentId', 'firstName lastName email')
.select('type status grade dueAt completedAt feedback suggestedTotalHours loggedHours assignedAt')
.select(
'type status grade dueAt completedAt feedback suggestedTotalHours loggedHours assignedAt',
)
.sort({ assignedAt: -1 })
.limit(MAX_RECORDS_PER_REPORT)
.lean(),
Expand All @@ -114,7 +116,7 @@ async function fetchStudentReport(studentId, startDate, endDate) {
return null;
}

const taskData = tasks.map(task => ({
const taskData = tasks.map((task) => ({
taskName: task.type || 'N/A',
type: task.type,
status: task.status,
Expand All @@ -127,10 +129,10 @@ async function fetchStudentReport(studentId, startDate, endDate) {
assignedAt: task.assignedAt,
}));

const completed = tasks.filter(t => t.status === 'completed').length;
const inProgress = tasks.filter(t => t.status === 'in_progress').length;
const graded = tasks.filter(t => t.status === 'graded').length;
const assigned = tasks.filter(t => t.status === 'assigned').length;
const completed = tasks.filter((t) => t.status === 'completed').length;
const inProgress = tasks.filter((t) => t.status === 'in_progress').length;
const graded = tasks.filter((t) => t.status === 'graded').length;
const assigned = tasks.filter((t) => t.status === 'assigned').length;

return {
student: {
Expand Down Expand Up @@ -215,7 +217,7 @@ async function fetchClassReport(classId, startDate, endDate) {
return Number.isNaN(grade) ? sum : sum + grade;
}, 0);

const studentsWithGrades = students.filter(s => s.averageGrade !== 'N/A').length;
const studentsWithGrades = students.filter((s) => s.averageGrade !== 'N/A').length;

return {
classId,
Expand Down Expand Up @@ -373,14 +375,12 @@ function generateCSVReport(res, reportData, metadata, type) {
{ label: 'Feedback', value: 'feedback' },
];

data = reportData.tasks.map(task => ({
data = reportData.tasks.map((task) => ({
taskName: task.taskName,
status: task.status,
grade: task.grade,
dueDate: task.dueDate ? new Date(task.dueDate).toLocaleDateString() : 'N/A',
completedDate: task.completedDate
? new Date(task.completedDate).toLocaleDateString()
: 'N/A',
completedDate: task.completedDate ? new Date(task.completedDate).toLocaleDateString() : 'N/A',
suggestedHours: task.suggestedHours,
loggedHours: task.loggedHours,
feedback: task.feedback || '',
Expand Down Expand Up @@ -479,4 +479,4 @@ const downloadReportController = {
},
};

module.exports = downloadReportController;
module.exports = downloadReportController;
Loading