Do not repeat yourselves or DRY way of working with AMC

Version 3 (Pieter Van den Hombergh, 01/19/2013 12:06 am)

1 1
h1. Do not repeat yourselves or DRY way of working with AMC
2 1
3 3 Pieter Van den Hombergh
I am from a object oriented software engineering school and one main principle of OO is _do not repeat yourselves_ (DRY principle), that is,
4 1
optimize your design in such a way that you do not duplicate (your work on) anything.
5 1
Some people could say it is a way of being lazy, which is fine by me, as long as you compensate that with sufficient cleverness.
6 1
7 1
The way I use AMC in multiple courses is a follows:
8 1
9 2 Pieter Van den Hombergh
I keep all questions in separate files, organised by course and subject.
10 1
I also keep them in a version control system. At the moment that is subversion.
11 1
12 1
Say I teach course LNX, MOD and SEN.
13 3 Pieter Van den Hombergh
Then for instance my directory structure looks a lot like this.
14 1
<pre>
15 1
16 1
├── lnx
17 1
│   └── exam
18 1
│       ├── builds
19 1
│       │   ├── 20110624
20 1
│       │   └── 20120627
21 1
│       └── questions
22 1
│           ├── chap1
23 1
│           ├── chap2
24 1
│           ├── chap3
25 1
│           ├── chap4
26 1
│           ├── chap5
27 1
│           ├── chap6
28 1
│           └── chap7
29 1
├── mod
30 1
│   └── exam
31 1
│       ├── builds
32 1
│       └── questions
33 1
└── se
34 1
    └── exam
35 1
        ├── builds
36 1
        └── questions
37 1
</pre>
38 1
39 3 Pieter Van den Hombergh
I keep the question below the questions directory as in @lnx/exam/questions/chap1/cmdline1.tex@, which contain the normal
40 1
amc *question* and *questionmult* environments. I prepare the questions with a normal editor (I normally use _emacs_, yes, I am already that old).
41 1
42 1
For each exam that I build from this I create one *exam.tex*, one *questions.tex* and one *students.csv* file in a sub directory specific to the exam instance or exam event.
43 1
I have the convention to use date in short iso8601 format, so 20120627 would be for the exam on 27th of June 2012.
44 1
45 1
The *exam.tex* file defines all the things that describe the exam and these details are put mostly on the frontpage of each exam.
46 1
Think of date, time of the exam, target group, subject title, teachers name and such.
47 1
48 3 Pieter Van den Hombergh
The *questions.tex* file is a more or less simple file with one line specifying the question and the AMC-element group (the element group is what AMC uses to randomize the question order). A *questions.tex* file for a typical exam contains 30 or 40 such lines.
49 1
A line looks like this:
50 1
<pre>
51 1
\element{general}{\inputQ{lpic101-101-1/o004.tex}}
52 1
</pre>
53 2 Pieter Van den Hombergh
Keeping the questions separate from the exam file eases the way to create it, for instance from an spread sheet or a database query and also eases the comparison with earlier exams, 
54 1
so one can easily see if there is not to much overlap in questions for instance for a resit of an exam with (a subset) of the same audience.
55 1
56 3 Pieter Van den Hombergh
The *students.csv* file contains the id's and names (and in my case also the exam language) for the participating students.
57 1
58 3 Pieter Van den Hombergh
I can run (and do it for testing purposes of the exams) pdflatex on the *exam.tex* file, but for a real production I use the MC-projects directory and the AMC gui to do all the 
59 1
nice things that AMC provides.
60 1
61 1
To make this work I use a symbolic link *source.tex* pointing to *exam.tex* the tree explained above, for instance in the lnx exam that would be
62 1
<pre>
63 1
hom@threehundred:~/MC-Projects/lnx_20120629
64 3 Pieter Van den Hombergh
$ ls -l
65 1
source.tex -> ../courses/lnx/exam/builds/20120629/exam.tex
66 1
</pre>
67 1
but you could point anywhere.
68 1
To make sure AMC (or more precisely, pdflatex) can find the files to link and include I define a few macros that help latex.
69 1
These macros are  
70 1
<pre>
71 1
\def\CourseDir{/home/hom/fthv/lnx/exam}
72 1
\def\QuestionBaseDir{\CourseDir/questions}
73 1
\def\ExamInstanceDir{\CourseDir/builds/20120629}
74 1
</pre>
75 1
76 1
*\CourseDir* specifies the course, the *\QuestionsBaseDir* should be obvious as is the *\ExamInstanceDir*.
77 1
Note that they specify absolute paths, so that pdflatex can find them, where ever your working directory and latex process directory is.
78 1
79 2 Pieter Van den Hombergh
I also symbolically link the students.csv to the MC-projects subdirectory.
80 2 Pieter Van den Hombergh
81 2 Pieter Van den Hombergh
To make this exam known to AMC, I start it via the gui and let I create a new *empty* exam with an appropriate name like lnx_20120629. Then I press edit exam file, which brings up my editor with a new source.tex file.
82 3 Pieter Van den Hombergh
I save that file and close the editor, cd  (in a terminal window) to the ~/MC-projects/lnx_20120629 subdirectory and create the symbolic link with 
83 2 Pieter Van den Hombergh
<pre>
84 2 Pieter Van den Hombergh
ln -s ../courses/lnx/exam/builds/20120629/exam.tex source.tex
85 2 Pieter Van den Hombergh
</pre>
86 2 Pieter Van den Hombergh
Back in the AMC guy I complete all steps to create the pdf file, check the layouts, print the stuff and after the exam process all.
87 2 Pieter Van den Hombergh
88 3 Pieter Van den Hombergh
To make the automatic association and thus producing a personal exam per student, I use the macros as proposed by Alexis Bienvenüe in ticket #32.