From b3462d1c67e0cb297f8c6c2b89c4db3eeb4a7aa2 Mon Sep 17 00:00:00 2001 From: Sarina Canelake Date: Fri, 16 May 2014 09:39:53 -0400 Subject: [PATCH] Fix issues with psychometrics and git import --- lms/djangoapps/courseware/module_render.py | 2 +- lms/djangoapps/dashboard/git_import.py | 7 ++++++- lms/djangoapps/psychometrics/psychoanalyze.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 51b4bb7de8..b68618b70a 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -503,7 +503,7 @@ def get_module_system_for_user(user, field_data_cache, if settings.FEATURES.get('ENABLE_PSYCHOMETRICS'): system.set( 'psychometrics_handler', # set callback for updating PsychometricsData - make_psychometrics_data_update_handler(course_id, user, descriptor.location.to_deprecated_string()) + make_psychometrics_data_update_handler(course_id, user, descriptor.location) ) system.set(u'user_is_staff', has_access(user, u'staff', descriptor.location, course_id)) diff --git a/lms/djangoapps/dashboard/git_import.py b/lms/djangoapps/dashboard/git_import.py index 29614c222c..9b92cdba40 100644 --- a/lms/djangoapps/dashboard/git_import.py +++ b/lms/djangoapps/dashboard/git_import.py @@ -17,7 +17,9 @@ from django.utils.translation import ugettext as _ import mongoengine from dashboard.models import CourseImportLog +from opaque_keys import InvalidKeyError from xmodule.modulestore.keys import CourseKey +from xmodule.modulestore.locations import SlashSeparatedCourseKey log = logging.getLogger(__name__) @@ -230,7 +232,10 @@ def add_repo(repo, rdir_in, branch=None): match = re.search(r'(?ms)===> IMPORTING course (\S+)', ret_import) if match: course_id = match.group(1) - course_key = CourseKey.from_string(course_id) + try: + course_key = CourseKey.from_string(course_id) + except InvalidKeyError: + course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) cdir = '{0}/{1}'.format(GIT_REPO_DIR, course_key.course) log.debug('Studio course dir = {0}'.format(cdir)) diff --git a/lms/djangoapps/psychometrics/psychoanalyze.py b/lms/djangoapps/psychometrics/psychoanalyze.py index a315a8b89b..68fb625801 100644 --- a/lms/djangoapps/psychometrics/psychoanalyze.py +++ b/lms/djangoapps/psychometrics/psychoanalyze.py @@ -307,7 +307,7 @@ def make_psychometrics_data_update_handler(course_id, user, module_state_key): the PsychometricData instance for the given StudentModule instance. """ sm, status = StudentModule.objects.get_or_create( - course_id=course_id.to_deprecated_string(), + course_id=course_id, student=user, module_state_key=module_state_key, defaults={'state': '{}', 'module_type': 'problem'},