Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Added connector setting in course #123

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 10 additions & 0 deletions common/lib/xmodule/xmodule/course_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,16 @@ class CourseFields(object):
default=False,
scope=Scope.settings
)
ccx_connector = String(
# Translators: Custom Courses for edX (CCX) is an edX feature for re-using course content.
display_name=_("CCX Connector URL"),
# Translators: Custom Courses for edX (CCX) is an edX feature for re-using course content.
help=_(
"URL for CCX Connector application for managing creation of CCXs. (optional)."
" Ignored unless 'CCX Enabled' is set to 'True'."
),
scope=Scope.settings
)
allow_anonymous = Boolean(
display_name=_("Allow Anonymous Discussion Posts"),
help=_("Enter true or false. If true, students can create discussion posts that are anonymous to all users."),
Expand Down
29 changes: 29 additions & 0 deletions lms/djangoapps/ccx/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import requests

from django.conf import settings

from lms.djangoapps.instructor.access import list_with_level

from lms.djangoapps.courseware.courses import get_course_info_section
from student.models import unique_id_for_user


def send_course_detail_to_ccx_connector(request, course):
if course.ccx_connector:
list_staff = list_with_level(course, 'staff')

course_detail = {
"title": course.display_name,
"author_name": None,
"edx_instance": settings.SITE_NAME,
"overview": get_course_info_section(request, course, "updates"),
"video_url": course.course_image,
"instructors": [unique_id_for_user(staff) for staff in list_staff]
}

response = requests.post(
course.ccx_connector,
data=course_detail
)

print "course_detail: ", course_detail, "response:", response.content
2 changes: 2 additions & 0 deletions lms/djangoapps/ccx/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
get_email_params,
)

from lms.djangoapps.ccx.api import send_course_detail_to_ccx_connector
from lms.djangoapps.ccx.models import CustomCourseForEdX
from lms.djangoapps.ccx.overrides import (
get_override_for_ccx,
Expand Down Expand Up @@ -208,6 +209,7 @@ def create_ccx(request, course, ccx=None):
email_params=email_params,
)

send_course_detail_to_ccx_connector(request, course)
return redirect(url)


Expand Down