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.8.tar.gz"
- "pip uninstall -y xblock-problem-builder && python setup.py sdist && pip install dist/xblock-problem-builder-2.6.9.tar.gz"
- "pip install -r test_requirements.txt"
- "mkdir var"
test:
Expand Down
16 changes: 9 additions & 7 deletions problem_builder/management/commands/copy_deprecated_course_id.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import math
import time
from django.core.management.base import BaseCommand
from problem_builder.models import Answer
Expand Down Expand Up @@ -29,18 +28,21 @@ def handle(self, *args, **options):
batch_size = options['batch_size']
sleep_time = options['sleep']
queryset = Answer.objects.filter(course_key__isnull=True)
batch_count = int(math.ceil(queryset.count() / float(batch_size)))

self.stdout.write(
"Copying Answer.course_id field into Answer.course_key in batches of {}".format(batch_size)
)

for batch in xrange(1, batch_count + 1):
for answer in queryset[:batch_size]:
idx = 0
while True:
idx += 1
batch = queryset[:batch_size]
if not batch:
break
for answer in batch:
answer.course_key = answer.course_id
answer.save()
self.stdout.write("Processed batch {} of {}".format(batch, batch_count))
if batch != batch_count:
time.sleep(sleep_time)
self.stdout.write("Processed batch {}".format(idx))
time.sleep(sleep_time)

self.stdout.write("Successfully copied Answer.course_id into Answer.course_key")
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.8',
version='2.6.9',
description='XBlock - Problem Builder',
packages=['problem_builder', 'problem_builder.v1'],
install_requires=[
Expand Down