From f6bb69f994b6275de8330f673ccc14e4143c54d3 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Sun, 21 Jan 2024 00:30:44 +0000 Subject: [PATCH] Updated the condition to close assignment: to be end date or when all students finish the assignment --- src/dashboards/Teacher.tsx | 5 ++-- src/exams/pdf/details/radial.result.tsx | 31 +++++++++------------ src/exams/pdf/details/skill.exam.tsx | 24 ++++++++--------- src/interfaces/module.scores.ts | 36 ++++++++++++------------- 4 files changed, 45 insertions(+), 51 deletions(-) diff --git a/src/dashboards/Teacher.tsx b/src/dashboards/Teacher.tsx index e40d5a28..2d181089 100644 --- a/src/dashboards/Teacher.tsx +++ b/src/dashboards/Teacher.tsx @@ -151,8 +151,9 @@ export default function TeacherDashboard({user}: Props) { }; const AssignmentsPage = () => { - const activeFilter = (a: Assignment) => moment(a.endDate).isAfter(moment()) && moment(a.startDate).isBefore(moment()); - const pastFilter = (a: Assignment) => moment(a.endDate).isBefore(moment()); + const activeFilter = (a: Assignment) => + moment(a.endDate).isAfter(moment()) && moment(a.startDate).isBefore(moment()) && a.assignees.length > a.results.length; + const pastFilter = (a: Assignment) => moment(a.endDate).isBefore(moment()) || a.assignees.length === a.results.length; const futureFilter = (a: Assignment) => moment(a.startDate).isAfter(moment()); return ( diff --git a/src/exams/pdf/details/radial.result.tsx b/src/exams/pdf/details/radial.result.tsx index 125983a2..e5aa62db 100644 --- a/src/exams/pdf/details/radial.result.tsx +++ b/src/exams/pdf/details/radial.result.tsx @@ -1,24 +1,17 @@ /* eslint-disable jsx-a11y/alt-text */ import React from "react"; -import { View, Text, Image } from "@react-pdf/renderer"; -import { styles } from "../styles"; -import { ModuleScore } from "@/interfaces/module.scores"; +import {View, Text, Image} from "@react-pdf/renderer"; +import {styles} from "../styles"; +import {ModuleScore} from "@/interfaces/module.scores"; -export const RadialResult = ({ - module, - score, - total, - png, -}: ModuleScore) => ( - - - {module} - - - - {score} - out of {total} - - +export const RadialResult = ({module, score, total, png}: ModuleScore) => ( + + {module} + + + {score.toFixed(2)} + out of {total} + + ); diff --git a/src/exams/pdf/details/skill.exam.tsx b/src/exams/pdf/details/skill.exam.tsx index eb8a9581..459d4e3e 100644 --- a/src/exams/pdf/details/skill.exam.tsx +++ b/src/exams/pdf/details/skill.exam.tsx @@ -1,20 +1,20 @@ import React from "react"; -import { View, StyleSheet } from "@react-pdf/renderer"; -import { ModuleScore } from "@/interfaces/module.scores"; -import { RadialResult } from "./radial.result"; +import {View, StyleSheet} from "@react-pdf/renderer"; +import {ModuleScore} from "@/interfaces/module.scores"; +import {RadialResult} from "./radial.result"; interface Props { - testDetails: ModuleScore[]; + testDetails: ModuleScore[]; } const customStyles = StyleSheet.create({ - container: { display: "flex", flexDirection: "row", gap: 30 }, + container: {display: "flex", flexDirection: "row", gap: 30}, }); -export const SkillExamDetails = ({ testDetails }: Props) => ( - - {testDetails.map((detail) => { - const { module } = detail; - return ; - })} - +export const SkillExamDetails = ({testDetails}: Props) => ( + + {testDetails.map((detail) => { + const {module} = detail; + return ; + })} + ); diff --git a/src/interfaces/module.scores.ts b/src/interfaces/module.scores.ts index 2a4d4149..d52d51c4 100644 --- a/src/interfaces/module.scores.ts +++ b/src/interfaces/module.scores.ts @@ -1,22 +1,22 @@ import {Module} from "@/interfaces"; export interface ModuleScore { - score: number; - total: number; - code: Module; - module: Module | 'Overall'; - png?: string, - evaluation?: string, - suggestions?: string, - } + score: number; + total: number; + code: Module; + module: Module | "Overall"; + png?: string; + evaluation?: string; + suggestions?: string; +} - export interface StudentData { - id: string; - name: string; - email: string; - gender: string; - date: string; - result: string; - level?: string; - bandScore: number; - } \ No newline at end of file +export interface StudentData { + id: string; + name: string; + email: string; + gender: string; + date: string; + result: string; + level?: string; + bandScore: number; +}