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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-qti

v1.0.0

Published

<h3 align="center"> @schule4-0/react-qti </h3>

Downloads

3

Readme

Installation

# npm
npm install @schule4-0/react-qti

# Yarn
yarn add @schule4-0/react-qti

Components

This project is still in early development. New components will be added later

Roadmap

This project is still in early development, but the plan is to build out most of the QTI Elements used by the Common Cartridge standard.


Multiple Choice

The MultipleChoice component accepts a path to an MultipleChoice QTI XML file and provides you with all the necessary abstractions so that you just have to care about rendering and styling the Element.

Basic example

MultipleChoice Exercises are built using the MultipleChoice, MultipleChoice.Exercise, MultipleChoice.Choice, and MultipleChoice.Button components.

The MultipleChoice.Button will automatically submit the provided answers for now the responses are not actually submitted to the QTI Endpoint.

import { Fragment } from 'react';
import { MultipleChoice } from '@schule4-0/react-qti';

function Exercise() {
  return (
    <MultipleChoice path="/multiple-choice.xml" as="div">
      <MultipleChoice.Exercise>
        {({ prompt }) => (
          <Fragment>
            <h1>{prompt}</h1>
            <MultipleChoice.Choice />
          </Fragment>
        )}
      </MultipleChoice.Exercise>
      <MultipleChoice.Button />
    </MultipleChoice>
  );
}

Styling

This is a headless component so there are no styles included by default. Instead, the components expose useful information via render props that you can use to apply the styles you'd like to apply yourself.

Rendering a different element for a component

By default, the MultipleChoice and its subcomponents each render a default element that is sensible for that component.

For example, MultipleChoice.Button renders a button by default. MultipleChoice and MultipleChoice.Exercise interestingly do not render an extra element, and instead render their children directly by default.

This is easy to change using the as prop, which exists on every component.

import { MultipleChoice } from '@headlessui/react'

function Exercise() {
  return (
    <MultipleChoice path="/multiple-choice.xml" as="div">
      <MultipleChoice.Exercise as"div">
        {({ prompt }) => (
          <Fragment>
            <h1>{prompt}</h1>
            <MultipleChoice.Choice />
          </Fragment>
        )}
      </MultipleChoice.Exercise>
      <MultipleChoice.Button as="a" />
    </MultipleChoice>
  );
}

To tell an element to render its children directly with no wrapper element, use as={React.Fragment}.

Component API

MultipleChoice

<MultipleChoice>
  <MultipleChoice.Exercise>
    {...}
  </MultipleChoice.Exercise>
</MultipleChoice>
Props

| Prop | Type | Default | Description | | ---- | ------------------- | --------------------------------------- | --------------------------------------------------------------- | | as | String | Component | React.Fragment (no wrapper element) | The element or component the MultipleChoice should render as. |

MultipleChoice.Button

<MultipleChoice.Exercise>
  {({ prompt }) => (
    <>
      <h1>{prompt}</h1>
      <MultipleChoice.Choice />
    </>
  )}
</MultipleChoice.Exercise>
Props

| Prop | Type | Default | Description | | ---- | ------------------- | -------- | ---------------------------------------------------------------------- | | as | String | Component | button | The element or component the MultipleChoice.Button should render as. |

Render prop object

| Prop | Type | Description | | -------- | ------ | -------------------------------------- | | prompt | String | The prompt/question from the QTI File. |

MultipleChoice.Items

<MultipleChoice.Choice>
  {({ text, checked }) => (
    <span>
      {checked ? '✅' : '❌'}: {text}
    </span>
  )}
</MultipleChoice.Choice>
Props

| Prop | Type | Default | Description | | ---- | ------------------- | ------- | --------------------------------------------------------------------- | | as | String | Component | div | The element or component the MultipleChoice.Items should render as. |

Render prop object

| Prop | Type | Description | | --------- | ------- | ----------------------------------------------------------- | | checked | Boolean | Wheather the input element is seleced/checked at the moment | | text | string | The text/value for the choice item / question |

MultipleChoice.Item

<MultipleChoice.Button></MultipleChoice.Button>
Props

| Prop | Type | Default | Description | | ---- | ------------------- | --------------------------------------- | -------------------------------------------------------------------- | | as | String | Component | React.Fragment (no wrapper element) | The element or component the MultipleChoice.Item should render as. |

Single Choice

The MultipleChoice component accepts a path to an MultipleChoice QTI XML file and provides you with all the necessary abstractions so that you just have to care about rendering and styling the Element.

For now please look at the documentation for the MultipleChoice component because they are fairly similar