Quiz VS Code Extension
A VS Code extension that provides comprehensive support for .quiz
files with JSON validation, syntax highlighting, and real-time diagnostics for multiple question types.

The extension automatically detects .quiz
files and provides real-time validation with detailed error messages, as shown above where invalid correct_answers
indices are highlighted with clear diagnostic messages.
🆕 What's New in v0.2.0
- Multiple Question Types: Added support for
single_choice
and true_false
questions
- Enhanced Validation: Type-specific validation rules for each question type
- New Code Snippets: Quick templates for all question types including bilingual true/false
- Improved Sample Generation: Create comprehensive quiz examples with all question types
- Better Error Messages: More specific validation messages based on question type
Features
- Automatic recognition:
.quiz
files are automatically recognized with custom language support
- Multiple Question Types: Support for various question formats:
multiple_choice
- Questions with one or more correct answers
single_choice
- Questions with exactly one correct answer
true_false
- Boolean questions with true/false options
- Schema validation: Real-time validation of quiz file structure using JSON Schema
- Advanced diagnostics: Comprehensive error detection including:
- Structure validation for quiz metadata and questions
- Question type-specific validation rules
- Correct answer indices within valid ranges
- Required field validation for metadata and questions
- Type-specific option requirements (e.g., exactly 2 options for true/false)
- Syntax highlighting: Quiz-specific JSON highlighting
- Code snippets: Pre-built snippets for all question types
- Commands: Manual validation and sample quiz creation with examples of all question types
Quiz File Structure
Basic Structure
{
"metadata": {
"title": "Sample Quiz",
"description": "A comprehensive quiz example with multiple question types",
"version": "1.0.0",
"author": "Quiz Author",
"created_date": "2025-01-01T00:00:00Z",
"tags": ["education", "assessment"]
},
"questions": [
{
"type": "multiple_choice",
"text": "What is the capital of France?",
"options": ["Madrid", "Paris", "Rome", "Berlin"],
"correct_answers": [1],
"explanation": "Paris is the capital city of France."
}
]
}
Question Types
Multiple Choice Questions
Supports one or more correct answers:
{
"type": "multiple_choice",
"text": "Which of the following are programming languages?",
"options": ["Python", "HTML", "C++", "CSS"],
"correct_answers": [0, 2],
"points": 2,
"explanation": "Python and C++ are programming languages, while HTML and CSS are markup/styling languages."
}
Single Choice Questions
Must have exactly one correct answer:
{
"type": "single_choice",
"text": "What is the most widely used programming language for web development?",
"options": ["Python", "JavaScript", "Java", "C++"],
"correct_answers": [1],
"explanation": "JavaScript is the most widely used programming language for web development."
}
True/False Questions
Must have exactly two options and one correct answer:
{
"type": "true_false",
"text": "The Earth is flat.",
"options": ["True", "False"],
"correct_answers": [1],
"explanation": "The Earth is not flat; it is an oblate spheroid, roughly spherical in shape."
}
{
"type": "true_false",
"text": "Python is an interpreted programming language.",
"options": ["Verdadero", "Falso"],
"correct_answers": [0],
"explanation": "Python is indeed an interpreted programming language."
}
Requirements
- VS Code 1.102.0 or higher
Commands
Quiz: Validate Quiz File
: Manually validate the current quiz file
Quiz: Create Sample Quiz
: Create a sample quiz file with examples of all question types
Quiz: Diagnose Quiz File Detection
: Troubleshoot file detection issues
Code Snippets
The extension provides several code snippets to speed up quiz creation:
quiz
- Complete quiz template
mcq
- Multiple choice question
mcq-multi
- Multiple choice with multiple correct answers
scq
- Single choice question
tf
- True/False question (English)
vf
- True/False question (Spanish: Verdadero/Falso)
q-explain
- Question with explanation (any type)
q-full
- Complete question with all optional fields
metadata
- Complete metadata block
Development Installation
Clone this repository
git clone https://github.com/vicajilau/quiz_vs_extension.git
cd quiz_vs_extension
Install dependencies
npm install
Compile the extension
npm run compile
Test the extension
- Press
F5
to open a new VS Code window with the extension loaded
- Create or open a
.quiz
file to test the features
Development and Commands
Main Commands
npm run compile
: Compile TypeScript and run linting
npm run watch
: Compile in watch mode (recompiles automatically)
npm run test
: Run automated tests
npm run vsce:package
: Create VSIX package for distribution
npm run vsce:publish
: Publish extension to VS Code Marketplace
Development Workflow
During active development:
npm run watch
This maintains automatic compilation while you edit the code.
To test changes:
- Press
F5
to launch extension in debug mode
- Use
Ctrl+Shift+F5
to reload the extension window
Before committing:
npm run compile # Verify everything compiles without errors
To create a new version:
# 1. Compile and verify
npm run compile
# 2. Run tests to ensure quality
npm test
# 3. Create VSIX package
npm run vsce:package
# 4. Install locally to test
code --install-extension quiz-file-support-0.2.0.vsix
Testing
The extension includes comprehensive validation to ensure quiz file accuracy:
- JSON Schema validation: Validates against comprehensive schema
- Type validation: Ensures correct data types for all fields
- Range validation: Verifies
correct_answers
indices are valid
- Structure validation: Confirms required fields and proper nesting
- Custom validation: Question-type specific validation rules
# Run all tests
npm test
# Run tests in watch mode during development
npm run test:watch
# Test from VS Code: Use "Run Extension Tests" debug configuration
Validation Rules
The extension validates:
Extensible Architecture
The extension is designed to easily support new question types:
// Currently supported (v0.2.0)
type QuestionType = "multiple_choice" | "single_choice" | "true_false";
// Future support planned
type QuestionType =
| "multiple_choice"
| "single_choice"
| "true_false"
| "fill_in_blank"
| "essay"
| "matching"
| "ordering";
| "fill_in_blank"
| "essay"
| "matching";
Project Structure
quiz_vs_extension/
├── .github/
│ └── assets/ # Demo images and assets
│ ├── demo.png # Demo screenshot
│ └── icon.png # Extension icon
├── schemas/
│ └── quiz-schema.json # JSON Schema for validation
├── syntaxes/
│ └── quiz.tmLanguage.json # Grammar for syntax highlighting
├── snippets/
│ └── quiz.json # Code snippets
├── samples/
│ └── sample.quiz # Example quiz file
├── src/
│ └── extension.ts # Main extension code
├── dist/ # Compiled JavaScript (generated)
├── package.json # Extension configuration
├── language-configuration.json # Language configuration
└── README.md
Contributing
Contributions are welcome! Please follow these steps:
To Contribute
Fork the repository
Create a branch for your feature:
git checkout -b feature/new-question-type
Make changes and compile:
npm run compile # Verify it compiles without errors
Test the extension:
# Create test package
npm run vsce:package
# Install it locally
code --install-extension quiz-file-support-*.vsix
Commit and push:
git add .
git commit -m "feat: add true_false question type support"
git push origin feature/new-question-type
Create Pull Request
Conventions
Adding New Question Types
The extension currently supports three question types. To add a new question type:
- Update the JSON schema (
schemas/quiz-schema.json
) with validation rules
- Add TypeScript interfaces (
src/extension.ts
) following the BaseQuestion
pattern
- Implement validation logic for the new type in the validation function
- Add code snippets (
snippets/quiz.json
) for easy question creation
- Add comprehensive tests in the test suite
- Update documentation and examples
Example of adding a new question type:
interface FillInBlankQuestion extends BaseQuestion {
type: "fill_in_blank";
template: string; // Text with {blanks} to fill
answers: string[]; // Possible answers for each blank
}
Reporting Issues
If you find a bug or have a suggestion:
- Check that a similar issue doesn't already exist
- Create a new issue with:
- Clear description of the problem
- Steps to reproduce
- Example
.quiz
file if relevant
- VS Code and extension version
License
This project is under the MIT license.