Vídeo presenting the project
My cs50x final project is a web application that allow the user to easily get the submission data from a classroom course activity that he/she teaches or administers and export this data to a csv file or to google sheets
the app.py
is the file that should be executed to start the application it contains the configuration and all the routes of the flask application, all the functions in this file are decorated with @app.route()
.
-
index()
this function just redirect the user to the/select
route -
select()
this function render theselect.html
and pass to it all user's courses if the user has already login -
request_api()
this function return the requested data to the client using AJAX, this function checks if it was given enough data to request the classroom API for the topic activities and return it if it wasn't it will request the classroom API for the course topics -
submission_data()
this function rendersubmission_data.html
and pass to it the students submission state of the selected activity after requesting the classroom API -
export_google_sheets()
this function create a new spread sheet in google sheets, append the students submission state data to it and return the url for the recently created spread sheet if the user has already granted us permission to do so if the user didn't than we will ask him/her for permission -
google_sheets_oauth2callback()
this function is executed after the user grant us permission to create and modify his/her spread sheets, this function will create the google sheets credentials for the user, store it incredentials.db
and redirect the user to/select
-
login()
this function create an authorization url and redirect the user to this url so that he/she can grant us permission to see his/her classroom data -
classroom_oauth2callback()
this function is executed after the user grant us permission to see his/her classroom data, this function will create the classroom credentials for the user, store it incredentials.db
and redirect the user to/select
-
logout()
this function revoke the user's classroom credentials, revoke the user's google sheets credentials, delete the user id from the session storage and delete the credentials fromcredentials.db
helpers folders contains two files: database.py
and credentials.py
this files contain helper functions to interact with the database and manage the credentials respectively
-
-
get_credentials()
this function takes one argumentservise
that is a string and should be "classroom" or "google_sheets", this function is responsible for getting the user credentials to theservise
if it's stored incredentials.db
-
store_credentials()
this function is responsible for storing the userservise
credentials incredentials.db
, it takes two argumentsservise
that is a string it should be "classroom" or "google_sheets" andcredentials
that is agoogle.oauth2.credentials.Credentials
object to be store incredentials.db
-
remove_credentials()
this function is responsible for removing the userservise
credentials fromcredentials.db
it takes one argumentsservise
that is a string it should be "classroom" or "google_sheets"
-
-
-
create_credentials
create theservise
credentials for the user -
create_authorization_url()
create an authorization url that the user should be redirected to grant us authorization according to theservise
-
connections folder contains two files: classroom_connection.py
and google_sheets_connections.py
this files contain classes to create connections between this web application and google APIs
-
-
support context manager by implementing
__enter__()
and__exit__()
-
get_user_id()
return the id of the user -
get_courses()
return a dictionary with the courses and the corresponding id -
get_course_activities()
return a dictionary with the course activities and the corresponding id -
get_course_topics()
return a dictionary with the topics of the course and the corresponding id -
get_activities_from_topic()
return a dictionary with the course activities and the corresponding id that belong to the specified topic -
get_students()
return a dictionary with the stundents names and the corresponding id -
submission_data()
return a dictionary with the stundents names as keys and 'Missing'/'Done' as values acording to the submission state
-
-
-
support context manager by implementing
__enter__()
and__exit__()
-
create_spread_sheet()
create a spread sheet and return it's id -
append()
append data to the given spread sheet
-
the templates folder contains three templates layout.html
, select.html
and submission_data.html
-
layout.html
contains the basic layout of the application all the order templates extends from this -
select.html
if the user is logged allow the he/she to select course, topic and activity from where the students subimssion data should come if the user isn't logged than allow him/her to do so -
submission_data.html
display the students submission state data and allow the user to export that data to google sheets or to a csv file
-
CREATE TABLE classroom_credentials( user_id TEXT, token TEXT, token_uri TEXT, client_id TEXT, refresh_token TEXT, client_secret TEXT, scopes TEXT ); CREATE INDEX user_index_classroom ON classroom_credentials (user_id);
-
CREATE TABLE google_sheets_credentials( user_id TEXT, token TEXT, token_uri TEXT, client_id TEXT, refresh_token TEXT, client_secret TEXT, scopes TEXT ); CREATE INDEX user_index_google_sheets ON google_sheets_credentials (user_id);