Skip to content

Commit 37ec169

Browse files
committed
LTI1.3 tool: Create lineitem if not found while sending grade
Fix for the issue where after some moodle operations grades would no longer be sent from A+ to moodle. Now lineitem existence is checked before trying to send the grade, and is recreated if not found. Fixes #1483
1 parent bfaf2eb commit 37ec169

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lti_tool/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from pylti1p3.exception import LtiException, LtiServiceException
1212

1313
from course.models import CourseInstance
14+
from lib.localization_syntax import pick_localized
1415

1516

1617
logger = logging.getLogger('aplus.lti_tool')
@@ -116,8 +117,13 @@ def send_lti_points(request, submission):
116117
.set_activity_progress('Completed')
117118
.set_grading_progress('FullyGraded')
118119
.set_user_id(launch.get_launch_data().get('sub')))
120+
121+
# Check for lineitem existence and remake if not found
122+
e = submission.exercise
119123
line_item = LineItem()
120-
line_item.set_tag(str(submission.exercise.id))
124+
line_item.set_tag(str(e.id)).set_score_maximum(e.max_points).set_label(pick_localized(str(e), 'en'))
125+
ags.find_or_create_lineitem(line_item)
126+
121127
try:
122128
ags.put_grade(grade, line_item)
123129
except LtiServiceException as exc:

0 commit comments

Comments
 (0)