Skip to content

feat: finish score review flow - #26

Merged
NguyenTuKien merged 1 commit into
mainfrom
feature/danh-gia-phieu-diem
Apr 12, 2026
Merged

NguyenTuKien merged 1 commit into
mainfrom
feature/danh-gia-phieu-diem

Conversation

@NguyenTuKien

Copy link
Copy Markdown
Collaborator

This pull request introduces several new APIs and a major new component for lecturer evaluation management. The main focus is on enabling lecturers to view, manage, and finalize student evaluation results for their classes, including support for exporting reports and handling status changes. Additionally, new API modules are added for both monitor and student evaluation flows.

Key changes include:

Lecturer Evaluation Management:

  • Added a new LecturerClassEvaluation React component that allows lecturers to view all students in their classes, see evaluation statuses, finalize all approved evaluations, and export results to Excel. The component handles class and semester selection, paginated student lists, and integrates a modal for reviewing individual evaluations.

API Enhancements:

  • Added new API functions in monitorEvaluationApi.js to fetch class evaluation lists, get evaluation detail, and submit monitor reviews, supporting monitor-level evaluation workflows.
  • Introduced studentEvaluationApi.js with endpoints for fetching and submitting student evaluation forms, streamlining the student-side evaluation process.
  • Added a getAllCriteria API function to evaluationApi.js for retrieving all evaluation criteria, supporting dynamic forms and evaluation logic.

@NguyenTuKien

Copy link
Copy Markdown
Collaborator Author

@copilot review

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

@copilot review

I reviewed the current PR changes in commit f617634. The frontend build passes (npm run build). Lint failures are present but are pre-existing/unrelated across other areas of the repo, so I did not make additional code changes in this pass. If you want, I can open a follow-up to clean up lint issues in the touched lecturer/monitor/student files.

@NguyenTuKien
NguyenTuKien merged commit 9c712be into main Apr 12, 2026
14 of 18 checks passed
@NguyenTuKien
NguyenTuKien deleted the feature/danh-gia-phieu-diem branch April 12, 2026 16:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes the evaluation/score review flow by adding student self-evaluation UI, monitor review UI, and lecturer finalization UI, along with supporting API utilities and styling.

Changes:

  • Added student “Phiếu rèn luyện” board (criteria display + self-scoring + submit/draft) and integrated it into the student navigation.
  • Reworked monitor class view into an evaluation management table with per-student review modal and export.
  • Added lecturer class evaluation management page with per-student review modal and “finalize all” action, plus API additions (e.g., criteria fetch).

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
frontend/src/styles/MonitorClass.css New shared styling for monitor/lecturer evaluation tables + modal UI.
frontend/src/pages/StudentPage.jsx Adds “evaluation” feature routing + monitor “manage-class” routing.
frontend/src/pages/LecturerPage.jsx Adds lecturer sidebar entry + routes to new evaluation management component.
frontend/src/hooks/useCurrentSemester.js Refactors semester hook to return semesters + activeSemesterId.
frontend/src/features/student/StudentEvaluationBoard.jsx New student evaluation board UI and semester selection logic.
frontend/src/features/student/StudentEvaluationBoard.css Styling for the student evaluation board UI.
frontend/src/features/student/hooks/useStudentEvaluationForm.js New hook to fetch criteria + form data and submit draft/final.
frontend/src/features/student/components/StudentMobileNav.jsx Adds “Đánh giá” shortcut to mobile nav.
frontend/src/features/monitor/hooks/useMonitorEvaluationList.js New hook to fetch monitor’s class evaluation list + basic stats.
frontend/src/features/monitor/components/MonitorReviewModal.jsx New monitor modal to view/adjust student-evaluated criteria and submit review.
frontend/src/features/monitor/components/MonitorClass.jsx Replaces legacy class management with evaluation management UI + modal + export.
frontend/src/features/lecturer/hooks/useLecturerEvaluationList.js New hook to fetch lecturer class evaluation list + stats.
frontend/src/features/lecturer/components/LecturerReviewModal.jsx New lecturer modal to review/confirm MONITOR_APPROVED evaluations.
frontend/src/features/lecturer/components/LecturerClassEvaluation.jsx New lecturer evaluation management page (class/semester select, export, finalize).
frontend/src/api/studentEvaluationApi.js New student evaluation API module.
frontend/src/api/monitorEvaluationApi.js New monitor evaluation API module.
frontend/src/api/evaluationApi.js Adds getAllCriteria() API helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}, []);

