Skip to content

Commit

Permalink
check ins progress
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissdelaney committed May 2, 2024
1 parent ade7d9c commit c8662d5
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 61 deletions.
34 changes: 31 additions & 3 deletions app/spreadsheet_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import time
import numpy as np
import pandas as pd


load_dotenv()
Expand Down Expand Up @@ -256,6 +257,35 @@ def get_assignment_scores(self, student_email:str, course_id:str, assignment_id:
return details_to_return


####################
# WEEKLY CHECK INS #
####################
def get_weekly_check_ins(self, course_id:str, email:str, user_role:str, check_in_sheet_name:str):
if self.doc.id == GOOGLE_SHEETS_MASTER_DOCUMENT_ID:
courses_sheet = self.get_sheet("courses")
courses_records = courses_sheet.get_all_records()

course_document_id_list = [c["SHEETS_DOCUMENT_ID"] for c in courses_records if c["COURSE_ID"] == int(course_id)]

if len(course_document_id_list) == 0:
raise Exception("course not found...")
#TODO: handle within the route
if len(course_document_id_list) > 1:
raise Exception("course duplicate found...error")
#TODO: handle within the route

self.set_active_document(course_document_id_list[0])

if user_role == "STUDENT":
check_in_sheet = self.get_sheet(check_in_sheet_name)
check_in_records = check_in_sheet.get_all_records()
student_check_in_records = [r for r in check_in_records if r.get('Email Address') == email]

student_records_df = pd.DataFrame(student_check_in_records)
print(student_records_df)




#####################
# AUTH FUNCTIONS #
Expand All @@ -280,8 +310,6 @@ def get_user_courses(self, email:str) -> list:

ss = SpreadsheetService()

ss.get_courses("[email protected]")

#ss.get_student_courses("[email protected]")
ss.get_weekly_check_ins(course_id=12345, email='[email protected]', user_role="STUDENT", check_in_sheet_name="check-ins-aggregate")

#ss.get_assignment_scores("[email protected]", "12345", "onboarding")
72 changes: 62 additions & 10 deletions web_app/routes/courses_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
from web_app.routes.wrappers import authenticated_route, student_route, teacher_route, ta_route

@courses_routes.route("/courses/<course_id>")
@authenticated_route
@student_route()
def course(course_id):
print(f"COURSE {course_id}")
ss = current_app.config["SPREADSHEET_SERVICE"]
current_user = session.get("current_user")
email = current_user["email"]
#TODO: change hard coded email to "email" fetched from session
email = "[email protected]"
##################################
assignments_list = []


courses_info = [c for c in current_user.get('user_courses') if int(c['COURSE_ID']) == int(course_id)]
Expand All @@ -23,16 +21,44 @@ def course(course_id):
flash(str(courses_info))
return redirect('/user/courses')

print(courses_info)

role = courses_info[0].get('USER_TYPE')
course_name = courses_info[0].get('COURSE_NAME')

return render_template("course.html", ROLE=role, COURSE_ID=course_id, COURSE_NAME = course_name)


@courses_routes.route("/courses/<course_id>/assignments")
@student_route()
def course_assignments(course_id):
ss = current_app.config["SPREADSHEET_SERVICE"]
current_user = session.get("current_user")
email = current_user["email"]
#TODO: change hard coded email to "email" fetched from session
email = "[email protected]"
##################################
assignments_list = []


courses_info = [c for c in current_user.get('user_courses') if int(c['COURSE_ID']) == int(course_id)]

if role == "STUDENT":
assignments_list = ss.get_course_assignments(email, course_id)
return render_template("assignments.html", assignments=assignments_list, course_id=course_id)
elif role == "TEACHER" or role == "TA":
roster_data = ss.get_course_roster(course_id)
return render_template("course_roster.html", roster_data=roster_data, course_id=course_id)
if len(courses_info) == 0:
flash(str(courses_info))
return redirect('/user/courses')

role = courses_info[0].get('USER_TYPE')
assignments_list = ss.get_course_assignments(email, course_id)
return render_template("assignments.html", assignments=assignments_list, course_id=course_id)

@courses_routes.route("/courses/<course_id>/students")
@ta_route()
def course_students(course_id):
ss = current_app.config["SPREADSHEET_SERVICE"]
roster_data = ss.get_course_roster(course_id)
return render_template("course_students.html", roster_data=roster_data, course_id=course_id)



@courses_routes.route("/courses/<course_id>/assignments/<assignment_id>")
@authenticated_route
Expand Down Expand Up @@ -67,4 +93,30 @@ def student_grades(course_id, student_info):
student_email = student_info_list[2]
ss = current_app.config["SPREADSHEET_SERVICE"]
assignments_list = ss.get_course_assignments(student_email, course_id)
return render_template("assignments_teacher.html", assignments=assignments_list, course_id=course_id, student_email=student_email, first_name=first_name, last_name=last_name)
return render_template("assignments_teacher.html", assignments=assignments_list, course_id=course_id, student_email=student_email, first_name=first_name, last_name=last_name)


@courses_routes.route("/courses/<course_id>/check_ins")
@authenticated_route
@ta_route()
def student_grades(course_id, student_info):
ss = current_app.config["SPREADSHEET_SERVICE"]
current_user = session.get("current_user")
email = current_user["email"]
#TODO: change hard coded email to "email" fetched from session
email = "[email protected]"
##################################


courses_info = [c for c in current_user.get('user_courses') if int(c['COURSE_ID']) == int(course_id)]

if len(courses_info) == 0:
flash(str(courses_info))
return redirect('/user/courses')

user_role = courses_info[0].get('USER_TYPE')
course_name = courses_info[0].get('COURSE_NAME')
check_in_sheet_name = courses_info[0].get('CHECK_IN_SHEET_NAME')

if user_role == "STUDENT":
check_in_data = ss.get_weekly_check_ins(course_id=course_id, email=email, user_role=user_role, check_in_sheet_name=check_in_sheet_name)
Empty file.
45 changes: 45 additions & 0 deletions web_app/templates/course.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{% extends "bootstrap_5_layout.html" %}
{% set active_page = "courses" %}

{% block content %}

<h1>Course: {{ COURSE_NAME }}</h1>

<table class="table table-hover text-center">
<tbody>
{% if ROLE == "STUDENT" %}
<tr class="clickable-row" data-href="/courses/{{ COURSE_ID }}/assignments">
<td>
Assignments
</td>
</tr>
<tr class="clickable-row" data-href="/courses/{{ COURSE_ID }}/check_ins">
<td>
Weekly Check Ins
</td>
</tr>
{% elif ROLE == "TA" or ROLE == "TEACHER" %}
<tr class="clickable-row" data-href="/courses/{{ COURSE_ID }}/students">
<td>
Roster
</td>
</tr>
<tr class="clickable-row" data-href="/courses/{{ COURSE_ID }}/check_ins">
<td>
Weekly Check Ins Summary
</td>
</tr>
{% endif %}
</tbody>
</table>

<script>
document.addEventListener("DOMContentLoaded", function(){
document.querySelectorAll('.clickable-row').forEach(row => {
row.addEventListener('click', function() {
window.location.href = this.dataset.href;
});
});
});
</script>
{% endblock %}
File renamed without changes.
48 changes: 0 additions & 48 deletions web_app/templates/products.html

This file was deleted.

0 comments on commit c8662d5

Please sign in to comment.