1 | # CodeGradXagent
|
2 |
|
3 | CodeGradXagent is a script providing a command line interface to ease
|
4 | interaction with the CodeGradX infrastructure. It internally uses the
|
5 | CodeGradXlib library (an npm module) that runs on top of Node.js.
|
6 | Reading the [page associated to the CodeGradXlib
|
7 | ](https://www.npmjs.com/package/codegradxlib)
|
8 | npm module is recommended.
|
9 |
|
10 | People interested in that script are mainly teachers wanting to mark a
|
11 | batch of students' files or authors of exercises. Basic knowledge of
|
12 | command line interface is required to automatize interactions with the
|
13 | CodeGradX infrastructure. Others may prefer a Web interface.
|
14 |
|
15 | ## Installation
|
16 |
|
17 | ```javascript
|
18 | npm install codegradxagent
|
19 | ```
|
20 |
|
21 | Caution, if you are an author and wants to use the virtual machine for
|
22 | authors, named [VMauthor
|
23 | ](http://paracamplus.com/CodeGradX/VM/CodeGradX-VMauthor-latest.img.bz2).
|
24 | You should also install the [codegradxvmauthor
|
25 | ](https://www.npmjs.com/package/codegradxvmauthor) module that configures the
|
26 | agent to use VMauthor rather than the real constellation of servers.
|
27 | See how to authenticate with VMauthor in the `codegradxvmauthor`
|
28 | documentation.
|
29 |
|
30 | ## Usage
|
31 |
|
32 | You may run this script with the regular CodeGradX infrastructure with
|
33 | node as (where `...` is a path leading to the script):
|
34 |
|
35 | ```sh
|
36 | node .../codegradxagent.js
|
37 | ```
|
38 |
|
39 | If the `codegradxagent` script is executable, you may simply write:
|
40 |
|
41 | ```sh
|
42 | .../codegradxagent.js
|
43 | ```
|
44 |
|
45 | And, if `codegradxagent` is on your PATH, you just write:
|
46 |
|
47 | ```sh
|
48 | codegradxagent.js
|
49 | ```
|
50 |
|
51 | By default or with the `-h` or `--help` options, the script prints a
|
52 | short summary of the possible options.
|
53 |
|
54 | Two other global options, `-v` or `-V`, ask the codegradxagent to
|
55 | be verbose and to show what it does. The second option also asks the
|
56 | CodeGradXlib library to be verbose.
|
57 |
|
58 | ### Authentication
|
59 |
|
60 | You cannot use the CodeGradX infrastructure if you are not registered
|
61 | that is, you have a login and a password. These login and password may
|
62 | be passed with the `--user` and `--password` options. Since that last
|
63 | option may reveal your password to other users of your computer, you
|
64 | may prefer to use a credentials file (by default, this file is named
|
65 | `.fw4ex.json`). You mention that credentials file with the
|
66 | `--credentials` option. When authenticated, the CodeGradX
|
67 | infrastructure identifies you with a safe-cookie (a ciphered cookie).
|
68 | This cookie is available for some hours so it may be stored in your
|
69 | credentials file using the `--update-credentials` option.
|
70 | Therefore, a series of invocations of the script starts often with
|
71 |
|
72 | ```bash
|
73 | $ cat .fw4ex.json
|
74 | { "user": "myLogin",
|
75 | "password": "myPassword"
|
76 | }
|
77 | $ ./codegradxagent.js --update-credentials
|
78 | ```
|
79 |
|
80 |
|
81 |
|
82 | ### Sending an answer against an exercise
|
83 |
|
84 | An exercise is identified by a safe-cookie (a long string of
|
85 | characters). An exercise is specified by the `--exercise` option, the
|
86 | associated value may take several forms, all of them yielding a
|
87 | safe-cookie.
|
88 |
|
89 | If you are the author of an exercise then, when this exercise was
|
90 | checked and deployed, its safe-cookie was returned to you in the
|
91 | authorExerciseReport file, say `2-exerciseAuthorReport.xml`.
|
92 | Then `--exercise=file:2-exerciseAuthorReport.xml` allows the
|
93 | CodeGradXagent to extract the safe-cookie from that file.
|
94 |
|
95 | If the exercise is part of a campaign you can access, say this is the
|
96 | 3rd exercise of a campaign named `free`, then saying `--exercise
|
97 | campaign:free#2` will extract the safe-cookie associated to that third
|
98 | exercise.
|
99 |
|
100 | Once you know how to get the safe-cookie identifying an exercise, you
|
101 | may send an answer to that exercise. Depending on the exercise, the
|
102 | expected answer may be a single file or a bunch of files. The answer
|
103 | should be packed within a tar gzipped file, say `answer.tgz` and sent
|
104 | with the `--stuff` option as in:
|
105 |
|
106 | ```bash
|
107 | $ ./codegradxagent.js -t job -e 'campaign:free#2' --stuff answer.tgz
|
108 | ```
|
109 |
|
110 | The `-t` or `--type` option specifies that we send an answer against
|
111 | an exercise.
|
112 |
|
113 | #### Produced files
|
114 |
|
115 | The CodeGradX infrastructure is operated via REST protocols,
|
116 | interactions often yields reports in XML or JSON. These reports are
|
117 | stored in the directory specified by `--xmldir` (by default the
|
118 | current directory), their name is prefixed by an integer starting with
|
119 | the value of `--counter` (by default `0`). For instance, the
|
120 | previous command will produce some reports:
|
121 | - `1-jobSubmittedReport.xml` an intermediate report acknowledging the
|
122 | reception of a job to mark
|
123 | - `2-jobStudentReport.xml` the grading report containing the mark
|
124 | given to the answer as well as a (perhaps lengthy) description of
|
125 | the tests performed on the answer.
|
126 | - `3-jobStudentReport.html` an HTML translation of the grading report.
|
127 | You may prefer to run your own translation (this one is not very
|
128 | good).
|
129 | - `4-jobProblemReport.xml` is intended for authors of exercises and
|
130 | contains information related to the bad behavior of the exercise.
|
131 | The most common errors are that the output of the exercise is
|
132 | invalid with respect to the XML grammar or some grading script is
|
133 | erroneous.
|
134 |
|
135 | #### Time management
|
136 |
|
137 | Some exercises may require a number of seconds to grade an answer. On
|
138 | the other hand, some answers may loop or be stuck, they will be killed
|
139 | once a given duration set by the author of the exercise is overrun.
|
140 | Therefore three other options exist dealing with time:
|
141 |
|
142 | - `offset` (by default 0 second) tells the script to wait that number of
|
143 | seconds before attempting to fetch the grading report.
|
144 | - `retry` (by default 30) tells the script to try to fetch the grading
|
145 | report at most that number.
|
146 | - `timeout` (by default 5 seconds, cannot be less than 5) tells the
|
147 | script to wait that number of seconds before any two attempts to
|
148 | fetch the grading report.
|
149 |
|
150 | ### Sending a batch against an exercise
|
151 |
|
152 | The `--type` option should now be set to `batch`.
|
153 |
|
154 | The identification of the exercise does not vary.
|
155 |
|
156 | A batch of students' answers is described by a manifest, a `fw4ex.xml`
|
157 | file. Suppose for instance that we have the two students' files
|
158 | `1.tgz` and `2.tgz` then the manifest may look like:
|
159 |
|
160 | ```sh
|
161 | $ cat fw4ex.xml
|
162 | <?xml version='1.0' encoding='UTF-8' ?>
|
163 | <fw4ex version='1.0'>
|
164 | <multiJobSubmission label='batch.test.sh.1'>
|
165 | <job label='premiere' filename='1.tgz' />
|
166 | <job label='seconde' filename='2.tgz' />
|
167 | </multiJobSubmission>
|
168 | </fw4ex>
|
169 | ```
|
170 |
|
171 | The whole batch file is then created and sent as:
|
172 |
|
173 | ```bash
|
174 | $ tar czf /tmp/batch1.tgz fw4ex.xml 1.tgz 2.tgz
|
175 | $ ./codegradxagent.js -t batch -e 'campaign:free#2' \
|
176 | --stuff /tmp/batch1.tgz \
|
177 | --offset=30 --timeout=25 --retry 5 \
|
178 | --xmldir /tmp/ --counter=100 \
|
179 | --follow
|
180 | ```
|
181 |
|
182 | #### Produced files
|
183 |
|
184 | The `--follow` option tells the script to fetch the grading reports of
|
185 | the students as soon as they are graded. They will be stored in the
|
186 | `/tmp/` directory with names prefixed by numbers starting at 100.
|
187 |
|
188 | Some files are produced:
|
189 | - `101-multiJobSubmittedReport.xml` acknowledges the reception of the batch
|
190 | - `102-multiJobStudentReport.xml` is the batch instantaneous report in
|
191 | which appears the references to the students' grading reports as
|
192 | well as how many reports are graded.
|
193 | - `103-jobStudentReport.xml` grading report of the first answer with
|
194 | label `premiere`
|
195 | - etc.
|
196 |
|
197 | #### Resumption
|
198 |
|
199 | The management of time does not vary but, of course, should accomodate
|
200 | the number of students' answers to be graded. If it appears that you
|
201 | mention a too short duration and miss some students' grading report,
|
202 | you may resume your script with:
|
203 |
|
204 | ```bash
|
205 | $ ./codegradxagent.js --resume 101-multiJobSubmittedReport.xml --follow
|
206 | ```
|
207 |
|
208 | ### Submitting an exercise
|
209 |
|
210 | The `--type` option should now be set to `exercise`.
|
211 |
|
212 | An exercise is a somewhat complex tar gzipped file (see more thorough
|
213 | documentation) that may be submitted as:
|
214 |
|
215 | ```bash
|
216 | $ ./codegradxagent.js -t exercise --stuff
|
217 | ```
|
218 |
|
219 | Since an exercise contains a number of answers of pseudo-students, it
|
220 | may take some time to check that all these answers are appropriately
|
221 | graded: you must manage time accordingly.
|
222 |
|
223 | #### Produced files
|
224 |
|
225 | The `--follow` option tells the script to fetch the grading reports of
|
226 | the pseudo-students once graded.
|
227 |
|
228 | Some files are produced:
|
229 | - `1-exerciseSubmittedReport.xml` acknowledges the reception of the exercise
|
230 | - `2-exerciseAuthorReport.xml` is the final report where appears the
|
231 | safe-cookie of the exercise if no problem was detected.
|
232 |
|
233 | #### Resumption
|
234 |
|
235 | The management of time does not vary but, of course, should accomodate
|
236 | the number of students' answers to be graded. If it appears that you
|
237 | mention a too short duration, you may resume your script and ask
|
238 | for the grading reports of the pseudo-jobs with:
|
239 |
|
240 | ```bash
|
241 | $ ./codegradxagent.js --resume 1-exerciseSubmittedReport.xml --follow
|
242 | ```
|
243 |
|
244 | You may also set new options for time management.
|
245 |
|
246 | ## Miscellaneous
|
247 |
|
248 | The `Samples` directory contains examples of XML files obtained
|
249 | from the CodeGradX infrastructure.
|
250 |
|
251 | Some features of the underlying library `codegradxlib` cannot be
|
252 | operated through `codegradxagent`. The most prominent one is probably
|
253 | the history of the user: its past jobs, batches and exercises.
|
254 |
|
255 | New features such as sending a whole directory as an exercise, checking
|
256 | the manifest `fw4ex.xml` could be added.
|