Commit 1e7dd064 by Waheed Ahmed

Merge pull request #7422 from edx/waheed/tnl1736-fix-beta-tester-functionality-for-ora

Fixed beta tester functionality for ora problems.
parents badbc3e3 d9b685d5
...@@ -41,6 +41,7 @@ from edxmako.shortcuts import render_to_string ...@@ -41,6 +41,7 @@ from edxmako.shortcuts import render_to_string
from eventtracking import tracker from eventtracking import tracker
from psychometrics.psychoanalyze import make_psychometrics_data_update_handler from psychometrics.psychoanalyze import make_psychometrics_data_update_handler
from student.models import anonymous_id_for_user, user_by_anonymous_id from student.models import anonymous_id_for_user, user_by_anonymous_id
from student.roles import CourseBetaTesterRole
from xblock.core import XBlock from xblock.core import XBlock
from xblock.fields import Scope from xblock.fields import Scope
from xblock.runtime import KvsFieldData, KeyValueStore from xblock.runtime import KvsFieldData, KeyValueStore
...@@ -642,6 +643,8 @@ def get_module_system_for_user(user, field_data_cache, ...@@ -642,6 +643,8 @@ def get_module_system_for_user(user, field_data_cache,
system.set(u'user_is_staff', user_is_staff) system.set(u'user_is_staff', user_is_staff)
system.set(u'user_is_admin', has_access(user, u'staff', 'global')) system.set(u'user_is_admin', has_access(user, u'staff', 'global'))
system.set(u'user_is_beta_tester', CourseBetaTesterRole(course_id).has_user(user))
system.set(u'days_early_for_beta', getattr(descriptor, 'days_early_for_beta'))
# make an ErrorDescriptor -- assuming that the descriptor's system is ok # make an ErrorDescriptor -- assuming that the descriptor's system is ok
if has_access(user, u'staff', descriptor.location, course_id): if has_access(user, u'staff', descriptor.location, course_id):
......
...@@ -997,6 +997,7 @@ class TestAnonymousStudentId(ModuleStoreTestCase, LoginEnrollmentTestCase): ...@@ -997,6 +997,7 @@ class TestAnonymousStudentId(ModuleStoreTestCase, LoginEnrollmentTestCase):
_field_data_cache={}, _field_data_cache={},
_dirty_fields={}, _dirty_fields={},
fields={}, fields={},
days_early_for_beta=None,
) )
descriptor.runtime = CombinedSystem(descriptor._runtime, None) # pylint: disable=protected-access descriptor.runtime = CombinedSystem(descriptor._runtime, None) # pylint: disable=protected-access
# Use the xblock_class's bind_for_student method # Use the xblock_class's bind_for_student method
...@@ -1308,6 +1309,25 @@ class LMSXBlockServiceBindingTest(ModuleStoreTestCase): ...@@ -1308,6 +1309,25 @@ class LMSXBlockServiceBindingTest(ModuleStoreTestCase):
service = runtime.service(descriptor, expected_service) service = runtime.service(descriptor, expected_service)
self.assertIsNotNone(service) self.assertIsNotNone(service)
def test_beta_tester_fields_added(self):
"""
Tests that the beta tester fields are set on LMS runtime.
"""
descriptor = ItemFactory(category="pure", parent=self.course)
descriptor.days_early_for_beta = 5
runtime, _ = render.get_module_system_for_user(
self.user,
self.field_data_cache,
descriptor,
self.course.id,
self.track_function,
self.xqueue_callback_url_prefix,
self.request_token
)
self.assertFalse(getattr(runtime, u'user_is_beta_tester'))
self.assertEqual(getattr(runtime, u'days_early_for_beta'), 5)
class PureXBlockWithChildren(PureXBlock): class PureXBlockWithChildren(PureXBlock):
""" """
......
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