lmscn

Order

Drag-and-drop (or keyboard) sequencing activity with correct-order feedback.

Installation

npx shadcn@latest add https://lmscn.vercel.app/r/order.json

Required primitives: button, progress, badge

npx shadcn@latest add button progress badge

Usage

import { Order } from "@/components/lms/order"
import type { OrderData, OrderResult } from "@/components/lms/order"

export function MyOrder() {
  return (
    <Order
      orderData={{
        title: "Star Lifecycle",
        questions: [
          {
            id: "q1",
            prompt: "Order the stages of a star's life:",
            hint: "It starts with a cloud of gas and dust.",
            items: [
              { id: "1", label: "Nebula",        description: "A cloud of gas and dust" },
              { id: "2", label: "Protostar" },
              { id: "3", label: "Main Sequence",  description: "Stable hydrogen fusion" },
              { id: "4", label: "Red Giant" },
              { id: "5", label: "White Dwarf" },
            ],
          },
        ],
      }}
      onComplete={(result: OrderResult) => {
        console.log(result.percentage + "%")
      }}
    />
  )
}

Props

OrderProps

PropTypeRequiredDescription
orderDataOrderDataQuestions configuration
onComplete(result: OrderResult) => voidCalled after the last question
classNamestringAdditional CSS classes

Data shape

OrderData

FieldTypeDescription
titlestringActivity title
descriptionstringSubtitle
questionsOrderQuestion[]List of sequencing questions

OrderQuestion

FieldTypeDescription
idstringUnique identifier
promptstringInstruction shown above the list
itemsOrderItem[]Items listed in the correct order — the component shuffles them on mount
hintstringOptional hint shown before submitting

OrderItem

FieldTypeDescription
idstringUnique identifier
labelstringPrimary label text
descriptionstringOptional secondary line shown below the label

Result

onComplete receives an OrderResult object:

FieldTypeDescription
attemptsOrderAttempt[]Per-question attempt records
scorenumberNumber of questions where the entire order was correct
maxScorenumberTotal number of questions
percentagenumberRounded score percentage
interface OrderAttempt {
  questionId: string
  givenOrder: string[]   // item IDs in the order the learner submitted
  correctOrder: string[] // item IDs in the correct order
  correct: boolean
}

Behaviour

Drag and drop — items have a grab handle on the left. Drag an item over another to reorder.

Keyboard — focus an item and press ↑ or ↓ to move it one position. This makes the activity fully accessible without a pointer device.

Shuffle — a Shuffle button re-randomises the list, resetting any manual ordering. It is disabled once the learner has submitted.

After submitting an incorrect order, the correct sequence is displayed in a muted panel below the list. Per-item ✓ / ✗ icons indicate which positions were right.

On this page