Git Product home page Git Product logo

optlite's Introduction

OPT Lite

Online Python Tutor (OPT) is a popular virtual learning tool that provides interactive visualisation of program execution in a browser without login. However, such a tool is not easy to maintain because serving allowing the public to run programs in a server without login incurs high computational cost in addition to security risks.

This project makes OPT serverless, i.e., usuable offline without a server. Python programs are run by the browser using pyodide. Hence, teachers can enable more python packages/functions than the original setup without worrying about network attacks. For online exam, students may also use the tool to debug programs without worry of network outage. It can also run in Safe Exam Browser.

How to use

Simply visit

https://dive4dec.github.io/optlite/

The live edit mode is at

https://dive4dec.github.io/optlite/live.html

Programs can be shared using permalinks

Create a custom site

Git clone the current repository by running

git clone https://github.com/dive4dec/optlite

Setup a python environment. In the root folder of the repository, run the following to create the python wheel file under dist folder.

pip install -r optlite/requirements.txt
python setup.py bdist_wheel -d dist

Setup [NodeJs]. Install the required packages as

npm install
npm run build:prod

Serve the content in build directory using an http server, e.g.:

python -m simple.http -d build

To install addition packages, take a look at the OptLite object at

E.g., to install snowballstemmer, modify the script tag in the header of build/index.html to

<script>
OptLite = {
  packages: ['snowballstemmer']
};

(function () {
  let script = document.createElement('script');
  script.src = 'visualize.bundle.js';
  script.defer = true;
  document.head.appendChild(script);
}) ();
</script>

and modify the script tag in the header of build/live.html to

<script>
OptLite = {
  packages: ['snowballstemmer']
};

(function () {
  let script = document.createElement('script');
  script.src = 'opt-live.bundle.js';
  script.defer = true;
  document.head.appendChild(script);
}) ();
</script>

optlite's People

Contributors

ccha23 avatar thchan384 avatar chunxy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.