UNPKG

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