return { semesterId, loading, error };
return { semesters, activeSemesterId, loading, error };

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useCurrentSemester() previously returned { semesterId, loading, error } (e.g. components/evaluation/SemesterRouteWrapper.jsx destructures semesterId). This hook now returns { semesters, activeSemesterId, ... }, which will break existing consumers at runtime/compile time unless they’re updated. Consider preserving a semesterId alias (mapped to activeSemesterId) for backward compatibility or updating all call sites in the same PR.

Suggested change
return { semesters, activeSemesterId, loading, error };
return {
semesters,
activeSemesterId,
semesterId: activeSemesterId,
loading,
error,
};

Copilot uses AI. Check for mistakes.
padding: 20px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
display: flex;
flex-col;

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flex-col; is not a valid CSS declaration, so the summary cards won’t lay out as intended. Replace it with flex-direction: column; (or the intended flex layout).

Suggested change
flex-col;
flex-direction: column;

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,274 @@
import React, { useEffect, useMemo, useState } from 'react';

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React is imported but never used in this component. With the current ESLint config (no-unused-vars), this will fail linting—remove the default React import and only import the hooks you use.

Suggested change
import React, { useEffect, useMemo, useState } from 'react';
import { useEffect, useMemo, useState } from 'react';

Copilot uses AI. Check for mistakes.
Comment on lines +16 to +22
function getInitials(name) {
if (!name) return "NA";
const parts = name.split(' ');
if (parts.length >= 2) {
return `${parts[parts.length - 2][0]}${parts[parts.length - 1][0]}`.toUpperCase();
}
if (normalized.includes("đạt")) {
return { passed: true, ratio: text.split(" ")[0] || text };
}
return { passed: true, ratio: text };
return name.substring(0, 2).toUpperCase();

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getInitials uses name.split(' '), which can produce empty parts when the name contains leading/trailing or multiple spaces; indexing [0] on an empty string can throw. Consider using name.trim().split(/\s+/) (as done elsewhere) and guarding against missing characters.

Copilot uses AI. Check for mistakes.
Comment on lines +94 to +96
const selectedSemesterObj = semesters.find(s => s.id === Number(selectedSemester));
const semesterName = selectedSemesterObj?.name || 'Học kỳ...';

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semesterName is declared but never used, which will trip the repo’s no-unused-vars lint rule. Either use it in the UI (e.g., in the header/subtitle) or remove it.

Suggested change
const selectedSemesterObj = semesters.find(s => s.id === Number(selectedSemester));
const semesterName = selectedSemesterObj?.name || 'Học kỳ...';

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +12
const response = await apiRequest(`/api/v1/student/evaluations/form/${semesterId}`);
// Often backend wraps data inside { data: ... }
return response.data || response;
}

