def get_master_survey(self): org, number, run = COURSE_ID.split('/') course_key = SlashSeparatedCourseKey(org, number, run) course = get_course_by_id(course_key) section = None for each in course.get_children(): if each.display_name == 'Survey': section = each break return section
def get_master_course(user=None, command=None): from contentstore.utils import add_instructor, initialize_permissions from courseware.courses import get_course_by_id from opaque_keys.edx.locations import SlashSeparatedCourseKey from student.roles import CourseRole from xmodule.modulestore.exceptions import InvalidLocationError if not user: user = User.objects.get(id=ADMIN_USER_ID) display_name = "LabsterX Master" org, number, run = COURSE_ID.split('/') try: course_key = SlashSeparatedCourseKey(org, number, run) fields = {'display_name': display_name} wiki_slug = u"{0}.{1}.{2}".format(course_key.org, course_key.course, course_key.run) definition_data = {'wiki_slug': wiki_slug} fields.update(definition_data) if CourseRole.course_group_already_exists(course_key): raise InvalidLocationError() course = get_modulestore().create_course( course_key.org, course_key.course, course_key.run, user.id, fields=fields, ) # Make sure user has instructor and staff access to the new course add_instructor(course.id, user, user) # Initialize permissions for user in the new course initialize_permissions(course.id, user) command and command.stdout.write("name: {}\n".format(course.display_name)) except InvalidLocationError: course = get_course_by_id(course_key) return course
def get_master_data(self): data = {} org, number, run = COURSE_ID.split('/') course_key = SlashSeparatedCourseKey(org, number, run) course = get_course_by_id(course_key) for section in course.get_children(): if section.display_name != 'Labs': continue for sub_section in section.get_children(): unit_data = {} for unit in sub_section.get_children(): problem_data = {} for problem in unit.get_children(): problem_data[problem.display_name] = problem unit_data[unit.display_name] = problem_data data[sub_section.display_name] = unit_data return data