# Docked Cell lesson chooser

I have a question about creating a docked cell that will let me choose files.

This is just as much a "design" question as a Mathematica question.

I'm a math teacher and I want to bundle a bunch of Mathematica lesson content into a unit.

I have a whole bunch of files that make up a unit. We'll call them simply Lesson1.cdf, Lesson2.cdf, Lesson3.cdf etc. We'll say there are 10 of them.

I wanted to build the unit in smaller pieces , since it seems logical not to have a huge amount of info in one file. So, create in pieces.

I can see how to use ActionMenu to do this... at least it's one way, not saying it's the best way!!

b1 = ActionMenu["Open a lesson",
{"Lesson 1" :>
NotebookOpen[FileNameJoin[{NotebookDirectory[], "lesson1.cdf"}]],
"Lesson 2" :>
NotebookOpen[
FileNameJoin[{NotebookDirectory[], "lesson2.cdf"}]]},
]


It works...

I then create a docked cell in the Notebook...

    SetOptions[SelectedNotebook[],
DockedCells -> Cell[BoxData[ToBoxes[b1]], "DockedCell"]];


This too works... so far so good!

So , sadly, that's as far as my knowledge will take me.

I tried using hyperlinks to open the lesson notebooks from a main document, but it seemed really cluttered , having more than one notebook open on screen. This method seems potentially better, but can I have it close the "calling" notebook when it opens the selected lesson?

Would there be an easy way to write this docked cell to all the other lessons? (Yes, I think I could do that by just getting a list of lesson files and setting their options for docked cells)

Finally, this way of opening the notebooks generates the "unsafe" content warning. That will be bad since then every lesson notebook will have this issue.

Way over my depth here, but hoping someone can give some "design" advice for packaging up a bunch of notebooks into a nice unit, and being able to get from one to another easily.

My students do not have Mathematica and are using CDFPlayer to view my lessons.

It's interesting that bundling a "NotebookOpen" inside a Button does NOT trigger the warning, which is a big thing. So, buttons aren't as elegant, but they do work and allow students to move between lessons with no issues.

But I know that can't be right... I've probably managed to add that path to my TrustedDirectories or something... it's a real nuisance not to be able to do this in a straightforward way...

-
Hi again, I should mention that if I create a BUTTON, to open a file, I got no "unsafe content" warning. I.E. I can create a button that opens a file, and dock that, and it does what I want. But it looks pretty clunky having 10 - 15 buttons at the top of a document to open the other files in the unit. But it does work... Tom –  Tom De Vries Sep 12 '12 at 19:28
Tom what you seem to be wanting to do is the sort of thing Eric Schulz outlined in an online CDF workshop.The materials from his presentation are available for download from Wolfram. –  Mike Honeychurch Sep 12 '12 at 21:53
Thanks! Yes, I have those, and they are probably brilliant, but I can manage to decipher the code, and there is one function that he didn't include in his lesson materials. I'm also one step less structured in that I'm just opening single files, not at the "cell by cell" with tags level as he is. I spent a couple hours this afternoon, really wanted to make that work and couldn't manage it. –  Tom De Vries Sep 12 '12 at 21:57
It seems to me that the underlying quesion is "why doesn't an ActionMenu work in a docked cell." They don't inside my toolbars. –  George Wolfe Sep 17 '12 at 3:08

1- Closing the notebook you're in could be done with:

NotebookClose[InputNotebook[]]


Note that this closes without warnings and saves (tip R.M.). Use NotebookSave to manually save the notebook or set the notebook's NotebookAutoSave to True to save after every result.

2- Notebooks[] will give you a list of open notebooks, so mapping your SetOptions over this will give all open notebooks the docked cells

SetOptions[#,   DockedCells -> Cell[BoxData[ToBoxes[b1]], "DockedCell"]]&/@Notebooks[]


You can use Select/Cases and NotebookFileName to find specific notebooks. Or set the option when you open a notebook and have its link at your disposal.

3- With respect to CDFs: they have published restrictions regarding importing/getting external stuff. In many cases (among other things, for loading notebooks which is your requirement) you'll need Player Pro (see feature table).

4- More about notebook security (which relates to the warning you mention in your question) can be found here.

-
It's a de Vries party! –  The Toad Sep 12 '12 at 21:15
@R.M I felt obliged to answer ;-) –  Sjoerd C. de Vries Sep 12 '12 at 21:16