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

@graffiticode/learnosity-cqt

v0.1.2

Published

Language-agnostic Learnosity custom question type runtime for Graffiticode languages

Downloads

514

Readme

@graffiticode/learnosity-cqt

The Learnosity custom question type runtime shared by Graffiticode languages.

Learnosity loads two bundles per question type — a browser question.js and a scorer.js that also runs server-side — and instantiates new Question(init, lrnUtils) and new Scorer(question, responseValue). This package supplies both classes; a language supplies only its renderer and its scoring functions.

Usage

import { createQuestion, createScorer } from "@graffiticode/learnosity-cqt";
import { Form, scoreCells, getCellsValidation } from "@graffiticode/l0166";

const defaultData = {
  validation:  { points: 0, ranges: {}, cells: {} },
  interaction: { type: "table", v: "0.0.1", cells: {}, columns: {} },
};

export const Question = createQuestion({ Form, scoreCells, getCellsValidation, defaultData });
export const Scorer   = createScorer({ scoreCells, defaultData });

defaultData is a parameter rather than a constant because the fallback envelope is language-specific — the shape above is the spreadsheet one.

Ship the stylesheet and the authoring layout alongside the bundles:

import "@graffiticode/learnosity-cqt/styles.css";

@graffiticode/learnosity-cqt/authoring-layout.html is the Question Editor layout: a 348-line postMessage bridge that opens the Graffiticode editor in a popup and writes the authored item back through editor.getJson() / setJson(). It is generic apart from a single __GC_LANG__ placeholder, which the consuming build substitutes with the four-digit language id.

Scoring contract

This package implements the cell-scoring contract: scoreCells({ cells, validation }) returns the cells with a score attached, and the question's total is the sum of score.points across cells. That yields partial credit.

Languages that predate scoreCells — l0152, l0153, l0154, l0155, l0157 — use an all-or-nothing contract instead, comparing the response against question.valid_response.value. That path is not implemented here yet. Adding it means a sibling pair of factories (createSimpleQuestion / createSimpleScorer) rather than branching inside these: the two differ in their state reducer, their suggested-answer derivation, and their scoring, so a shared implementation would be mostly if.

Notes

  • Built with Babel, not the repo's tsconfig.base.json — this is browser JSX, and that config targets Node (lib: ["ES2022"], no DOM, no jsx). Output is ESM so consumers can keep the usual exclude: /node_modules/ on their own babel-loader.
  • react and react-dom are peer dependencies.