UNPKG

9.13 kBMarkdownView Raw
1# CodeGradXagent
2
3CodeGradXagent is a script providing a command line interface to ease
4interaction with the CodeGradX infrastructure. It internally uses the
5CodeGradXlib library (an npm module) that runs on top of Node.js.
6Reading the [page associated to the CodeGradXlib
7](https://www.npmjs.com/package/codegradxlib)
8npm module is recommended.
9
10People interested in that script are mainly teachers wanting to mark a
11batch of students' files or authors of exercises. Basic knowledge of
12command line interface is required to automatize interactions with the
13CodeGradX infrastructure. Others may prefer a Web interface.
14
15## Installation
16
17```javascript
18npm install codegradxagent
19```
20
21Caution, if you are an author and wants to use the virtual machine for
22authors, named [VMauthor
23](http://paracamplus.com/CodeGradX/VM/CodeGradX-VMauthor-latest.img.bz2).
24You should also install the [codegradxvmauthor
25](https://www.npmjs.com/package/codegradxvmauthor) module that configures the
26agent to use VMauthor rather than the real constellation of servers.
27See how to authenticate with VMauthor in the `codegradxvmauthor`
28documentation.
29
30## Usage
31
32You may run this script with the regular CodeGradX infrastructure with
33node as (where `...` is a path leading to the script):
34
35```sh
36node .../codegradxagent.js
37```
38
39If the `codegradxagent` script is executable, you may simply write:
40
41```sh
42.../codegradxagent.js
43```
44
45And, if `codegradxagent` is on your PATH, you just write:
46
47```sh
48codegradxagent.js
49```
50
51By default or with the `-h` or `--help` options, the script prints a
52short summary of the possible options.
53
54Two other global options, `-v` or `-V`, ask the codegradxagent to
55be verbose and to show what it does. The second option also asks the
56CodeGradXlib library to be verbose.
57
58### Authentication
59
60You cannot use the CodeGradX infrastructure if you are not registered
61that is, you have a login and a password. These login and password may
62be passed with the `--user` and `--password` options. Since that last
63option may reveal your password to other users of your computer, you
64may 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
67infrastructure identifies you with a safe-cookie (a ciphered cookie).
68This cookie is available for some hours so it may be stored in your
69credentials file using the `--update-credentials` option.
70Therefore, 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
84An exercise is identified by a safe-cookie (a long string of
85characters). An exercise is specified by the `--exercise` option, the
86associated value may take several forms, all of them yielding a
87safe-cookie.
88
89If you are the author of an exercise then, when this exercise was
90checked and deployed, its safe-cookie was returned to you in the
91authorExerciseReport file, say `2-exerciseAuthorReport.xml`.
92Then `--exercise=file:2-exerciseAuthorReport.xml` allows the
93CodeGradXagent to extract the safe-cookie from that file.
94
95If the exercise is part of a campaign you can access, say this is the
963rd exercise of a campaign named `free`, then saying `--exercise
97campaign:free#2` will extract the safe-cookie associated to that third
98exercise.
99
100Once you know how to get the safe-cookie identifying an exercise, you
101may send an answer to that exercise. Depending on the exercise, the
102expected answer may be a single file or a bunch of files. The answer
103should be packed within a tar gzipped file, say `answer.tgz` and sent
104with the `--stuff` option as in:
105
106```bash
107$ ./codegradxagent.js -t job -e 'campaign:free#2' --stuff answer.tgz
108```
109
110The `-t` or `--type` option specifies that we send an answer against
111an exercise.
112
113#### Produced files
114
115The CodeGradX infrastructure is operated via REST protocols,
116interactions often yields reports in XML or JSON. These reports are
117stored in the directory specified by `--xmldir` (by default the
118current directory), their name is prefixed by an integer starting with
119the value of `--counter` (by default `0`). For instance, the
120previous 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
137Some exercises may require a number of seconds to grade an answer. On
138the other hand, some answers may loop or be stuck, they will be killed
139once a given duration set by the author of the exercise is overrun.
140Therefore 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
152The `--type` option should now be set to `batch`.
153
154The identification of the exercise does not vary.
155
156A batch of students' answers is described by a manifest, a `fw4ex.xml`
157file. 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
171The 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
184The `--follow` option tells the script to fetch the grading reports of
185the 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
188Some 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
199The management of time does not vary but, of course, should accomodate
200the number of students' answers to be graded. If it appears that you
201mention a too short duration and miss some students' grading report,
202you may resume your script with:
203
204```bash
205$ ./codegradxagent.js --resume 101-multiJobSubmittedReport.xml --follow
206```
207
208### Submitting an exercise
209
210The `--type` option should now be set to `exercise`.
211
212An exercise is a somewhat complex tar gzipped file (see more thorough
213documentation) that may be submitted as:
214
215```bash
216$ ./codegradxagent.js -t exercise --stuff
217```
218
219Since an exercise contains a number of answers of pseudo-students, it
220may take some time to check that all these answers are appropriately
221graded: you must manage time accordingly.
222
223#### Produced files
224
225The `--follow` option tells the script to fetch the grading reports of
226the pseudo-students once graded.
227
228Some 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
235The management of time does not vary but, of course, should accomodate
236the number of students' answers to be graded. If it appears that you
237mention a too short duration, you may resume your script and ask
238for the grading reports of the pseudo-jobs with:
239
240```bash
241$ ./codegradxagent.js --resume 1-exerciseSubmittedReport.xml --follow
242```
243
244You may also set new options for time management.
245
246## Miscellaneous
247
248The `Samples` directory contains examples of XML files obtained
249from the CodeGradX infrastructure.
250
251Some features of the underlying library `codegradxlib` cannot be
252operated through `codegradxagent`. The most prominent one is probably
253the history of the user: its past jobs, batches and exercises.
254
255New features such as sending a whole directory as an exercise, checking
256the manifest `fw4ex.xml` could be added.