diff --git a/app/routers/school_quiz_reports.py b/app/routers/school_quiz_reports.py new file mode 100644 index 0000000..e69de29 diff --git a/app/templates/student_quiz_report_v2.html b/app/templates/student_quiz_report_v2.html index 716bc91..5efd683 100644 --- a/app/templates/student_quiz_report_v2.html +++ b/app/templates/student_quiz_report_v2.html @@ -5,11 +5,13 @@
{% if report_data["name"] != "" %} -

Name: {{report_data["name"]}} +

Name: {{report_data["name"]}} {% endif %} -

Student ID: {{report_data["user_id"]}} + {% if report_data["test_name"] != "" %} +

Test Name: {{report_data["test_name"]}} + {% endif %} {% if report_data["school"] != "" %} -

School: {{report_data["school"]}} +

School: {{report_data["school"]}} {% endif %}

diff --git a/generate_table/__main__.py b/generate_table/__main__.py index ba3cd36..6da9168 100644 --- a/generate_table/__main__.py +++ b/generate_table/__main__.py @@ -6,7 +6,9 @@ add_secondary_index, drop_secondary_index, drop_student_quiz_reports, + generate_student_quiz_reports, generate_student_quiz_reports_v2, + add_secondary_index_v2, ) # Update and use `.env.prod` to write to prod dynamodb table @@ -33,6 +35,7 @@ def generate_tables(): Generates all required dynamodb table (for now only student_quiz_reports) """ ddb = initialize_db() + generate_student_quiz_reports(ddb) generate_student_quiz_reports_v2(ddb) @@ -49,6 +52,11 @@ def add_secondary_ind(): add_secondary_index(ddb) +def add_secondary_ind_v2(): + ddb = initialize_db() + add_secondary_index_v2(ddb) + + def drop_secondary_ind(index_name: str): """ Drops a secondary index @@ -61,5 +69,5 @@ def drop_secondary_ind(index_name: str): """ Creates empty dynamodb table with correct schema for local usage. """ - generate_tables() - # add_secondary_ind() + # generate_tables() + add_secondary_ind_v2() diff --git a/generate_table/student_quiz_reports.py b/generate_table/student_quiz_reports.py index 6ffef7c..ef4e275 100644 --- a/generate_table/student_quiz_reports.py +++ b/generate_table/student_quiz_reports.py @@ -36,7 +36,36 @@ def generate_student_quiz_reports_v2(ddb): print("Successfully created Student Quiz Reports V2 Table") +def add_secondary_index_v2(ddb): + """ + Adds a secondary index to the student + quiz reports table + """ + table = ddb.Table("student_quiz_reports_v2") + response = table.update( + AttributeDefinitions=[ + {"AttributeName": "session_id", "AttributeType": "S"}, + {"AttributeName": "user_id", "AttributeType": "S"}, + {"AttributeName": "school_code", "AttributeType": "S"}, + ], + GlobalSecondaryIndexUpdates=[ + { + "Create": { + "IndexName": "gsi_school_code", + "KeySchema": [{"AttributeName": "school_code", "KeyType": "HASH"}], + "Projection": {"ProjectionType": "ALL"}, + } + } + ], + ) + print(response) + + def add_secondary_index(ddb): + """ + Adds a secondary index (school code) to the student + quiz reports v2 table + """ table = ddb.Table("student_quiz_reports") response = table.update( AttributeDefinitions=[