1 | # CodeGradXlib
|
2 |
|
3 | CodeGradX is a grading infrastructure
|
4 | - where students submit programs to solve exercises and these programs
|
5 | are mechanically graded,
|
6 | - where authors deploy exercises and propose them to students,
|
7 | - where teachers may follow the progress of a cohort of students.
|
8 |
|
9 | The CodeGradX infrastructure (or constellation since the
|
10 | infrastructure is made of a number of independent servers) is operated
|
11 | via REST protocols. To ease its use, CodeGradXlib is a Javascript
|
12 | Library that provides a programmatic API to operate the CodeGradX
|
13 | infrastructure.
|
14 |
|
15 | CodeGradXlib is a low level library, using promises everywhere. A
|
16 | higher level library is provided by `CodeGradXagent`: a command line
|
17 | script, running on top of Node.js (another higher level library is the
|
18 | `CodeGradXvmauthor` command line script that operates a local virtual
|
19 | machine that runs locally the whole CodeGradX infrastructure). This
|
20 | low lever library may be used by other web applications.
|
21 |
|
22 | More information (partially in French) on the [CodeGradX
|
23 | ](https://codegradx.org) infrastructure.
|
24 |
|
25 | ## Installation
|
26 |
|
27 | ```javascript
|
28 | npm install codegradxlib
|
29 | ```
|
30 |
|
31 | If you are CLI-inclined then
|
32 |
|
33 | ```javascript
|
34 | npm install codegradxagent
|
35 | ```
|
36 |
|
37 | If you use the virtual machine for authors then
|
38 |
|
39 | ```javascript
|
40 | npm install codegradxvmauthor
|
41 | ```
|
42 |
|
43 | ## Terminology
|
44 |
|
45 | In this section, important words are capitalized and correspond to
|
46 | classes in the CodeGradXlib code.
|
47 |
|
48 | Here is an example of use of the CodeGradXlib library.
|
49 |
|
50 | ```javascript
|
51 | // Example of use:
|
52 | var CodeGradX = require('codegradxlib');
|
53 |
|
54 | new CodeGradX.State();
|
55 |
|
56 | CodeGradX.getCurrentState().
|
57 | // ask for user's login and password:
|
58 | getAuthenticatedUser(login, password).
|
59 | then(function (user) {
|
60 | // let the user choose one campaign among user.getCampaigns()
|
61 | // let us say that we choose campaign 'free':
|
62 | user.getCampaign('free').
|
63 | then(function (campaign) {
|
64 | // let the user choose one exercise among campaign.getExercisesSet()
|
65 | campaign.getExercise('some.exercise.name').
|
66 | then(function (exercise) {
|
67 | exercise.getDescription().
|
68 | then(function (description) {
|
69 | // display stem of exercise and get user's answer:
|
70 | exercise.sendFileAnswer("some.filename").
|
71 | then(function (job) {
|
72 | // wait for the marking report:
|
73 | job.getReport().
|
74 | then(function (job) {
|
75 | // display job.report
|
76 | ```
|
77 |
|
78 |
|
79 | You must first initialize the CodeGradXlib library by creating a
|
80 | State. This State concentrates some global resources for the library and
|
81 | mentions the various servers of the CodeGradX
|
82 | infrastructure and how to check their availability. It is probably
|
83 | worthless to change the default setting.
|
84 |
|
85 | Then you must authenticate with respect to the CodeGradX
|
86 | infrastructure with a login and a password. To get this login and
|
87 | password, you must [register](https://p.codegradx.org/).
|
88 | The authentication process returns a User object.
|
89 |
|
90 | The User object lists the Campaigns the User may access. A Campaign is
|
91 | a Javascript object offering a set of Exercises (an ExercisesSet), to
|
92 | a group of students during a certain period of time. You may then
|
93 | choose one campaign among the available campaigns. Once a campaign is
|
94 | choosen, the tree of associated exercises can be obtained from that
|
95 | campaign and from that tree, one may choose a particular exercise.
|
96 |
|
97 | To an Exercise is associated a description containing a stem (an XML
|
98 | document ruled by a [RelaxNG
|
99 | grammar](https://codegradx.org/CodeGradX/Resources/fw4exRngDoc.pdf))
|
100 | and, somewhere hidden in the constellation of CodeGradX servers, some
|
101 | grading scripts. A User may send a string or a file (a tar gzipped
|
102 | file if more than one file is expected) against an Exercise. Other
|
103 | metadata are associated to the Exercise defining the authors, the
|
104 | expectations (one or multiple files, how they should be named,
|
105 | templates for them, approximate size, etc.): all information useful to
|
106 | set appropriately the user interface.
|
107 |
|
108 | When an answer is sent towards an Exercise, a Job is returned from
|
109 | which a grading report may be obtained. The grading report is stored
|
110 | as a property of the Job. The grading report is an XML document ruled
|
111 | by a [RelaxNG
|
112 | grammar](https://codegradx.org/CodeGradX/Resources/fw4exRngDoc.pdf)
|
113 | so this report is skinnable. This XML is a side-set of HTML, a naive
|
114 | converter (named `CodeGradX.xml2html`) is included in the library.
|
115 |
|
116 | Users that are also potential authors of Exercises may submit a new exercise
|
117 | that is, a tar-gzipped file with a precise structure., An Exercise is then
|
118 | returned from which an author's report may be obtained telling whether the
|
119 | Exercise was deployed or not. Grading reports must be valid XML document
|
120 | with respect to the grammar mentioned above. If the new exercise produces
|
121 | invalid document or if the grading scripts are erroneous a problem report
|
122 | can also be obtained from the job: see the `getProblemReport` method.
|
123 |
|
124 | Users may gather students' answers in a big tar gzipped file and submit
|
125 | all these answers against one Exercise in a Batch. A Batch object is
|
126 | returned from which Jobs can be individually obtained.
|
127 |
|
128 | Many details can be found (in English) in the [documentation
|
129 | ](https://codegradx.org/CodeGradX/Resources/overview.pdf)
|
130 | that contains the [RelaxNG grammar
|
131 | ](https://codegradx.org/CodeGradX/Resources/fw4exRngDoc.pdf).
|
132 |
|
133 | ## Documentation
|
134 |
|
135 | Chapter 1 of the [big
|
136 | documentation](https://codegradx.org/CodeGradX/Resources/overview.pdf)
|
137 | is useful to have an overview of the CodeGradX constellation.
|
138 |
|
139 | State, User, Exercise, Job etc. are classes defined in the source
|
140 | code, they are equiped with multiple methods.
|
141 |
|
142 | The grammar of XML documents provides information on the various
|
143 | fields of objects of classes State, User, Exercise, Job etc. It also
|
144 | describes the various exchanges between the user's browser and the
|
145 | CodeGradX constellation.
|