Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit a50438e

Browse files
committed
Initial commit of the khanex (Khan exercise) component.
1 parent f0eb1fb commit a50438e

587 files changed

Lines changed: 104743 additions & 16 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package-lock.json

Lines changed: 484 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runestone/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from .mchoice import MChoice, QuestionNumber
99
from .blockly import Blockly
1010
from .quizly import Quizly
11+
from .khanex import Khanex
1112
from .codelens import Codelens
1213
from .clickableArea import ClickableArea
1314
from .datafile import DataFile

runestone/khanex/README.txt

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
README.txt
2+
3+
The khanex directive, in this first pass looks like this:
4+
-----------------------------------------------
5+
6+
.. khanex::
7+
:exercise: unique-exercise-name /qs folder
8+
9+
The quizly component uses and requires the following resources:
10+
----------------------------------------------
11+
12+
runestone/khanex/khanex.py -- creates KhanexNode from directive
13+
runestone/khanex/__init__.py -- imports the khanex code
14+
15+
runestone/khanex/js -- javascript resources
16+
17+
18+
runestone/khanex/test -- some test code
19+
-- _sources -- test files
20+
-- conf.py -- sphinx config file for runestone
21+
-- pavement.py -- needed for runestone build
22+
23+
The files that need to be coded by the developer
24+
-----------------------------------------------
25+
26+
./runestone/khanex/khanex.py
27+
----------------------------
28+
Th script that runs during runestone build. Runestone build parses the
29+
source document and translates the directive and its options into a QuizlyNode.
30+
31+
- Copies resource files from quizly/js to the project/_static folder, from where
32+
they are copied to build/quizly/_static during build, where they are used by
33+
the _sources web pages.
34+
35+
- QuizlyNode -- defines the node. The only option needed for this is the quizname,
36+
which is parsed from the directive.
37+
38+
- visit_quizly_mode(self, node) -- appends the quizly template, instantiated, to the
39+
body of the html document that will represent the quizly exercise
40+
41+
- Quizly(RunestoneDirective) -- its run() method instantiates and returns QuizlyNode,
42+
probably called by runestone build.
43+
44+
./runestone/khanex/__init__.py -- called by runestone build, imports khanex.py
45+
------------------------------
46+
47+
./runestone/khanex/js/khanex.js
48+
-------------------------------
49+
50+
This script runs when the html page containing the khanex iframe is loaded. It contains
51+
methods to render the khanex component and to handle the interface with runestone.
52+
53+
This script will be invoked automatically when the page is loaded, provided a khanex entry
54+
is made in the module.exports list in webpack.config.js.
55+
56+
"./runestone/khanex/js/khanex.js",
57+
58+
khanex.js contains the following methods and functions:
59+
60+
-- class Khanex extends RunestoneBase -- constructs a Khanex object that holds the
61+
data from the exercise. Calls renderQuiz() method.
62+
63+
-- getIFrame() -- extracts the iframe from the fully instantiated html code produced
64+
by khanex.py and contained in KhanexNode.
65+
66+
-- renderKhanex() -- renders the khanex iframe inside a container <div>.
67+
68+
-- submitKhanex() -- the method invoked from the callback function when the user
69+
clicks "Check Me" button in the khanex exercise.
70+
71+
$(document).bind( ,,, function() {}) -- function that sets up the callback function
72+
and binds it to the html document.
73+
74+
setupCallback(khanex) -- defines the callback function that is invoked when the "Check Me"
75+
button is clicked. It calls khanex.submitKhanex(result), where result is the
76+
khanex-graded response to the user's attempt.
77+

runestone/khanex/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .khanex import *

runestone/khanex/js/.htaccess

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Header set Access-Control-Allow-Origin "*"
5.9 KB
Loading
38.8 KB
Loading
44 KB
Loading
292 Bytes
Loading
1.29 KB
Loading

0 commit comments

Comments
 (0)