Do not repeat yourselves or DRY way of working with AMC
Version 6 (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 | 6 | Pieter Van den Hombergh | h2. Directory structure |
13 | 1 | Say I teach course LNX, MOD and SEN. |
|
14 | 3 | Pieter Van den Hombergh | Then for instance my directory structure looks a lot like this. |
15 | 1 | <pre> |
|
16 | 1 | ||
17 | 1 | âââ lnx |
|
18 | 1 | â  âââ exam |
|
19 | 1 | â  âââ builds |
|
20 | 1 | â  â  âââ 20110624 |
|
21 | 1 | â  â  âââ 20120627 |
|
22 | 1 | â  âââ questions |
|
23 | 1 | â  âââ chap1 |
|
24 | 1 | â  âââ chap2 |
|
25 | 1 | â  âââ chap3 |
|
26 | 1 | â  âââ chap4 |
|
27 | 1 | â  âââ chap5 |
|
28 | 1 | â  âââ chap6 |
|
29 | 1 | â  âââ chap7 |
|
30 | 1 | âââ mod |
|
31 | 1 | â  âââ exam |
|
32 | 1 | â  âââ builds |
|
33 | 1 | â  âââ questions |
|
34 | 4 | Pieter Van den Hombergh | âââ sen |
35 | 1 | âââ exam |
|
36 | 1 | âââ builds |
|
37 | 1 | âââ questions |
|
38 | 1 | </pre> |
|
39 | 1 | ||
40 | 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 |
41 | 1 | amc *question* and *questionmult* environments. I prepare the questions with a normal editor (I normally use _emacs_, yes, I am already that old). |
|
42 | 1 | ||
43 | 6 | Pieter Van den Hombergh | h3. Role of files |
44 | 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. |
|
45 | 1 | I have the convention to use date in short iso8601 format, so 20120627 would be for the exam on 27th of June 2012. |
|
46 | 1 | ||
47 | 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. |
|
48 | 1 | Think of date, time of the exam, target group, subject title, teachers name and such. |
|
49 | 1 | ||
50 | 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. |
51 | 1 | A line looks like this: |
|
52 | 1 | <pre> |
|
53 | 4 | Pieter Van den Hombergh | \element{general}{\inputQ{chap1/cmdline1.tex}} |
54 | 1 | </pre> |
|
55 | 4 | Pieter Van den Hombergh | The macro <pre>\inputQ</pre> is no more then an abbrivation of <pre>\input{\QuestionBaseDir/#1</pre>, of which *\QuestionBaseDir* is explained below. |
56 | 4 | Pieter Van den Hombergh | |
57 | 4 | Pieter Van den Hombergh | Keeping the questions separate from the exam file eases the way to create this file, for instance from a spread-sheet or a database query and also eases the comparison with earlier exams, |
58 | 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. |
|
59 | 1 | ||
60 | 1 | The *students.csv* file contains the id's and names (and in my case also the exam language) for the participating students. |
|
61 | 4 | Pieter Van den Hombergh | |
62 | 4 | Pieter Van den Hombergh | h2. Using the AMC gui with the above setup |
63 | 1 | ||
64 | 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 |
65 | 1 | nice things that AMC provides. |
|
66 | 1 | ||
67 | 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 |
|
68 | 1 | <pre> |
|
69 | 1 | hom@threehundred:~/MC-Projects/lnx_20120629 |
|
70 | 3 | Pieter Van den Hombergh | $ ls -l |
71 | 1 | source.tex -> ../courses/lnx/exam/builds/20120629/exam.tex |
|
72 | 1 | </pre> |
|
73 | 1 | but you could point anywhere. |
|
74 | 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. |
|
75 | 1 | These macros are |
|
76 | 1 | <pre> |
|
77 | 1 | \def\CourseDir{/home/hom/fthv/lnx/exam} |
|
78 | 1 | \def\QuestionBaseDir{\CourseDir/questions} |
|
79 | 1 | \def\ExamInstanceDir{\CourseDir/builds/20120629} |
|
80 | 1 | </pre> |
|
81 | 1 | ||
82 | 1 | *\CourseDir* specifies the course, the *\QuestionsBaseDir* should be obvious as is the *\ExamInstanceDir*. |
|
83 | 1 | Note that they specify absolute paths, so that pdflatex can find them, where ever your working directory and latex process directory is. |
|
84 | 1 | ||
85 | 1 | I also symbolically link the students.csv to the MC-projects subdirectory. |
|
86 | 1 | ||
87 | 6 | 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. Source.tex is the default file that AMC uses and I am fine with this name. |
88 | 6 | Pieter Van den Hombergh | |
89 | 6 | 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 |
90 | 1 | <pre> |
|
91 | 1 | ln -s ../courses/lnx/exam/builds/20120629/exam.tex source.tex |
|
92 | 1 | </pre> |
|
93 | 6 | Pieter Van den Hombergh | This of course removes the auto generated source.tex file and replaces it with a link to the real exam file. |
94 | 6 | Pieter Van den Hombergh | |
95 | 6 | Pieter Van den Hombergh | Back in the AMC guy I then complete all steps to create the pdf file, check the layouts, print the stuff and after the exam process all. |
96 | 2 | Pieter Van den Hombergh | |
97 | 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. |
98 | 5 | Pieter Van den Hombergh | |
99 | 5 | Pieter Van den Hombergh | The toyexam.zip attached to this page is a copy of my current collection of test questions, which we can freely use and distribute (unless you teach European topology, |
100 | 5 | Pieter Van den Hombergh | then you might want to use the questions in a real exam). Anyway, they are the same kind of questions that the maintainers of AMC use to test various features and question type. |
101 | 5 | Pieter Van den Hombergh | |
102 | 5 | Pieter Van den Hombergh | Use them freely as a base to clarify questions and answers with respect to this DRY way of working. |