Skip to content

Commit

Permalink
feat!: upgrading api to DRF.
Browse files Browse the repository at this point in the history
  • Loading branch information
awais786 committed Oct 9, 2024
1 parent f7f8608 commit 6d51145
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 7 additions & 3 deletions lms/djangoapps/instructor/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2012,11 +2012,11 @@ def post(self, request, course_id):
all_students and unique_student_identifier cannot both be present.
"""

course_id = CourseKey.from_string(course_id)
course = get_course_with_access(request.user, 'staff', course_id)

serializer_data = self.serializer_class(data=request.data)
student = None

if not serializer_data.is_valid():
return HttpResponseBadRequest(reason=serializer_data.errors)
Expand All @@ -2025,11 +2025,15 @@ def post(self, request, course_id):
all_students = serializer_data.validated_data.get("all_students")
only_if_higher = serializer_data.validated_data.get("only_if_higher")

student = serializer_data.validated_data.get("unique_student_identifier")
student_identifier = request.data.get("unique_student_identifier")

import pdb;
pdb.set_trace()

if all_students and not has_access(request.user, 'instructor', course):
return HttpResponseForbidden("Requires instructor access.")

student = serializer_data.validated_data.get("unique_student_identifier")

if not (problem_to_reset and (all_students or student)):
return HttpResponseBadRequest("Missing query parameters.")

Expand Down
8 changes: 7 additions & 1 deletion lms/djangoapps/instructor/views/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,11 @@ class ProblemResetSerializer(UniqueStudentIdentifierSerializer):
)
only_if_higher = serializers.BooleanField(
default=False,
help_text=_("Whether to reset the problem for all students."),
)

# Override the unique_student_identifier field to make it optional
unique_student_identifier = serializers.CharField(
required=False, # Make this field optional
allow_null=True,
help_text=_("unique student identifier.")
)

0 comments on commit 6d51145

Please sign in to comment.