Skip to main content

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
string
required
Name of the practice test component
type
string
required
Must be "practice_test"
config
object
required
Practice test configuration object

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

features.enableHistory
boolean
default:"true"
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>
I