Skip to content

Commit

Permalink
✨ 강의 계획서 개선 및 에브리타임 강의평 정보 연동 (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbsp1221 authored Sep 15, 2023
1 parent 8ce47c1 commit 9c03ee9
Show file tree
Hide file tree
Showing 11 changed files with 644 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [Fixed] 수강인원 조회 기능이 동작하지 않던 오류를 해결했습니다. (https://github.com/klas-helper/klas-helper-extension/issues/16)
- [Fixed] 빠졌던 기능인 검색어 없이 강의를 검색할 수 있는 기능을 추가했습니다.
- [Added] 졸업가부 및 졸업불가사유 확인 메뉴를 추가했습니다.
- [Added] 강의 계획서 개선 및 에브리타임 강의평 정보 연동 기능이 추가되었습니다. (https://github.com/klas-helper/klas-helper-extension/pull/24)

## 2.0.3.0 (2023.06.25)
- [Fixed] KLAS 구조 변경으로 인해 작동하지 않던 일부 기능(강의계획서 수강인원 조회 등)을 수정하였습니다.
Expand Down
31 changes: 31 additions & 0 deletions src/apis/fetchCommonSubjects.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export interface CommonSubject {
code: string;
name: string;
}

function parseCommonSubject(data: any): CommonSubject {
return {
code: data.code,
name: data.codeName1,
};
}

/**
* 광운대학교의 공통 과목 목록을 가져옵니다.
*/
export async function fetchCommonSubjects(): Promise<CommonSubject[]> {
const response = await fetch('/std/cps/atnlc/CmmnGamokList.do', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: '{}',
});

if (!response.ok) {
throw new Error(`Failed to fetch common subjects. Status: ${response.status}`);
}

return (await response.json()).map(parseCommonSubject);
}
39 changes: 39 additions & 0 deletions src/apis/fetchDepartments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export interface Department {
code: string;
name: string;
}

export interface FetchDepartmentsRequestData {
year: number | string;
semester: string;
}

function parseDepartment(data: any): Department {
return {
code: data.classCode,
name: data.openMajorName,
};
}

/**
* 광운대학교의 학과 목록을 가져옵니다.
*/
export async function fetchDepartments(requestData: FetchDepartmentsRequestData): Promise<Department[]> {
const response = await fetch('/std/cps/atnlc/CmmnHakgwaList.do', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
selectYear: requestData.year,
selecthakgi: requestData.semester,
}),
});

if (!response.ok) {
throw new Error(`Failed to fetch departments. Status: ${response.status}`);
}

return (await response.json()).map(parseDepartment);
}
77 changes: 77 additions & 0 deletions src/apis/fetchLectures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
export interface Lecture {
year: string;
semester: string;
majorCode: string;
grade: string;
code: string;
classNumber: string;
name: string;
professorName: string;
classification: string;
classHours: number;
credits: number;
contact: string;
description: string;
isClosed: boolean;
introVideoUrl: string;
}

export interface FetchLecturesRequestData {
year: number | string;
semester: string;
enrollmentStatus: string;
lectureName?: string;
professorName?: string;
commonSubjectCode?: string;
departmentCode?: string;
majorCode?: string;
}

function parseLecture(data: any): Lecture {
return {
year: data.thisYear,
semester: data.hakgi,
majorCode: data.openMajorCode,
grade: data.openGrade,
code: data.openGwamokNo,
classNumber: data.bunbanNo,
name: data.gwamokKname,
professorName: data.memberName,
classification: data.codeName1,
classHours: data.sisuNum,
credits: data.hakjumNum,
contact: data.telNo ?? '',
description: data.summary ?? '',
isClosed: Boolean(data.closeOpt),
introVideoUrl: data.videoUrl ?? '',
};
}

/**
* 광운대학교의 강의 목록을 가져옵니다.
*/
export async function fetchLectures(requestData: FetchLecturesRequestData): Promise<Lecture[]> {
const response = await fetch('/std/cps/atnlc/LectrePlanStdList.do', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
selectYear: requestData.year,
selecthakgi: requestData.semester,
selectRadio: requestData.enrollmentStatus,
selectText: requestData.lectureName ?? '',
selectProfsr: requestData.professorName ?? '',
cmmnGamok: requestData.commonSubjectCode ?? '',
selecthakgwa: requestData.departmentCode ?? '',
selectMajor: requestData.majorCode ?? '',
}),
});

if (!response.ok) {
throw new Error(`Failed to fetch lectures. Status: ${response.status}`);
}

return (await response.json()).map(parseLecture);
}
41 changes: 41 additions & 0 deletions src/apis/fetchMajors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export interface Major {
code: string;
name: string;
}

export interface FetchMajorsRequestData {
year: number | string;
semester: string;
departmentCode: string;
}

function parseMajor(data: any): Major {
return {
code: data.code,
name: data.codeName1,
};
}

/**
* 광운대학교의 전공 목록을 가져옵니다.
*/
export async function fetchMajors(requestData: FetchMajorsRequestData): Promise<Major[]> {
const response = await fetch('/std/cps/atnlc/CmmnMagerCodeList.do', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
selectYear: requestData.year,
selecthakgi: requestData.semester,
selecthakgwa: requestData.departmentCode,
}),
});

if (!response.ok) {
throw new Error(`Failed to fetch majors. Status: ${response.status}`);
}

return (await response.json()).map(parseMajor);
}
4 changes: 4 additions & 0 deletions src/apis/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './fetchCommonSubjects';
export * from './fetchDepartments';
export * from './fetchLectures';
export * from './fetchMajors';
48 changes: 48 additions & 0 deletions src/components/UniversitySyllabus/UniversitySyllabus.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.helper-form {
.helper-title {
margin-bottom: 4px;
font-weight: bold;
}

.helper-control {
display: flex;
align-items: center;
gap: 4px;
height: 32px;
}
}

.helper-table {
th {
white-space: pre-line;
}

tbody {
tr.ant-table-row {
cursor: pointer;
}

td {
font-weight: normal;
}
}

.helper-missing {
background-color: #f5f5f5;
color: gray;
}

.helper-closed {
background-color: #fef2f2;
color: red;
}

.helper-rate {
font-size: 14px;

li {
margin: 0 !important;
cursor: pointer !important;
}
}
}
Loading

0 comments on commit 9c03ee9

Please sign in to comment.