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
05898df1
Commit
05898df1
authored
Mar 22, 2016
by
Tasawer
Committed by
tasawernawaz
Mar 29, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated dashboard with providers text
ECOM-2935
parent
1dff9d45
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
24 deletions
+98
-24
common/djangoapps/student/tests/test_credit.py
+37
-1
common/djangoapps/student/views.py
+3
-1
lms/templates/dashboard/_dashboard_credit_info.html
+3
-0
openedx/core/djangoapps/credit/email_utils.py
+36
-21
openedx/core/djangoapps/credit/tests/test_api.py
+19
-1
No files found.
common/djangoapps/student/tests/test_credit.py
View file @
05898df1
...
...
@@ -4,9 +4,9 @@ Tests for credit courses on the student dashboard.
import
unittest
import
datetime
import
ddt
from
mock
import
patch
import
pytz
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
django.test.utils
import
override_settings
...
...
@@ -28,6 +28,7 @@ TEST_CREDIT_PROVIDER_SECRET_KEY = "931433d583c84ca7ba41784bad3232e6"
"hogwarts"
:
TEST_CREDIT_PROVIDER_SECRET_KEY
,
})
@patch.dict
(
settings
.
FEATURES
,
{
"ENABLE_CREDIT_ELIGIBILITY"
:
True
})
@ddt.ddt
class
CreditCourseDashboardTest
(
ModuleStoreTestCase
):
"""
Tests for credit courses on the student dashboard.
...
...
@@ -106,9 +107,12 @@ class CreditCourseDashboardTest(ModuleStoreTestCase):
# The user should still have the option to purchase credit,
# but there should also be a message urging the user to purchase soon.
response
=
self
.
_load_dashboard
()
self
.
assertContains
(
response
,
"credit-eligibility-msg"
)
self
.
assertContains
(
response
,
"purchase-credit-btn"
)
self
.
assertContains
(
response
,
"You have completed this course and are eligible"
)
def
test_purchased_credit
(
self
):
# Simulate that the user has purchased credit, but has not
...
...
@@ -206,3 +210,35 @@ class CreditCourseDashboardTest(ModuleStoreTestCase):
def
_set_request_status
(
self
,
uuid
,
status
):
"""Set the status of a request for credit, simulating the notification from the provider. """
credit_api
.
update_credit_request_status
(
uuid
,
self
.
PROVIDER_ID
,
status
)
@ddt.data
(
(
[
u'Arizona State University'
],
'You are now eligible for credit from Arizona State University'
),
(
[
u'Arizona State University'
,
u'Hogwarts School of Witchcraft'
],
'You are now eligible for credit from Arizona State University and Hogwarts School of Witchcraft'
),
(
[
u'Arizona State University'
,
u'Hogwarts School of Witchcraft and Wizardry'
,
u'Charter Oak'
],
'You are now eligible for credit from Arizona State University, Hogwarts School'
' of Witchcraft and Wizardry, and Charter Oak'
),
([],
'You have completed this course and are eligible'
),
(
None
,
'You have completed this course and are eligible'
)
)
@ddt.unpack
def
test_eligible_for_credit_with_providers_names
(
self
,
providers_list
,
credit_string
):
"""Verify the message on dashboard with different number of providers."""
# Simulate that the user has completed the only requirement in the course
# so the user is eligible for credit.
self
.
_make_eligible
()
# The user should have the option to purchase credit
with
patch
(
'student.views.get_credit_provider_display_names'
)
as
mock_method
:
mock_method
.
return_value
=
providers_list
response
=
self
.
_load_dashboard
()
self
.
assertContains
(
response
,
"credit-eligibility-msg"
)
self
.
assertContains
(
response
,
"purchase-credit-btn"
)
self
.
assertContains
(
response
,
credit_string
)
common/djangoapps/student/views.py
View file @
05898df1
...
...
@@ -124,6 +124,7 @@ from notification_prefs.views import enable_notifications
# Note that this lives in openedx, so this dependency should be refactored.
from
openedx.core.djangoapps.credentials.utils
import
get_user_program_credentials
from
openedx.core.djangoapps.credit.email_utils
import
get_credit_provider_display_names
,
make_providers_strings
from
openedx.core.djangoapps.user_api.preferences
import
api
as
preferences_api
from
openedx.core.djangoapps.programs.utils
import
get_programs_for_dashboard
...
...
@@ -926,12 +927,13 @@ def _credit_statuses(user, course_enrollments):
statuses
=
{}
for
eligibility
in
credit_api
.
get_eligibilities_for_user
(
user
.
username
):
course_key
=
CourseKey
.
from_string
(
unicode
(
eligibility
[
"course_key"
]))
providers_names
=
get_credit_provider_display_names
(
course_key
)
status
=
{
"course_key"
:
unicode
(
course_key
),
"eligible"
:
True
,
"deadline"
:
eligibility
[
"deadline"
],
"purchased"
:
course_key
in
credit_enrollments
,
"provider_name"
:
None
,
"provider_name"
:
make_providers_strings
(
providers_names
)
,
"provider_status_url"
:
None
,
"provider_id"
:
None
,
"request_status"
:
request_status_by_course
.
get
(
course_key
),
...
...
lms/templates/dashboard/_dashboard_credit_info.html
View file @
05898df1
...
...
@@ -15,6 +15,9 @@
#
Translators:
provider_name
is
the
name
of
a
credit
provider
or
university
(
e
.
g
.
State
University
)
credit_msg =
_("You
have
completed
this
course
and
are
eligible
to
purchase
course
credit
.
Select
<
strong
>
Get Credit
</strong>
to get started.")
if credit_status['provider_name']:
credit_msg = _("You are now eligible for credit from {provider}. Congratulations!").format(provider=credit_status['provider_name'])
credit_msg_class = "credit-eligibility-msg"
credit_btn_class = "purchase-credit-btn"
credit_btn_label = _("Get Credit")
...
...
openedx/core/djangoapps/credit/email_utils.py
View file @
05898df1
...
...
@@ -68,26 +68,8 @@ def send_credit_notifications(username, course_key):
# strip enclosing angle brackets from 'logo_image' cache 'Content-ID'
logo_image_id
=
logo_image
.
get
(
'Content-ID'
,
''
)[
1
:
-
1
]
providers
=
get_credit_provider_display_names
(
course_key
)
providers_string
=
None
if
providers
:
if
len
(
providers
)
>
1
:
if
len
(
providers
)
>
2
:
# Translators: The join of three or more university names. The first of these formatting strings
# represents a comma-separated list of names (e.g., MIT, Harvard, Dartmouth).
providers_string
=
_
(
"{first_providers}, and {last_provider}"
)
.
format
(
first_providers
=
u", "
.
join
(
providers
[:
-
1
]),
last_provider
=
providers
[
-
1
]
)
else
:
# Translators: The join of two university names (e.g., Harvard and MIT).
providers_string
=
_
(
"{first_provider} and {second_provider}"
)
.
format
(
first_provider
=
providers
[
0
],
second_provider
=
providers
[
1
]
)
else
:
providers_string
=
providers
[
0
]
providers_names
=
get_credit_provider_display_names
(
course_key
)
providers_string
=
make_providers_strings
(
providers_names
)
context
=
{
'full_name'
:
user
.
get_full_name
(),
'platform_name'
:
settings
.
PLATFORM_NAME
,
...
...
@@ -107,7 +89,8 @@ def send_credit_notifications(username, course_key):
notification_msg
.
attach
(
msg_alternative
)
# render the credit notification templates
subject
=
_
(
u'Course Credit Eligibility'
)
if
providers
:
if
providers_string
:
subject
=
_
(
u'You are eligible for credit from {providers_string}'
)
.
format
(
providers_string
=
providers_string
)
...
...
@@ -259,3 +242,35 @@ def get_credit_provider_display_names(course_key):
cache
.
set
(
cache_key
,
provider_names
,
credit_config
.
cache_ttl
)
return
provider_names
def
make_providers_strings
(
providers
):
"""Get the list of course providers and make them comma seperated string.
Arguments:
providers : List containing the providers names
Returns:
strings containing providers names in readable way .
"""
if
not
providers
:
return
None
if
len
(
providers
)
==
1
:
providers_string
=
providers
[
0
]
elif
len
(
providers
)
==
2
:
# Translators: The join of two university names (e.g., Harvard and MIT).
providers_string
=
_
(
"{first_provider} and {second_provider}"
)
.
format
(
first_provider
=
providers
[
0
],
second_provider
=
providers
[
1
]
)
else
:
# Translators: The join of three or more university names. The first of these formatting strings
# represents a comma-separated list of names (e.g., MIT, Harvard, Dartmouth).
providers_string
=
_
(
"{first_providers}, and {last_provider}"
)
.
format
(
first_providers
=
u", "
.
join
(
providers
[:
-
1
]),
last_provider
=
providers
[
-
1
]
)
return
providers_string
openedx/core/djangoapps/credit/tests/test_api.py
View file @
05898df1
...
...
@@ -18,7 +18,7 @@ import mock
import
pytz
from
opaque_keys.edx.keys
import
CourseKey
from
openedx.core.djangoapps.credit
import
api
from
openedx.core.djangoapps.credit.email_utils
import
get_credit_provider_display_names
from
openedx.core.djangoapps.credit.email_utils
import
get_credit_provider_display_names
,
make_providers_strings
from
openedx.core.djangoapps.credit.exceptions
import
(
InvalidCreditRequirements
,
InvalidCreditCourse
,
...
...
@@ -1204,3 +1204,21 @@ class CourseApiTests(CreditApiTestBase):
self
.
_mock_ecommerce_courses_api
(
self
.
course_key
,
self
.
COURSE_API_RESPONSE
)
CreditProvider
.
objects
.
all
()
.
update
(
active
=
False
)
self
.
assertEqual
(
get_credit_provider_display_names
(
self
.
course_key
),
[])
@ddt.data
(
None
,
[
'asu'
],
[
'asu'
,
'co'
],
[
'asu'
,
'co'
,
'mit'
])
def
test_make_providers_strings
(
self
,
providers
):
""" Verify that method returns given provider list as comma separated string. """
provider_string
=
make_providers_strings
(
providers
)
if
not
providers
:
self
.
assertEqual
(
provider_string
,
None
)
elif
len
(
providers
)
==
1
:
self
.
assertEqual
(
provider_string
,
providers
[
0
])
elif
len
(
providers
)
==
2
:
self
.
assertEqual
(
provider_string
,
'asu and co'
)
else
:
self
.
assertEqual
(
provider_string
,
'asu, co, and mit'
)
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