Top Related Projects
The open LMS by Instructure, Inc.
Moodle - the world's open source learning platform
Quick Overview
Perseus is an open-source framework developed by Khan Academy for building interactive exercises and assessments. It provides a set of tools and components to create engaging educational content, including multiple-choice questions, interactive graphs, and more complex problem types.
Pros
- Highly customizable and extensible for creating various types of educational content
- Integrates well with React and other modern web technologies
- Supports a wide range of question types and interactive elements
- Actively maintained by Khan Academy and the open-source community
Cons
- Steep learning curve for developers new to the framework
- Documentation can be sparse or outdated in some areas
- May be overkill for simple quiz or assessment needs
- Requires a good understanding of React and modern JavaScript
Code Examples
- Creating a simple multiple-choice question:
import { Perseus } from "@khanacademy/perseus";
const question = {
question: {
content: "What is the capital of France?",
widgets: {},
},
answerArea: {
type: "multiple-choice",
options: {
choices: [
{ content: "London" },
{ content: "Paris", correct: true },
{ content: "Berlin" },
{ content: "Madrid" },
],
},
},
};
const PerseusQuestion = () => (
<Perseus
question={question}
onScore={(score) => console.log("Score:", score)}
/>
);
- Creating an interactive graph:
import { Perseus } from "@khanacademy/perseus";
const graphQuestion = {
question: {
content: "Plot the point (3, 2) on the graph.",
widgets: {
"graph1": {
type: "interactive-graph",
options: {
range: [[-5, 5], [-5, 5]],
labels: ["x", "y"],
step: [1, 1],
correct: { type: "point", coords: [3, 2] },
},
},
},
},
};
const GraphQuestion = () => (
<Perseus
question={graphQuestion}
onScore={(score) => console.log("Score:", score)}
/>
);
- Creating a numeric input question:
import { Perseus } from "@khanacademy/perseus";
const numericQuestion = {
question: {
content: "What is 2 + 2?",
widgets: {},
},
answerArea: {
type: "input-number",
options: {
value: "4",
simplify: "required",
size: "small",
},
},
};
const NumericQuestion = () => (
<Perseus
question={numericQuestion}
onScore={(score) => console.log("Score:", score)}
/>
);
Getting Started
To get started with Perseus:
-
Install the package:
npm install @khanacademy/perseus
-
Import and use Perseus in your React application:
import { Perseus } from "@khanacademy/perseus"; import "@khanacademy/perseus/styles/perseus-renderer.css"; function App() { return ( <Perseus question={yourQuestionObject} onScore={(score) => handleScore(score)} /> ); }
-
Create question objects as shown in the examples above and pass them to the Perseus component.
-
Customize and extend Perseus as needed for your specific educational content requirements.
Competitor Comparisons
The open LMS by Instructure, Inc.
Pros of Canvas LMS
- More comprehensive LMS solution with broader feature set
- Larger community and wider adoption in educational institutions
- Better documentation and support resources
Cons of Canvas LMS
- More complex codebase, potentially harder to contribute to
- Heavier system requirements for deployment
- Less focused on interactive content creation
Code Comparison
Perseus:
const question = Perseus.renderQuestion({
question: {
content: "What is 2 + 2?",
widgets: {}
},
answerArea: {
calculator: false
}
});
Canvas LMS:
class Assignment < ActiveRecord::Base
belongs_to :course
has_many :submissions
validates :name, presence: true
validates :points_possible, numericality: { greater_than_or_equal_to: 0 }
end
Summary
Perseus is a specialized library for creating interactive educational content, while Canvas LMS is a full-featured learning management system. Perseus focuses on rendering interactive questions and exercises, making it more suitable for content creators. Canvas LMS, on the other hand, provides a complete platform for course management, grading, and student interaction, making it more appropriate for educational institutions looking for an all-in-one solution.
Moodle - the world's open source learning platform
Pros of Moodle
- More comprehensive learning management system (LMS) with a wider range of features
- Larger and more active community, resulting in frequent updates and extensive plugin ecosystem
- Supports multiple languages and is highly customizable for various educational institutions
Cons of Moodle
- Steeper learning curve due to its complexity and extensive feature set
- Requires more server resources and may be slower than Perseus for simpler applications
- Can be overwhelming for users who only need basic assessment functionality
Code Comparison
Perseus (JavaScript):
const question = Perseus.renderQuestion({
question: {
content: "What is 2 + 2?",
widgets: {}
},
answerArea: {
calculator: false
}
});
Moodle (PHP):
$question = new stdClass();
$question->qtype = 'numerical';
$question->name = 'Simple arithmetic';
$question->questiontext = 'What is 2 + 2?';
$question->answer = 4;
Perseus focuses on interactive, client-side rendering of questions, while Moodle's approach is more server-centric and integrated into a larger LMS framework. Perseus is better suited for lightweight, interactive math and science problems, whereas Moodle offers a complete solution for managing courses, assignments, and assessments across various subjects and educational settings.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Perseus
Perseus Exercise Renderer
Perseus is Khan Academy's exercise system. This repo contains the code needed to take a problem in the Perseus format and present it, allow interaction, and grade the result of a learner's work.
This repo is a constellation of sub-repos for showing exercise content. Please see individual projects in in the packages/
folder for more information about each sub-project.
Getting started
Prerequisites
Installation
To install Perseus, you need to run the following commands:
pnpm install
Installs project dependencies and tooling
Using Storybook
The components and widgets of Perseus are developed using Storybook. After you clone the project and get dependencies installed, the next step is to start storybook by running pnpm storybook
. This will start a server and give you a playground to use each component.
Using Changesets
We use changesets to help manage our versioning/releases. Before pushing a new PR, add a changeset by running pnpm changeset
. Commit and submit that with the PR.
Updating Dependencies
If you want to use another library in Perseus, you will need up update the dependencies.
Use peerDependencies
and devDependencies
for dependencies that webapp is already using, such as
Wonder Blocks or React.
cd
into to the package in which you would like to update the dependency.
cd packages/[package-name]
// Example
cd packages/perseus-editor
- Run the following command to update the dev dependencies and the peer dependencies.
// All dependencies
pnpm add --dev [dependency name]
// Include this too if webapp is using this dependency
pnpm add --peer [dependency name]
// Example
pnpm add --dev @khanacademy/wonder-blocks-button
pnpm add --peer @khanacademy/wonder-blocks-button
Contributing
The Perseus project is not accepting external contributions. Weâre releasing the code for others to refer to and learn from, but we are not open to pull requests or issues at this time.
KA Contribution Guide
For a slightly more detailed overview, see the "Shipping a Change to Perseus" document in Confluence.
Perseus is a monorepo - a single repository that ships multiple npm packages. Generally you can treat Perseus as a single code base; things should generally just work as you expect them to during the development process. We use scripts and a tool called changesets to keep package inter-dependencies organized, release the one repo to multiple npm packages, and version changes appropriately.
Working
-
git checkout main; git pull
-
git checkout -b [FEATURE_BRANCH_NAME]
-
â¢ï¸ We donât use deploy branches in Perseus
-
Start a dev server
a.
pnpm start
will start Storybook on localhost:6006b.
pnpm dev
will start the custom Dev UI on localhost:5173 -
Do stuff
-
pnpm test
will run Jest/RTL tests;pnpm cypress
will run Cypress tests -
pnpm changeset
will walk you through creating a changeset (we generally stick to semver) -
â¢ï¸ Empty changesets should be considered an exception to the rule and should generally be avoided
-
git add
andgit commit
-
git pull-request
will walk you through creating a pull request
CI/CD aka Github
- When you create/update a PR, we run a series of checks against your code
- Gerald requests reviewers (thereâs a âperseusâ user group that primary maintainers are in)
- Linting/Types/Tests; checks to make sure code is properly covered
- Check for a changeset
- ð A snapshot release is made and can be used to check changes before merging/releasing
- Once checks pass and code is approved, land your changes into
main
usinggit land
- ð¨
main
should always be releasable! Donât land code to main that youâre not ready to ship! - ð Use stacked feature branches if youâre working on a big change that depends on multiple PRs
Releasing Perseus to npm
- Landing changes to
main
creates/updates a âVersion Packagesâ PR - To cut a Perseus release, approve and land the âVersion Packagesâ PR
(typically with
git land
) - â¢ï¸ If the CI/CD checks arenât running, you might need to close and reopen the PR
- After the release script runs, you should see the new releases on the release page
Random notes
- We use
v8
to track Jest coverage. There's some old legacy code that we don't want coverage for, so we ignore that withc8 ignore
. It might look likec8
isn't be used, but it's used by thev8
coverageProvider
(defined in config/test/test.config.js).
License
Top Related Projects
The open LMS by Instructure, Inc.
Moodle - the world's open source learning platform
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot