Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BD-24] [TNL-7661] [BB-3172] LTI Improvements - Use declarative gradi…
…ng model on XBlock launch (#116) * create default LineItem, WIP grade save * add score to django admin * WIP: find user and save grade to xblock * boolean pragramatic grade interaction flag and optional params in enable_ags method * Submit grades using grade signals * lineitem urls should be optional * lineitem is now readonly in declarative method * test grade_submit called properly * quality issue * raise LTIError * moved listener to signal.py, refactored models.py, added due and start date, updated tests. * use load_block_as_anonymous_user and remove load_block, refactor tests * refactor test to fix quality issue * make lineitems_url required * refactor tests, accept_grades_past_due on check * test accept_grades_past_due * add comma to last items * refactor get_lti_ags_lineitems_url * make sure crum returns user and not None * nitpicks & use maximum score when given score is larger than maximum * fix docstring of load_block_as_anonymous_user
- Loading branch information
Showing
11 changed files
with
290 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
LTI Consumer related Signal handlers | ||
""" | ||
|
||
from django.db.models.signals import post_save | ||
from django.dispatch import receiver | ||
|
||
from lti_consumer.models import LtiAgsScore | ||
from lti_consumer.plugin import compat | ||
|
||
|
||
@receiver(post_save, sender=LtiAgsScore, dispatch_uid='publish_grade_on_score_update') | ||
def publish_grade_on_score_update(sender, instance, **kwargs): # pylint: disable=unused-argument | ||
""" | ||
Publish grade to xblock whenever score saved/updated and its grading_progress is set to FullyGraded. | ||
""" | ||
if instance.grading_progress == LtiAgsScore.FULLY_GRADED: | ||
block = compat.load_block_as_anonymous_user(instance.line_item.resource_link_id) | ||
if not block.is_past_due() or block.accept_grades_past_due: | ||
user = compat.get_user_from_external_user_id(instance.user_id) | ||
# check if score_given is larger than score_maximum | ||
score = instance.score_given if instance.score_given < instance.score_maximum else instance.score_maximum | ||
compat.publish_grade( | ||
block, | ||
user, | ||
score, | ||
instance.score_maximum, | ||
comment=instance.comment | ||
) |
Oops, something went wrong.