jazkarta / edx-platform

the edX learning management system (LMS) and course authoring tool, Studio
http://code.edx.org/
GNU Affero General Public License v3.0
1 stars 0 forks source link

`CCXLocator cannot be deprecated` error #102

Closed pdpinch closed 9 years ago

pdpinch commented 9 years ago

I'm getting the following error when I try to create a new course (in studio) in our sandbox:

InvalidKeyError: <class 'ccx_keys.locator.CCXLocator'>: cannot be deprecated

This is a new course, in old mongo. I haven't done anything to add a CCX to it.

Full traceback:

Traceback (most recent call last):

 File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 109, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 20, in _wrapped_view
   return view_func(request, *args, **kwargs)

 File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
   response = view_func(request, *args, **kwargs)

 File "/edx/app/edxapp/edx-platform/common/djangoapps/student/views.py", line 656, in dashboard
   return render_to_response('dashboard.html', context)

 File "/edx/app/edxapp/edx-platform/common/djangoapps/edxmako/shortcuts.py", line 147, in render_to_response
   return HttpResponse(render_to_string(template_name, dictionary, context_instance, namespace), **kwargs)

 File "/edx/app/edxapp/edx-platform/common/djangoapps/edxmako/shortcuts.py", line 134, in render_to_string
   return template.render_unicode(**context_dictionary)

 File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/mako/template.py", line 452, in render_unicode
   as_unicode=True)

 File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/mako/runtime.py", line 807, in _render
   **_kwargs_for_callable(callable_, data))

 File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/mako/runtime.py", line 839, in _render_context
   _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)

 File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/mako/runtime.py", line 865, in _exec_template
   callable_(context, *args, **kwargs)

 File "/tmp/mako_lms/main.html.py", line 274, in render_body
   __M_writer(filters.decode.utf8(self.body()))

 File "/tmp/mako_lms/dashboard.html.py", line 232, in render_body
   runtime._include_file(context, u'ccx/_dashboard_ccx_listing.html', _template_uri, ccx=ccx, membership=membership, course=course, show_courseware_link=show_courseware_link, is_course_blocked=is_course_blocked)

 File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/mako/runtime.py", line 734, in _include_file
   callable_(ctx, **_kwargs_for_include(callable_, context._data, **kwargs))

 File "/tmp/mako_lms/ccx/_dashboard_ccx_listing.html.py", line 34, in render_body
   ccx_target = reverse('info', args=[CCXLocator.from_course_locator(course.id, ccx.id)])

 File "/edx/app/edxapp/venvs/edxapp/src/ccx-keys/ccx_keys/locator.py", line 70, in from_course_locator
   ccx=ccx,

 File "/edx/app/edxapp/venvs/edxapp/src/ccx-keys/ccx_keys/locator.py", line 56, in __init__
   raise InvalidKeyError(self.__class__, "cannot be deprecated")

InvalidKeyError: <class 'ccx_keys.locator.CCXLocator'>: cannot be deprecated
cewing commented 9 years ago

Hmmmmm. It looks like the ccx coach dashboard is showing up there (or at least being rendered). I did not realize that was a possibility. The dashboard code on line 34 is predicated on the course being a new-style course. I'll see what I can do to avoid the problem.

Thanks for the bug report @pdpinch.

cewing commented 9 years ago

Sorry, that's not the coach dashboard but rather the dashboard display of a CCX. @pdpinch, the one code path that leads to that template being rendered would indicate that there is a ccx in your database that has been created for a course which has an old-style key.

I believe that there is a way to have created a ccx for a course with an old-style key. And it would appear that having done so will leave you in this state, where the display of the dashboard will fail.

My plan is to attack this on two fronts:

  1. Prevent a ccx from ever being created for a course that has a deprecated id.
  2. Prevent the dashboard display of a ccx that was somehow created for a course with a deprecated id.
cewing commented 9 years ago

