Skip to content
Closed
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
5 changes: 4 additions & 1 deletion cms/djangoapps/contentstore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@

from .models import ComponentLink, ContainerLink

from openedx.core.lib.gating.services import GatingService

IMPORTABLE_FILE_TYPES = ('.tar.gz', '.zip')
log = logging.getLogger(__name__)

Expand Down Expand Up @@ -1311,7 +1313,8 @@ def load_services_for_studio(runtime, user):
"settings": SettingsService(),
"lti-configuration": ConfigurationService(CourseAllowPIISharingInLTIFlag),
"teams_configuration": TeamsConfigurationService(),
"library_tools": LegacyLibraryToolsService(modulestore(), user.id)
"library_tools": LegacyLibraryToolsService(modulestore(), user.id),
'gating': GatingService(),
}

runtime._services.update(services) # lint-amnesty, pylint: disable=protected-access
Expand Down
2 changes: 1 addition & 1 deletion lms/templates/video.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ <h4 class="hd hd-5">${_('Transcripts')}</h4>
% if handout:
<div class="wrapper-handouts">
<h4 class="hd hd-5">${_('Handouts')}</h4>
<a class="btn-link" href="${handout}">${_('Download Handout')}</a>
<a class="btn-link" href="${handout}" download>${_('Download Handout')}</a>
</div>
% endif
% if branding_info:
Expand Down
13 changes: 13 additions & 0 deletions openedx/core/lib/gating/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,16 @@ def is_gate_fulfilled(self, course_key, gating_content_key, user_id):
Returns False otherwise
"""
return gating_api.is_gate_fulfilled(course_key, gating_content_key, user_id)

def get_required_prereq_metadata(course_key, gated_content_key):
"""
Returns the prerequisite information of the provided subsection

Arguments:
course_key (str|CourseKey): The course key
content_key (str|UsageKey): The content usage key

Returns:
dict or None: The gating milestone dict or None
"""
return gating_api.get_required_content(course_key, gated_content_key)
21 changes: 20 additions & 1 deletion xmodule/seq_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
from .x_module import AUTHOR_VIEW, PUBLIC_VIEW
from .xml_block import XmlMixin


log = logging.getLogger(__name__)

# HACK: This shouldn't be hard-coded to two types
Expand Down Expand Up @@ -375,6 +374,26 @@ def get_metadata(self, view=STUDENT_VIEW, context=None):
meta['navigation_disabled'] = self.is_sequence_navigation_disabled()
return meta

def get_prereq_metadata(self, course_key, gated_content_key):
"""
Returns the prerequisite of this sequence if there is one.

Arguments:
course_key (str|CourseKey): The course key
content_key (str|UsageKey): The content usage key

Returns:
dict or None: The gating milestone dict or None
"""
logging.warning(f'INSPECTING-LOG get_prereq_metadata type is = %s', type(self))
logging.warning(f'INSPECTING-LOG get_prereq_metadata vars is = %s', vars(self))

gating_service = self.runtime.service(self, 'gating')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cup0fCoffee This always returns an empty object.

if gating_service:
return gating_service.get_required_prereq_metadata(course_key, gated_content_key)
else:
return None

def is_sequence_navigation_disabled(self):
"""
Returns whether the navigation to other sequences is disabled.
Expand Down
24 changes: 23 additions & 1 deletion xmodule/xml_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
from xblock.runtime import KvsFieldData
from xmodule.modulestore import EdxJSONEncoder
from xmodule.modulestore.inheritance import InheritanceKeyValueStore, own_metadata

log = logging.getLogger(__name__)

# assume all XML files are persisted as utf-8.
EDX_XML_PARSER = XMLParser(dtd_validation=False, load_dtd=False, remove_blank_text=True, encoding='utf-8')



def name_to_pathname(name):
"""
Convert a location name for use in a path: replace ':' with '/'.
Expand Down Expand Up @@ -455,6 +455,28 @@ def add_xml_to_node(self, node):
xml_object.tag = self.category
node.tag = self.category

# Populate Prerequisite information of a sequential object
if self.category == 'sequential':
course_id = self.scope_ids.usage_id.context_key
content_id = self.location
logging.warning(f'INSPECTING-LOG self type is = %s', type(self))
logging.warning(f'INSPECTING-LOG self vars is = %s', vars(self))

logging.warning(f'INSPECTING-LOG course_id is = %s', course_id)
logging.warning(f'INSPECTING-LOG content_id is = %s', content_id)

milestone = self.get_prereq_metadata(course_id, content_id)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values to be exported will be populated from the results found at milestone object. @Cup0fCoffee

if milestone :
logging.warning(f'INSPECTING-LOG milestone type is = %s', type(milestone))
logging.warning(f'INSPECTING-LOG milestone vars is = %s', vars(milestone))
# xml_object.set('is_prereq', '')
# xml_object.set('prereq', '')
# xml_object.set('prereq_min_score', '')
# xml_object.set('prereq_min_completion', '')
else :
logging.warning(f'INSPECTING-LOG milestone is None= %s', (milestone))


# Add the non-inherited metadata
for attr in sorted(own_metadata(self)):
# don't want e.g. data_dir
Expand Down
Loading