Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
- "pip install -r requirements.txt"
- "pip install -r $VIRTUAL_ENV/src/xblock-sdk/requirements/base.txt"
- "pip install -r $VIRTUAL_ENV/src/xblock-sdk/requirements/test.txt"
- "pip uninstall -y xblock-problem-builder && python setup.py sdist && pip install dist/xblock-problem-builder-2.6.4.tar.gz"
- "pip uninstall -y xblock-problem-builder && python setup.py sdist && pip install dist/xblock-problem-builder-2.6.5.tar.gz"
- "pip install -r test_requirements.txt"
- "mkdir var"
test:
Expand Down
16 changes: 6 additions & 10 deletions problem_builder/answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from django.core.exceptions import ValidationError
from django.db import IntegrityError
from django.db.models import Q
from django.utils.crypto import get_random_string

from .models import Answer
Expand Down Expand Up @@ -70,16 +71,11 @@ def _get_student_id(self):

@staticmethod
def _fetch_model_object(name, student_id, course_id):
sql_query = '''SELECT * FROM problem_builder_answer
WHERE name = %s
AND student_id = %s
AND (course_key = %s
OR course_id = %s)'''
params = [name, student_id, course_id, course_id]
try:
answer = Answer.objects.raw(sql_query, params)[0]
except IndexError:
raise Answer.DoesNotExist()
answer = Answer.objects.get(
Q(name=name),
Q(student_id=student_id),
Q(course_key=course_id) | Q(course_id=course_id)
)
if not answer.course_key:
answer.course_key = answer.course_id

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT this change won't be saved on the model. Is that intentional?

@mtyaka mtyaka Dec 7, 2016

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maxrothman Yes, that's intentional to avoid a DB write. The course_key attribute is set here so that we can assume it's present in other parts of the code, but it does not have to be persisted.

Value of course_id will be copied and persisted to course_key in a data migration. The migration will be faked by edX and performed in batches instead.

I was thinking of doing that migration in a separate release, but I could also add it to this PR if that doesn't complicate things from edX devops perspective. What works better for you?

Edit: In order to get this out ASAP, we will add the migration in a separate release.

return answer
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def package_data(pkg, root_list):

setup(
name='xblock-problem-builder',
version='2.6.4',
version='2.6.5',
description='XBlock - Problem Builder',
packages=['problem_builder', 'problem_builder.v1'],
install_requires=[
Expand Down