Commit 5a1489b5 by Bogdan Licar

Look up the source block by UsageKey rather than a selector, as now the backend…

Look up the source block by UsageKey rather than a selector, as now the backend receives the full block ID
parent 63386133
...@@ -6,7 +6,8 @@ import time ...@@ -6,7 +6,8 @@ import time
from celery.task import task from celery.task import task
from celery.utils.log import get_task_logger from celery.utils.log import get_task_logger
from lms.djangoapps.instructor_task.models import ReportStore from lms.djangoapps.instructor_task.models import ReportStore
from opaque_keys.edx.keys import CourseKey from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey, UsageKey
from student.models import user_by_anonymous_id from student.models import user_by_anonymous_id
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.exceptions import ItemNotFoundError
...@@ -29,11 +30,12 @@ def export_data(course_id, source_block_id_str, block_types, user_ids, match_str ...@@ -29,11 +30,12 @@ def export_data(course_id, source_block_id_str, block_types, user_ids, match_str
logger.debug("Beginning data export") logger.debug("Beginning data export")
try: try:
course_key = CourseKey.from_string(course_id) course_key = CourseKey.from_string(course_id)
src_block = modulestore().get_items(course_key, qualifiers={'name': source_block_id_str}, depth=0)[0] usage_key = UsageKey.from_string(source_block_id_str)
except IndexError: except InvalidKeyError:
raise ValueError("Could not find the specified Block ID.") raise ValueError("Could not find the specified Block ID.")
course_key_str = unicode(course_key)
src_block = modulestore().get_item(usage_key)
course_key_str = unicode(course_key)
type_map = {cls.__name__: cls for cls in [MCQBlock, RatingBlock, AnswerBlock]} type_map = {cls.__name__: cls for cls in [MCQBlock, RatingBlock, AnswerBlock]}
if not block_types: if not block_types:
......
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