Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: suffix statements if not exists #3

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 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 @@ -611,5 +611,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
Loading