import Whop from '@whop/sdk';
const client = new Whop({
apiKey: process.env['WHOP_API_KEY'], // This is the default and can be omitted
});
const response = await client.courseLessons.submitAssessment('lesson_id', {
answers: [{ question_id: 'question_id' }],
});
console.log(response.id);{
"id": "crsar_xxxxxxxxxxxx",
"created_at": "2023-12-01T05:00:00.401Z",
"updated_at": "2023-12-01T05:00:00.401Z",
"result_grade": 6.9,
"result_correct": 42,
"result_question_count": 42,
"result_passing_grade": true,
"result_graded_questions": {},
"score_percent": 6.9,
"user": {
"id": "user_xxxxxxxxxxxxx",
"name": "John Doe",
"username": "johndoe42"
},
"lesson": {
"id": "lesn_xxxxxxxxxxxxx",
"title": "Understanding Candlestick Patterns"
}
}Submit answers for a quiz or knowledge check lesson and receive a graded result.
import Whop from '@whop/sdk';
const client = new Whop({
apiKey: process.env['WHOP_API_KEY'], // This is the default and can be omitted
});
const response = await client.courseLessons.submitAssessment('lesson_id', {
answers: [{ question_id: 'question_id' }],
});
console.log(response.id);{
"id": "crsar_xxxxxxxxxxxx",
"created_at": "2023-12-01T05:00:00.401Z",
"updated_at": "2023-12-01T05:00:00.401Z",
"result_grade": 6.9,
"result_correct": 42,
"result_question_count": 42,
"result_passing_grade": true,
"result_graded_questions": {},
"score_percent": 6.9,
"user": {
"id": "user_xxxxxxxxxxxxx",
"name": "John Doe",
"username": "johndoe42"
},
"lesson": {
"id": "lesn_xxxxxxxxxxxxx",
"title": "Understanding Candlestick Patterns"
}
}A company API key, company scoped JWT, app API key, or user OAuth token. You must prepend your key/token with the word 'Bearer', which will look like Bearer ***************************
The unique identifier of the quiz or knowledge check lesson to submit answers for (e.g., "les_XXXXX").
Parameters for SubmitAssessment
The list of answers to submit for each assessment question.
Show child attributes
A successful response
The result of a user's assessment attempt
The unique identifier for the assessment result.
"crsar_xxxxxxxxxxxx"
The datetime the assessment result was created.
"2023-12-01T05:00:00.401Z"
The datetime the assessment result was last updated.
"2023-12-01T05:00:00.401Z"
The grade achieved on the assessment
6.9
The number of correct answers
42
The total number of questions in the assessment
42
Whether the user achieved a passing grade
Array of graded questions with details
The percentage score achieved on the assessment
6.9
The user who took the assessment
Show child attributes
The lesson this assessment result is for
Show child attributes
Was this page helpful?