Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I teach an Intro to Mathematica course, and one of the things I try to reinforce early on is just how helpful Mathematica's help is. In the very first lab for the course, I even give the students a randomly selected command (from among simple ones like PrimeQ, IntegerDigits, etc.) and ask them to tell me what that command does. As of right now, they get this question right if they correctly explain what the given command does.

What I'd like to do is make sure they are actually going to the help. Is there some way to capture an F1 key press within an EventHandler or something similar?

share|improve this question
    
If it helps, MemberQ[Contexts[], "DocumentationSearch`"] will only start returning True after the documentation search has been used at least once in the session ... Otherwise I think it's really the students' responsibility to listen to something as simple as "use the documentation!" –  Szabolcs Feb 7 at 19:02
1  
Trying to make sure they press F1 may not be such a good idea... what if they go to help by typing ? or by searching google? If you want to make sure they go to help, ask a question like: how many items are there in the examples subsection of the help page? –  bill s Feb 7 at 19:20
    
So you are giving them notebook with questions and you want to check this? –  Kuba Feb 7 at 19:51
    
    
@bills: I actually would like to make sure they visit the help, however they do it. It's just that I explain the F1 option to them in class, which is why I would expect most would go that route. –  Steve D Feb 7 at 21:15
add comment

2 Answers

up vote 3 down vote accepted

You could add a trap to Documentation`HelpLookup which is called when F1 is pressed:

Unprotect[Documentation`HelpLookup];
Documentation`HelpLookup[link_String, nb_, lang_String, opts : OptionsPattern[]] :=
 Block[{$inblock = True},
       lookedup[link] = True;
       Documentation`HelpLookup[link, nb, opts]] /; ! TrueQ[$inblock]

You can add whatever code you want. As an example I assign a downvalue to lookedup so the searched expressions can be viewed with ? lookedup

share|improve this answer
    
It seems it is called whenever documentation page is opened. So not only with F1 but also when you dig throught See also... or if you open documentation in menu. –  Kuba Feb 7 at 20:54
1  
Heh, poor Mr.Wizard... he's gonna lose a grade by wasting time counting leaves :D –  rm -rf Feb 7 at 20:54
    
@rm-rf, ha ha. I didn't see that question 2 days ago, I was hoping everyone would be stunned by my spelunking skills, now it just looks like I'm copying from higher rep users ;-) –  Simon Woods Feb 7 at 21:09
    
This is great, but is there any way to store the lookedup variable between sessions? The students will do the lab, close it, send it to me, then I open it. Any way I can still find out what help items they've visited? –  Steve D Feb 7 at 21:12
1  
@SteveD "but how does one store a value in a notebook?" --> use TaggingRules! This is better than making up an option like Stored and it was recommended in the past as the solution to use. 1. Check the value of CurrentValue[SelectedNotebook[], {TaggingRules, "lookups"}]. If it's "Inherited", then initialize it: CurrentValue[SelectedNotebook[], {TaggingRules, "lookups"}] = {}. Then keep appending AppendTo[CurrentValue[ SelectedNotebook[], {TaggingRules, "lookups"}], "asd"]. When they save the notebook, this gets saved with it. –  Szabolcs Feb 8 at 3:04
show 6 more comments

This is my idea.

If you give them the notebook with questions just put the following code in the cell with a question text (as InlineCell Alt+9)

DynamicModule[{},
 DynamicWrapper["test",
   Refresh[
    help = DeleteDuplicates @ Join[help, "WindowTitle" /. NotebookInformation /@
    Select[Notebooks[], ("DocumentType" /. NotebookInformation[#]) == "Help" &]]
    , UpdateInterval -> .5]]
 , Initialization :> (help = {};)]

Then EvaluateInPlace this with Ctrl+Shift+Enter or via menu.

There is now variable help that will show you which documentation pages were opened.

Test this with

Dynamic@help
{Dynamic - Wolfram Mathematica, Animate - Wolfram Mathematica,...}

You can work on this to get the date etc. The only problem is it will show a message that the notebook contains dynamic content.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.