Flask JWT Auth API Documentation
Flask JWT Auth API Documentation
No, a student cannot delete an assignment. The API only allows tutors the permission to delete assignments. This restriction ensures that students cannot modify the availability of assignments that they do not author .
User type determines the actions available to users in the assignment services. Tutors can add, delete, and view all student-submitted assignments, whereas students can only submit assignments and view their own. The API uses JWT tokens, which encode user type, to enforce these permissions and restrict actions accordingly .
To submit an assignment, a student would send a POST request to the '/assignment/submitassignment' endpoint with their JWT token in the Authorization header to authenticate their identity as a student. The request must include form-encoded data specifying the assignment ID and any remarks. This process ensures the submission is correctly attributed to the student and linked to the assignment .
Using the '/assignment/feedassignment' endpoint with improper parameters, like incorrect 'published_at' formatting or a nonexistent 'status', could result in incomplete or erroneous data retrieval. Such issues could cause the client to receive no results or an unfiltered list, causing confusion or additional processing burdens. Correct parameter specification is critical for the intended data output .
The API leverages JWT tokens containing encoded user type information to differentiate between student and tutor actions. Endpoints use this data to enforce role-based permissions, ensuring security and that specific actions, like adding or deleting assignments, are restricted to appropriate user types. Shared endpoints handle user roles carefully to limit access based on these encoded credentials .
HTTP POST requests in the API are crucial as they handle state changes and create actions such as registration, login, assignment submission, and CRUD operations on assignments. POST requests are suitable for sending data securely in the body, preserving confidentiality and security when communicating sensitive information like passwords and JWT tokens. They are essential for executing operations where data changes occur on the server .
Using 'application/x-www-form-urlencoded' is adequate for sending simple structured data, such as form submissions which align with the API's need for handling credentials, assignment descriptions, and submission details. However, it can be less efficient for complex data or larger payloads than JSON, and might increase development complexity if a need for nested data arises. The decision stresses simplicity and compatibility over flexibility .
The JWT token serves as a means of validating and providing credentials for a user's session after login. It allows the API to authenticate subsequent requests by including the token in the request header. This ensures that the requester has the necessary permissions to perform certain actions, such as adding, submitting, or retrieving assignments .
Yes, tutors can use the 'getassignment' API endpoint to retrieve assignments uploaded by students. While the specific filtering for individual students isn't explicitly described, the endpoint supports gaining insights into all submissions, indicating that individual filtering is feasible if coupled with personalized parameters .
The 'published_at' parameter in the assignment feed API is significant as it allows both students and tutors to filter assignments by their publication date. For tutors, it can return only the assignments published after the specified date. For students, additional filters can be applied based on assignment status, such as 'PENDING', allowing more targeted queries .