diff --git a/frontend/src/components/StudentCourseEnrollment/StudentCourseEnrollment.vue b/frontend/src/components/StudentCourseEnrollment/StudentCourseEnrollment.vue index 793cfb44d14d3ca8ff3fdc7b5624484e3f036ff5..009780daad7cca82d5aaa0ad5490a4a2fb7db464 100644 --- a/frontend/src/components/StudentCourseEnrollment/StudentCourseEnrollment.vue +++ b/frontend/src/components/StudentCourseEnrollment/StudentCourseEnrollment.vue @@ -76,7 +76,7 @@ <td>{{ index + 1 }}</td> <td>{{ course.code }}</td> <td>{{ course.name }}</td> - <td class="text-center">01</td> + <td class="text-center">{{ course.classNumber }}</td> <td class="text-center">{{ course.credits }}</td> <td class="text-center">{{ course.type }}</td> @@ -226,6 +226,8 @@ <script> import axios from "axios"; import { Modal } from "bootstrap"; +import { getAllClassNumber } from "../../store/classNumber"; +import { getClassNumberById } from "../../store/classNumber"; export default { name: "StudentCourseEnrollment", @@ -238,11 +240,15 @@ export default { studyPlanStatus: null, notesModal: null, reasonApproval: null, - isZeroCredits: false + isZeroCredits: false, + courses: [], + classes: [] }; }, async mounted() { await this.getStudyPlan(); + await this.getAllCourses(); + await this.getAllClasses(); }, methods: { GetTotalSKS(TypeFlag) { @@ -371,6 +377,10 @@ export default { this.studentCourseData[i].credits = responseChild.data.credits; this.studentCourseData[i].type = responseChild.data.type; + this.studentCourseData[i].classNumber = getClassNumberById( + response.data.id, + this.classes + ); }) .catch((error) => { console.error(error); @@ -413,6 +423,36 @@ export default { }, cancelNotesApproval() { this.notesModal.hide(); + }, + async getAllCourses() { + await axios + .get(process.env.VUE_APP_API_ENDPOINT + "/course") + .then((response) => { + if (response.status == 200) { + this.courses = response.data; + } + }) + .catch((error) => { + console.error(error); + }); + }, + async getAllClasses() { + const params = { + status: "OPEN" + }; + await axios + .get(process.env.VUE_APP_API_ENDPOINT + "/course-class", { + params: params + }) + .then((response) => { + if (response.status == 200) { + this.classes = response.data; + this.classes = getAllClassNumber(this.courses, this.classes); + } + }) + .catch((error) => { + console.error(error); + }); } } }; diff --git a/frontend/src/components/StudentSchedule/StudentSchedule.vue b/frontend/src/components/StudentSchedule/StudentSchedule.vue index 0611777f5ed476829be70b923ea0dd72c2e2ae21..07544d68cfa615991ee0bb9a5684d1c0760c48cd 100644 --- a/frontend/src/components/StudentSchedule/StudentSchedule.vue +++ b/frontend/src/components/StudentSchedule/StudentSchedule.vue @@ -40,7 +40,7 @@ <td>{{ index + 1 }}</td> <td>{{ course.code }}</td> <td>{{ course.name }}</td> - <td class="text-center">01</td> + <td class="text-center">{{ course.classNumber }}</td> <td class="text-center">{{ course.credits }}</td> <td class="text-center">{{ course.type }}</td> <td class="text-center"> @@ -206,6 +206,8 @@ import { CalendarMath } from "vue-simple-calendar"; // published version //} from "../../vue-simple-calendar/src/components/bundle.js" // local repo +import { getAllClassNumber } from "../../store/classNumber"; +import { getClassNumberById } from "../../store/classNumber"; export default { components: { @@ -249,7 +251,9 @@ export default { useDefaultTheme: true, useHolidayTheme: true, useTodayIcons: false, - items: [] + items: [], + courses: [], + classes: [] }; }, computed: { @@ -282,6 +286,8 @@ export default { async mounted() { this.newItemStartDate = CalendarMath.isoYearMonthDay(CalendarMath.today()); this.newItemEndDate = CalendarMath.isoYearMonthDay(CalendarMath.today()); + await this.getAllCourses(); + await this.getAllClasses(); await this.getStudyPlan(); await this.getCourseClassMeeting(); }, @@ -429,6 +435,10 @@ export default { this.studentCourseData[i].credits = responseChild.data.credits; this.studentCourseData[i].type = responseChild.data.type; + this.studentCourseData[i].classNumber = getClassNumberById( + response.data.id, + this.classes + ); }) .catch((error) => { console.error(error); @@ -464,13 +474,12 @@ export default { params ) .then((childResponse) => { - console.log(childResponse.data); if (childResponse.status == 200) { for (let i = 0; i < childResponse.data.length; i++) { let item = { id: childResponse.data[i].id, - startDate: childResponse.data[i].startTime, - endDate: childResponse.data[i].endTime, + startDate: new Date(childResponse.data[i].startTime), + endDate: new Date(childResponse.data[i].endTime), courseCode: childResponse.data[i].CourseClass.Course.code, courseName: childResponse.data[i].CourseClass.Course.name, title: @@ -505,11 +514,11 @@ export default { let startTime = new Date(response.data.startTime); let endTime = new Date(response.data.endTime); this.classModalData.startTime = - (startTime.getHours() - 7).toString() + + startTime.getHours().toString() + ":" + String(startTime.getMinutes()).padStart(2, "0"); this.classModalData.endTime = - (endTime.getHours() - 7).toString() + + endTime.getHours().toString() + ":" + String(endTime.getMinutes()).padStart(2, "0"); this.classModalData.courseCode = courseCode; @@ -606,6 +615,36 @@ export default { fullDate = date + " " + month + " " + year; return fullDate; + }, + async getAllCourses() { + await axios + .get(process.env.VUE_APP_API_ENDPOINT + "/course") + .then((response) => { + if (response.status == 200) { + this.courses = response.data; + } + }) + .catch((error) => { + console.error(error); + }); + }, + async getAllClasses() { + const params = { + status: "OPEN" + }; + await axios + .get(process.env.VUE_APP_API_ENDPOINT + "/course-class", { + params: params + }) + .then((response) => { + if (response.status == 200) { + this.classes = response.data; + this.classes = getAllClassNumber(this.courses, this.classes); + } + }) + .catch((error) => { + console.error(error); + }); } } }; diff --git a/frontend/src/store/classNumber.js b/frontend/src/store/classNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..0b3034ec7ed0682d9b80140b330ef650b6a6c266 --- /dev/null +++ b/frontend/src/store/classNumber.js @@ -0,0 +1,34 @@ +function convertNumber(numb) { + return numb > 9 ? "" + numb : "0" + numb; +} + +function getAllClassNumber(courses, classes) { + for (let i = 0; i < courses.length; i++) { + let number = 1; + for (let j = 0; j < classes.length; j++) { + if (courses[i].id === classes[j].courseId) { + classes[j].classNumber = convertNumber(number); + number += 1; + } + } + } + + return classes; +} + +function getClassNumberById(id, classes) { + let classNumber = "01"; + for (let i = 0; i < classes.length; i++) { + if (id === classes[i].id) { + classNumber = classes[i].classNumber; + break; + } + } + + return classNumber; +} + +module.exports = { + getAllClassNumber, + getClassNumberById +}; diff --git a/frontend/src/views/CourseEnrollment/SelectCourse.vue b/frontend/src/views/CourseEnrollment/SelectCourse.vue index 71571f7b22da7076a711cd0e3fb108ef1b953628..068c336a00d12fe006555ef857374669ff05c92b 100644 --- a/frontend/src/views/CourseEnrollment/SelectCourse.vue +++ b/frontend/src/views/CourseEnrollment/SelectCourse.vue @@ -152,7 +152,7 @@ <td>{{ classes.courseName }}</td> <td>{{ classes.courseLecturer }}</td> <td class="text-center">{{ classes.courseCredits }}</td> - <td class="text-center">01</td> + <td class="text-center">{{ classes.classNumber }}</td> <td class="text-center"> {{ classes.participantCount }}/{{ classes.capacity }} </td> @@ -219,6 +219,7 @@ import Sidebar from "@/components/Sidebar/Sidebar"; import VPagination from "vue3-pagination"; import "vue3-pagination/dist/vue3-pagination.css"; import axios from "axios"; +import { getAllClassNumber } from "../../store/classNumber"; export default { components: { @@ -234,6 +235,7 @@ export default { year: 2021, faculties: [], majors: [], + courses: [], classList: [], filteredClassList: [], showedClass: [], @@ -269,6 +271,7 @@ export default { async mounted() { await this.getStudyPlan(); await this.getAllLecturer(); + await this.getAllCourses(); await this.getAllClass(); await this.getCoursesData(); this.getAllFaculties(); @@ -381,12 +384,30 @@ export default { console.error(error); }); }, + async getAllCourses() { + await axios + .get(process.env.VUE_APP_API_ENDPOINT + "/course") + .then((response) => { + if (response.status == 200) { + this.courses = response.data; + } + }) + .catch((error) => { + console.error(error); + }); + }, async getAllClass() { + const params = { + status: "OPEN" + }; await axios - .get(process.env.VUE_APP_API_ENDPOINT + "/course-class") + .get(process.env.VUE_APP_API_ENDPOINT + "/course-class", { + params: params + }) .then((response) => { if (response.status == 200) { this.classList = response.data; + this.classList = getAllClassNumber(this.courses, this.classList); this.filteredClassList = this.classList; this.pageNumberTotal = Math.ceil( this.classList.length / this.classPerPage