Commit c34a0aac by Bessie Steinberg

improve readability

parent 5c4bc98b
...@@ -344,11 +344,14 @@ def add_course_content_milestone(course_id, content_id, relationship, milestone) ...@@ -344,11 +344,14 @@ def add_course_content_milestone(course_id, content_id, relationship, milestone)
return milestones_api.add_course_content_milestone(course_id, content_id, relationship, milestone) return milestones_api.add_course_content_milestone(course_id, content_id, relationship, milestone)
def get_course_content_milestones(course_id, content_id, relationship, user_id=None): def get_course_content_milestones(course_id, content_id=None, relationship='requires', user_id=None):
""" """
Client API operation adapter/wrapper Client API operation adapter/wrapper
Uses the request cache to store all of a user's Uses the request cache to store all of a user's
milestones milestones
Returns all content blocks in a course if content_id is None, otherwise it just returns that
specific content block.
""" """
if not settings.FEATURES.get('MILESTONES_APP'): if not settings.FEATURES.get('MILESTONES_APP'):
return [] return []
......
...@@ -173,7 +173,10 @@ class CourseOutlinePage(PageObject): ...@@ -173,7 +173,10 @@ class CourseOutlinePage(PageObject):
raise ValueError("Could not find section '{0}'".format(section_title)) raise ValueError("Could not find section '{0}'".format(section_title))
try: try:
log.info(">>> self._subsection_titles(section_index + 1): '{0}'".format(self._subsection_titles(section_index + 1)))
log.info(">>> subsection_title: '{0}'".format(subsection_title))
subsection_index = self._subsection_titles(section_index + 1).index(subsection_title) subsection_index = self._subsection_titles(section_index + 1).index(subsection_title)
log.info(">>> subsection_index: '{0}'".format(subsection_index))
except ValueError: except ValueError:
raise ValueError("Could not find subsection '{0}' in section '{1}'".format( raise ValueError("Could not find subsection '{0}' in section '{1}'".format(
subsection_title, section_title subsection_title, section_title
...@@ -241,10 +244,16 @@ class CourseOutlinePage(PageObject): ...@@ -241,10 +244,16 @@ class CourseOutlinePage(PageObject):
Return a list of all subsection titles on the page Return a list of all subsection titles on the page
for the section at index `section_index` (starts at 1). for the section at index `section_index` (starts at 1).
""" """
log.info(">>> calling _subsection_titles...")
log.info(">>> section_index: '{0}'".format(section_index))
subsection_css = self.SUBSECTION_TITLES_SELECTOR.format(section_index) subsection_css = self.SUBSECTION_TITLES_SELECTOR.format(section_index)
return self.q(css=subsection_css).map( log.info(">>> subsection_css: '{0}'".format(subsection_css))
return_val = self.q(css=subsection_css).map(
lambda el: el.get_attribute('innerHTML').strip() lambda el: el.get_attribute('innerHTML').strip()
).results ).results
log.info(">>> return_val: '{0}'".format(return_val))
return return_val
def _wait_for_course_section(self, section_title, subsection_title): def _wait_for_course_section(self, section_title, subsection_title):
""" """
......
...@@ -41,23 +41,21 @@ from openedx.core.djangolib.markup import HTML, Text ...@@ -41,23 +41,21 @@ from openedx.core.djangolib.markup import HTML, Text
<span class="menu-icon icon fa fa-unlock" <span class="menu-icon icon fa fa-unlock"
aria-hidden="true"> aria-hidden="true">
</span> </span>
<span class="subsection-title-name">
${ subsection['display_name'] }
</span>
<span class="sr">&nbsp;${_("Unlocked")}</span>
% else: % else:
<span class="menu-icon icon fa fa-lock" <span class="menu-icon icon fa fa-lock"
aria-hidden="true"> aria-hidden="true">
</span> </span>
% endif <span class="subsection-title-name">
% endif ${ subsection['display_name'] }
<span class="subsection-title-name"> </span>
${ subsection['display_name'] }
</span>
% if subsection['id'] in milestones:
% if milestones[subsection['id']]['completed_prereqs']:
<span class="sr">&nbsp;${_("Unlocked")}</span>
% else:
<span class="details"> <span class="details">
${ _("(Prerequisite required)") } ${ _("(Prerequisite required)") }
</span> </span>
% endif % endif
% endif % endif
<div class="details"> <div class="details">
......
...@@ -48,19 +48,13 @@ class CourseOutlineFragmentView(EdxFragmentView): ...@@ -48,19 +48,13 @@ class CourseOutlineFragmentView(EdxFragmentView):
""" """
course_content_milestones = {} course_content_milestones = {}
all_course_prereqs = get_course_content_milestones( all_course_prereqs = get_course_content_milestones(course_id=course_key)
course_id=course_key,
content_id=None,
relationship='requires',
user_id=None)
for milestone in all_course_prereqs: for milestone in all_course_prereqs:
course_content_milestones[milestone['content_id']] = {'completed_prereqs': True} course_content_milestones[milestone['content_id']] = {'completed_prereqs': True}
unfulfilled_prereqs = get_course_content_milestones( unfulfilled_prereqs = get_course_content_milestones(
course_id=course_key, course_id=course_key,
content_id=None,
relationship='requires',
user_id=request.user.id) user_id=request.user.id)
for milestone in unfulfilled_prereqs: for milestone in unfulfilled_prereqs:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment