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

feat: set course for wiki based on the wiki_slug #590

Conversation

Cup0fCoffee
Copy link
Member

Upstream PR: openedx#33338

Description

Learners want to have the usual course navigation when viewing a wiki, so that they can go back to the course related to the wiki and browse other tabs/sections of the course.

Wiki reads the course from the request.course. If it's not present, i.e. None or not set on the request, it will not show the course navigation UI.

It seems like WikiAccessMiddleware already has the code that parses course id from the request (when the request is for a wiki view) and sets the course for the request. However, it doesn't work in most scenarios, because the course id is not in the it's normal format in most requests that go to wiki.

For example, when a leaner clicks on a wiki tab from the course overview, they are redirected to /wiki/<wiki_slug>/ path. The wiki slug is taken from course's wiki_slug field. This slug can be used to figure out what course this wiki belongs to in most (not all) cases.

This commit adds code to the WikiAccessMiddleware that attempts to find a course based on wiki slug, and in case of success, sets the course to the request.course, so that wiki can display course navigation UI.

Testing instructions

  • Setup devstack of latest version

  • make dev.up.lms+cms+frontend-app-learning

  • Log in at localhost:18000 as [email protected] (edx as password)

  • Enroll into the demo course

  • Go to studio for this course, in the navigation find "Content -> Pages", click on it, and make the Wiki tab visible by clicking the crossed eye icon

  • Go back to the course, and click the wiki tab

  • You will see that the wiki doesn't have any course tabs, there is no way to go back to the course you came from, etc.

    Screenshot

    image

  • Now checkout the branch from the PR

  • Go back to the wiki page and reload (it might need a minute for the dev server to restart)

  • You will now see that the course navigation UI is showing correctly.

    Screenshot

    image

  • Check that the links are pointing to the correct course

Deadline

"None"

Learners want to have the usual course navigation when viewing a wiki,
so that they can go back to the course related to the wiki and browse
other tabs/sections of the course.

Wiki reads the course from the `request.course`. If it's not present,
i.e.  None or not set on the request, it will not show the course
navigation UI.

It seems like `WikiAccessMiddleware` already has the code that parses
course id from the request (when the request is for a wiki view) and
sets the course for the request. However, it doesn't work in most
scenarios, because the course id is not in the it's normal format in
most requests that go to wiki.

For example, when a leaner clicks on a wiki tab from the course
overview, they are redirected to `/wiki/<wiki_slug>/` path. The wiki
slug is taken from course's `wiki_slug` field. This slug can be used to
figure out what course this wiki belongs to in most (not all) cases.

This commit adds code to the `WikiAccessMiddleware` that attempts to
find a course based on wiki slug, and in case of success, sets the
course to the `request.course`, so that wiki can display course
navigation UI.
@viadanna
Copy link
Member

LGTM 👍

  • I tested this
  • I read through the code

@Cup0fCoffee Cup0fCoffee merged commit 377bb07 into opencraft-release/palm.1 Sep 29, 2023
41 checks passed
@Cup0fCoffee Cup0fCoffee deleted the maxim/fixing-navigation-from-wiki-back-to-course-opencraft-palm branch September 29, 2023 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants