Skip to content

API Endpoints ​

Reference for all server endpoints.

Overview ​

The Express server (app.js) exposes the following endpoints:

EndpointMethodDescription
/submitPOSTSubmit code to Gradescope
/starter/:filenameGETGet starter code template
/lti/launchPOSTHandle LTI 1.3 launch
/auth/statusGETCheck authentication status

POST /submit ​

Submit student code to Gradescope for grading.

Request ​

http
POST /submit
Content-Type: application/json

Body:

json
{
  "code": "print('Hello, World!')",
  "email": "student@school.edu",
  "stud_id": "900123456",
  "asg_id": "6617143",
  "file_name": "program.py"
}

Parameters ​

FieldTypeRequiredDescription
codestringYesThe Python code to submit
emailstringNoStudent email address
stud_idstringNoStudent ID
asg_idstringYesGradescope assignment ID
file_namestringNoFilename (default: program.py)

Response ​

Success (200):

json
{
  "success": true,
  "message": "Submission successful",
  "url": "https://www.gradescope.com/courses/1106756/assignments/6617143/submissions/123456"
}

Error (400):

json
{
  "success": false,
  "error": "Missing required field: asg_id"
}

Error (500):

json
{
  "success": false,
  "error": "Gradescope submission failed"
}

GET /starter/:filename ​

Retrieve starter code template for an assignment.

Request ​

http
GET /starter/lab1_starter.py

Response ​

Success (200):

json
{
  "code": "# Lab 1 Starter Code\n\ndef calculate_total(items):\n    pass"
}

Not Found (404):

json
{
  "error": "Starter file not found"
}

POST /lti/launch ​

Handle LTI 1.3 launch from D2L Brightspace.

Request ​

This endpoint receives an LTI 1.3 launch request from D2L. The request contains:

  • JWT token with student information
  • Course and assignment context
  • Custom parameters

Response ​

On successful validation, redirects to the code editor with context:

302 Redirect → /codemirror-demo.html?email=...&asg_id=...

On failure:

json
{
  "error": "Invalid LTI launch"
}

GET /auth/status ​

Check if the current session has valid Gradescope credentials.

Request ​

http
GET /auth/status

Response ​

Authenticated:

json
{
  "authenticated": true,
  "email": "student@school.edu"
}

Not Authenticated:

json
{
  "authenticated": false
}

Static Files ​

The server also serves static files:

PathFile
/codemirror-demo.html
/mockD2L.htmlMock D2L interface
/login.htmlGradescope login page
/styles/*CSS files

Error Handling ​

All endpoints return consistent error responses:

json
{
  "success": false,
  "error": "Error message here"
}

HTTP Status Codes ​

CodeMeaning
200Success
400Bad request (missing/invalid parameters)
401Unauthorized (no valid session)
404Not found
500Server error

Rate Limiting ​

Currently, there is no rate limiting implemented. For production, consider adding:

javascript
const rateLimit = require('express-rate-limit');

const limiter = rateLimit({
  windowMs: 60 * 1000, // 1 minute
  max: 10 // 10 requests per minute
});

app.use('/submit', limiter);

Released under the MIT License.