[IPython-dev] 2 questions about notebooks : disabling cells for edition and best hiding menu bar process

Benjamin Ninassi benjamin.ninassi at inria.fr
Wed May 28 10:56:41 EDT 2014


Again thanks a lot, I made it work with this snipet of code in custom.js (for the record if someone search through this thread):

$([IPython.events]).on('notebook_loaded.Notebook', function(){
  var cells = IPython.notebook.get_cells();
  for(var i in cells){
    var cell = cells[i];
    if (!(cell instanceof IPython.CodeCell)) {
      cell.code_mirror.setOption('readOnly','nocursor');
    }
  }
})

I'll be happy to provide you with feedback !

We're preparing a Mooc on robotic with some python exercices that will be available on the governmental french Mooc plateform https://www.france-universite-numerique-mooc.fr/ (which is based on EDX) at the end of the year, and we were looking for a solution to allow student to quickly be able to do the exercices without having to install python and all the stuff (numpy, matplotlib and so on) on their computer. Skulpt and other javascript librairy still can't be used with numpy, so I turned on server-side execution with ipython.
And I'm pretty sure now that ipython will do the trick. :)

We may also add some automatic evaluation to, I'll keep you inform on our progress !

-- 
Benjamin Ninassi 
INRIA - SEISM & Mooclab
Tél. (+33) 02 99 84 73 43 
benjamin.ninassi at inria.fr 

----- Mail original -----
> De: "Matthias BUSSONNIER" <bussonniermatthias at gmail.com>
> À: "IPython developers list" <ipython-dev at scipy.org>
> Envoyé: Mercredi 28 Mai 2014 15:49:27
> Objet: Re: [IPython-dev] 2 questions about notebooks : disabling cells for	edition and best hiding menu bar process
> 
> 
> Le 28 mai 2014 à 15:22, Benjamin Ninassi a écrit :
> 
> > Thanks a lot for your quick answears !
> > 
> > It should be possible by directly setting the read-only mode to some cell
> > in CodeMiror itself, but it will require a bit of javscript:
> > 
> > http://codemirror.net/doc/manual.html#option_readOnly
> > I'll drill into that, thanks ! My major issue will be to identify the cells
> > that i want to disable through the DOM as they have no ID ... is-it
> > possible to give them one with metadata ?
> 
> You cannot (yet) get a dom identity through the metadata, but you can a list
> of sell by
> 
> IPython.notebook.get_cells()
> 
> then loop on all cell and on each cell do approximatively a
> 
> var ro = (cell.metadata.my_namespace || {}).readonly
> 
> if(ro === true):
> 	cell.editor.set_options('readOnly','nocursor')
> 
> Which should do the desired effect.
> You might want to capture a few other event like execution request on theses
> cell by monkey patching
> the CellClass.prototype.execute
> 
> CellClass.prototype.old_execute = CellClass.prototype.execute
> CellClass.prototype.execute = function(){
> 	if not read only :
> 		this.old_execute(arguments)
> 
> }
> 
> 
> 
> 
> 
> > I suppose css with the same target and display:none in custom.css should
> > works.
> > I was supposing that to, but there is a  style="display: block;" generated
> > in the html for the header div that overwrite the custom.css
> > #header{   display:none; } …
> 
> Hum, we should probably fix that then.
> 
> > No, there is no list. You can grep through the source for IPython.events
> > out should give yo an idea of existing event,
> > 
> > The rest depend if when using IPython for a MOOC you will be providing the
> > sever,in which case you can customize it a lot
> > or if you plan on users to install IPython in which case you probably want
> > to avoid too aggressive customization.
> > We will be providing a server, so we can customize it a lot. I'm convince
> > ipython and notebooks are great tools for online education, providing some
> > minor adjustments !
> 
> Then you can probably apply a patch on the template to remove whatever
> element for the time being.
> We'll be happy to get your feedback from using the notebook for teaching.
> 
> --
> M
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
> 



More information about the IPython-dev mailing list