Developer's Guide
1) init_vpython
The init_vpython function defined in preload.py handles the following:
- CSS styling of the GlowScript simulation components & importing of the GlowScript scripts required to make and display the simulation
- Custom logic to ensure that only one GlowScript simulation is running at a time
- Bugs with conflicting versions of MathJax
This function must be called in content.catsoop using a <python> element.
2) vpython.py
2.1) Defaults
Thevpython question type extends the built-in pythoncode question type.
The question uses two new variables, csq_vpython_pre and csq_vpython_post, which are analogous to csq_code_pre and csq_code_post.
The difference is that csq_vpython_pre and csq_vpython_post are used by handle_check to generate the GlowScript simulation response,
whereas csq_code_pre and csq_code_post are used by handle_submit to grade submissions.
2.2) Code Injection
This question type expectscsq_name to have the format X_Y where X is any string and Y is an integer.
This format enables a vpython question to get a user's submitted code for all questions with a matching X and smaller Y value.
Those code submissions are then injected into the simulation code in handle_check wherever that submission's corresponding csq_name is found.
2.3) GlowScript
Thehandle_check function returns a JavaScript <script> element which compiles the submitted Python code into JavaScript and uses it to generate the GlowScript animation in the response.