1

Problem Statement :

I want to develop a custom "XBlock" for edx-platform which allows the course creator to upload images, associate a text description with each image which will show up as a Slider on course content.

I have a basic slider working with some static images, however I am having some issues while uploading the images using the Xblock.Basically I think there are two ways to achieve this functionality.

  1. Using edx's default APIs to upload the image asset and then retrieving its relative path in my xblock content. However, I am not sure how I should go about this.. Sending request on below url from cms's url.py:

    url(r'^assets/{}/{}?$'.format(settings.COURSE_KEY_PATTERN, settings.ASSET_KEY_PATTERN), 'assets_handler'),

  2. From some other sources on the internet, I figured that may be I should create a custom upload handler for my xblock which would upload the files to server.

I did try create a handler using method : 2, but I ran into the following error as soon as I upload my image using Ajax multipart/form-data.

Traceback (most recent call last):

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

File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py", line 145, in inner
return func(*args, **kwargs)

File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py", line 145, in inner
return func(*args, **kwargs)

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

File "/edx/app/edxapp/edx-platform/cms/djangoapps/contentstore/views/component.py", line 359, in component_handler
return webob_to_django_response(resp)

File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/xblock/django/request.py", line 14, in webob_to_django_response
webob_response.app_iter,

AttributeError: 'dict' object has no attribute 'app_iter'

Any hints regarding how I should approach this problem would greatly help. Thanks in advance.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Jay Modi
  • 3,161
  • 4
  • 35
  • 52

0 Answers0