UNPKG

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