diff --git a/frontend/src/pages/oj/views/problem/Problem.vue b/frontend/src/pages/oj/views/problem/Problem.vue
index 0f24a9e5b..7d6ed959e 100644
--- a/frontend/src/pages/oj/views/problem/Problem.vue
+++ b/frontend/src/pages/oj/views/problem/Problem.vue
@@ -574,7 +574,8 @@ export default {
language: this.language,
code: this.code,
contest_id: this.contestID,
- assignment_id: this.assignmentID
+ assignment_id: this.assignmentID,
+ course_id: this.courseID
}
if (this.captchaRequired) {
data.captcha = this.captchaCode
diff --git a/frontend/src/pages/prof/api.js b/frontend/src/pages/prof/api.js
index a25f6bae3..dee7ca4bf 100644
--- a/frontend/src/pages/prof/api.js
+++ b/frontend/src/pages/prof/api.js
@@ -148,6 +148,36 @@ export default {
params: params
})
},
+ getCourseProblem (courseId, problemId, limit, offset) {
+ return ajax('lecture/professor/course/problem/', 'get', {
+ params: {
+ course_id: courseId,
+ problem_id: problemId,
+ limit: limit,
+ offset: offset
+ }
+ })
+ },
+ createCourseProblem (data) {
+ return ajax('lecture/professor/course/problem/', 'post', {
+ data
+ })
+ },
+ editCourseProblem (data) {
+ return ajax('lecture/professor/course/problem/', 'put', {
+ data
+ })
+ },
+ deleteCourseProblem (id) {
+ return ajax('lecture/professor/course/problem/', 'delete', {
+ params: { id: id }
+ })
+ },
+ addCourseProblemFromPublic (data) {
+ return ajax('lecture/professor/course/add_problem_from_public/', 'post', {
+ data
+ })
+ },
// only assignmentId param => return problemList instead
getAssignmentProblem (assignmentId, problemId) {
const params = { problem_id: problemId, assignment_id: assignmentId }
diff --git a/frontend/src/pages/prof/components/SideMenu.vue b/frontend/src/pages/prof/components/SideMenu.vue
index 38d912922..d1a5bd0ea 100644
--- a/frontend/src/pages/prof/components/SideMenu.vue
+++ b/frontend/src/pages/prof/components/SideMenu.vue
@@ -53,6 +53,17 @@
/>
Dashboard
+
+
+ Problems
+
@@ -212,7 +214,9 @@ export default {
'Operation'
],
selectedAssignmentId: null,
- studentTotal: 0
+ selectedCourseId: null,
+ studentTotal: 0,
+ courseId: ''
}
},
async mounted () {
@@ -283,8 +287,9 @@ export default {
createAssignmentProblem (assignment) {
if (this.routeName === 'course-assignment-list') {
this.$router.push({
- name: 'create-course-problem',
+ name: 'create-assignment-problem',
params: {
+ courseId: this.courseId,
assignmentId: assignment.id,
courseInfo: this.pageLocations[0].text,
assignmentInfo: assignment.title
@@ -295,7 +300,7 @@ export default {
editAssignmentProblem (assignment, problemId) {
if (this.routeName === 'course-assignment-list') {
this.$router.push({
- name: 'edit-course-problem',
+ name: 'edit-assignment-problem',
params: {
courseId: this.courseId,
assignmentId: assignment.id,
@@ -355,8 +360,9 @@ export default {
}
await api.editAssignment(data)
},
- showImportPublicProblemModal (assignmentId) {
+ showImportPublicProblemModal (assignmentId, courseId) {
this.selectedAssignmentId = assignmentId
+ this.selectedCourseId = courseId
this.$bvModal.show('import-public-problem-modal')
},
async getUserTotal () {
diff --git a/frontend/src/pages/prof/views/assignment/ImportPublicProblem.vue b/frontend/src/pages/prof/views/assignment/ImportPublicProblem.vue
index 6fabe23b1..d523e88d3 100644
--- a/frontend/src/pages/prof/views/assignment/ImportPublicProblem.vue
+++ b/frontend/src/pages/prof/views/assignment/ImportPublicProblem.vue
@@ -94,7 +94,7 @@ import { DIFFICULTY_COLOR } from '@/utils/constants'
export default {
name: 'ImportPublicProblem',
mixins: [ProblemMixin],
- props: ['assignmentId'],
+ props: ['assignmentId', 'courseId', 'mode'],
data () {
return {
form: {
@@ -197,12 +197,17 @@ export default {
return
}
const data = {
+ course_id: this.courseId,
assignment_id: this.assignmentId,
problem_id: this.form.selectedProblemId,
display_id: this.form.displayId
}
try {
- await profApi.addProblemFromPublic(data)
+ if (this.mode === 'assignment') {
+ await profApi.addProblemFromPublic(data)
+ } else {
+ await profApi.addCourseProblemFromPublic(data)
+ }
} catch (err) {
}
this.$set(this.form, 'selectedProblemId', null)
diff --git a/frontend/src/pages/prof/views/general/CourseBookmark.vue b/frontend/src/pages/prof/views/general/CourseBookmark.vue
index 72c88acda..8708be342 100644
--- a/frontend/src/pages/prof/views/general/CourseBookmark.vue
+++ b/frontend/src/pages/prof/views/general/CourseBookmark.vue
@@ -95,7 +95,6 @@ export default {
try {
const resp = await api.getCourseList()
this.courseList = resp.data.data.results
- console.log(this.courseList)
} catch (err) {
}
},
diff --git a/frontend/src/pages/prof/views/general/CourseDashboard.vue b/frontend/src/pages/prof/views/general/CourseDashboard.vue
index cb5274b1c..4f1b399cd 100644
--- a/frontend/src/pages/prof/views/general/CourseDashboard.vue
+++ b/frontend/src/pages/prof/views/general/CourseDashboard.vue
@@ -15,10 +15,8 @@
cols = "1"
class="course-dashboard"
>
-
-
+
+
@@ -47,9 +45,41 @@
+
+
+
+
+
+
+
+
+
+ {{ data.value }}
+ -
+
+
+
+
@@ -63,6 +93,8 @@
import api from '../../api.js'
import UserList from '../users/UserList.vue'
+import moment from 'moment'
+
export default {
name: 'CourseDashboard',
components: {
@@ -77,7 +109,11 @@ export default {
'-1': 'Ended'
},
pageSize: 5,
- currentPage: 1,
+ mode: '',
+ assignmentCurrentPage: 1,
+ problemCurrentPage: 1,
+ assignmentTotal: 0,
+ problemTotal: 0,
courseId: null,
createdBy: {},
title: '',
@@ -109,7 +145,22 @@ export default {
}
],
assignmentList: [
- ]
+ ],
+ problemListField: [
+ 'title',
+ {
+ key: 'assignment_name',
+ label: 'Assignment'
+ },
+ {
+ key: 'create_time',
+ label: 'Create Time',
+ formatter: (value) => {
+ return moment(value).format('YYYY-M-D HH:mm')
+ }
+ }
+ ],
+ problemList: []
}
},
async mounted () {
@@ -125,25 +176,41 @@ export default {
} catch (err) {
this.$error(err)
}
- this.getAssignmentList(1)
+ await this.getCourseProblem(1)
+ await this.getAssignmentList(1)
this.pageLocations[0].text = this.title + '_' + this.courseCode + '-' + this.classNumber
},
methods: {
- async currentChange (page) {
- this.currentPage = page
+ async currentAssignmentChange (page) {
+ this.assignmentCurrentPage = page
await this.getAssignmentList(page)
},
+ async currentProblemChange (page) {
+ this.problemCurrentPage = page
+ await this.getCourseProblem(page)
+ },
async getAssignmentList (page) {
this.loading = true
try {
const res = await api.getAssignmentList(this.courseId, null, this.pageSize, (page - 1) * this.pageSize)
- this.total = res.data.data.total
+ this.assignmentTotal = res.data.data.total
this.assignmentList = res.data.data.results
} catch (err) {
} finally {
this.loading = false
}
},
+ async getCourseProblem (page) {
+ this.loading = true
+ try {
+ const res = await api.getCourseProblem(this.$route.params.courseId, null, this.pageSize, (page - 1) * this.pageSize)
+ this.problemList = res.data.data.results
+ this.problemTotal = res.data.data.total
+ } catch (err) {
+ } finally {
+ this.loading = false
+ }
+ },
async updateCourseList () {
try {
const res = await api.getCourseList()
@@ -156,8 +223,11 @@ export default {
}
},
computed: {
- updateCurrentPage () {
- return this.currentChange(this.currentPage)
+ updateAssignmentCurrentPage () {
+ return this.currentAssignmentChange(this.assignmentCurrentPage)
+ },
+ updateProblemCurrentPage () {
+ return this.currentProblemChange(this.problemCurrentPage)
}
}
}
diff --git a/frontend/src/pages/prof/views/index.js b/frontend/src/pages/prof/views/index.js
index 22b4c7e0c..72fe701f1 100644
--- a/frontend/src/pages/prof/views/index.js
+++ b/frontend/src/pages/prof/views/index.js
@@ -7,7 +7,8 @@ import Home from './Home.vue'
import QnA from './qna/QnA.vue'
import ProblemGrade from './problem/ProblemGrade.vue'
import CourseBookmark from './general/CourseBookmark.vue'
+import CourseProblem from './problem/CourseProblem.vue'
export {
- Dashboard, CourseDashboard, Problem, AssignmentList, Login, Home, QnA, ProblemGrade, CourseBookmark
+ Dashboard, CourseDashboard, Problem, CourseProblem, AssignmentList, Login, Home, QnA, ProblemGrade, CourseBookmark
}
diff --git a/frontend/src/pages/prof/views/problem/CourseProblem.vue b/frontend/src/pages/prof/views/problem/CourseProblem.vue
new file mode 100644
index 000000000..b9f589754
--- /dev/null
+++ b/frontend/src/pages/prof/views/problem/CourseProblem.vue
@@ -0,0 +1,221 @@
+
+
+
+
+
+
+
+
+ {{ data.value }}
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/pages/prof/views/problem/Problem.vue b/frontend/src/pages/prof/views/problem/Problem.vue
index c0c51b91e..a48076d31 100644
--- a/frontend/src/pages/prof/views/problem/Problem.vue
+++ b/frontend/src/pages/prof/views/problem/Problem.vue
@@ -549,21 +549,18 @@ export default {
],
search: '',
assignmentId: '',
+ courseId: '',
pageLocations: [
{
text: this.$route.params.courseInfo,
to: '/course/' + this.$route.params.courseId + '/dashboard'
- },
- {
- text: this.$route.params.assignmentInfo,
- to: '/course/' + this.$route.params.courseId + '/assignment'
}
]
}
},
async mounted () {
this.routeName = this.$route.name
- if (this.routeName === 'edit-course-problem') {
+ if (this.routeName === 'edit-assignment-problem' || this.routeName === 'edit-course-problem') {
this.mode = 'edit'
} else {
this.mode = 'add'
@@ -571,6 +568,8 @@ export default {
this.problem = this.reProblem = {
_id: '',
title: '',
+ course_id: '',
+ assignment_id: '',
description: '',
input_description: '',
output_description: '',
@@ -596,6 +595,8 @@ export default {
io_mode: { io_mode: 'Standard IO', input: 'input.txt', output: 'output.txt' }
}
this.assignmentId = this.$route.params.assignmentId
+ this.courseId = this.$route.params.courseId
+ this.problem.course_id = this.reProblem.course_id = this.courseId
if (this.assignmentId) {
this.problem.assignment_id = this.reProblem.assignment_id = this.assignmentId
const res = await api.getAssignmentList(null, this.assignmentId)
@@ -609,7 +610,9 @@ export default {
// get problem after getting languages list to avoid find undefined value in `watch problem.languages`
if (this.mode === 'edit') {
this.title = 'Edit Problem'
- const problemRes = await api.getAssignmentProblem(this.assignemntId, this.$route.params.problemId)
+ const problemRes = (this.routeName === 'edit-assignment-problem')
+ ? await api.getAssignmentProblem(this.assignmentId, this.$route.params.problemId)
+ : await api.getCourseProblem(this.courseId, this.$route.params.problemId)
const data = problemRes.data.data
if (!data.spj_code) {
data.spj_code = ''
@@ -623,20 +626,13 @@ export default {
this.problem.testcases = this.problem.testcases.concat(testcaseData.testcases)
if (testcaseData.spj === 'True') this.problem.spj = true
else this.problem.spj = testcaseData.spj === 'True'
- this.pageLocations.push({
- text: this.$route.params.problemId + ' - ' + this.problem.title
- }, {
- text: 'Edit problem'
- })
} else {
this.title = 'Add Problem'
for (const item of allLanguage.languages) {
this.problem.languages.push(item.name)
}
- this.pageLocations.push({
- text: 'Create Problem'
- })
}
+ this.setPageLocation()
this.getProblemTagList()
},
watch: {
@@ -676,6 +672,25 @@ export default {
}
},
methods: {
+ setPageLocation () {
+ if (this.assignmentId) {
+ this.pageLocations.push({
+ text: this.$route.params.assignmentInfo,
+ to: '/course/' + this.$route.params.courseId + '/assignment'
+ })
+ }
+ if (this.mode === 'edit') {
+ this.pageLocations.push({
+ text: this.$route.params.problemId + ' - ' + this.problem.title
+ }, {
+ text: 'Edit problem'
+ })
+ } else {
+ this.pageLocations.push({
+ text: 'Create Problem'
+ })
+ }
+ },
onTagClick ({ item, addTag }) {
addTag(item)
this.search = ''
@@ -854,8 +869,10 @@ export default {
}
}
const funcName = {
- 'create-course-problem': 'createAssignmentProblem',
- 'edit-course-problem': 'editAssignmentProblem'
+ 'create-assignment-problem': 'createAssignmentProblem',
+ 'edit-assignment-problem': 'editAssignmentProblem',
+ 'create-course-problem': 'createCourseProblem',
+ 'edit-course-problem': 'editCourseProblem'
}[this.routeName]
if (funcName === 'editAssignmentProblem') {
this.problem.assignment_id = this.assignment.id
@@ -904,16 +921,35 @@ export default {
})
})
await api[funcName](this.problem)
- this.$router.push({ name: 'course-assignment-list', params: { assignmentId: this.assignmentId } })
+ if (funcName === 'createCourseProblem' || funcName === 'editCourseProblem') {
+ this.$router.push({
+ name: 'course-problem',
+ params: { courseId: this.courseId }
+ })
+ } else {
+ this.$router.push({
+ name: 'course-assignment-list',
+ params: { assignmentId: this.assignmentId }
+ })
+ }
} catch (err) {
console.error(err)
}
} else {
try {
await api[funcName](this.problem)
- this.$router.push({ name: 'course-assignment-list', params: { assignmentId: this.assignmentId } })
- } catch (err) {
- }
+ if (funcName === 'createCourseProblem' || funcName === 'editCourseProblem') {
+ this.$router.push({
+ name: 'course-problem',
+ params: { courseId: this.courseId }
+ })
+ } else {
+ this.$router.push({
+ name: 'course-assignment-list',
+ params: { assignmentId: this.assignmentId }
+ })
+ }
+ } catch (err) {}
}
}
},