Do not repeat yourselves or DRY way of working with AMC
Version 13 (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 | 13 | Pieter Van den Hombergh | Object oriented software design has a main principle, the _do not repeat yourselves_ or 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 | 13 | Pieter Van den Hombergh | A way of use AMC in multiple courses is a follows: |
8 | 1 | ||
9 | 13 | Pieter Van den Hombergh | Keep all questions in separate files, organised by course and subject. |
10 | 13 | Pieter Van den Hombergh | Preferably 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 | 7 | Pieter Van den Hombergh | |
14 | 13 | Pieter Van den Hombergh | Say you teach course LNX, MOD and SEN. |
15 | 3 | Pieter Van den Hombergh | Then for instance my directory structure looks a lot like this. |
16 | 1 | <pre> |
|
17 | 1 | ||
18 | 1 | âââ lnx |
|
19 | 1 | â  âââ exam |
|
20 | 1 | â  âââ builds |
|
21 | 1 | â  â  âââ 20110624 |
|
22 | 1 | â  â  âââ 20120627 |
|
23 | 1 | â  âââ questions |
|
24 | 1 | â  âââ chap1 |
|
25 | 1 | â  âââ chap2 |
|
26 | 1 | â  âââ chap3 |
|
27 | 1 | â  âââ chap4 |
|
28 | 1 | â  âââ chap5 |
|
29 | 1 | â  âââ chap6 |
|
30 | 1 | â  âââ chap7 |
|
31 | 1 | âââ mod |
|
32 | 1 | â  âââ exam |
|
33 | 1 | â  âââ builds |
|
34 | 1 | â  âââ questions |
|
35 | 4 | Pieter Van den Hombergh | âââ sen |
36 | 1 | âââ exam |
|
37 | 1 | âââ builds |
|
38 | 1 | âââ questions |
|
39 | 1 | </pre> |
|
40 | 1 | ||
41 | 13 | Pieter Van den Hombergh | Keep the question below the questions directory as in @lnx/exam/questions/chap1/cmdline1.tex@, which contain the normal |
42 | 13 | Pieter Van den Hombergh | AMC *question* and *questionmult* environments. Prepare the questions with a normal editor. |
43 | 1 | ||
44 | 8 | Pieter Van den Hombergh | h3. Role of files |
45 | 8 | Pieter Van den Hombergh | |
46 | 13 | Pieter Van den Hombergh | For each exam that you build from this, create one *exam.tex*, one *questions.tex* and one *students.csv* file in a sub directory specific to the exam instance or exam event. |
47 | 13 | Pieter Van den Hombergh | You could use the convention to use date in short iso8601 format, so 20120627 would be for the exam on 27th of June 2012. |
48 | 1 | ||
49 | 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. |
|
50 | 1 | Think of date, time of the exam, target group, subject title, teachers name and such. |
|
51 | 1 | ||
52 | 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. |
53 | 1 | A line looks like this: |
|
54 | 1 | <pre> |
|
55 | 4 | Pieter Van den Hombergh | \element{general}{\inputQ{chap1/cmdline1.tex}} |
56 | 1 | </pre> |
|
57 | 9 | 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. |
58 | 4 | Pieter Van den Hombergh | |
59 | 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, |
60 | 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. |
|
61 | 1 | ||
62 | 1 | The *students.csv* file contains the id's and names (and in my case also the exam language) for the participating students. |
|
63 | 4 | Pieter Van den Hombergh | |
64 | 4 | Pieter Van den Hombergh | h2. Using the AMC gui with the above setup |
65 | 1 | ||
66 | 13 | Pieter Van den Hombergh | You can run (and do it for testing purposes of the exams) pdflatex on the *exam.tex* file, but for a real production, use the ~/MC-projects directory and the AMC gui to do all the |
67 | 1 | nice things that AMC provides. |
|
68 | 1 | ||
69 | 13 | Pieter Van den Hombergh | To make this work you use a symbolic link *source.tex* pointing to *exam.tex* the tree explained above, for instance in the lnx exam that would be |
70 | 1 | <pre> |
|
71 | 1 | hom@threehundred:~/MC-Projects/lnx_20120629 |
|
72 | 1 | $ ls -l |
|
73 | 1 | source.tex -> ../courses/lnx/exam/builds/20120629/exam.tex |
|
74 | 1 | </pre> |
|
75 | 1 | but you could point anywhere. |
|
76 | 13 | Pieter Van den Hombergh | To make sure AMC (or more precisely, pdflatex) can find the files to link and include, you should define a few macros that help latex. |
77 | 1 | These macros are |
|
78 | 1 | <pre> |
|
79 | 1 | \def\CourseDir{/home/hom/fthv/lnx/exam} |
|
80 | 1 | \def\QuestionBaseDir{\CourseDir/questions} |
|
81 | 1 | \def\ExamInstanceDir{\CourseDir/builds/20120629} |
|
82 | 1 | </pre> |
|
83 | 13 | Pieter Van den Hombergh | It could even be dryer if you keep to conventions like questions and builds always under these names. The you only need to set the coursedir once and the date for a specific exam instance. |
84 | 1 | ||
85 | 1 | *\CourseDir* specifies the course, the *\QuestionsBaseDir* should be obvious as is the *\ExamInstanceDir*. |
|
86 | 13 | Pieter Van den Hombergh | Note that these specify absolute paths, so that pdflatex can find them, where ever your working directory and latex process directory is. |
87 | 1 | ||
88 | 13 | Pieter Van den Hombergh | You can symbolically link the students.csv to the MC-projects subdirectory. |
89 | 1 | ||
90 | 13 | Pieter Van den Hombergh | To make this exam known to AMC, start it via the gui and let it create a new *empty* exam with an appropriate name like +lnx_20120629+. Then press edit exam file, which brings up your editor with a new _source.tex_ file. Source.tex is the default file that AMC uses. This is fine. |
91 | 6 | Pieter Van den Hombergh | |
92 | 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 |
93 | 1 | <pre> |
|
94 | 1 | ln -s ../courses/lnx/exam/builds/20120629/exam.tex source.tex |
|
95 | 1 | </pre> |
|
96 | 13 | 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. You can however still use the edit button with AMC, which will then edit |
97 | 13 | Pieter Van den Hombergh | the newly linked to file. Emacs even recognises the fact that it is a symbolic link to a versioned file and ask if you want to visit the original (pointed to) file. I always say yes. |
98 | 6 | Pieter Van den Hombergh | |
99 | 13 | Pieter Van den Hombergh | Back in the AMC guy you can then complete all steps to create the pdf file, check the layouts, print the stuff and after the exam process all. |
100 | 2 | Pieter Van den Hombergh | |
101 | 13 | Pieter Van den Hombergh | To make the automatic association and thus producing a personal exam per student, you can use the macros as proposed by Alexis Bienvenüe in ticket #32. |
102 | 5 | Pieter Van den Hombergh | |
103 | 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, |
104 | 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. |
105 | 1 | Use them freely as a base to clarify questions and answers with respect to this DRY way of working. |
|
106 | 10 | Pieter Van den Hombergh | |
107 | 10 | Pieter Van den Hombergh | h3. Use of the toyexam |
108 | 10 | Pieter Van den Hombergh | Unzip it somewhere conventient. |
109 | 12 | Pieter Van den Hombergh | Create a new exam in the AMC gui e.g., toyexam1 and let the source.tex file point to the *.../toyexam/40_exam/builds/exam1/exam.tex* file. |
110 | 12 | Pieter Van den Hombergh | The names of the directories may differ a bit from the description above, but it is the internal convention we use in our institute. |
111 | 11 | Pieter Van den Hombergh | |
112 | 12 | Pieter Van den Hombergh | The subdir *exam2* now contains a complete working example of using a students.csv and auto association. |
113 | 13 | Pieter Van den Hombergh | Link the exam.tex file in the way as described above. |