Skip to content

Commit

Permalink
Adding test name
Browse files Browse the repository at this point in the history
  • Loading branch information
pritamps committed Aug 7, 2024
1 parent 654349e commit 6b0784d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
Empty file.
8 changes: 5 additions & 3 deletions app/templates/student_quiz_report_v2.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@

<div id="name_card">
{% if report_data["name"] != "" %}
<p>Name: {{report_data["name"]}}
<p><b>Name</b>: {{report_data["name"]}}
{% endif %}
<p>Student ID: {{report_data["user_id"]}}
{% if report_data["test_name"] != "" %}
<p><b>Test Name</b>: {{report_data["test_name"]}}
{% endif %}
{% if report_data["school"] != "" %}
<p> School: {{report_data["school"]}}
<p> <b>School</b>: {{report_data["school"]}}
{% endif %}
</div>

Expand Down
12 changes: 10 additions & 2 deletions generate_table/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)


Expand All @@ -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
Expand All @@ -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()
29 changes: 29 additions & 0 deletions generate_table/student_quiz_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down

0 comments on commit 6b0784d

Please sign in to comment.