Commit c34a0aac by Bessie Steinberg

improve readability

parent 5c4bc98b
......@@ -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)
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
Uses the request cache to store all of a user's
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'):
return []
......
......@@ -173,7 +173,10 @@ class CourseOutlinePage(PageObject):
raise ValueError("Could not find section '{0}'".format(section_title))
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)
log.info(">>> subsection_index: '{0}'".format(subsection_index))
except ValueError:
raise ValueError("Could not find subsection '{0}' in section '{1}'".format(
subsection_title, section_title
......@@ -241,10 +244,16 @@ class CourseOutlinePage(PageObject):
Return a list of all subsection titles on the page
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)
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()
).results
log.info(">>> return_val: '{0}'".format(return_val))
return return_val
def _wait_for_course_section(self, section_title, subsection_title):
"""
......
......@@ -41,23 +41,21 @@ from openedx.core.djangolib.markup import HTML, Text
<span class="menu-icon icon fa fa-unlock"
aria-hidden="true">
</span>
<span class="subsection-title-name">
${ subsection['display_name'] }
</span>
<span class="sr">&nbsp;${_("Unlocked")}</span>
% else:
<span class="menu-icon icon fa fa-lock"
aria-hidden="true">
</span>
% endif
% endif
<span class="subsection-title-name">
${ subsection['display_name'] }
</span>
% if subsection['id'] in milestones:
% if milestones[subsection['id']]['completed_prereqs']:
<span class="sr">&nbsp;${_("Unlocked")}</span>
% else:
<span class="subsection-title-name">
${ subsection['display_name'] }
</span>
<span class="details">
${ _("(Prerequisite required)") }
</span>
% endif
% endif
% endif
<div class="details">
......
......@@ -48,19 +48,13 @@ class CourseOutlineFragmentView(EdxFragmentView):
"""
course_content_milestones = {}
all_course_prereqs = get_course_content_milestones(
course_id=course_key,
content_id=None,
relationship='requires',
user_id=None)
all_course_prereqs = get_course_content_milestones(course_id=course_key)
for milestone in all_course_prereqs:
course_content_milestones[milestone['content_id']] = {'completed_prereqs': True}
unfulfilled_prereqs = get_course_content_milestones(
course_id=course_key,
content_id=None,
relationship='requires',
user_id=request.user.id)
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