Instructor participation report: per-student histograms, outcome mix by class day, and a sortable table including the fairness ratio (answered calls over questions present for, with opt-out days out of the denominator), plus CSV exports of students, calls, and opt-outs. Assessment scales are now per-course data: ordered levels with labels and points out of 100 (defaults carry the old R grading values), with calls referencing levels by id so renames follow through to history. Renaming, re-pointing, reordering, and adding levels are always allowed; deleting a level in use by recorded calls is blocked. Pronouns and course term dates come from Canvas custom variable substitutions, at launch and roster-wide via rlid-scoped NRPS; the student page notes that names/pronouns are Canvas-sourced. Rosters can also be refreshed outside launches: a "Sync roster now" button and a sync-rosters CLI command for an hourly cron job, skipping ended courses. Alembic now runs SQLite-compatible batch migrations with a constraint naming convention. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
72 lines
2.5 KiB
Python
72 lines
2.5 KiB
Python
from coldcall_lti import launch, models
|
|
|
|
|
|
def sample_launch_data(is_instructor=False):
|
|
roles = [launch.ROLE_INSTRUCTOR] if is_instructor else [launch.ROLE_LEARNER]
|
|
return {
|
|
"sub": "canvas-user-42",
|
|
"name": "Pat Example",
|
|
"email": "pat@example.edu",
|
|
"picture": "https://example.edu/pat.png",
|
|
launch.CLAIM_DEPLOYMENT: "dep-1",
|
|
launch.CLAIM_CONTEXT: {"id": "ctx-abc", "title": "COM 999"},
|
|
launch.CLAIM_ROLES: roles,
|
|
}
|
|
|
|
|
|
def test_extract_launch_info_student():
|
|
info = launch.extract_launch_info(sample_launch_data())
|
|
assert info.context_id == "ctx-abc"
|
|
assert info.course_title == "COM 999"
|
|
assert info.user_id == "canvas-user-42"
|
|
assert info.deployment_id == "dep-1"
|
|
assert not info.is_instructor
|
|
|
|
|
|
def test_extract_launch_info_instructor():
|
|
info = launch.extract_launch_info(sample_launch_data(is_instructor=True))
|
|
assert info.is_instructor
|
|
|
|
|
|
def test_extract_launch_info_pronouns_custom_claim():
|
|
data = sample_launch_data()
|
|
data[launch.CLAIM_CUSTOM] = {"pronouns": "ze/zir"}
|
|
assert launch.extract_launch_info(data).pronouns == "ze/zir"
|
|
|
|
data[launch.CLAIM_CUSTOM] = {"pronouns": "$com.instructure.Person.pronouns"}
|
|
assert launch.extract_launch_info(data).pronouns is None
|
|
|
|
|
|
def test_extract_launch_info_course_dates():
|
|
data = sample_launch_data()
|
|
data[launch.CLAIM_CUSTOM] = {
|
|
"course_start": "2026-09-30T07:00:00Z",
|
|
"course_end": "$Canvas.course.endAt",
|
|
}
|
|
info = launch.extract_launch_info(data)
|
|
assert info.course_start == launch.datetime.date(2026, 9, 30)
|
|
assert info.course_end is None
|
|
|
|
|
|
def test_upsert_launch_creates_and_is_idempotent(db_session):
|
|
info = launch.extract_launch_info(sample_launch_data())
|
|
course, student = launch.upsert_launch(db_session, info)
|
|
assert course.title == "COM 999"
|
|
assert student.canvas_user_id == "canvas-user-42"
|
|
|
|
course2, student2 = launch.upsert_launch(db_session, info)
|
|
assert course2.id == course.id
|
|
assert student2.id == student.id
|
|
assert db_session.query(models.Enrollment).count() == 1
|
|
|
|
|
|
def test_upsert_launch_reactivates_dropped_enrollment(db_session):
|
|
info = launch.extract_launch_info(sample_launch_data())
|
|
course, student = launch.upsert_launch(db_session, info)
|
|
enrollment = db_session.query(models.Enrollment).one()
|
|
enrollment.active = False
|
|
db_session.flush()
|
|
|
|
launch.upsert_launch(db_session, info)
|
|
assert db_session.query(models.Enrollment).one().active
|