Skip to content

Commit

Permalink
fix: Fix problem, submission API to use course info
Browse files Browse the repository at this point in the history
  • Loading branch information
pinecone28 committed Feb 16, 2022
1 parent 0e2b110 commit a79bea9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions backend/problem/views/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions backend/problem/views/oj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion backend/problem/views/professor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions backend/submission/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a79bea9

Please sign in to comment.