Moocfi Python Editor is a React component that provides an in-browser editing, running and testing environment for TestMyCode python courses. The editor is based on Pyodide python runtime environment that is run using webworkers.
Install with npm install moocfi-python-editor
.
The editor component can be used in a following way:
import { ProgrammingExercise } from "moocfi-python-editor"
const App = () => {
// ...
return (
<ProgrammingExercise
organization="organization-slug"
course="course-name"
exercise="exercise-name"
userId="user-id"
token="user-token"
/>
)
}
Required properties:
organization
,course
andexercise
Define which TMC exercise will be loaded.userId
andtoken
are used to identify the current user.
Optional properties:
debug
Show and log debug information if set totrue
.language
Editor's localization. Currently supportsen
(default) andfi
.height
Height of the editor. Defaults to400px
.outputHeight
Maximum height of the output content in pixels.onExerciseDetailsChange
Callback function that provides details about the exercise. These details vary by user.
- Clone the project on GitHub
- Go to the project root directory and run
npm ci
&npm run encode:worker
- Go to the
example
directory and runnpm ci
To run the project in example environment, go to the example
directory and
run npm start
.
If you make any changes to the worker, you will always need to run the encode:worker
command again.
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license, (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.