Skip to content

Commit

Permalink
fix: prefix statements if not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
ziafazal committed Dec 21, 2023
1 parent c386044 commit 2576490
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 3 additions & 4 deletions openedx_cmi5_xblock/openedx_cmi5_xblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CMI5XBlock(XBlock, CompletableXBlockMixin):
display_name = String(
display_name=_('Display Name'),
help=_('Display name'),
default='CMI5 module',
default='CMI5 Module',
scope=Scope.settings,
)

Expand Down Expand Up @@ -179,7 +179,7 @@ def lrs_endpoint(self, request, _suffix):
"""
credentials = self.get_credentials()

if request.params.get('statementId') and request.method == 'PUT':
if request.params.get('statementId') and request.method == 'PUT' and credentials["EXTERNAL_LRS_URL"]:
statement_data = get_request_body(request)
# send statements to external lrs.
send_xapi_to_external_lrs(
Expand Down Expand Up @@ -235,7 +235,6 @@ def studio_submit(self, request, _suffix):
self.height = parse_int(request.params['height'], None)
self.has_score = request.params['has_score'] == '1'
self.weight = parse_float(request.params['weight'], 1)
self.icon_class = 'problem' if self.has_score else 'video'

response = {'result': 'success', 'errors': []}
if not hasattr(request.params['file'], 'file'):
Expand Down Expand Up @@ -307,6 +306,7 @@ def get_erollment_id(self):
)
return enrollment.id
except Exception as err:
logger.error('Error occurred while getting enrollment id: %s', err)
return 'anonymous'

def get_enrollment_uuid(self):
Expand Down Expand Up @@ -612,4 +612,3 @@ def cmi5_location():
class CMI5Error(Exception):
"""Base exception class for CMI5-related errors."""

pass
2 changes: 2 additions & 0 deletions openedx_cmi5_xblock/utils/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def send_xapi_to_external_lrs(xapi_data, lrs_url, LRS_AUTH_KEY, LRS_AUTH_SECRET)
'Content-Type': 'application/json',
'X-Experience-API-Version': '1.0.3'
}
if not lrs_url.endswith(('statements', 'statements/')):
lrs_url += '/statements'

try:
response = requests.post(
Expand Down

0 comments on commit 2576490

Please sign in to comment.