-
Notifications
You must be signed in to change notification settings - Fork 0
Python back end documentation
This API will check correctness of the provided questions in python. There are specific types of question models that are defined. This wiki page will outline what the endpoints are expecting and what will be returned.
For all these following endpoints:
- If not POST, 405 is returned
- If
Content-Type
header is notapplication/json
, 415 is returned
This endpoint will run userAnswer
and testCode
and compare the standard output of each program.
Expected body:
{
userAnswer?: string,
testCode?: string
}
Where userAnswer
is the student's provided answer and testCode
is the code that should be ran. If the variable is not provided, it will become an empty string.
Response:
{
pass: boolean,
failMessage?: string
}
This endpoint will compare userAnswer
to expectedAnswer
where these two variables are both strings.
Expected body:
{
userAnswer?: string,
expectedAnswer?: string
}
Where userAnswer
is the student's provided answer and expectedAnswer
is the correct choice. If the variable is not provided, it will become an empty string.
Response:
{
pass: boolean,
failMessage?: string
}
This endpoint will compare the userAnswer
to expectedAnswer
as a string if questionCode
isn't provided, otherwise it will run the code and compare the outputs.
Expected body:
{
userAnswer?: string,
questionCode?: string,
expectedAnswer?: string
}
If questionCode
is provided, it will run both the userAnswer
and questionCode
then compare the outputs.
If questionCode
is not provided, it will just compare the userAnswer
to expectedAnswer
as a string.
Response:
{
pass: boolean,
failMessage?: string
}
This endpoint will compare the userAnswer
to the expectedAnswer
. Given the data type of these two variables described below, it checks for the entire contents to be similar, otherwise it fails. This can be expanded on in the future in order to check each individual wrong solution to determine customized responses, but for now it just checks for simple correctness.
Note that the variables below are required.
Expected body:
{
userAnswer: string[],
expectedAnswer: string[]
}
Response:
{
pass: boolean,
failMessage?: string
}
This endpoint compares a 2d array of answers (m x n) to a 2d array of questions (m x n), and returns a 2d array with the results (m x n)
Expected body and interface:
{
answer: Answer[n][m],
questions: Question[n][m]
}
interface Answer = string[] | string
interface Question = {
type: "fillBlank" | "multipleChoice" | "writeCode" | "checkboxQuestion",
code?: string
answer?: string[] | string
}
Answer
is a string or string array. The string array is for checkbox questions.
A single question should correspond to the answer, and they should be similar to the previous endpoints. For example, a string[]
in the Question
's answer
field is for a checkboxQuestion
, and therefore the corresponding Answer
is expected to also be a string[]
.
Question.answer
is not needed in all cases because if you recall in some of the other endpoints, we compared the output of the code
rather than the expectedAnswer
, same thing in this case.
Response and interface:
Response[n][m]
interface Response = {
pass?: boolean,
failMessage?: string,
blank?: true
}
If the question type does not match, it will result in the response for that cell just being {blank: true}
This endpoint compares a memory table's expected outputs to the user's input and determines if they were correct or not
Expected body and interface:
{
expectedAnswer: {
[key: string]: string[]
},
userAnswer: {
[key: string]: string[]
}
}
It will basically compare the expectedAnswer
object to the userAnswer
object and return a pass true if these are deeply equivalent, otherwise it returns false
Response:
{
pass: boolean,
failMessage?: string
}