Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrading list_instructor_tasks to DRF ( 10th ) #35332

Merged
merged 16 commits into from
Sep 18, 2024

Conversation

awais786
Copy link
Contributor

@awais786 awais786 commented Aug 21, 2024

Issue

verify via Postman

  1. use this URL as post method in postman.
  2. You can post this without any data and get all the task or you can do the following 3rd step for specific test purpose.
  3. form-data ( these are optional params )

unique_student_identifier = student-id
problem_location_str = block-v1:edx+cs201+2023+type@drag-and-drop-v2+block@f20140b461814222bbe3a0617b2a532b ( you can use the inspect element to pick the problem id from site.

expected result
You need some data in instructor tasks table for this.

{
    "tasks": [
        {
            "task_type": "may_enroll_info_csv",
            "task_input": "{\"features\": [\"email\"]}",
            "task_id": "c058529e-095e-450c-9ff5-2fa53c7df1ed",
            "requester": "admin",
            "task_state": "SUCCESS",
            "created": "2024-08-19T18:00:12.070978+00:00",
            "duration_sec": 0,
            "status": "Incomplete",
            "task_message": "Status: generated 2 of 2 (out of 1)"
        }
    ]
}

Verify via intructor dashboard-datadownload

  1. Go to this URL
Screenshot 2024-08-21 at 4 21 31 PM

@awais786 awais786 changed the title List instructor tasks api feat: upgrading list_instructor_tasks to DRF Aug 21, 2024
@awais786 awais786 requested a review from feanil August 21, 2024 11:22
@awais786 awais786 changed the title feat: upgrading list_instructor_tasks to DRF feat: upgrading list_instructor_tasks to DRF ( 10th ) Aug 21, 2024
@awais786 awais786 marked this pull request as ready for review August 21, 2024 11:27
Copy link
Contributor

@feanil feanil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of comments that might require some re-work here.

@@ -59,3 +59,40 @@ def validate_unique_student_identifier(self, value):
return None

return user


class ListInstructorSerializer(serializers.Serializer): # pylint: disable=abstract-method
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: I think a better name for this would be the ListInstructorTaskInputSerializer.

course_id = CourseKey.from_string(course_id)
params = getattr(request, 'query_params', request.POST)
problem_location_str = strip_if_string(params.get('problem_location_str', False))
student = params.get('unique_student_identifier', None)

# For the DRF POST method, retrieve the data from request.data
if not student and not problem_location_str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just pass the serializer from the POST method above? You've already parsed this data out, may as well use that rather than re-getting it from the post data.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, now picking validated-data.

serializer_class = ListInstructorSerializer

@method_decorator(ensure_csrf_cookie)
def post(self, request, course_id):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this API was previously a POST method but with query string input params, Can we just update the instructor dash to call this as a GET method instead since it doesn't actually modify any data?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not sending any data. Its a just a post call without any payload. I just maintained the behaviour. May be some other front-end is using it this way ?

Also another similar api exists with GET and its hitting same method for getting data. But its different version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, okay seems like we have some redundancy that we should cleanup but that can be part of some future work. I don't want to blow up the scope of this change.

serializer_class = ListInstructorSerializer

@method_decorator(ensure_csrf_cookie)
def post(self, request, course_id):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, okay seems like we have some redundancy that we should cleanup but that can be part of some future work. I don't want to blow up the scope of this change.

@awais786 awais786 merged commit 3de0dbd into master Sep 18, 2024
49 checks passed
@awais786 awais786 deleted the list_instructor_tasks-api branch September 18, 2024 10:54
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants