diff --git a/coldcall_lti/instructor.py b/coldcall_lti/instructor.py index f035fc3..2dd763d 100644 --- a/coldcall_lti/instructor.py +++ b/coldcall_lti/instructor.py @@ -92,6 +92,10 @@ def home(): db = get_db() course = current_course() today = datetime.date.today() + # The working date: everything on the page targets it. Defaults to + # today, but e.g. printing tomorrow's list a day early just means + # picking tomorrow here. + day = _parse_date(request.args.get("date")) recent_days = db.execute( select( @@ -105,16 +109,19 @@ def home(): .limit(10) ).all() - today_calls = calls.calls_for_day(db, course.id, today) - context = _day_context(db, course, today) + day_calls = calls.calls_for_day(db, course.id, day) + context = _day_context(db, course, day) context.update( recent_days=recent_days, today=today, - has_pending_today=any( - c.status == STATUS_PENDING for c in today_calls + upcoming_class_days=[ + d.date for d in class_days(db, course.id, start=today) + ][:4], + has_pending=any( + c.status == STATUS_PENDING for c in day_calls ), - resolved_today=sum( - 1 for c in today_calls if c.status != STATUS_PENDING + resolved=sum( + 1 for c in day_calls if c.status != STATUS_PENDING ), ) return render_template("instructor_home.html", **context) diff --git a/coldcall_lti/templates/instructor_home.html b/coldcall_lti/templates/instructor_home.html index 9509c9d..c62c478 100644 --- a/coldcall_lti/templates/instructor_home.html +++ b/coldcall_lti/templates/instructor_home.html @@ -4,12 +4,30 @@

{{ course.title or course.lti_context_id }}

{{ roster_count }} active students on the roster; - {{ present_count }} available today ({{ optout_count }} opted out). + {{ present_count }} available on {{ day.isoformat() }} + ({{ optout_count }} opted out).

+
+ + + {% if day != today %} + back to today + {% endif %} + {% if upcoming_class_days %} + Class days: + {% for d in upcoming_class_days %} + + {{ d.strftime("%a %b %-d") }} + {% endfor %} + {% endif %} +
+

- Live cold call · - Today's calls · + Live cold call · + Calls for {{ day.isoformat() }} · Report · Grades · Schedule · @@ -23,22 +41,22 @@

Printable list

-{% if has_pending_today %} +{% if has_pending %}

- - View today's list + + View the list for {{ day.isoformat() }}

{% endif %}
@@ -46,14 +64,14 @@

Recent days

- {% for day, total, answered in recent_days %} + {% for d, total, answered in recent_days %} - + {% endfor %} diff --git a/tests/test_instructor_ui.py b/tests/test_instructor_ui.py index f9fad39..e719c65 100644 --- a/tests/test_instructor_ui.py +++ b/tests/test_instructor_ui.py @@ -69,7 +69,7 @@ def test_regenerate_replaces_pending_and_labels_change(instructor): instructor.post(f"/instructor/day/{TODAY}/generate", data={"n": "12"}) page = instructor.get("/instructor/").get_data(as_text=True) - assert "View today's list" in page + assert f"View the list for {TODAY}" in page assert "Regenerate list" in page # Regenerating replaces the unused list outright. @@ -95,6 +95,26 @@ def test_regenerate_replaces_pending_and_labels_change(instructor): assert "already have recorded outcomes" in page +def test_home_working_date_override(instructor): + tomorrow = ( + datetime.date.today() + datetime.timedelta(days=1) + ).isoformat() + page = instructor.get(f"/instructor/?date={tomorrow}").get_data(as_text=True) + assert f"available on {tomorrow}" in page + assert f"Generate list for {tomorrow}" in page + assert "back to today" in page + + # Generate tomorrow's list a day in advance; today stays untouched. + resp = instructor.post( + f"/instructor/day/{tomorrow}/generate", + data={"n": "5"}, + follow_redirects=True, + ) + assert resp.get_data(as_text=True).count("") == 6 + page = instructor.get(f"/instructor/day/{TODAY}/print").get_data(as_text=True) + assert "No call list has been generated" in page + + def test_add_call_after_the_fact(instructor): page = instructor.get(f"/instructor/day/{TODAY}").get_data(as_text=True) student_id = re.search(r'
DateCallsAnswered
{{ day.isoformat() }}{{ d.isoformat() }} {{ total }} {{ answered or 0 }} - edit · - print + edit · + print