rma...@mun.ca writes: > Hello, > > Has anyone used Org to create exams? It would be useful to have the > value per question totalled to provide the total per section etc and to > be able to embed the answers in the exam and expose them in the final > document using some kind of conditional processing. > > If anyone has done this kind of thing I'd be interested to see an > example file.
I've done part of it (not the value of the questions, but including the answers in the source). For an exam I gave last year on the OCaml language, I put the solution for the code questions in the source, and use it to generate the expected type of the function. (This way I could also make sure I was not asking to code something too difficult.) Here is part of the exam (sorry, it's in French, but it should give you the general idea). I also include the beginning of the file since I've found that more examples about how to set things up always helps. There are two kinds of code blocks below: those with results "silent" are just used to add some things to the session (OCaml works by default with a session in org), those with results "verbatim" export the result of evaluating of the source, which is what the toplevel answers (i.e., the type). --8<---------------cut here---------------start------------->8--- # -*- org-confirm-babel-evaluate: nil -*- #+begin_src emacs-lisp :results silent :exports none (setq org-export-latex-minted-options '(("frame" "lines") )) (add-to-list 'org-structure-template-alist '("Q" "#+BEGIN_question\n?\n#+END_question" "<question>\n?\n</question>")) #+end_src #+TITLE: Programmation Fonctionnelle #+DATE: jeudi 6 juin 2013 #+Author: #+LANGUAGE: fr #+OPTIONS: num:t toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t #+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc #+EXPORT_SELECT_TAGS: export #+EXPORT_EXCLUDE_TAGS: noexport #+LATEX_CMD: xelatex #+LaTeX_HEADER: \usepackage{lastpage} #+LaTeX_HEADER: \usepackage{tikz} #+LaTeX_HEADER: \usepackage{minted} #+LaTeX_HEADER: \usemintedstyle{emacs} \newtheorem{question}{Question} * Arbres binaires annotés Les fonctions demandées dans les questions suivantes peuvent dépendre les unes des autres. Vous pouvez toujours utiliser les fonctions que vous ne savez pas définir. ** Définition du type #+BEGIN_question Définir un type polymorphe ~('a,'b) tree~ représentant un arbre annoté. Les constructeurs de ce type seront l'arbre vide ~Emp~ contenant une annotation de type ~('a)~, une feuille ~Leaf~ contenant une annotation de type ~('a)~ et une valeur de type ~('b)~, et un nœud ~Node~ contenant une annotation de type ~('a)~, un sous-arbre gauche et un sous-arbre droit. #+END_question #+name: treetype #+BEGIN_SRC ocaml :results silent :exports results type ('a,'b) tree = | Emp of 'a | Leaf of 'a * 'b | Node of 'a * ('a,'b) tree * ('a,'b) tree #+END_SRC Dans les questions suivantes, il faudra maintenir l'invariant suivant: un arbre est soit vide (constructeur ~Emp~), soit il ne contient pas de sous-arbre vide (tous les sous-arbres sont soit ~Leaf~ soit ~Node~). #+BEGIN_question Écrire une fonction ~tag~ prenant un arbre et renvoyant son annotation. #+END_question #+name: tag #+BEGIN_SRC ocaml :results code verbatim :exports results let tag = function | Emp a -> a | Leaf (a,_) -> a | Node (a,_,_) -> a #+END_SRC --8<---------------cut here---------------end--------------->8--- Alan