Closed dmitry-viskov closed 1 year ago
This has broken put_grade in the case that you supply a LineItem that has an ID. I call find_or_create_lineitem myself because I need to control how it is matched.
My code says
lineitem = LineItem() \
.set_resource_link_id(resource_link_id) \
.set_tag('score') \
.set_label(resource_link_title) \
.set_score_maximum(score.max_marks)
lineitem = service.find_or_create_lineitem(lineitem, 'resource_link_id')
service.put_grade(sc, lineitem)
Now this fails with the exception Can't find lineitem to put grade
This is because you are missing this line of code now from the old path that could create an item:
score_url = lineitem.get_id()
My solution to this is
diff --git a/pylti1p3/assignments_grades.py b/pylti1p3/assignments_grades.py
index a53ae81..12ab414 100644
--- a/pylti1p3/assignments_grades.py
+++ b/pylti1p3/assignments_grades.py
@@ -55,8 +55,9 @@ class AssignmentsGradesService(object):
if not self.can_put_grade():
raise LtiException("Can't put grade: Missing required scope")
- if lineitem and not lineitem.get_id():
- lineitem = self.find_or_create_lineitem(lineitem)
+ if lineitem:
+ if not lineitem.get_id():
+ lineitem = self.find_or_create_lineitem(lineitem)
score_url = lineitem.get_id()
elif not lineitem and self._service_data.get('lineitem'):
score_url = self._service_data.get('lineitem')
I've submitted #102 to fix this.
Related issues: