Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
dc081666
Commit
dc081666
authored
Jan 28, 2015
by
Matt Drayer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6792 from edx/ziafazal/make-course-requirements-links
make course requirement as link
parents
40d109e9
ba5fd98a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
10 deletions
+25
-10
common/djangoapps/util/milestones_helpers.py
+7
-2
lms/djangoapps/courseware/tests/test_about.py
+9
-6
lms/templates/courseware/course_about.html
+9
-2
No files found.
common/djangoapps/util/milestones_helpers.py
View file @
dc081666
...
...
@@ -111,14 +111,19 @@ def get_pre_requisite_courses_not_completed(user, enrolled_courses):
def
get_prerequisite_courses_display
(
course_descriptor
):
"""
It would retrieve pre-requisite courses, make display strings
and return them as list
and return list of dictionary with course key as 'key' field
and course display name as `display` field.
"""
pre_requisite_courses
=
[]
if
settings
.
FEATURES
.
get
(
'ENABLE_PREREQUISITE_COURSES'
,
False
)
and
course_descriptor
.
pre_requisite_courses
:
for
course_id
in
course_descriptor
.
pre_requisite_courses
:
course_key
=
CourseKey
.
from_string
(
course_id
)
required_course_descriptor
=
modulestore
()
.
get_course
(
course_key
)
pre_requisite_courses
.
append
(
get_course_display_name
(
required_course_descriptor
))
prc
=
{
'key'
:
course_key
,
'display'
:
get_course_display_name
(
required_course_descriptor
)
}
pre_requisite_courses
.
append
(
prc
)
return
pre_requisite_courses
...
...
lms/djangoapps/courseware/tests/test_about.py
View file @
dc081666
...
...
@@ -23,6 +23,7 @@ from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from
util.milestones_helpers
import
(
set_prerequisite_courses
,
seed_milestone_relationship_types
,
get_prerequisite_courses_display
,
)
from
.helpers
import
LoginEnrollmentTestCase
...
...
@@ -132,9 +133,10 @@ class AboutTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
url
=
reverse
(
'about_course'
,
args
=
[
unicode
(
course
.
id
)])
resp
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertIn
(
"<span class=
\"
important-dates-item-text pre-requisite
\"
>{} {}</span>"
.
format
(
pre_requisite_course
.
display_org_with_default
,
pre_requisite_course
.
display_number_with_default
),
pre_requisite_courses
=
get_prerequisite_courses_display
(
course
)
pre_requisite_course_about_url
=
reverse
(
'about_course'
,
args
=
[
unicode
(
pre_requisite_courses
[
0
][
'key'
])])
self
.
assertIn
(
"<span class=
\"
important-dates-item-text pre-requisite
\"
><a href=
\"
{}
\"
>{}</a></span>"
.
format
(
pre_requisite_course_about_url
,
pre_requisite_courses
[
0
][
'display'
]),
resp
.
content
.
strip
(
'
\n
'
))
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_PREREQUISITE_COURSES'
:
True
,
'MILESTONES_APP'
:
True
})
...
...
@@ -168,9 +170,10 @@ class AboutTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
url
=
reverse
(
'about_course'
,
args
=
[
unicode
(
course
.
id
)])
resp
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertIn
(
"<span class=
\"
important-dates-item-text pre-requisite
\"
>{} {}</span>"
.
format
(
pre_requisite_course
.
display_org_with_default
,
pre_requisite_course
.
display_number_with_default
),
pre_requisite_courses
=
get_prerequisite_courses_display
(
course
)
pre_requisite_course_about_url
=
reverse
(
'about_course'
,
args
=
[
unicode
(
pre_requisite_courses
[
0
][
'key'
])])
self
.
assertIn
(
"<span class=
\"
important-dates-item-text pre-requisite
\"
><a href=
\"
{}
\"
>{}</a></span>"
.
format
(
pre_requisite_course_about_url
,
pre_requisite_courses
[
0
][
'display'
]),
resp
.
content
.
strip
(
'
\n
'
))
url
=
reverse
(
'about_course'
,
args
=
[
unicode
(
pre_requisite_course
.
id
)])
...
...
lms/templates/courseware/course_about.html
View file @
dc081666
...
...
@@ -320,12 +320,19 @@ from edxmako.shortcuts import marketing_link
% endif
% if pre_requisite_courses:
<
%
prc_target =
reverse('about_course',
args=
[unicode(pre_requisite_courses[0]['key'])])
%
>
<li
class=
"prerequisite-course important-dates-item"
>
<i
class=
"icon fa fa-list-ul"
></i>
<p
class=
"important-dates-item-title"
>
${_("Prerequisites")}
</p>
## Multiple pre-requisite courses are not supported on frontend that's why we are pulling first element
<span
class=
"important-dates-item-text pre-requisite"
>
${pre_requisite_courses[0]}
</span>
<p
class=
"tip"
>
${_("You must successfully complete {course} before you begin this course").format(course=pre_requisite_courses[0])}.
</p>
<span
class=
"important-dates-item-text pre-requisite"
><a
href=
"${prc_target}"
>
${pre_requisite_courses[0]['display']}
</a></span>
<p
class=
"tip"
>
${_("You must successfully complete {link_start}{prc_display}{link_end} before you begin this course.").format(
link_start='
<a
href=
"{}"
>
'.format(prc_target),
link_end='
</a>
',
prc_display=pre_requisite_courses[0]['display'],
)}
</p>
</li>
% endif
% if get_course_about_section(course, "prerequisites"):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment