Repository navigation
feat: finish score review flow - #26
Conversation
|
@copilot review |
|
I reviewed the current PR changes in commit |
There was a problem hiding this comment.
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 }; |
There was a problem hiding this comment.
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.
| return { semesters, activeSemesterId, loading, error }; | |
| return { | |
| semesters, | |
| activeSemesterId, | |
| semesterId: activeSemesterId, | |
| loading, | |
| error, | |
| }; |
| padding: 20px; | ||
| box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04); | ||
| display: flex; | ||
| flex-col; |
There was a problem hiding this comment.
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).
| flex-col; | |
| flex-direction: column; |
| @@ -0,0 +1,274 @@ | |||
| import React, { useEffect, useMemo, useState } from 'react'; | |||
There was a problem hiding this comment.
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.
| import React, { useEffect, useMemo, useState } from 'react'; | |
| import { useEffect, useMemo, useState } from 'react'; |
| 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(); |
There was a problem hiding this comment.
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.
| const selectedSemesterObj = semesters.find(s => s.id === Number(selectedSemester)); | ||
| const semesterName = selectedSemesterObj?.name || 'Học kỳ...'; | ||
|
|
There was a problem hiding this comment.
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.
| const selectedSemesterObj = semesters.find(s => s.id === Number(selectedSemester)); | |
| const semesterName = selectedSemesterObj?.name || 'Học kỳ...'; |
| 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`, { |
There was a problem hiding this comment.
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.
| 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`, { |
| 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; | ||
| } |
There was a problem hiding this comment.
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.
| 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>` |
There was a problem hiding this comment.
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.
| `<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>` |
| </div> | ||
| </td> | ||
| <td className="cell-score final" style={{ textAlign: 'center' }}> | ||
| {student.finalScore || '--'} |
There was a problem hiding this comment.
Using student.finalScore || '--' will render '--' for a real score of 0. Prefer a nullish check (e.g. student.finalScore ?? '--') so zero scores display correctly.
| {student.finalScore || '--'} | |
| {student.finalScore ?? '--'} |
| <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> |
There was a problem hiding this comment.
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.



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:
LecturerClassEvaluationReact 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:
monitorEvaluationApi.jsto fetch class evaluation lists, get evaluation detail, and submit monitor reviews, supporting monitor-level evaluation workflows.studentEvaluationApi.jswith endpoints for fetching and submitting student evaluation forms, streamlining the student-side evaluation process.getAllCriteriaAPI function toevaluationApi.jsfor retrieving all evaluation criteria, supporting dynamic forms and evaluation logic.