Commit 3fbdebcd by aamir-khan

ECOM-3107: Updated the progress page to not display the eligibility if user is…

ECOM-3107: Updated the progress page to not display the eligibility if user is not enrolled as credit mode
parent 5df15fcf
......@@ -4,6 +4,7 @@ Tests for credit requirement display on the progress page.
import datetime
import ddt
from mock import patch
from pytz import UTC
......@@ -15,11 +16,13 @@ from xmodule.modulestore.tests.factories import CourseFactory
from student.tests.factories import UserFactory, CourseEnrollmentFactory
from util.date_utils import get_time_display, DEFAULT_SHORT_DATE_FORMAT
from course_modes.models import CourseMode
from openedx.core.djangoapps.credit import api as credit_api
from openedx.core.djangoapps.credit.models import CreditCourse
@patch.dict(settings.FEATURES, {"ENABLE_CREDIT_ELIGIBILITY": True})
@ddt.ddt
class ProgressPageCreditRequirementsTest(ModuleStoreTestCase):
"""
Tests for credit requirement display on the progress page.
......@@ -133,6 +136,28 @@ class ProgressPageCreditRequirementsTest(ModuleStoreTestCase):
)
self.assertContains(response, "Verification Failed")
@ddt.data(
(CourseMode.VERIFIED, True),
(CourseMode.CREDIT_MODE, True),
(CourseMode.HONOR, False),
(CourseMode.AUDIT, False),
(CourseMode.PROFESSIONAL, False),
(CourseMode.NO_ID_PROFESSIONAL_MODE, False)
)
@ddt.unpack
def test_credit_requirements_on_progress_page(self, enrollment_mode, is_requirement_displayed):
"""Test the progress table is only displayed to the verified and credit students."""
self.enrollment.mode = enrollment_mode
self.enrollment.save() # pylint: disable=no-member
response = self._get_progress_page()
# Verify the requirements are shown only if the user is in a credit-eligible mode.
classes = ('credit-eligibility', 'eligibility-heading')
method = self.assertContains if is_requirement_displayed else self.assertNotContains
for _class in classes:
method(response, _class)
def _get_progress_page(self):
"""Load the progress page for the course the user is enrolled in. """
url = reverse("progress", kwargs={"course_id": unicode(self.course.id)})
......
......@@ -107,6 +107,9 @@ log = logging.getLogger("edx.courseware")
template_imports = {'urllib': urllib}
CONTENT_DEPTH = 2
# Only display the requirements on learner dashboard for
# credit and verified modes.
REQUIREMENTS_DISPLAY_MODES = CourseMode.CREDIT_MODES + [CourseMode.VERIFIED]
def user_groups(user):
......@@ -1019,7 +1022,8 @@ def _credit_course_requirements(course_key, student):
course_key (CourseKey): Identifier for the course.
student (User): Currently logged in user.
Returns: dict
Returns: dict if the credit eligibility enabled and it is a credit course
and the user is enrolled in either verified or credit mode, and None otherwise.
"""
# If credit eligibility is not enabled or this is not a credit course,
......@@ -1028,6 +1032,13 @@ def _credit_course_requirements(course_key, student):
if not (settings.FEATURES.get("ENABLE_CREDIT_ELIGIBILITY", False) and is_credit_course(course_key)):
return None
# If student is enrolled not enrolled in verified or credit mode,
# short-circuit and return None. This indicates that
# credit requirements should NOT be displayed on the progress page.
enrollment = CourseEnrollment.get_enrollment(student, course_key)
if enrollment.mode not in REQUIREMENTS_DISPLAY_MODES:
return None
# Credit requirement statuses for which user does not remain eligible to get credit.
non_eligible_statuses = ['failed', 'declined']
......
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