lms.djangoapps.course_wiki package#

Subpackages#

Submodules#

lms.djangoapps.course_wiki.editors module#

Support for using the CodeMirror code editor as a wiki content editor.

class lms.djangoapps.course_wiki.editors.CodeMirror(instance=None)#

Bases: BaseEditor

Wiki content editor using CodeMirror.

class AdminMedia#

Bases: object

css = {'all': ('wiki/markitup/skins/simple/style.css', 'wiki/markitup/sets/admin/style.css')}#
js = ('wiki/markitup/admin.init.js', 'wiki/markitup/jquery.markitup.js', 'wiki/markitup/sets/admin/set.js')#
class Media#

Bases: object

css = {'all': ('js/vendor/CodeMirror/codemirror.css',)}#
js = ('js/vendor/CodeMirror/codemirror.js', 'js/vendor/CodeMirror/addons/xml.js', 'js/vendor/CodeMirror/addons/edx_markdown.js', 'js/wiki/accessible.js', 'js/wiki/CodeMirror.init.js')#
editor_id = 'codemirror'#
get_admin_widget(instance=None)#
get_widget(instance=None)#
class lms.djangoapps.course_wiki.editors.CodeMirrorWidget(attrs=None)#

Bases: Widget

Use CodeMirror as a Django form widget (like a textarea).

property media#
render(name, value, attrs=None, renderer=None)#

Render the widget as an HTML string.

lms.djangoapps.course_wiki.middleware module#

Middleware for course_wiki

class lms.djangoapps.course_wiki.middleware.WikiAccessMiddleware(get_response)#

Bases: MiddlewareMixin

This middleware wraps calls to django-wiki in order to handle authentication and redirection between the root wiki and the course wikis.

TODO: removing the “root wiki” would obviate the need for this middleware; it could be replaced

with a wrapper function around the wiki views. This is currently difficult or impossible to do because there are two sets of wiki urls loaded in urls.py

process_response(request, response)#

Modify the redirect from /wiki/123 to /course/foo/bar/wiki/123/ if the referrer comes from a course page

process_view(request, view_func, view_args, view_kwargs)#

This function handles authentication logic for wiki urls and redirects from the “root wiki” to the “course wiki” if the user accesses the wiki from a course url

lms.djangoapps.course_wiki.settings module#

These callables are used by django-wiki to check various permissions a user has on an article.

lms.djangoapps.course_wiki.settings.CAN_ASSIGN(article, user)#

Is user allowed to change owner or group of article?

lms.djangoapps.course_wiki.settings.CAN_ASSIGN_OWNER(article, user)#

Is user allowed to change group of article to one of its own groups?

lms.djangoapps.course_wiki.settings.CAN_CHANGE_PERMISSIONS(article, user)#

Is user allowed to change permissions on article?

lms.djangoapps.course_wiki.settings.CAN_DELETE(article, user)#

Is user allowed to soft-delete article?

lms.djangoapps.course_wiki.settings.CAN_MODERATE(article, user)#

Is user allowed to restore or purge article?

lms.djangoapps.course_wiki.tab module#

These callables are used by django-wiki to check various permissions a user has on an article.

class lms.djangoapps.course_wiki.tab.WikiTab(tab_dict)#

Bases: EnrolledTab

Defines the Wiki view type that is shown as a course tab.

is_default = False#
classmethod is_enabled(course, user=None)#

Returns true if the wiki is enabled and the specified user is enrolled or has staff access.

is_hideable = True#
priority = 70#
title = 'Wiki'#
to_json()#

Serializes the necessary members of the CourseTab object to a json-serializable representation. This method is overridden by subclasses that have more members to serialize.

Returns:

a dictionary with keys for the properties of the CourseTab object.

type = 'wiki'#
view_name = 'course_wiki'#

lms.djangoapps.course_wiki.utils module#

Utility functions for course_wiki.

lms.djangoapps.course_wiki.utils.article_course_wiki_root_slug(article)#

We assume the second level ancestor is the course wiki root. Examples: / returns None /Phy101 returns ‘Phy101’ /Phy101/Mechanics returns ‘Phy101’ /Chem101/Metals/Iron returns ‘Chem101’

Note that someone can create an article /random-article/sub-article on the wiki. In this case this function will return ‘some-random-article’ even if no course with course number ‘some-random-article’ exists.

lms.djangoapps.course_wiki.utils.course_wiki_slug(course)#

Returns the slug for the course wiki root.

lms.djangoapps.course_wiki.utils.slug_is_numerical(slug)#

Returns whether the slug can be interpreted as a number.

lms.djangoapps.course_wiki.utils.user_is_article_course_staff(user, article)#

The root of a course wiki is /<course_number>. This means in case there are two courses which have the same course_number they will end up with the same course wiki root e.g. MITx/Phy101/Spring and HarvardX/Phy101/Fall will share /Phy101.

This looks at the course wiki root of the article and returns True if the user belongs to a group whose name starts with ‘instructor_’ or ‘staff_’ and contains ‘/<course_wiki_root_slug>/’. So if the user is staff on course MITx/Phy101/Spring they will be in ‘instructor_MITx/Phy101/Spring’ or ‘staff_MITx/Phy101/Spring’ groups and so this will return True.

lms.djangoapps.course_wiki.views module#

This file contains view functions for wrapping the django-wiki.

lms.djangoapps.course_wiki.views.course_wiki_redirect(request, course_id, wiki_path='')#

This redirects to whatever page on the wiki that the course designates as it’s home page. A course’s wiki must be an article on the root (for example, “/6.002x”) to keep things simple.

lms.djangoapps.course_wiki.views.get_or_create_root()#

Returns the root article, or creates it if it doesn’t exist.

lms.djangoapps.course_wiki.views.root_create(request)#

In the edX wiki, we don’t show the root_create view. Instead, we just create the root automatically if it doesn’t exist.

Module contents#