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

Jupyter notebook: protect cells #2641

Closed
profbrady opened this issue Jan 16, 2018 · 11 comments
Closed

Jupyter notebook: protect cells #2641

profbrady opened this issue Jan 16, 2018 · 11 comments

Comments

@profbrady
Copy link

I use Jupyter notebooks with Python 3 to teach an engineering programming class. The interface is great for giving students notes and instructions with code cells, however it is very easy for students to accidentally delete or modify cells. Can a method be added to protect cells from inadvertent deletion or modification. I don't know, but maybe a cell toolbar named "Protection" that can be turned on via the View menu with a couple of check boxes; allow deletion, allow modification, allow movement.

This way, an instructor could go into that view mode when creating assignments and turn off allow deletion and allow modification then set the view mode back to None before assigning to students. It would not keep them from switching modes, but it would require an overtly deliberate act.

@williamstein
Copy link
Contributor

Is there anything already like this in the "normal" jupyter ecosystem (for classical jupyter)? If so, can you find it and post a link. The reason is only since it would be easier to make this compatible with that (e.g., use the same description/name).

Actually implementing what you describe in terms of CoCalc Jupyter would I think be very easy.

@haraldschilly
Copy link
Contributor

I found

@williamstein
Copy link
Contributor

REQUESTED BY: Richard Bilonick, among other people.

@haraldschilly
Copy link
Contributor

Another one, in Jupyter notebook version 5 (i.e. rather recent), there is the metadata field "editable:true|false" and "deletable:true|false". I think we should support these two, and also add a more convenient switch to the menu than having to fiddle around with the metadata json directly.

Steps to see this in action:

  1. open the plain classical jupyter server and there an ipynb file.
  2. eval a cell with stuff like 2+2.
  3. menu: view → cell toolbar → edit metadata.
  4. make this like
{
  "trusted": true,
  "editable": false,
  "deletable": false
}
  1. try to edit or delete the cell. For me, it only lets you eval it!

@profbrady
Copy link
Author

I am all in favor of this. I just opened one of my assignment notebooks in classical mode and edited metadata for the cells I want locked various ways. I love it. Please add and make simple toggles or check boxes. Modifying the metadata for multiple selected cells at one time would also be nice.

@dduque10
Copy link

My markdown cell is still editable after editing the metadata as suggested, what could I be doing wrong? I am running jupyter on Pycharm and Python 3

@williamstein
Copy link
Contributor

Instead of directly editing metadata (where you could make a mistake), use the Edit menu with the cell selected:

image

@dduque10
Copy link

I don't have those options :(

@williamstein
Copy link
Contributor

I don't have those options :(

That's not possible if you are using cocalc-jupyter, since they are always visible. Please post a screenshot (showing your entire browser window) so I can better direct you.

@dduque10
Copy link

I am not using cocalc-jupyter I thought this was a jupyter forum. I am sorry.

@williamstein
Copy link
Contributor

Oh that makes sense. The same options should be supported in Jupyter classic and JupyterLab (soon, at least), since I made an accepted PR to the nbformat docs:

https://nbformat.readthedocs.io/en/latest/format_description.html#cell-metadata

I'm not sure what the implementation status is though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants