From 0f41cfc61007d378441837df17f37d2b1c61629e Mon Sep 17 00:00:00 2001 From: Chris Pyles Date: Tue, 30 Jan 2024 10:29:27 -0800 Subject: [PATCH 1/4] update save_notebook to use ottr_force_save_labextension hook --- R/save_notebook.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/R/save_notebook.R b/R/save_notebook.R index 4f2a163..6dd6084 100644 --- a/R/save_notebook.R +++ b/R/save_notebook.R @@ -24,9 +24,10 @@ save_notebook <- function(nb_path, timeout = 10) { IRdisplay::display_javascript(" if (typeof Jupyter !== 'undefined') { Jupyter.notebook.save_checkpoint(); - } - else { - document.querySelector('[data-command=\"docmanager:save\"]').click(); + } else if ('__ottr_force_save_labextension_force_save' in window) { + window.__ottr_force_save_labextension_force_save(); + } else { + alert('ottr_force_save_labextension\\'s force-save hook was not found. Make sure you have installed ottr_force_save_labextension.'); } ") From 17d5deb55f6be040c171946094b0dda533d22ebc Mon Sep 17 00:00:00 2001 From: Chris Pyles Date: Wed, 31 Jan 2024 17:02:17 -0800 Subject: [PATCH 2/4] remove alert --- R/save_notebook.R | 2 -- 1 file changed, 2 deletions(-) diff --git a/R/save_notebook.R b/R/save_notebook.R index 6dd6084..e041dbb 100644 --- a/R/save_notebook.R +++ b/R/save_notebook.R @@ -26,8 +26,6 @@ save_notebook <- function(nb_path, timeout = 10) { Jupyter.notebook.save_checkpoint(); } else if ('__ottr_force_save_labextension_force_save' in window) { window.__ottr_force_save_labextension_force_save(); - } else { - alert('ottr_force_save_labextension\\'s force-save hook was not found. Make sure you have installed ottr_force_save_labextension.'); } ") From 9f4cd058d8d9748398564a207269ed4a3204ac5e Mon Sep 17 00:00:00 2001 From: Chris Pyles Date: Wed, 31 Jan 2024 20:27:35 -0800 Subject: [PATCH 3/4] update failed force save warning message --- R/export.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/export.R b/R/export.R index 4fe0ed5..c5cf06b 100644 --- a/R/export.R +++ b/R/export.R @@ -44,8 +44,10 @@ ext <- tools::file_ext(submission_path) success <- save_notebook(submission_path) if (!success) { warning(paste0( - "Couldn't automatically save the notebook; we recommend using File > Save & ", - "Checkpoint and then re-running this cell. The zip file returned by this call ", + "Couldn't automatically save the notebook; ensure that you have ", + "ottr_force_save_labextension installed. If you have it installed and this issue keeps", + "reoccurring, you should use File > Save & ", + "Checkpoint and then rerun this cell. The zip file generated by this call ", "will use the last saved version of this notebook." )) } From 0b916075d2c5d0714de88086c230d02b2287ae5b Mon Sep 17 00:00:00 2001 From: Chris Pyles Date: Wed, 31 Jan 2024 20:51:45 -0800 Subject: [PATCH 4/4] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd68585..5da66f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Updated `ottr::export` so that notebook PDF generation failures do not prevent zip file creation [#766](https://github.com/ucbds-infra/otter-grader/issues/766) * Added the `debug` argument to `ottr::export` to assist in debugging PDF generation failures +* Updated `ottr::export` force-save functionality to rely on [`ottr_force_save_labextension`](https://github.com/chrispyles/ottr-force-save-labextension) per [#767](https://github.com/ucbds-infra/otter-grader/issues/767) **v1.4.0:**