|
29 | 29 |
|
30 | 30 | # pylint: disable=unused-import |
31 | 31 |
|
| 32 | +# TODO: It might make sense to handle imports separately. This part just |
| 33 | +# separates the `StudentModule` import from others to avoid conflicting |
| 34 | +# with `studentmodule` models in Juniper. Without this, a `RuntimeError` |
| 35 | +# is raised, as it causes other modules to be imported with a full import |
| 36 | +# path, which is not supported in Juniper. |
| 37 | +try: |
| 38 | + from courseware.models import StudentModule |
| 39 | +except Exception: |
| 40 | + try: |
| 41 | + from lms.djangoapps.courseware.models import StudentModule |
| 42 | + except ImportError: |
| 43 | + # If we are not running within edx-platform |
| 44 | + # (e.g., we are running problem-builder unit tests). |
| 45 | + StudentModule = None |
| 46 | + |
32 | 47 | try: |
33 | 48 | # Koa and earlier: use shortened import path. |
34 | 49 | # This will raise a warning in Koa, but that's OK. |
35 | | - from courseware.models import StudentModule |
36 | 50 | from static_replace import replace_static_urls |
37 | 51 | from student.models import AnonymousUserId |
38 | 52 | from xblock_django.models import XBlockConfiguration |
|
42 | 56 | # of the former, and only exists on edx-platform master between Koa and Lilac). |
43 | 57 | try: |
44 | 58 | # Post-Koa: we must use the full import path. |
45 | | - from lms.djangoapps.courseware.models import StudentModule |
46 | 59 | from common.djangoapps.static_replace import replace_static_urls |
47 | 60 | from common.djangoapps.student.models import AnonymousUserId |
48 | 61 | from common.djangoapps.xblock_django.models import XBlockConfiguration |
49 | 62 | except ImportError: |
50 | 63 | # If we get here, we are not running within edx-platform |
51 | 64 | # (e.g., we are running problem-builder unit tests). |
52 | | - StudentModule = None |
53 | 65 | replace_static_urls = None |
54 | 66 | AnonymousUserId = None |
55 | 67 | XBlockConfiguration = None |
0 commit comments