Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thang/Add exam grading feature, submit image for grading and validate submission status #115

Merged
merged 21 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0aa4a7e
Merge branch 'main' of https://github.com/AnataAria/Fall2023SWP391_NE…
PoserDungeon2003 Nov 6, 2023
d999f54
Merge branch 'main' of https://github.com/AnataAria/Fall2023SWP391_NE…
PoserDungeon2003 Nov 6, 2023
5b6226e
Fix upload image for course
PoserDungeon2003 Nov 6, 2023
b0b4629
Merge branch 'main' of https://github.com/AnataAria/Fall2023SWP391_NE…
PoserDungeon2003 Nov 6, 2023
3a675cb
Merge branch 'main' of https://github.com/AnataAria/Fall2023SWP391_NE…
PoserDungeon2003 Nov 6, 2023
3d205af
Validate exam submission
PoserDungeon2003 Nov 6, 2023
b15d6db
Add course content type
PoserDungeon2003 Nov 6, 2023
6bd1fd9
Add type for course content type
PoserDungeon2003 Nov 6, 2023
165ccb1
Increase max file size
PoserDungeon2003 Nov 6, 2023
ba0548e
Add course content type dropdown
PoserDungeon2003 Nov 6, 2023
4c6cae8
Merge branch 'main' of https://github.com/AnataAria/Fall2023SWP391_NE…
PoserDungeon2003 Nov 6, 2023
e9e2427
Merge branch 'main' of https://github.com/AnataAria/Fall2023SWP391_NE…
PoserDungeon2003 Nov 7, 2023
51f34ed
Add submit exam validation
PoserDungeon2003 Nov 7, 2023
678c946
Add grading page
PoserDungeon2003 Nov 7, 2023
ad1e7ab
Change grading page route
PoserDungeon2003 Nov 7, 2023
fb7d951
Fix exam submission status
PoserDungeon2003 Nov 7, 2023
2b828de
Merge branch 'main' of https://github.com/AnataAria/Fall2023SWP391_NE…
PoserDungeon2003 Nov 7, 2023
ff56f46
Add types
PoserDungeon2003 Nov 7, 2023
ffa9023
Add exam grading feature
PoserDungeon2003 Nov 7, 2023
0d62e86
Add auto mark as completed for exam
PoserDungeon2003 Nov 7, 2023
3671041
Add redirect button to grading page
PoserDungeon2003 Nov 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ResponseEntity<List<CourseContentCompletionDto>> 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 ResponseEntity<ExamDto>submitExam(@RequestParam(value = "id")BigDecimal id,
@RequestParam(value = "file")MultipartFile file,
@RequestHeader(value = "Authorization") String authorization){
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -122,6 +123,7 @@ public CourseContentDto convertEntityToDto(CourseContent data) {
.description(data.getDescription())
.videoLink(data.getVideoLink())
.createDate(data.getCreateDate())
.courseType(data.getCourseContentType())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 37 additions & 1 deletion frontend/my-app/src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,6 +47,7 @@ export type CourseContent = {
description:string;
videoLink:string;
createDate:Date;
courseType:string;
}

export type SectionDetail = {
Expand Down Expand Up @@ -115,7 +151,7 @@ type AccountPagination = {
empty: boolean;
};

type Customer = {
export type Customer = {
customerID: number;
fullName: string;
birthDate: Date;
Expand Down
4 changes: 2 additions & 2 deletions frontend/my-app/src/routes/CreateCourse.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions frontend/my-app/src/routes/CreateCourseSection.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -39,6 +43,7 @@
createDate: new Date("2023-10-19"),
title: "",
videoLink: "",
courseType: ""
},
};
let section: SectionCreate = {
Expand Down Expand Up @@ -91,6 +96,7 @@
async function CreateCourseContent() {
let res;
DisableSubmitButton();
console.log(content);
res = await axios
.post(apiBaseUrl + "course-content", content, {
headers: {
Expand Down Expand Up @@ -284,6 +290,10 @@
required
/>
</Label>
<Label>
Course content type
<Select class="mt-2" items={courseContentType} bind:value={content.courseContent.courseType} />
</Label>
{/if}
<div id="submitButton">
<Button
Expand Down
6 changes: 3 additions & 3 deletions frontend/my-app/src/routes/Score.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script>
<script lang="ts">
let open = false;
let score = null;
export let score:string = "";

function selectScore(s) {
function selectScore(s:string) {
score = s;
open = false;
}
Expand Down
263 changes: 237 additions & 26 deletions frontend/my-app/src/routes/ScoringPage.svelte

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions frontend/my-app/src/routes/instructor/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import type { Course } from "$lib/types";
import CreateCourseSection from "../CreateCourseSection.svelte";
import CreateCourse from "../CreateCourse.svelte";
import { Button } from "flowbite-svelte";

interface Instructorinterface {
email: string;
Expand Down Expand Up @@ -152,6 +153,11 @@
>
Add Course</a
> -->
<div class="flex flex-col items-center justify-center mt-2">
<Button href="/instructor/grading" color="blue"
>Grade Submission</Button
>
</div>
</div>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions frontend/my-app/src/routes/instructor/grading/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script>
import ScoringPage from "../../ScoringPage.svelte";

</script>
<ScoringPage/>
Loading