diff --git a/backend/src/qp.rs b/backend/src/qp.rs index 6dda220..1ef5ebc 100644 --- a/backend/src/qp.rs +++ b/backend/src/qp.rs @@ -99,7 +99,7 @@ impl From for String { match value { Exam::Midsem => "midsem".into(), Exam::Endsem => "endsem".into(), - Exam::Unknown => "unknown".into(), + Exam::Unknown => "".into(), Exam::CT(None) => "ct".into(), Exam::CT(Some(i)) => format!("ct{}", i), } diff --git a/frontend/src/components/Common/PaperEditModal.tsx b/frontend/src/components/Common/PaperEditModal.tsx index df8fc3a..d8e25c2 100644 --- a/frontend/src/components/Common/PaperEditModal.tsx +++ b/frontend/src/components/Common/PaperEditModal.tsx @@ -87,7 +87,7 @@ function PaperEditModal(props: } if (validateYear(data.year)) similarityDetails['year'] = data.year; - if (validateExam(data.exam) && data.exam !== 'unknown' && data.exam !== 'ct') similarityDetails['exam'] = data.exam; + if (validateExam(data.exam) && data.exam !== '' && data.exam !== 'ct') similarityDetails['exam'] = data.exam; if (validateSemester(data.semester)) similarityDetails['semester'] = data.semester; getSimilarPapers(similarityDetails); diff --git a/frontend/src/components/Search/SearchResults.tsx b/frontend/src/components/Search/SearchResults.tsx index 1fab6d3..4bb723e 100644 --- a/frontend/src/components/Search/SearchResults.tsx +++ b/frontend/src/components/Search/SearchResults.tsx @@ -168,7 +168,7 @@ function ResultCard(result: ISearchResult) { // unknown - N/A // midsem - MID; endsem - END // ctx - CT1, CT2, etc. - return exam === 'unknown' ? 'N/A' : + return exam === '' ? 'N/A' : (exam === 'midsem' || exam === 'endsem') ? exam.slice(0, 3).toUpperCase() : exam.toUpperCase(); @@ -178,7 +178,7 @@ function ResultCard(result: ISearchResult) { // unknown - Exam Unknown // midsem - Midsem; endsem - Endsem // ctx - Class Test 1, Class Test 2, etc. - return exam === 'unknown' ? 'Exam Unknown' : + return exam === '' ? 'Exam Unknown' : (exam === 'midsem' || exam === 'endsem') ? exam[0].toUpperCase() + exam.slice(1) : `Class Test ${exam.slice(2).length > 0 ? exam.slice(2) : '?'}`; diff --git a/frontend/src/types/question_paper.ts b/frontend/src/types/question_paper.ts index 25a9260..e6beda5 100644 --- a/frontend/src/types/question_paper.ts +++ b/frontend/src/types/question_paper.ts @@ -10,7 +10,7 @@ export interface IQuestionPaper { course_name: string; year: number; semester: Semester; - exam: Exam | "ct" | "unknown"; + exam: Exam | "ct" | ""; }; export interface ISearchResult extends IQuestionPaper { diff --git a/frontend/src/utils/autofillData.ts b/frontend/src/utils/autofillData.ts index 352aa10..50bfd48 100644 --- a/frontend/src/utils/autofillData.ts +++ b/frontend/src/utils/autofillData.ts @@ -159,7 +159,7 @@ export const autofillData = async ( const course_code = filenameOrPdfFallback(filenameCourseCode, pdfCourseCode, validateCourseCode, 'Unknown Course'); const year = filenameOrPdfFallback(filenameYear, pdfYear, validateYear, new Date().getFullYear()); - const exam = filenameOrPdfFallback(filenameExam, pdfExam, validateExam, 'unknown'); + const exam = filenameOrPdfFallback(filenameExam, pdfExam, validateExam, ''); const semester = filenameOrPdfFallback(filenameSemester, pdfSemester, validateSemester, new Date().getMonth() > 7 ? "autumn" : "spring"); const qpDetails: IQuestionPaper = {