4
$\begingroup$

Is it possible to create a (graphical) interface with Mathematica so that instead of having a Mathematica document where I change definitions and so on, I can just input values and it will use my code to compute things and display the results?

This would be helpful in an exam situation, where one is time-pressed. It is allowed in my situation (I have asked).

I am going to use this myself for my own written exams.

Example:

I input a function and it computes the partial derivatives, gradient and directional derivative.

If you have other ideas, please tell me!

UPDATE:

Please continue telling about your exam workflow/interface/ideas, even though I have accepted an answer!

$\endgroup$
  • $\begingroup$ This seems ideally suited for the Computable Document Format $\endgroup$ – Jason B. Jan 8 '16 at 14:50
  • $\begingroup$ @JasonB That seems promising. I need several sections for computing different things. $\endgroup$ – macurie Jan 8 '16 at 14:52
  • $\begingroup$ How much do you need to lock it down? You could just put all your code into a cell that is not open, not editable, and has the property of being an initialization cell, so that it is evaluated as soon as any other cell in the notebook is evaluated. But, I think if they wanted to, they could click on the cell icon on the right, seen here: i.imgur.com/e6tlqOp.png, and make it editable and open. $\endgroup$ – Jason B. Jan 8 '16 at 14:57
  • $\begingroup$ @JasonB If you mean "obfuscate" by "lock down" I don't need to lock it down at all, what matters is that it's practical and fast to use. $\endgroup$ – macurie Jan 8 '16 at 15:03
  • $\begingroup$ This and this and this can help on how to hide cells and use a regular notebook in making a test - but if they go looking they will always be able to find the underlying code, I don't see how to password protect the code. $\endgroup$ – Jason B. Jan 8 '16 at 15:04
4
$\begingroup$

You could take some code like this (with a nod to this answer)

Manipulate[
 update;
 resultlabels = (Subscript["\[PartialD]", ToString@#] & /@ varlist)~
   Join~{"\[Del]"};
 results = (D[f, #] & /@ varlist)~Join~{Grad[f, varlist]};
 Grid[
  Transpose[
   {resultlabels,
    ConstantArray["f =", Length@varlist + 1],
    results}
   ]
  ],
 {{f, x^3 Sin[x - y], "f="}, InputField},
 {{varlist, {x, y}, "Variables"}, InputField}, {{update, 0}, None}, 
 Button["update", update++], TrackedSymbols :> {update}
 ]

Then click on the cell brackets beside it, go to Cell Propterties and uncheck "Open" and check "Initialization Cell"

Next, put some cell at the top where they enter their name or something, save it.

When they open it, it will look like this: enter image description here

Have them enter their name and hit Shift+Enter, this will pop up,

enter image description here

Hit Yes, and then you see the Dynamic object,

enter image description here

You can do whatever you like in the Dynamic, there are plenty of cool examples around.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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