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` module that configures the
|
25 | agent to use VMauthor rather than the real constellation of servers.
|
26 | See how to authenticate with VMauthor in the `codegradxvmauthor`
|
27 | documentation.
|
28 |
|
29 | ## Usage
|
30 |
|
31 | You may run this script with the regular CodeGradX infrastructure with
|
32 | node as (where `...` is a path leading to the script):
|
33 |
|
34 | ```sh
|
35 | node .../codegradxagent.js
|
36 | ```
|
37 |
|
38 | If the `codegradxagent` script is executable, you may simply write:
|
39 |
|
40 | ```sh
|
41 | .../codegradxagent.js
|
42 | ```
|
43 |
|
44 | By default or with the `-h` or `--help` options, the script prints a
|
45 | short summary of the possible options.
|
46 |
|
47 | Two other global options, `-v` or `-V`, ask the codegradxagent to
|
48 | be verbose and to show what it does. The second option also asks the
|
49 | CodeGradXlib library to be verbose.
|
50 |
|
51 | ### Authentication
|
52 |
|
53 | You cannot use the CodeGradX infrastructure if you are not registered
|
54 | that is, you have a login and a password. These login and password may
|
55 | be passed with the `--user` and `--password` options. Since that last
|
56 | option may reveal your password to other users of your computer, you
|
57 | may 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
|
60 | infrastructure identifies you with a safe-cookie (a ciphered cookie).
|
61 | This cookie is available for some hours so it may be stored in your
|
62 | credentials file using the `--update-credentials` option.
|
63 | Therefore, 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 |
|
77 | An exercise is identified by a safe-cookie (a long string of
|
78 | characters). An exercise is specified by the `--exercise` option, the
|
79 | associated value may take several forms, all of them yielding a
|
80 | safe-cookie.
|
81 |
|
82 | If you are the author of an exercise then, when this exercise was
|
83 | checked and deployed, its safe-cookie was returned to you in the
|
84 | authorExerciseReport file, say `2-exerciseAuthorReport.xml`.
|
85 | Then `--exercise=file:2-exerciseAuthorReport.xml` allows the
|
86 | CodeGradXagent to extract the safe-cookie from that file.
|
87 |
|
88 | If the exercise is part of a campaign you can access, say this is the
|
89 | 3rd exercise of a campaign named `free`, then saying `--exercise
|
90 | campaign:free#2` will extract the safe-cookie associated to that third
|
91 | exercise.
|
92 |
|
93 | Once you know how to get the safe-cookie identifying an exercise, you
|
94 | may send an answer to that exercise. Depending on the exercise, the
|
95 | expected answer may be a single file or a bunch of files. The answer
|
96 | should be packed within a tar gzipped file, say `answer.tgz` and sent
|
97 | with the `--stuff` option as in:
|
98 |
|
99 | ```bash
|
100 | $ ./codegradxagent.js -t job -e 'campaign:free#2' --stuff answer.tgz
|
101 | ```
|
102 |
|
103 | The `-t` or `--type` option specifies that we send an answer against
|
104 | an exercise.
|
105 |
|
106 | #### Produced files
|
107 |
|
108 | The CodeGradX infrastructure is operated via REST protocols,
|
109 | interactions often yields reports in XML or JSON. These reports are
|
110 | stored in the directory specified by `--xmldir` (by default the
|
111 | current directory), their name is prefixed by an integer starting with
|
112 | the value of `--counter` (by default `0`). For instance, the
|
113 | previous 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 |
|
125 | Some exercises may require a number of seconds to grade an answer. On
|
126 | the other hand, some answers may loop or be stuck, they will be killed
|
127 | once a given duration set by the author of the exercise is overrun.
|
128 | Therefore 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 |
|
140 | The `--type` option should now be set to `batch`.
|
141 |
|
142 | The identification of the exercise does not vary.
|
143 |
|
144 | A batch of students' answers is described by a manifest, a `fw4ex.xml`
|
145 | file. 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 |
|
159 | The 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 |
|
172 | The `--follow` option tells the script to fetch the grading reports of
|
173 | the 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 |
|
176 | Some 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 |
|
187 | The management of time does not vary but, of course, should accomodate
|
188 | the number of students' answers to be graded. If it appears that you
|
189 | mention a too short duration and miss some students' grading report,
|
190 | you may resume your script with:
|
191 |
|
192 | ```bash
|
193 | $ ./codegradxagent.js --resume 101-multiJobSubmittedReport.xml --follow
|
194 | ```
|
195 |
|
196 | ### Submitting an exercise
|
197 |
|
198 | The `--type` option should now be set to `exercise`.
|
199 |
|
200 | An exercise is a somewhat complex tar gzipped file (see more thorough
|
201 | documentation) that may be submitted as:
|
202 |
|
203 | ```bash
|
204 | $ ./codegradxagent.js -t exercise --stuff
|
205 | ```
|
206 |
|
207 | Since an exercise contains a number of answers of pseudo-students, it
|
208 | may take some time to check that all these answers are appropriately
|
209 | graded: you must manage time accordingly.
|
210 |
|
211 | #### Produced files
|
212 |
|
213 | The `--follow` option tells the script to fetch the grading reports of
|
214 | the pseudo-students once graded.
|
215 |
|
216 | Some 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 |
|
223 | The management of time does not vary but, of course, should accomodate
|
224 | the number of students' answers to be graded. If it appears that you
|
225 | mention a too short duration, you may resume your script and ask
|
226 | for the grading reports of the pseudo-jobs with:
|
227 |
|
228 | ```bash
|
229 | $ ./codegradxagent.js --resume 1-exerciseSubmittedReport.xml --follow
|
230 | ```
|
231 |
|
232 | You may also set new options for time management.
|
233 |
|
234 | ## Miscellaneous
|
235 |
|
236 | The `Samples` directory contains examples of XML files obtained
|
237 | from the CodeGradX infrastructure.
|
238 |
|
239 | Some features of the underlying library `codegradxlib` cannot be
|
240 | operated through `codegradxagent`. The most prominent one is probably
|
241 | the history of the user: its past jobs, batches and exercises.
|
242 |
|
243 | New features such as sending a whole directory as an exercise, checking
|
244 | the manifest `fw4ex.xml` could be added.
|