Overview
The Practice Test component creates comprehensive tests from your study materials with multiple question types, difficulty levels, and customizable settings. Perfect for exam preparation and knowledge assessment.
Creating a Practice Test Component
import StudyfetchSDK from '@studyfetch/sdk' ;
const client = new StudyfetchSDK ({
apiKey: 'your-api-key' ,
baseURL: 'https://studyfetchapi.com' ,
});
const testComponent = await client . v1 . components . create ({
name: 'Biology Midterm Practice' ,
type: 'practice_test' ,
config: {
materials: [ 'mat-123' , 'mat-456' ],
folders: [ 'folder-789' ],
questionTypes: [ 'multiplechoice' , 'truefalse' , 'shortanswer' ],
questionsPerTest: 25 ,
difficulty: 'medium' ,
timeLimit: 45 ,
showCorrectAnswers: true ,
randomizeQuestions: true ,
allowRetakes: true ,
passingScore: 75
}
});
console . log ( 'Practice test component created:' , testComponent . _id );
Configuration Parameters
Name of the practice test component
Practice test configuration object Show Configuration Properties
Array of material IDs to generate questions from
Array of folder IDs containing materials
Types of questions to include:
multiplechoice
- Multiple choice questions
truefalse
- True/false questions
essay
- Essay questions
shortanswer
- Short answer questions
fillintheblanks
- Fill in the blank questions
Number of questions per test (minimum: 5, maximum: 50)
Test difficulty level:
easy
- Basic recall and understanding
medium
- Application and analysis
hard
- Synthesis and evaluation
Time limit in minutes (0 for no limit)
Show correct answers after submission
Randomize question order for each attempt
Allow multiple attempts at the test
Minimum passing percentage (0-100)
Response
{
"_id" : "comp_789ghi" ,
"name" : "Biology Midterm Practice" ,
"type" : "practice_test" ,
"status" : "active" ,
"config" : {
"materials" : [ "mat-123" , "mat-456" ],
"folders" : [ "folder-789" ],
"questionTypes" : [ "multiplechoice" , "truefalse" , "shortanswer" ],
"questionsPerTest" : 25 ,
"difficulty" : "medium" ,
"timeLimit" : 45 ,
"showCorrectAnswers" : true ,
"randomizeQuestions" : true ,
"allowRetakes" : true ,
"passingScore" : 75
},
"createdAt" : "2024-01-15T10:00:00Z" ,
"updatedAt" : "2024-01-15T10:00:00Z" ,
"organizationId" : "org_456def" ,
"statistics" : {
"totalAttempts" : 0 ,
"averageScore" : null
}
}
Embedding This Component
Once you’ve created a Practice Test component, you can embed it on your website using the embedding API.
Generate Embed URL
const embedResponse = await client . v1 . components . generateEmbed ( testComponent . _id , {
// User tracking
userId: 'user-456' ,
studentName: 'Jane Smith' , // Student name for display
groupIds: [ 'class-101' , 'class-102' ],
sessionId: 'session-789' ,
// Practice Test-specific features
features: {
enableHistory: true
},
// Dimensions
width: '100%' ,
height: '700px' ,
// Token expiry
expiryHours: 24
});
Practice Test-Specific Embedding Features
Track test attempts, scores, and allow reviewing past submissions
Embed in Your HTML
< iframe
src = "https://embed.studyfetch.com/component/comp_789ghi?token=..."
width = "100%"
height = "700px"
frameborder = "0"
style = "border: 1px solid #e5e5e5; border-radius: 8px;" >
</ iframe >