diff --git a/api/drawingcouseselling/src/main/java/com/group1/drawingcouseselling/controller/CourseContentCompletionController.java b/api/drawingcouseselling/src/main/java/com/group1/drawingcouseselling/controller/CourseContentCompletionController.java index adc32a7e..f1c6d3ab 100644 --- a/api/drawingcouseselling/src/main/java/com/group1/drawingcouseselling/controller/CourseContentCompletionController.java +++ b/api/drawingcouseselling/src/main/java/com/group1/drawingcouseselling/controller/CourseContentCompletionController.java @@ -38,7 +38,7 @@ public ResponseEntity> getCustomerCourseComplet String email = jwtService.extractUserEmail(authorization.substring(7)); return ResponseEntity.ok(courseContentCompletionService.checkCourseContentCompleted(id, email)); } - @GetMapping("/course-content-completion/submit-exam") + @PostMapping("/course-content-completion/submit-exam") public ResponseEntitysubmitExam(@RequestParam(value = "id")BigDecimal id, @RequestParam(value = "file")MultipartFile file, @RequestHeader(value = "Authorization") String authorization){ diff --git a/api/drawingcouseselling/src/main/java/com/group1/drawingcouseselling/model/dto/CourseContentDto.java b/api/drawingcouseselling/src/main/java/com/group1/drawingcouseselling/model/dto/CourseContentDto.java index fedfee75..f06d8fda 100644 --- a/api/drawingcouseselling/src/main/java/com/group1/drawingcouseselling/model/dto/CourseContentDto.java +++ b/api/drawingcouseselling/src/main/java/com/group1/drawingcouseselling/model/dto/CourseContentDto.java @@ -1,5 +1,6 @@ package com.group1.drawingcouseselling.model.dto; +import com.group1.drawingcouseselling.model.enums.ECourseContentType; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Pattern; @@ -19,12 +20,14 @@ public record CourseContentDto(BigDecimal id, @Pattern(regexp = "^(https?://)?(www\\.)?youtube\\.com/watch\\?v=[a-zA-Z0-9_-]+.*$", message = "Invalid YouTube link") @NotBlank(message = "The youtube link must not be empty") String videoLink, + ECourseContentType courseType, Date createDate) { - public CourseContentDto(BigDecimal id, String title, String description, String videoLink, Date createDate) { + public CourseContentDto(BigDecimal id, String title, String description, String videoLink, ECourseContentType courseType, Date createDate) { this.id = id; this.title = title; this.description = description; this.videoLink = videoLink; this.createDate = createDate; + this.courseType = courseType; } } diff --git a/api/drawingcouseselling/src/main/java/com/group1/drawingcouseselling/model/entity/CourseContent.java b/api/drawingcouseselling/src/main/java/com/group1/drawingcouseselling/model/entity/CourseContent.java index b85652d5..960eaa43 100644 --- a/api/drawingcouseselling/src/main/java/com/group1/drawingcouseselling/model/entity/CourseContent.java +++ b/api/drawingcouseselling/src/main/java/com/group1/drawingcouseselling/model/entity/CourseContent.java @@ -111,6 +111,7 @@ public CourseContent covertDtoToEntity(CourseContentDto data) { lesson.setDescription(data.description()); lesson.setVideoLink(data.videoLink()); lesson.setCreateDate(data.createDate()); + lesson.setCourseContentType(data.courseType()); return lesson; } @@ -122,6 +123,7 @@ public CourseContentDto convertEntityToDto(CourseContent data) { .description(data.getDescription()) .videoLink(data.getVideoLink()) .createDate(data.getCreateDate()) + .courseType(data.getCourseContentType()) .build(); } } diff --git a/api/drawingcouseselling/src/main/resources/application-dev.yml b/api/drawingcouseselling/src/main/resources/application-dev.yml index 78c9eebb..e69f0913 100644 --- a/api/drawingcouseselling/src/main/resources/application-dev.yml +++ b/api/drawingcouseselling/src/main/resources/application-dev.yml @@ -11,6 +11,10 @@ aws: key: tN7GXYsy2zZHqb1znrfCf/hmNXzdFuRN9MSPdG2P spring: + servlet: + multipart: + max-file-size: 10MB + max-request-size: 10MB datasource: url: jdbc:mariadb://${DB_HOST:anataarisa.hopto.org}:${DB_PORT:3306}/ademy # url: jdbc:mariadb://localhost:3307/ademy diff --git a/frontend/my-app/src/lib/types.ts b/frontend/my-app/src/lib/types.ts index d88a2967..832c62c9 100644 --- a/frontend/my-app/src/lib/types.ts +++ b/frontend/my-app/src/lib/types.ts @@ -1,4 +1,39 @@ import { type } from "os"; +export type GradingExam = { + examID:number; + score:string; + comment:string; +} +export type GetExamAllInfo = { + examInfo: ExamStatusInfo; + customerInfo:Customer + courseContent:CourseContent; + course:Course +}; +export type ReviewsPaginationForGrading = { + content: ExamStatusInfo[]; + pageable: Pageable; + totalElements: number; + totalPages: number; + last: boolean; + numberOfElements: number; + first: boolean; + size: number; + number: number; + sort: { + unsorted: boolean; + sorted: boolean; + empty: boolean; + }; + empty: boolean; +}; +export type ExamStatusInfo = { + id:number; + score:string; + artLink:string; + examStatus:string; + comment:string; +} export type Section = { id:number; @@ -12,6 +47,7 @@ export type CourseContent = { description:string; videoLink:string; createDate:Date; + courseType:string; } export type SectionDetail = { @@ -115,7 +151,7 @@ type AccountPagination = { empty: boolean; }; -type Customer = { +export type Customer = { customerID: number; fullName: string; birthDate: Date; diff --git a/frontend/my-app/src/routes/CreateCourse.svelte b/frontend/my-app/src/routes/CreateCourse.svelte index a6d41be8..82b2cc38 100644 --- a/frontend/my-app/src/routes/CreateCourse.svelte +++ b/frontend/my-app/src/routes/CreateCourse.svelte @@ -19,7 +19,7 @@ let counter = 6; let message = ""; let errorMsg = ""; - let file: any[] | Blob; + let file: FileList; let formData = new FormData(); let formModal = false; @@ -42,7 +42,7 @@ async function UploadImage() { let res; - formData.append("file", file[0]); + formData.set("file", file[0]); console.log(formData); let img_url:string; res = await axios diff --git a/frontend/my-app/src/routes/CreateCourseSection.svelte b/frontend/my-app/src/routes/CreateCourseSection.svelte index 2f76a62a..4118998d 100644 --- a/frontend/my-app/src/routes/CreateCourseSection.svelte +++ b/frontend/my-app/src/routes/CreateCourseSection.svelte @@ -29,6 +29,10 @@ let errorMsg = ""; export let id: number; let sectionList: Section[] = []; + let courseContentType = [ + { value: 'COURSE_CONTENT', name: 'Normal' }, + { value: 'TESTING', name: 'Test' } + ]; let modeSelect: string; let content: CourseContentCreate = { @@ -39,6 +43,7 @@ createDate: new Date("2023-10-19"), title: "", videoLink: "", + courseType: "" }, }; let section: SectionCreate = { @@ -91,6 +96,7 @@ async function CreateCourseContent() { let res; DisableSubmitButton(); + console.log(content); res = await axios .post(apiBaseUrl + "course-content", content, { headers: { @@ -284,6 +290,10 @@ required /> +