Assignment Handout
Contributors: Alicia Wang, Conner Swenberg
Last updated
Contributors: Alicia Wang, Conner Swenberg
Last updated
Due Date: Monday 11/11, 11:59pm
You will be building a CMS-style classroom manager. You will need to assign instructors to courses to manage assignments as well as students.
We have provided the starting files you will need to complete this assignment for your convenience. This also simplifies your submission by just having to zip this same folder.
We have shown you how to use the Flask framework to set up routes and respond to network requests. Your assignment is to implement a series of routes following the provided specification for responding to sample requests. This assignment has 7 routes for you to implement. If you are struggling with the assignment, we recommend referring to the Demo to see a concrete example.
A README.txt
file is included in the starter code for you to fill out after completing the assignment. Also note that you will not receive extra credit for extra credit challenges you complete if you do not let us know for when we grade!
Common mistakes in styling are:
NOT HAVING documentation/comments in each of your methods
Naming variables with CamelCase instead of snake_case
Too much/too little empty spaces/empty lines
Leaving in commented code
Take some time looking through the guide to learn how to make tests using Postman. You should submit your Postman collection along with your CMS submission. The best way to get full credit for your tests is to ensure that you check that the response from your API matches what the API specification is expecting to receive. Please make sure that all your tests pass when we run your collection (make sure to clear your database before running to ensure you get the result we will get).
While that should be enough to get full credit, your tests can be cleaner and easier to change if you use variables or environments. It's up to you how much you want to learn and incorporate into your tests - the better you get at it the easier the assignments will be in the future and the likelier your API will pass the test cases we release on the first try.
If you'd prefer to learn how to use Postman through a video, here is a link to everything you'll need to know for this class; however, the audio quality is quite poor due to a technical error. If you think you would benefit from a re-recording of a Postman demo, indicate that on the feedback form and we will be happy to record one.
Next, zip the starter folder and submit on CMS. For reference, your directory structure should look like the following:
For clarification, this means that you SHOULD NOT include your virtual environment, pycache, or .db file in your final submission. Doing so will lose you a few points on the project.
To receive credit for your assignment, you must fill out the feedback form so that we can better understand how effectively we are teaching and how long students are spending on assignments.
+1 point
Additional Routes
Add the following routes:
Drop a student from a course: /api/courses/{course_id}/drop/
Post body: {"user_id": <USER INPUT>}
Return:
{"error": "Course not found"}
{"error": "User not found"}
{"error": "User has not been added to this course"}
{<SERIALIZED USER>}
Update an assignment: /api/assignments/{assignment_id}/
Post body: new values for title
, due_date
, or both
Return:
{"error": "Assignment not found"}
{<UPDATED ASSIGNMENT>}
+1 points +1 point more if Tier I completed
Grading Submissions
Add a Submission model and functionality to allow instructors to assign numeric grades to students’ submissions. Note: For now, the content of the submission is arbitrary and you can just use a text field "content". This includes the following routes:
Submit an assignment: /api/assignments/{assignment_id}/submit/
Post Body: {"user_id": <USER INPUT>, "content": <USER INPUT>}
Return:
{"error": "Assignment not found"}
{"error": "User not found"}
{"error": "User does not have this assignment"}
{<SERIALIZED SUBMISSION>}
Grade an assignment: /api/assignments/{assignment_id}/grade/
Post Body: {"submission_id": <USER INPUT>, "score": <USER INPUT>}
Return:
{"error": "Assignment not found"}
{"error": "Submission not found"}
{"error": "Submission does not match this assignment"}
{<SERIALIZED SUBMISSION>}
+2 points +1 point more if Tier I & II completed
Submission File Uploads
Extend your submission functionality with real file uploads. Set up an Amazon Web Services account and connect to the S3 service using the boto3 package. You will need to learn how to set up your own AWS account, and successfully connect to S3 buckets.
Recommended approach: Use the same submit/
route as in Tier II, but change your request body type in postman from raw JSON
to form-data
. The form-data
body type allows you to send a combination of files and text data in the same request. Upon receiving the request, parse the uploaded file from the request and send them as a payload to S3 using boto3
. The boto3
methods will return you a string URL of where the file was stored. Save this URL in the content
field of your submission. You can test if the file upload worked correctly by copying this link into your browser → the file should download and appear.