lms.djangoapps.courseware.views package#
Submodules#
lms.djangoapps.courseware.views.index module#
View for Courseware Index
- class lms.djangoapps.courseware.views.index.CoursewareIndex(**kwargs)#
Bases:
ViewView class for the Courseware page.
- enable_unenrolled_access#
- get(request, course_id, section=None, subsection=None, position=None)#
Instead of loading the legacy courseware sequences pages, load the equivalent URL in the learning MFE. This view does not do any auth checks since they are done by the MFE when attempting to load content.
- Parameters:
request – HTTP request
course_id (unicode) – course id
section (unicode) – section url_name
subsection (unicode) – subsection url_name
position (unicode) – position in block, eg of <sequential> block
- lms.djangoapps.courseware.views.index.save_child_position(seq_block, child_name)#
child_name: url_name of the child
- lms.djangoapps.courseware.views.index.save_positions_recursively_up(user, request, field_data_cache, xmodule, course=None)#
Recurses up the course tree starting from a leaf Saving the position property based on the previous node as it goes
lms.djangoapps.courseware.views.views module#
Courseware views functions
- class lms.djangoapps.courseware.views.views.BasePublicVideoXBlockView(**kwargs)#
Bases:
ViewBase functionality for public video xblock view and embed view
- dispatch(request, *args, **kwargs)#
- get(_, usage_key_string)#
Load course and video and render public view
- get_course_and_video_block(usage_key_string)#
Load course and video from modulestore. Raises 404 if:
video_config.public_video_share waffle flag is not enabled for this course
block is not video
block is not marked as “public_access”
- class lms.djangoapps.courseware.views.views.CertData(cert_status, title, msg, download_url, cert_web_view_url, certificate_available_date)#
Bases:
tuple- cert_status#
Alias for field number 0
- cert_web_view_url#
Alias for field number 4
- certificate_available_date#
Alias for field number 5
- download_url#
Alias for field number 3
- msg#
Alias for field number 2
- title#
Alias for field number 1
- class lms.djangoapps.courseware.views.views.CourseTabView(**kwargs)#
Bases:
EdxFragmentViewView that displays a course tab page.
- static course_open_for_learner_enrollment(course)#
- create_page_context(request, course=None, tab=None, **kwargs)#
Creates the context for the fragment’s template.
- get(request, course_id, tab_type, **kwargs)#
Displays a course tab page that contains a web fragment.
- static handle_exceptions(request, course_key, course, exception)#
Handle exceptions raised when rendering a view.
- static register_user_access_warning_messages(request, course)#
Register messages to be shown to the user if they have limited access.
- render_standalone_response(request, fragment, course=None, tab=None, page_context=None, **kwargs)#
Renders this course tab’s fragment to HTML for a standalone page.
- render_to_fragment(request, course=None, page_context=None, **kwargs)#
Renders the course tab to a fragment.
- static url_to_enroll(course_key)#
Returns the URL to use to enroll in the specified course.
- class lms.djangoapps.courseware.views.views.EnrollStaffView(**kwargs)#
Bases:
ViewDisplays view for registering in the course to a global staff user. User can either choose to ‘Enroll’ or ‘Don’t Enroll’ in the course.
Enroll: Enrolls user in course and redirects to the courseware. Don’t Enroll: Redirects user to course about page.
- Parameters:
request (-) – HTTP request
course_id (-) – course id
- Returns:
RedirectResponse
- get(request, course_id)#
Display enroll staff view to global staff user with Enroll and Don’t Enroll options.
- post(request, course_id)#
Either enrolls the user in course or redirects user to course about page depending upon the option (Enroll, Don’t Enroll) chosen by the user.
- template_name = 'enroll_staff.html'#
- class lms.djangoapps.courseware.views.views.PerUserVideoMetadataThrottle#
Bases:
UserRateThrottlesetting rate limit for yt_video_metadata API
- rate = '10/minute'#
- class lms.djangoapps.courseware.views.views.PublicVideoXBlockEmbedView(**kwargs)#
Bases:
BasePublicVideoXBlockViewView for viewing public videos embedded within Twitter or other social media
- dispatch(request, *args, **kwargs)#
- get_template_and_context(course, video_block)#
Render the embed view
- class lms.djangoapps.courseware.views.views.PublicVideoXBlockView(**kwargs)#
Bases:
BasePublicVideoXBlockViewView for displaying public videos
- build_url(base_url, params, utm_params)#
Helper function to combine a base URL, params, and utm params into a full URL
- dispatch(request, *args, **kwargs)#
- get_catalog_course_data(course)#
Get information from the catalog service for this course
- get_is_enrolled_in_course(course)#
Returns whether the user is enrolled in the course
- get_learn_more_button_url(course, catalog_course_data, utm_params)#
If the marketing site is enabled and a course has a marketing page, use that URL. If not, point to the about_course view. Override all with the MKTG_URL_OVERRIDES setting.
- get_public_video_cta_button_urls(course, catalog_course_data)#
Get the links for the ‘enroll’ and ‘learn more’ buttons on the public video page
- get_social_sharing_metadata(course, video_block)#
Gather the information for the meta OpenGraph and Twitter-specific tags
- get_template_and_context(course, video_block)#
Render video xblock, gather social media metadata, and generate CTA links
- class lms.djangoapps.courseware.views.views.StaticCourseTabView(**kwargs)#
Bases:
EdxFragmentViewView that displays a static course tab with a given name.
- get(request, course_id, tab_slug, **kwargs)#
Displays a static course tab page with a given name
- render_standalone_response(request, fragment, course=None, tab=None, **kwargs)#
Renders this static tab’s fragment to HTML for a standalone page.
- render_to_fragment(request, course=None, tab=None, **kwargs)#
Renders the static tab to a fragment.
- class lms.djangoapps.courseware.views.views.XBlockContentInspector(block, fragment)#
Bases:
objectClass to inspect rendered XBlock content to determine dependencies.
A lot of content has been written with the assumption that certain JavaScript and assets are available. This has caused us to continue to include these assets in the render_xblock view, despite the fact that they are not used by the vast majority of content.
In order to try to provide faster load times for most users on most content, this class has the job of detecting certain patterns in XBlock content that would imply these dependencies, so we know when to include them or not.
- has_mathjax_content()#
Returns whether we detect any MathJax in the fragment.
Note that this only works for things that are rendered up front. If an XBlock is capable of modifying the DOM afterwards to inject math content into the page, this will not catch it.
- lms.djangoapps.courseware.views.views.course_about(request, course_id)#
Display the course’s about page.
- lms.djangoapps.courseware.views.views.course_survey(request, course_id)#
URL endpoint to present a survey that is associated with a course_id Note that the actual implementation of course survey is handled in the views.py file in the Survey Djangoapp
- lms.djangoapps.courseware.views.views.courses(request)#
Render “find courses” page. The course selection work is done in courseware.courses.
GET endpoint to return navigation sidebar toggles.
- lms.djangoapps.courseware.views.views.courseware_mfe_search_enabled(request, *args, **kwargs)#
Simple GET endpoint to expose whether the user may use Courseware Search for a given course.
- lms.djangoapps.courseware.views.views.credit_course_requirements(course_key, student)#
Return information about which credit requirements a user has satisfied. :param course_key: Identifier for the course. :type course_key: CourseKey :param student: Currently logged in user. :type student: User
Returns: dict if the credit eligibility enabled and it is a credit course and the user is enrolled in either verified or credit mode, and None otherwise.
- lms.djangoapps.courseware.views.views.dates(request, course_id)#
Simply redirects to the MFE dates tab, as this legacy view for dates no longer exists.
- lms.djangoapps.courseware.views.views.enclosing_sequence_for_gating_checks(block)#
Return the first ancestor of this block that is a SequenceDescriptor.
Returns None if there is no such ancestor. Returns None if you call it on a SequenceDescriptor directly.
We explicitly test against the three known tag types that map to sequences (even though two of them have been long since deprecated and are never used). We _don’t_ test against SequentialDescriptor directly because:
A direct comparison on the type fails because we magically mix it into a SequenceDescriptorWithMixins object.
An isinstance check doesn’t give us the right behavior because Courses and Sections both subclass SequenceDescriptor. >_<
Also important to note that some content isn’t contained in Sequences at all. LabXchange uses learning pathways, but even content inside courses like static_tab, book, and about live outside the sequence hierarchy.
- lms.djangoapps.courseware.views.views.financial_assistance(request, course_id=None)#
Render the initial financial assistance page.
- lms.djangoapps.courseware.views.views.financial_assistance_form(request, course_id=None)#
Render the financial assistance application form page.
- lms.djangoapps.courseware.views.views.financial_assistance_request(request)#
Submit a request for financial assistance to Zendesk.
- lms.djangoapps.courseware.views.views.financial_assistance_request_v2(request)#
Uses the new financial assistance application flow. Creates a post request to edx-financial-assistance backend.
- lms.djangoapps.courseware.views.views.generate_user_cert(request, course_id)#
Request that a course certificate be generated for the user.
In addition to requesting generation, this method also checks for and returns the certificate status. Note that because generation is an asynchronous process, the certificate may not have been generated when its status is retrieved.
- Parameters:
request (HttpRequest) – The POST request to this view.
course_id (unicode) – The identifier for the course.
- Returns:
200 on success, 400 if a new certificate cannot be generated.
- Return type:
HttpResponse
- lms.djangoapps.courseware.views.views.get_cert_data(student, course, enrollment_mode, course_grade=None)#
Returns students course certificate related data. :param student: Student for whom certificate to retrieve. :type student: User :param course: Course object for which certificate data to retrieve. :type course: Course :param enrollment_mode: Course mode in which student is enrolled. :type enrollment_mode: String :param course_grade: Student’s course grade record. :type course_grade: CourseGrade
- Returns:
returns dict if course certificate is available else None.
- lms.djangoapps.courseware.views.views.get_course_lti_endpoints(request, course_id)#
View that, given a course_id, returns the a JSON object that enumerates all of the LTI endpoints for that course. The LTI 2.0 result service spec at http://www.imsglobal.org/lti/ltiv2p0/uml/purl.imsglobal.org/vocab/lis/v2/outcomes/Result/service.html says “This specification document does not prescribe a method for discovering the endpoint URLs.” This view function implements one way of discovering these endpoints, returning a JSON array when accessed. :param request: the HTTP request object that triggered this view function :type request: django request object :param course_id: id associated with the course :type course_id: unicode
- Returns:
HTTP response. 404 if course is not found, otherwise 200 with JSON body.
- Return type:
(django response object)
- lms.djangoapps.courseware.views.views.get_financial_aid_courses(user, course_id=None)#
Retrieve the courses eligible for financial assistance.
- lms.djangoapps.courseware.views.views.get_learner_username(learner_identifier)#
Return the username
- lms.djangoapps.courseware.views.views.get_optimization_flags_for_content(block, fragment)#
Return a dict with a set of display options appropriate for the block.
This is going to start in a very limited way.
- lms.djangoapps.courseware.views.views.get_static_tab_fragment(request, course, tab)#
Returns the fragment for the given static tab
- lms.djangoapps.courseware.views.views.is_course_passed(student, course, course_grade=None)#
check user’s course passing status. return True if passed :param student: user object :param course: course object :param course_grade: contains student grade details. :type course_grade: CourseGrade
- Returns:
returns bool value
- lms.djangoapps.courseware.views.views.jump_to(request, course_id, location)#
Show the page that contains a specific location.
If the location is invalid or not in any class, return a 404. Otherwise, delegates to the courseware views to figure out whether this user has access, and what they should see.
By default, this view redirects to the active courseware experience. Alternatively, the experience query parameter may be provided as either “new” or “legacy” to force either a Micro-Frontend or Legacy-LMS redirect link to be generated, respectively.
- lms.djangoapps.courseware.views.views.jump_to_id(request, course_id, module_id)#
This entry point allows for a shorter version of a jump to where just the id of the element is passed in. This assumes that id is unique within the course_id namespace
- lms.djangoapps.courseware.views.views.load_metadata_from_youtube(video_id, request)#
Get metadata about a YouTube video.
This method is used via the standalone /courses/yt_video_metadata REST API endpoint, or via the video XBlock as a its ‘yt_video_metadata’ handler.
- lms.djangoapps.courseware.views.views.program_marketing(request, program_uuid)#
Display the program marketing page.
- lms.djangoapps.courseware.views.views.progress(request, course_id, student_id=None)#
Display the progress page.
- lms.djangoapps.courseware.views.views.registered_for_course(course, user)#
Return True if user is registered for course, else False
- lms.djangoapps.courseware.views.views.render_xblock(request, usage_key_string, check_if_enrolled=True, disable_staff_debug_info=False)#
Returns an HttpResponse with HTML content for the xBlock with the given usage_key. The returned HTML is a chromeless rendering of the xBlock (excluding content of the containing courseware).
- lms.djangoapps.courseware.views.views.submission_history(request, course_id, learner_identifier, location)#
Render an HTML fragment (meant for inclusion elsewhere) that renders a history of all state changes made by this user for this problem location. Right now this only works for problems because that’s all StudentModuleHistory records.
- lms.djangoapps.courseware.views.views.syllabus(request, course_id)#
Display the course’s syllabus.html, or 404 if there is no such course. Assumes the course_id is in a valid format.
- lms.djangoapps.courseware.views.views.user_groups(user)#
TODO (vshnayder): This is not used. When we have a new plan for groups, adjust appropriately.
- lms.djangoapps.courseware.views.views.yt_video_metadata(request, *args, **kwargs)#
Will hit the youtube API if the key is available in settings :return: youtube video metadata