export async function submitEvaluation(semesterId, payload) {
// Post payload with { isDraft, detailsJsonb }
const response = await apiRequest(`/api/v1/student/evaluations/${semesterId}/submit`, {

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API module uses /api/v1/... paths, but apiRequest already prefixes requests with API_BASE_URL (default /api). That will produce /api/api/v1/... at runtime. Align the paths with the rest of the codebase (e.g. /v1/...) or remove this module if evaluationApi is the intended source of truth.

Suggested change
const response = await apiRequest(`/api/v1/student/evaluations/form/${semesterId}`);
// Often backend wraps data inside { data: ... }
return response.data || response;
}
export async function submitEvaluation(semesterId, payload) {
// Post payload with { isDraft, detailsJsonb }
const response = await apiRequest(`/api/v1/student/evaluations/${semesterId}/submit`, {
const response = await apiRequest(`/v1/student/evaluations/form/${semesterId}`);
// Often backend wraps data inside { data: ... }
return response.data || response;
}
export async function submitEvaluation(semesterId, payload) {
// Post payload with { isDraft, detailsJsonb }
const response = await apiRequest(`/v1/student/evaluations/${semesterId}/submit`, {

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +25
import { apiRequest } from '../shared/api/http';

export async function getMonitorClassEvaluations(semesterId) {
if (!semesterId) return [];
const response = await apiRequest(`/v1/monitor/evaluations/class-list?semesterId=${semesterId}`);
return response?.data || response || [];
}

export async function getMonitorEvaluationDetail(evaluationId) {
if (!evaluationId) return null;
const response = await apiRequest(`/v1/monitor/evaluations/${evaluationId}`);
return response?.data || response;
}

export async function submitMonitorReview(evaluationId, adjustedDetails) {
const payload = {
evaluationId,
adjustedDetails
};
const response = await apiRequest(`/v1/monitor/evaluations/review`, {
method: 'POST',
body: JSON.stringify(payload)
});
return response;
}

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file duplicates monitor evaluation endpoints that already exist in src/api/evaluationApi.js (e.g. getMonitorEvaluationDetail, .../review). Keeping two clients for the same endpoints risks them diverging (different unwrapping, naming, error handling). Consider consolidating on a single API module and re-exporting helpers if needed.

Copilot uses AI. Check for mistakes.
const handleExportExcel = () => {
const header = `<tr><th>MSSV</th><th>Họ và Tên</th><th>Điểm tổng kết</th><th>Trạng thái</th></tr>`;
const rows = students.map(s =>
`<tr><td>${s.studentCode}</td><td>${s.fullName}</td><td>${s.finalScore || '--'}</td><td>${s.status || 'NOT_SUBMITTED'}</td></tr>`

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using s.finalScore || '--' will output '--' when finalScore is 0. Use a nullish check (e.g. s.finalScore ?? '--') to avoid losing legitimate zero scores in the export.

Suggested change
`<tr><td>${s.studentCode}</td><td>${s.fullName}</td><td>${s.finalScore || '--'}</td><td>${s.status || 'NOT_SUBMITTED'}</td></tr>`
`<tr><td>${s.studentCode}</td><td>${s.fullName}</td><td>${s.finalScore ?? '--'}</td><td>${s.status || 'NOT_SUBMITTED'}</td></tr>`

Copilot uses AI. Check for mistakes.
</div>
</td>
<td className="cell-score final" style={{ textAlign: 'center' }}>
{student.finalScore || '--'}

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using student.finalScore || '--' will render '--' for a real score of 0. Prefer a nullish check (e.g. student.finalScore ?? '--') so zero scores display correctly.

Suggested change
{student.finalScore || '--'}
{student.finalScore ?? '--'}

Copilot uses AI. Check for mistakes.
Comment on lines +252 to +260
<button
className="action-approve-all"
disabled={finalizing || stats.total === 0 || stats.approvedByMonitor < stats.total}
onClick={handleFinalizeAll}
style={{ backgroundColor: '#3b82f6', flex: 'none' }}
title={stats.approvedByMonitor < stats.total ? `Còn ${stats.pendingCount} phiếu chưa được lớp trưởng duyệt` : ''}
>
{finalizing ? 'Đang hoàn tất...' : 'Hoàn tất tổng kết'}
</button>

Copilot AI Apr 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The “Hoàn tất tổng kết” button is disabled unless approvedByMonitor === total, which prevents finalizing the subset of evaluations that are already monitor-approved. This conflicts with the described behavior of finalizing approved evaluations. Consider allowing finalize when approvedByMonitor > 0 (and finalizing only those), or adjust the UI copy/behavior to reflect the all-or-nothing requirement.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants