lms.djangoapps.ccx package#
Subpackages#
Submodules#
lms.djangoapps.ccx.apps module#
LMS CCX application configuration Signal handlers are connected here.
lms.djangoapps.ccx.custom_exception module#
This file has custom exceptions for ccx
- exception lms.djangoapps.ccx.custom_exception.CCXLocatorValidationException#
Bases:
ExceptionCustom Exception to validate CCX locator
- exception lms.djangoapps.ccx.custom_exception.CCXUserValidationException#
Bases:
ExceptionCustom Exception for validation of users in CCX
lms.djangoapps.ccx.models module#
Models for the custom course feature
- class lms.djangoapps.ccx.models.CcxFieldOverride(*args, **kwargs)#
Bases:
ModelField overrides for custom courses.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- ccx#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- ccx_id#
- field#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- location#
DO NOT REUSE THIS CLASS. Provided for backwards compatibility only!
A placeholder class that provides a way to set the attribute on the model.
- objects = <django.db.models.manager.Manager object>#
- value#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class lms.djangoapps.ccx.models.CustomCourseForEdX(*args, **kwargs)#
Bases:
ModelA Custom Course.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- ccxfieldoverride_set#
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- coach#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- coach_id#
- course()#
Return the CourseBlock of the course related to this CCX
- course_id#
DO NOT REUSE THIS CLASS. Provided for backwards compatibility only!
A placeholder class that provides a way to set the attribute on the model.
- display_name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- due()#
Get the value of the override of the ‘due’ datetime for this CCX
- has_ended()#
Return True if the CCX due date is set and is in the past
- has_started()#
Return True if the CCX start date is in the past
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property locator#
Helper property that gets a corresponding CCXLocator for this CCX.
- Returns:
The CCXLocator corresponding to this CCX.
- max_student_enrollments_allowed()#
Get the value of the override of the ‘max_student_enrollments_allowed’ datetime for this CCX
- objects = <django.db.models.manager.Manager object>#
- start()#
Get the value of the override of the ‘start’ datetime for this CCX
- property structure#
Deserializes a course structure JSON object
- structure_json#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
lms.djangoapps.ccx.modulestore module#
A modulestore wrapper
It will ‘unwrap’ ccx keys on the way in and re-wrap them on the way out
In practical terms this means that when an object is retrieved from modulestore using a CCXLocator or CCXBlockUsageLocator as the key, the equivalent CourseLocator or BlockUsageLocator will actually be used. And all objects returned from the modulestore will have their keys updated to be the CCX version that was passed in.
- class lms.djangoapps.ccx.modulestore.CCXModulestoreWrapper(modulestore)#
Bases:
objectThis class wraps a modulestore
The purpose is to remove ccx-specific identifiers during lookup and restore it after retrieval so that data can be stored local to a course, but referenced in app context as ccx-specific
- branch_setting(branch_setting, course_id=None)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- bulk_operations(course_id, emit_signals=True, ignore_case=False)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- check_supports(course_key, method)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- clone_course(source_course_id, dest_course_id, user_id, fields=None, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- convert_to_draft(location, user_id)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- copy_from_template(source_keys, dest_key, user_id, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- create_child(user_id, parent_usage_key, block_type, block_id=None, fields=None, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- create_item(user_id, course_key, block_type, block_id=None, fields=None, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- create_xblock(runtime, course_key, block_type, block_id=None, fields=None, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- delete_course(course_key, user_id)#
See xmodule.modulestore.__init__.ModuleStoreWrite.delete_course
- delete_item(location, user_id, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- fill_in_run(course_key)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- get_block_original_usage(usage_key)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- get_course(course_key, depth=0, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- get_item(usage_key, depth=0, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- get_items(course_key, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- get_modulestore_type(course_id)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- get_orphans(course_key, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- get_parent_location(location, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- has_changes(xblock)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- has_course(course_id, ignore_case=False, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- has_item(usage_key, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- has_published_version(xblock)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- import_xblock(user_id, course_key, block_type, block_id, fields=None, runtime=None, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- publish(location, user_id, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- revert_to_published(location, user_id)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- unpublish(location, user_id, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- update_item(xblock, user_id, allow_not_found=False, **kwargs)#
See the docs for xmodule.modulestore.mixed.MixedModuleStore
- lms.djangoapps.ccx.modulestore.remove_ccx(to_strip)#
A context manager for wrapping modulestore api methods.
yields a stripped value and a function suitable for restoring it
- lms.djangoapps.ccx.modulestore.restore_ccx(val, ccx_id)#
restore references to a CCX to the incoming value
returns the value converted to a CCX-aware state, using the provided ccx_id
- lms.djangoapps.ccx.modulestore.restore_ccx_collection(field_value, ccx_id=None)#
restore references to a CCX to collections of incoming values
returns the original collection with all values converted to a ccx-aware state, using the provided ccx_id
- lms.djangoapps.ccx.modulestore.strip_ccx(val)#
remove any reference to a CCX from the incoming value
return a tuple of the stripped value and the id of the ccx
lms.djangoapps.ccx.overrides module#
API related to providing field overrides for individual students. This is used by the individual custom courses feature.
- class lms.djangoapps.ccx.overrides.CustomCoursesForEdxOverrideProvider(user, fallback_field_data)#
Bases:
FieldOverrideProviderA concrete implementation of
FieldOverrideProviderwhich allows for overrides to be made on a per user basis.- classmethod enabled_for(block)#
CCX field overrides are enabled for CCX blocks.
- get(block, name, default)#
Just call the get_override_for_ccx method if there is a ccx
- lms.djangoapps.ccx.overrides.bulk_delete_ccx_override_fields(ccx, ids)#
Bulk delete for CcxFieldOverride model
- lms.djangoapps.ccx.overrides.clear_ccx_field_info_from_ccx_map(ccx, block, name)#
Remove field information from ccx overrides mapping dictionary
- lms.djangoapps.ccx.overrides.clear_override_for_ccx(ccx, block, name)#
Clears a previously set field override for the ccx. block and name specify the block and the name of the field on that block to clear. This function is idempotent–if no override is set, nothing action is performed.
- lms.djangoapps.ccx.overrides.get_current_ccx(course_key)#
Return the ccx that is active for this course.
course_key is expected to be an instance of an opaque CourseKey, a ValueError is raised if this expectation is not met.
- lms.djangoapps.ccx.overrides.get_override_for_ccx(ccx, block, name, default=None)#
Gets the value of the overridden field for the ccx. block and name specify the block and the name of the field. If the field is not overridden for the given ccx, returns default.
- lms.djangoapps.ccx.overrides.override_field_for_ccx(ccx, block, name, value)#
Overrides a field for the ccx. block and name specify the block and the name of the field on that block to override. value is the value to set for the given field.
lms.djangoapps.ccx.permissions module#
Permission definitions for the ccx djangoapp
lms.djangoapps.ccx.plugins module#
Registers the CCX feature for the edX platform.
- class lms.djangoapps.ccx.plugins.CcxCourseTab(tab_dict)#
Bases:
CourseTabThe representation of the CCX course tab
- is_dynamic = True#
- classmethod is_enabled(course, user=None)#
Returns true if CCX has been enabled and the specified user is a coach
- priority = 310#
- title = 'CCX Coach'#
- type = 'ccx_coach'#
- view_name = 'ccx_coach_dashboard'#
lms.djangoapps.ccx.tasks module#
Asynchronous tasks for the CCX app.
- lms.djangoapps.ccx.tasks.course_published_handler(sender, course_key, **kwargs)#
Consume signals that indicate course published. If course already a CCX, do nothing.
lms.djangoapps.ccx.urls module#
URLs for the CCX Feature.
lms.djangoapps.ccx.utils module#
CCX Enrollment operations for use by Coach APIs.
Does not include any access control, be sure to check access before calling.
- lms.djangoapps.ccx.utils.add_master_course_staff_to_ccx(master_course, ccx_key, display_name, send_email=True)#
Add staff and instructor roles on ccx to all the staff and instructors members of master course.
- Parameters:
master_course (CourseBlockWithMixins) – Master course instance.
ccx_key (CCXLocator) – CCX course key.
display_name (str) – ccx display name for email.
send_email (bool) – flag to switch on or off email to the users on access grant.
- lms.djangoapps.ccx.utils.assign_staff_role_to_ccx(ccx_locator, user, master_course_id)#
Check if user has ccx_coach role on master course then assign them staff role on ccx only if role is not already assigned. Because of this coach can open dashboard from master course as well as ccx. :param ccx_locator: CCX key :param user: User to whom we want to assign role. :param master_course_id: Master course key
- lms.djangoapps.ccx.utils.ccx_course(ccx_locator)#
Create a context in which the course identified by course_locator exists
- lms.djangoapps.ccx.utils.ccx_students_enrolling_center(action, identifiers, email_students, course_key, email_params, coach)#
Function to enroll or unenroll/revoke students.
- Parameters:
action (str) – type of action to perform (Enroll, Unenroll/revoke)
identifiers (list) – list of students username/email
email_students (bool) – Flag to send an email to students
course_key (CCXLocator) – a CCX course key
email_params (dict) – dictionary of settings for the email to be sent
coach (User) – ccx coach
- Returns:
list of error
- Return type:
list
- lms.djangoapps.ccx.utils.get_ccx_by_ccx_id(course, coach, ccx_id)#
Finds a CCX of given coach on given master course.
- Parameters:
course (CourseBlock) – Master course
coach (User) – Coach to ccx
ccx_id (long) – Id of ccx
- Returns:
Instance of CCX.
- Return type:
- lms.djangoapps.ccx.utils.get_ccx_creation_dict(course)#
Return dict of rendering create ccx form.
- Parameters:
course (CourseBlockWithMixins) – An edx course
- Returns:
A attribute dict for view rendering
- Return type:
dict
- lms.djangoapps.ccx.utils.get_ccx_for_coach(course, coach)#
Looks to see if user is coach of a CCX for this course. Returns the CCX or None.
- lms.djangoapps.ccx.utils.get_ccx_from_ccx_locator(course_id)#
helper function to allow querying ccx fields from templates
- lms.djangoapps.ccx.utils.get_date(ccx, node, date_type=None, parent_node=None)#
This returns override or master date for section, subsection or a unit.
- Parameters:
ccx – ccx instance
node – chapter, subsection or unit
date_type – start or due
parent_node – parent of node
- Returns:
start or due date
- lms.djangoapps.ccx.utils.get_enrollment_action_and_identifiers(request)#
Extracts action type and student identifiers from the request on Enrollment tab of CCX Dashboard.
- lms.djangoapps.ccx.utils.get_valid_student_with_email(identifier)#
Helper function to get an user email from an identifier and validate it.
In the UI a Coach can enroll users using both an email and an username. This function takes care of: - in case the identifier is an username, extracting the user object from
the DB and then the associated email
validating the email
- Parameters:
identifier (str) – Username or email of the user to enroll
- Returns:
- tuple containing:
email (str): A validated email for the user to enroll. user (User): A valid User object or None.
- Return type:
(tuple)
- Raises:
CCXUserValidationException – if the username is not found or the email is not valid.
- lms.djangoapps.ccx.utils.is_email(identifier)#
Checks if an identifier string is a valid email
- lms.djangoapps.ccx.utils.parse_date(datestring)#
Generate a UTC datetime.datetime object from a string of the form ‘YYYY-MM-DD HH:MM’. If string is empty or None, returns None.
- lms.djangoapps.ccx.utils.remove_master_course_staff_from_ccx(master_course, ccx_key, display_name, send_email=True)#
Remove staff and instructor roles on ccx to all the staff and instructors members of master course.
- Parameters:
master_course (CourseBlockWithMixins) – Master course instance.
ccx_key (CCXLocator) – CCX course key.
display_name (str) – ccx display name for email.
send_email (bool) – flag to switch on or off email to the users on revoke access.
- lms.djangoapps.ccx.utils.validate_date(year, month, day, hour, minute)#
avoid corrupting db if bad dates come in
lms.djangoapps.ccx.views module#
Views related to the Custom Courses feature.
- lms.djangoapps.ccx.views.TODAY()#
Current date or datetime: same as self.__class__.fromtimestamp(time.time()).
- lms.djangoapps.ccx.views.ccx_gradebook(request, course, ccx=None)#
Show the gradebook for this CCX.
- lms.djangoapps.ccx.views.ccx_grades_csv(request, course, ccx=None)#
Download grades as CSV.
- lms.djangoapps.ccx.views.ccx_schedule(request, course, ccx=None)#
get json representation of ccx schedule
- lms.djangoapps.ccx.views.ccx_students_management(request, course, ccx=None)#
Manage the enrollment of the students in a CCX
- lms.djangoapps.ccx.views.coach_dashboard(view)#
View decorator which enforces that the user have the CCX coach role on the given course and goes ahead and translates the course_id from the Django route into a course object.
- lms.djangoapps.ccx.views.create_ccx(request, course, ccx=None)#
Create a new CCX
- lms.djangoapps.ccx.views.dashboard(request, course, ccx=None)#
Display the CCX Coach Dashboard.
- lms.djangoapps.ccx.views.get_ccx_schedule(course, ccx)#
Generate a JSON serializable CCX schedule.
- lms.djangoapps.ccx.views.save_ccx(request, course, ccx=None)#
Save changes to CCX.
- lms.djangoapps.ccx.views.set_grading_policy(request, course, ccx=None)#
Set grading policy for the CCX.