diff --git a/nbgrader/server_extensions/course_list/handlers.py b/nbgrader/server_extensions/course_list/handlers.py index 302ece002..c12f8b571 100644 --- a/nbgrader/server_extensions/course_list/handlers.py +++ b/nbgrader/server_extensions/course_list/handlers.py @@ -79,7 +79,7 @@ def check_for_local_formgrader(self, config): if status: raise gen.Return([{ 'course_id': coursedir.course_id, - 'url': base_url + '/lab', + 'url': base_url + '/formgrader', 'kind': 'local' }]) @@ -113,7 +113,7 @@ def check_for_noauth_jupyterhub_formgraders(self, config): courses = [{ 'course_id': coursedir.course_id, - 'url': url + "/lab", + 'url': url + "/lab?formgrader=true", 'kind': 'jupyterhub' }] raise gen.Return(courses) @@ -156,7 +156,7 @@ def check_for_jupyterhub_formgraders(self, config): service = services[course] courses.append({ 'course_id': course, - 'url': self.get_base_url() + service['prefix'].rstrip('/') + "/lab", + 'url': self.get_base_url() + service['prefix'].rstrip('/') + "/lab?formgrader=true", 'kind': 'jupyterhub' }) diff --git a/src/course_list/courselist.ts b/src/course_list/courselist.ts index 3979e2371..ffb7dffd9 100644 --- a/src/course_list/courselist.ts +++ b/src/course_list/courselist.ts @@ -62,7 +62,7 @@ function createElementFromCourse(data: any, app: JupyterFrontEnd, isNotebook:boo } else { const url = data['url'] as string; if (isNotebook) { - anchor.href = URLExt.join(url.replace(/lab\/?$/, 'tree')); + anchor.href = url.replace(/\/lab(\/|\?)?/, '/tree$1'); } else { anchor.href = url } diff --git a/src/index.ts b/src/index.ts index 13cef2157..1459cdea1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { ILabShell, ILayoutRestorer, JupyterFrontEnd, JupyterFrontEndPlugin } from "@jupyterlab/application"; +import { ILabShell, ILayoutRestorer, IRouter, JupyterFrontEnd, JupyterFrontEndPlugin } from "@jupyterlab/application"; import { ICommandPalette, MainAreaWidget, WidgetTracker } from "@jupyterlab/apputils"; import { PageConfig, URLExt } from "@jupyterlab/coreutils"; import { IMainMenu } from '@jupyterlab/mainmenu'; @@ -178,7 +178,6 @@ const courseListExtension: JupyterFrontEndPlugin = { id: pluginIDs.coursesList, autoStart: true, optional: [ILayoutRestorer, INotebookTree], - activate: ( app: JupyterFrontEnd, restorer: ILayoutRestorer | null, @@ -240,11 +239,12 @@ const courseListExtension: JupyterFrontEndPlugin = { const formgraderExtension: JupyterFrontEndPlugin = { id: pluginIDs.formgrader, autoStart: true, - optional: [ILayoutRestorer, INotebookTree], + optional: [ILayoutRestorer, INotebookTree, IRouter], activate: ( app: JupyterFrontEnd, restorer: ILayoutRestorer | null, - notebookTree: INotebookTree | null + notebookTree: INotebookTree | null, + router: IRouter | null ) => { // Declare a widget variable let widget: MainAreaWidget; @@ -290,6 +290,15 @@ const formgraderExtension: JupyterFrontEndPlugin = { } }); + // Open formgrader from URL. + if (router) { + const formgraderPattern = /(\?|&)formgrader=true/; + router.register({ + command: commandIDs.openFormgrader, + pattern: formgraderPattern + }); + } + // Restore the widget state if (restorer != null){ restorer.restore(tracker, {