diff --git a/backend/problem/views/admin.py b/backend/problem/views/admin.py index ef48887fa..3f02af3ef 100644 --- a/backend/problem/views/admin.py +++ b/backend/problem/views/admin.py @@ -245,6 +245,8 @@ def get(self, request): ensure_created_by(problem.contest, request.user) elif problem.assignment: ensure_created_by(problem.assignment, request.user) + elif problem.course: + ensure_created_by(problem.course, request.user) else: ensure_created_by(problem, request.user) diff --git a/backend/problem/views/oj.py b/backend/problem/views/oj.py index e87ebcc49..004c1b0a6 100644 --- a/backend/problem/views/oj.py +++ b/backend/problem/views/oj.py @@ -78,7 +78,7 @@ def get(self, request): if problem_id: try: problem = Problem.objects.select_related("created_by") \ - .get(_id=problem_id, contest_id__isnull=True, assignment_id__isnull=True, visible=True) + .get(_id=problem_id, contest_id__isnull=True, assignment_id__isnull=True, course_id__isnull=True, visible=True) problem_data = ProblemSerializer(problem).data self._add_problem_status(request, problem_data) return self.success(problem_data) @@ -89,7 +89,7 @@ def get(self, request): if not limit: return self.error("Limit is needed") - problems = Problem.objects.select_related("created_by").filter(contest_id__isnull=True, assignment_id__isnull=True, visible=True) + problems = Problem.objects.select_related("created_by").filter(contest_id__isnull=True, assignment_id__isnull=True, course_id__isnull=True, visible=True) # filter by label tag_text = request.GET.get("tag") if tag_text: diff --git a/backend/problem/views/professor.py b/backend/problem/views/professor.py index b94cba883..af1334dcf 100644 --- a/backend/problem/views/professor.py +++ b/backend/problem/views/professor.py @@ -271,7 +271,7 @@ def get(self, request): except Course.DoesNotExist: return self.error("Course does not exist") - problems = Problem.objects.filter(course=course).order_by("create_time") + problems = Problem.objects.filter(course=course).order_by("-create_time") return self.success(self.paginate_data(request, problems, ProblemCourseProfessorSerializer)) @swagger_auto_schema( diff --git a/backend/submission/views.py b/backend/submission/views.py index a13368b91..c91f53d9d 100644 --- a/backend/submission/views.py +++ b/backend/submission/views.py @@ -4,6 +4,7 @@ from drf_yasg import openapi from assignment.models import Assignment +from course.models import Course from contest.models import ContestStatus, ContestRuleType from judge.tasks import judge_task from options.options import SysOptions