@pdpinch just pushed a fix for this with 268345d2a419a9115bb6e6187acb1ff836ef85f7

Please update and test. I don't have any ccx memberships created for courses with deprecated ids so I cannot duplicate this locally.

pdpinch commented 9 years ago

Thanks. @bdero can you grab this one to for the sandbox?

@cewing our sandbox is set up so that courses are created first in old mongo. We can then re-run into split. Are you testing with defaulting to split mongo?

cewing commented 9 years ago

No, I have a course that is in old-style format, and when I first started this work, I suspect I saw the same problem because I'd created memberships in a ccx before I had the split version. When such a membership exists, then the student dashboard will attempt to render the CCX in the dashboard. That doesn't work when the course is in the deprecated format because attempting to make a URL for the link to the course cannot work with the CCXLocator as written.

What I've done here is to filter out of the list of memberships any membership that is connected to a course in the deprecated format. This will just prevent the dashboard from attempting to render that CCX for view. At the same time, I'm logging warnings that say that memberships exist for a CCX that is connected to a deprecated format course so that cleanup of the database could be feasible.

I've also put code into the coach dashboard that should prevent a CCX from ever being created for a deprecated course. That was technically feasible before, and so somehow one may have snuck through the cracks.

pdpinch commented 9 years ago

Ok. This is really just because we have a legacy data.

But it is worth fixing, because edge.edx.org will have the same situation.

On Jun 9, 2015, at 4:06 PM, Cris Ewing notifications@github.com wrote:

No, I have a course that is in old-style format, and when I first started this work, I suspect I saw the same problem because I'd created memberships in a ccx before I had the split version. When such a membership exists, then the student dashboard will attempt to render the CCX in the dashboard. That doesn't work when the course is in the deprecated format because attempting to make a URL for the link to the course cannot work with the CCXLocator as written.

What I've done here is to filter out of the list of memberships any membership that is connected to a course in the deprecated format. This will just prevent the dashboard from attempting to render that CCX for view. At the same time, I'm logging warnings that say that memberships exist for a CCX that is connected to a deprecated format course so that cleanup of the database could be feasible.

I've also put code into the coach dashboard that should prevent a CCX from ever being created for a deprecated course. That was technically feasible before, and so somehow one may have snuck through the cracks.

— Reply to this email directly or view it on GitHub.

cewing commented 9 years ago

yes, absolutely. I think these fixes will prevent legacy data from becoming a problem, but need verification from you because I have no legacy data on which to test.

pwilkins commented 9 years ago

@cewing I have lots of legacy data in my devstack and I continue to encounter errors using 268345d.

pwilkins commented 9 years ago

Here's a gist of the console output: https://gist.github.com/pwilkins/c03a5307c315ed536b46

cewing commented 9 years ago

hmmm. It would appear that we cannot update the usage_id attribute of xblock.scope_ids.

@pwilkins, can you give me exact steps to reproduce this error? I do have the one edx demo course in my local dev instance that is in the old mongo store. It would help immensely if I could see these errors first-hand.

pwilkins commented 9 years ago

@cewing I can try. I have a instructor that has been involved with CCX courses from the start. What I have done is log in as that instructor and attempt to open (in Studio) an edx demo course that is also old. That what generates the console output I shared.
Does that help, or do you need more information?

cewing commented 9 years ago

Let me just be sure I understand completely here. You are logged in as an instructor for an edx demo course that is old, and simply attempting to view that course is raising these errors? I will try that here and see if I can duplicate.

pwilkins commented 9 years ago

note that the course appears to be in the split format, though I didn't explicitly make that conversion.

cewing commented 9 years ago

I have been unable to reproduce this error locally. Any news from your end on it?

pdpinch commented 9 years ago

I can't reproduce this any more, so I'm closing this.

pdpinch commented 9 years ago

Well, @pwilkins was able to reproduce it, but it was in a disallowed case. This is the error you get if you try to access a CCX attached to an old mongo course, which isn't currently supported.