hypothesis / lms

LTI app for integrating with learning management systems
BSD 2-Clause "Simplified" License
46 stars 14 forks source link

Upsert grading information in DB on Blackboard assignment launch #946

Closed seanh closed 5 years ago

seanh commented 5 years ago

Belongs to epic: https://github.com/hypothesis/lms/issues/662
Proof of concept: https://github.com/hypothesis/lms/pull/945

Whenever a student launches an assignment in Blackboard we need to persist some information about that launch in our LMS app's database, so that we'll be able to submit grades for that student and assignment to Blackboard later (in subsequent LTI launches by the course teacher).

Task list

What needs to be persisted

The information that needs to be saved to the DB is:

This requires a new database table with a unique constraint on the oauth_consumer_key, user_id, context_id and resource_link_id fields. We never want to have two rows of grading information with the same oauth_consumer_key, user_id, context_id and resource_link_id.

Logic for how the fields need to be created and updated

These fields need to be upserted on every assignment launch. When a user launches an assignment, if the request contains a lis_result_sourcedid parameter, we should:

Not every LTI launch contains the fields

When a teacher launches an assignment there are no lis_result_sourcedid and lis_outcome_service_url fields. You can't grade teachers. We need to detect this and not try to record the data in the DB, for teachers.

This may require more than one DB table

We may want a separate database table for recording the user information: the LTI oauth_consumer_key and user_id and our generated Hypothesis username and display_name. The other new DB table (the one containing the lis_result_sourcedid and other grading-specific fields) will then have foreign keys to this user table. That way, we can update the user's display name whenever that user launches any Hypothesis assignment, rather than having a separate copy of their display name per assignment and only updating it when they launch that particular assignment.

It may be that even more than two DB tables are needed...

Blackboard only

We should only save grading-specific data into the DB for Blackboard launches. This grading data is not used for grading in Canvas. And we do not yet support grading in other LMS's.

We can identify Blackboard based on these launch params that it sends:

After we've shipped grading for Blackboard we will likely very quickly ship it for Brightspace and Moodle, and maybe also Sakai (all the other LMS's that we have test sites for) based on the same code, and this will likely involve loosening this Blackboard-only logic in the code, but we still will not need this information for Canvas, and let's leave other LMS's out of this until Blackboard has been shipped and then deal with them separately.

Expiring old rows

Since we add a new row to the new DB table every time a new student launches a new assignment, this table grows forever. We should delete old rows. Maybe just delete rows more than one year old? (Would require a date column on the table.)

Note that we cannot expire rows after they have been used because they might need to be used again. A teacher can submit more than one grade for one student/assignment (overwriting the previous grade).

lyzadanger commented 5 years ago

We should delete old rows. Maybe just delete rows more than one year old? (Would require a date column on the table.)

What should kick off this pruning process?

lyzadanger commented 5 years ago

We should only save grading-specific data into the DB for Blackboard launches. This grading data is not used for grading in Canvas. And we do not yet support grading in other LMS's.

We can identify Blackboard based on these launch params that it sends:

tool_consumer_info_product_family_code: "BlackboardLearn" (this is a standard LTI launch param)

Given that we're planning on extending this beyond Blackboard eventually, I wonder if it would be useful to store the product_family info in the LMS DB as well, for metrics/debug purposes? i.e. be able to tell quickly that student/assignment combinations are Blackboard-originated? Everything will be Blackboard for now, but later...perhaps this could be useful.