Jupyter (ipython notebook), hide menu and some toolbar buttons, or run python code on loading

4.7k views Asked by At

I would like to use a Jupyter notebook to administer math tests to my high school students on there ipads, I would start a server for each student and have them connect to there own server on there ipads where they would find there own notebook test. I have written the test using widgets and it works great, but i would like to make sure they could not do anything with this notebook except take the test. I have two ideas that I have not been able to get working.

Idea 1: hide the menu bar and all the buttons from the toolbar and add one button that will run the only cell in the book that would have "%run exam.py" that would start the test. With this setup a student could not do extra coding because on the ipad they couldn't use Shift+Enter to start a new cell.

My problem is that I have not been able to find a way to hide the menu bar or hide specific buttons from the tool bar.

Idea 2: In custom.js I noticed that you can run python code with "IPython.notebook.kernel.execute('code here')". So I was hopeing on loading the notebook the custom.js would hide the header and then run my exam code automatically.

I can't seem to get any ipython code to run at loading time, I don't even know if this is possible?

I don't know javascript so my attempts have been fumbling around with the examples in the custom.js to no avail.

Is either idea possible and/or is there a better way to use a notebook to administer an exam?

1

There are 1 answers

3
Matt On BEST ANSWER

1) You probably want to read this about mass deploying IPython for student.

2) If you are not using IPython notebook to run code, then you are probably bending a tool beyond its usage, and a Flask app might be better suited.

3) You need to wrap the call to execute code to execute only once the kernel is started. IF you control the server why not put things in .ipython/profile_default/startup ? Otherwise use the following (might depends on exact version you use):

require(['base/js/events','base/js/namespace'], function(events, IPython){
    events.on('kernel_ready.Kernel', function () {
        // your code here
    })
});

But in general it seem you are miss-using the tools.