NodeJS server designed to record student grades (MOOC) in a Firestore database.
Inside a clone of this repository, run the following commands:
npm run-script build
npm start
If you are an HBP or BBP administrator of the NRP MOOC, you may want to copy config.json
and serviceAccount.json
from the Neurorobotics-MOOC-admin repository at the root of your cloned repository and in the dist
subfolder.
Each HTTP request requires the Authorization header to be filled with an OIDC token. In the current setting, this token is the OIDC token associated to the HBP account of the user performing the request, except for the requests that require administrator privileges.
The requests POST /final-grades
and POST /edx-submission
expect to administrator token to be set in the Authorization header.
A request of the form POST /edx-launch
creates an entry in a Firestore database that holds parts of the request itself as well as a token. The token is generated by the grading server based on the request details. The token is returned in the request response for further use by the request owner (MOOC user). The token corresponds to a unique MOOC exercise and a unique MOOC user. Users are asked to provide their tokens when submitting their answers.
Below is typical Form Data provided by edX when performing such LTI Launch request.
custom_component_display_name: Mini-project 1: Exercise
lti_version: LTI-1p0
oauth_nonce: 73504331815050623831563953221
resource_link_id: edge.edx.org-681ca6088bb44738b8b98dc0a1f13512
context_id: course-v1:EPFLx+RoboX+2017_T3
oauth_signature_method: HMAC-SHA1
oauth_timestamp: 1563953221
oauth_version: 1.0
custom_subheader: Mini-project 1
custom_header: EPFLx-RoboX-Neurorobotics 2019
oauth_signature: tof/vOyDHDIRryhYlfrL5Fqkl/w=
context_title: Neurorobotics
lti_message_type: basic-lti-launch-request
launch_presentation_return_url:
context_label: EPFLx
user_id: f08ca61dq2933764adf43780765548f5
roles: Instructor
oauth_consumer_key: x11123-d02fe5
lis_result_sourcedid: course-v1%3AEPFLx%2BRoboX%2B2017_T3:edge.edx.org-681ca6088bb44738b8b98dc0a1f13512:f08ca61d62933764adf43788155448f5
launch_presentation_locale: fr
lis_outcome_service_url: https://edge.edx.org/courses/course-v1:EPFLx+RoboX+2017_T3/xblock/block-v1:EPFLx+RoboX+2017_T3+type@lti_consumer+block@681ca6088bb44738b8b98dc0a1f13512/handler_noauth/outcome_service_handler
oauth_callback: about:blank
The fields with prefix custom_
are custom parameters that edX lets you specify through its graphical user interface for the creation of LTI Components.
The value of lis_result_sourcedid
identifies uniquely a specific user and a specific exercise.
The URL lis_outcome_service_url
is the URL to be used to grade eventually this exercise.
Below you can see how the token is displayed in the edx LTI Component of the MOOC exercise named Mini-project 1 after a successful LTI Launch request.
The response of POST /edx-launch
is the HTML document rendred above in which the token has been inserted.
The request GET /check-token
returns a JSON string of the form
{
"custom_header": "EPFLx-RoboX-Neurorobotics 2019",
"custom_subheader": "Mini-project 1"
}
if the token provided as a query parameter (GET /check-token?token=<value>
) corresponds to a token generated by a POST /edx-launch
request. The custom_header
and custom_subheader
values are then those of the recorded launch request.
A request of the form POST /submission
creates an entry in a Firestore database that holds to the request body.
The request body must be of the following form
{
"submissionInfo": {
"header": "NRP MOOC Reinforcement Learning",
"subheader": "Mini-project 0"
},
"answer" : { "1" : -123.5, "2": 10.0, "3": 5.6 },
"fileContent": "# Some content",
"fileName": "mySolution.py",
"token": "2e9a12df4de102f9c1d4a6e9936940b21d4c78f5f84719044hl4h34u9304j4324po4uin4m"
}
The submissionInfo
identifies the MOOC via its header
field and the MOOC exercise via its subheader
field.
The token
is the string provided by the response of POST /edx-launch
. Users need to copy their tokens from the corresponding edX pages.
The request POST /final-grades/:userId
records the final grades of the user userId
in the Firestore database.
The request body must be of the following form:
{
"finalGrades": {
"EPFLx-RoboX-Neurorobotics 2019": {
"Mini-project 1": 0.6,
"Mini-project 2": 0.7
}
}
}
Grades are floatting point numbers between 0 and 1. The Authorization header must contain the administrator token.
The request POST /final-grades
records the final grades specified in the request body in the Firestore database.
The request body must be of the following form:
{
"finalGrades": {
"users": {
"210788": {
"EPFLx-RoboX-Neurorobotics 2019":
{
"Mini-project 1": 0.1
}
},
"306005": {
"EPFLx-RoboX-Neurorobotics 2020":
{
"Mini-project 1": 1,
"Mini-project 2": 0.3
}
}
}
}
}
The request POST /edx-submission/:header/:userId
sends to edX the final grades of userId
corresponding to the exercises of the MOOC header
. The parameter header
is a URL encoded string, e.g "NRP%20MOOC%202019". These grades will be displayed in edX for each graded exercise of the MOOC header
.
The Authorization header must contain the administrator token.
The request POST /edx-submission/:header
sends final grades to all the users of the MOOC header
.
The parameter header
is a URL encoded string, e.g "NRP%20MOOC%202019". These grades will be displayed in edX for each graded exercise of the MOOC header
.
The Authorization header must contain the administrator token.