Commit e8dfac09 by christopher lee

MA-77 Auto VAL clone course

MA-77 Automatically adds the course id to the videos in VAL
when a course is rerun.
parent 3b150da1
......@@ -14,6 +14,8 @@ from course_action_state.models import CourseRerunState
from contentstore.utils import initialize_permissions
from opaque_keys.edx.keys import CourseKey
from edxval.api import copy_course_videos
@task()
def rerun_course(source_course_key_string, destination_course_key_string, user_id, fields=None):
......@@ -37,6 +39,10 @@ def rerun_course(source_course_key_string, destination_course_key_string, user_i
# update state: Succeeded
CourseRerunState.objects.succeeded(course_key=destination_course_key)
# call edxval to attach videos to the rerun
copy_course_videos(source_course_key, destination_course_key)
return "succeeded"
except DuplicateCourseError as exc:
......
......@@ -24,6 +24,8 @@ from openedx.core.lib.tempdir import mkdtemp_clean
from contentstore.tests.utils import parse_json, AjaxEnabledTestClient, CourseTestCase
from contentstore.views.component import ADVANCED_COMPONENT_TYPES
from edxval.api import create_video, get_videos_for_course
from xmodule.contentstore.django import contentstore
from xmodule.contentstore.utils import restore_asset_from_trashcan, empty_asset_trashcan
from xmodule.exceptions import InvalidVersionError
......@@ -1694,11 +1696,37 @@ class RerunCourseTest(ContentStoreTestCase):
self.assertInCourseListing(source_course_key)
self.assertInCourseListing(destination_course_key)
def test_rerun_course_no_videos_in_val(self):
"""
Test when rerunning a course with no videos, VAL copies nothing
"""
source_course = CourseFactory.create()
destination_course_key = self.post_rerun_request(source_course.id)
self.verify_rerun_course(source_course.id, destination_course_key, self.destination_course_data['display_name'])
videos = list(get_videos_for_course(destination_course_key))
self.assertEqual(0, len(videos))
self.assertInCourseListing(destination_course_key)
def test_rerun_course_success(self):
source_course = CourseFactory.create()
create_video(
dict(
edx_video_id="tree-hugger",
courses=[source_course.id],
status='test',
duration=2,
encoded_videos=[]
)
)
destination_course_key = self.post_rerun_request(source_course.id)
self.verify_rerun_course(source_course.id, destination_course_key, self.destination_course_data['display_name'])
# Verify that the VAL copies videos to the rerun
source_videos = list(get_videos_for_course(source_course.id))
target_videos = list(get_videos_for_course(destination_course_key))
self.assertEqual(1, len(source_videos))
self.assertEqual(source_videos, target_videos)
def test_rerun_of_rerun(self):
source_course = CourseFactory.create()
rerun_course_key = self.post_rerun_request(source_course.id)
......
......@@ -315,6 +315,7 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase):
self.assertEqual(val_info["client_video_id"], file_info["file_name"])
self.assertEqual(val_info["status"], "upload")
self.assertEqual(val_info["duration"], 0)
self.assertEqual(val_info["courses"], [unicode(self.course.id)])
# Ensure response is correct
response_file = response_obj["files"][i]
......
......@@ -341,6 +341,7 @@ def videos_post(course, request):
"client_video_id": file_name,
"duration": 0,
"encoded_videos": [],
"courses": [course.id]
})
resp_files.append({"file_name": file_name, "upload_url": upload_url})
......
......@@ -182,10 +182,6 @@ def video_summary(video_profiles, course_id, video_descriptor, request, local_ca
ret.update(always_available_data)
return ret
# First try to check VAL for the URLs we want.
val_video_info = local_cache['course_videos'].get(video_descriptor.edx_video_id, {})
if val_video_info:
video_url = val_video_info['url']
# Get encoded videos
video_data = local_cache['course_videos'].get(video_descriptor.edx_video_id, {})
......@@ -233,8 +229,6 @@ def video_summary(video_profiles, course_id, video_descriptor, request, local_ca
"size": size,
"transcripts": transcripts,
"language": video_descriptor.get_default_transcript_language(),
"category": video_descriptor.category,
"id": unicode(video_descriptor.scope_ids.usage_id),
"encoded_videos": video_data.get('profiles')
}
ret.update(always_available_data)
......
......@@ -429,7 +429,6 @@ class TestVideoSummaryList(
"""
REVERSE_INFO = {'name': 'video-summary-list', 'params': ['course_id']}
def test_only_on_web(self):
self.login_and_enroll()
......@@ -514,6 +513,7 @@ class TestVideoSummaryList(
'transcripts': {
'en': 'http://testserver/api/mobile/v0.5/video_outlines/transcripts/{}/testing_mobile_high_video/en'.format(self.course.id) # pylint: disable=line-too-long
},
'only_on_web': False,
'encoded_videos': {
u'mobile_high': {
'url': self.video_url_high,
......
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