diff --git a/backend/controller/course.js b/backend/controller/course.js index 066013b..d2de321 100644 --- a/backend/controller/course.js +++ b/backend/controller/course.js @@ -1,5 +1,5 @@ const express = require("express"); -const { getCourseList, getCourseListByInstructor, getCourseDetail, getAllCourses, createCourse, editCourse, editMultipleCourse, getAllSemesters, deleteCourse } = require("../service/course"); +const { getCourseList, getCourseListByInstructor, getCourseDetail, getAllCourses, createCourse, editCourse, editMultipleCourse, getAllSemesters, deleteCourse, getCourseAccess } = require("../service/course"); const courseController = express.Router(); // Query course list by user id @@ -78,4 +78,12 @@ courseController.delete("/delete", } ); +//get access list of courses by course id +courseController.get("/permissions/:courseId", + async (req, res) => { + const { courseId } = req.params; + const results = await getCourseAccess(courseId); + res.status(results.code || 200).json(results.data); + }); + module.exports = courseController; diff --git a/backend/query/course.js b/backend/query/course.js index 93c6173..6fa3e6c 100644 --- a/backend/query/course.js +++ b/backend/query/course.js @@ -92,7 +92,12 @@ FROM KP_Semester; const deleteCourseQuery = ` DELETE FROM KP_Course WHERE course_id = ?; -`; +` +const getCourseAccessByCouseId = ` +SELECT client_id FROM can_access_capture_files +WHERE couse_id = ? +` + module.exports = { getCourseList, getCourseListByInstructor, @@ -106,5 +111,6 @@ module.exports = { unregisterUser, editMultipleCourses, getSemestersQuery, - deleteCourseQuery + deleteCourseQuery, + getCourseAccessByCouseId }; diff --git a/backend/service/course.js b/backend/service/course.js index 0d07253..0330e4c 100644 --- a/backend/service/course.js +++ b/backend/service/course.js @@ -142,6 +142,15 @@ const deleteCourse = async({courseId}) => { } } +//get access list of courses by course id +const getCourseAccess = async courseId => { + const accessResults = await pool.execute(courseQuery.getCourseAccessByCouseId, [courseId]); + const accessList = accessResults[0]; + return { + data: {courseId: courseId, accessList: accessList} + }; +}; + module.exports = { getCourseList, getCourseListByInstructor, @@ -151,5 +160,6 @@ module.exports = { editCourse, editMultipleCourse, getAllSemesters, - deleteCourse + deleteCourse, + getCourseAccess }; diff --git a/backend/service/data.js b/backend/service/data.js index d056815..9b3950c 100644 --- a/backend/service/data.js +++ b/backend/service/data.js @@ -54,13 +54,20 @@ const exportMetricCsv = async(data) => { const getAllCsvExport = async(data) => { let userId = data.userId; - results = await pool.execute(dataQuery.getAllDataRequest,[userId]); - for(i=0;i 0){ + for(i=0;i {