emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: Roger Mason <rmason@mun.ca>
Cc: org-mode <emacs-orgmode@gnu.org>
Subject: Re: Exams with Org?
Date: Sat, 07 Dec 2013 23:00:57 +0100	[thread overview]
Message-ID: <m27gbg48yu.fsf@polytechnique.org> (raw)
In-Reply-To: <52A22441.2050704@mun.ca>

rmason@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

  parent reply	other threads:[~2013-12-07 22:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-06 19:23 Exams with Org? Roger Mason
2013-12-06 21:41 ` Suvayu Ali
2013-12-06 22:26 ` John Kitchin
2013-12-07 22:00 ` Alan Schmitt [this message]
2013-12-08 11:35 ` Roger Mason
2013-12-08 20:55   ` John Kitchin
2013-12-08 21:40     ` John Kitchin
  -- strict thread matches above, loose matches on Subject: below --
2013-12-07  2:21 Marvin Doyley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m27gbg48yu.fsf@polytechnique.org \
    --to=alan.schmitt@polytechnique.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=rmason@mun.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).