npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@molecule/api-ai-quiz-generation

v1.0.1

Published

AI quiz generation from source material + auto-grading

Readme

@molecule/api-ai-quiz-generation

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

@molecule/api-ai-quiz-generation — generate quizzes from source material + auto-grade student responses via the bonded AI provider.

Extracted from ai-study-buddy flagship. For pure rule-based grading (multiple-choice → exact match), use @molecule/api-utilities-quiz-grading. This package adds AI-assisted generation + free-response grading.

Quick Start

import { generateQuiz, gradeResponses } from '@molecule/api-ai-quiz-generation'

const quiz = await generateQuiz({
  source: chapterText,
  questionCount: 10,
  types: ['multiple_choice', 'short_answer'],
  difficulty: 'medium',
})

const result = await gradeResponses({
  quiz,
  responses: studentAnswers,
})

Type

utility

Installation

npm install @molecule/api-ai-quiz-generation @molecule/api-ai @molecule/api-bonds-default-express @molecule/api-database @molecule/api-i18n @molecule/api-middleware-validation

API

Interfaces

GradedResponse

AI-graded result for a single student response, including correctness, score, and feedback.

interface GradedResponse {
  question_id: string
  submitted: string
  correct: boolean
  score: number
  feedback?: string
}

GradeResult

Aggregated grading outcome for a full set of student responses.

interface GradeResult {
  responses: GradedResponse[]
  total: number
  earned: number
  percentage: number
}

Question

A single quiz question with prompt, answer, and optional metadata.

interface Question {
  id: string
  type: QuestionType
  prompt: string
  /** For multiple_choice / true_false. */
  options?: string[]
  /** The correct answer (or one of the accepted forms). */
  answer: string
  /** Why this is the right answer — surfaced after submission. */
  explanation?: string
  difficulty?: Difficulty
}

Quiz

A generated quiz containing an ordered list of questions and an optional source summary.

interface Quiz {
  questions: Question[]
  source_summary?: string
}

Types

Difficulty

Relative difficulty level for a question or generated quiz.

type Difficulty = 'easy' | 'medium' | 'hard'

QuestionType

Union of supported quiz question formats.

type QuestionType = 'multiple_choice' | 'true_false' | 'short_answer' | 'fill_in_the_blank'

Functions

generateQuiz(opts)

Generates a quiz from source material using the bonded AI provider, returning structured questions.

function generateQuiz(opts: {
  source: string
  questionCount?: number
  types?: QuestionType[]
  difficulty?: Difficulty
  model?: string
}): Promise<Quiz>

gradeResponses(opts)

Grades a set of student responses against the quiz answer key using the bonded AI provider.

function gradeResponses(opts: {
  quiz: Quiz
  responses: Array<{ question_id: string; submitted: string }>
  model?: string
}): Promise<GradeResult>

Injection Notes

Requirements

Peer dependencies:

  • @molecule/api-bonds-default-express ^1.0.1
  • @molecule/api-database ^1.0.1
  • @molecule/api-i18n ^1.0.1
  • @molecule/api-middleware-validation ^1.0.1
  • @molecule/api-ai ^1.0.1

Runtime Dependencies

  • @molecule/api-ai
  • @molecule/api-bonds-default-express
  • @molecule/api-database
  • @molecule/api-i18n
  • @molecule/api-middleware-validation

Requires a bonded ai chat provider (@molecule/api-ai) — both functions throw if none is bonded.

Failure shapes (no rejection): malformed model output — or a provider API failure, which arrives as an in-band error event this package does not treat as fatal — makes generateQuiz() resolve { questions: [] } and gradeResponses() resolve { responses: [], earned: 0, percentage: 0 }. An empty questions array means the model output failed to parse, not "the source had nothing to ask" — surface a retry instead of rendering an empty quiz, and don't record a 0% grade whose responses array is empty. total/percentage are computed from the quiz's own question count, so a partially-parsed grading under-reports earned, never over-reports.