Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
add index_page property to response about a scorm file
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyLykhoman authored and Igor Degtiarov committed Dec 20, 2018
1 parent 783ae08 commit 1fffccc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions scormxblock/scormxblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class ScormXBlock(XBlock):
display_name=_("Upload scorm file"),
scope=Scope.settings,
)
path_index_page = String(
display_name=_("Path to the index page in scorm file"),
scope=Scope.settings,
)
scorm_file_meta = Dict(
scope=Scope.content
)
Expand Down Expand Up @@ -273,7 +277,7 @@ def render_template(self, template_path, context):
return template.render(Context(context))

def set_fields_xblock(self, path_to_file):
path_index_page = 'index.html'
self.path_index_page = 'index.html'
try:
tree = ET.parse('{}/imsmanifest.xml'.format(path_to_file))
except IOError:
Expand All @@ -294,13 +298,13 @@ def set_fields_xblock(self, path_to_file):
schemaversion = root.find('metadata/schemaversion')

if resource:
path_index_page = resource.get('href')
self.path_index_page = resource.get('href')
if (schemaversion is not None) and (re.match('^1.2$', schemaversion.text) is None):
self.version_scorm = 'SCORM_2004'
else:
self.version_scorm = 'SCORM_12'

self.scorm_file = os.path.join(SCORM_URL, '{}/{}'.format(self.location.block_id, path_index_page))
self.scorm_file = os.path.join(SCORM_URL, '{}/{}'.format(self.location.block_id, self.path_index_page))

def get_completion_status(self):
completion_status = self.lesson_status
Expand Down Expand Up @@ -339,9 +343,12 @@ def student_view_data(self):
Make sure to include `student_view_data=scormxblock` to URL params in the request.
"""
if self.scorm_file and self.scorm_file_meta:
return {'last_modified': self.scorm_file_meta.get('last_updated', ''),
'scorm_data': default_storage.url(self._file_storage_path()),
'size': self.scorm_file_meta.get('size', 0)}
return {
'last_modified': self.scorm_file_meta.get('last_updated', ''),
'scorm_data': default_storage.url(self._file_storage_path()),
'size': self.scorm_file_meta.get('size', 0),
'index_page': self.path_index_page,
}
return {}

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def package_data(pkg, roots):

setup(
name='scormxblock-xblock',
version='0.4',
version='0.5',
description='scormxblock XBlock', # TODO: write a better description.
packages=[
'scormxblock',
Expand Down

0 comments on commit 1fffccc

Please sign in to comment.