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

Commit 9cfc824

Browse files
committed
Cleaned up code and documentation.
1 parent aeca1e2 commit 9cfc824

2 files changed

Lines changed: 18 additions & 62 deletions

File tree

runestone/quizly/README.txt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,24 @@ runestone/quizly/quizly.py -- creates QuizlyNode from directive
1313
runestone/quizly/__init__.py -- imports the quizly code
1414
runestone/quizly/toctree.rst
1515

16-
runestone/quizly/js -- javascript resources
16+
runestone/quizly/js -- javascript resources
17+
-- quizly.js -- renders quizly exercise and handles interface with runestone
18+
19+
Quizly source files must be store in COURSE/_static. They include:
1720
-- all_appinv.js -- compressed files
1821
-- all_blockly.js
1922
-- all_quizly.js
2023
-- blockly.html -- blockly iframe
2124
-- index.html -- quizly UI and iframe container
2225
-- main.css -- gcb style defs
23-
-- media -- image and icon files
24-
-- quizly.js -- renders quizly exercise and handles interface with runestone
26+
-- media -- directory image and icon files
2527
-- quizme-helper.js -- main quizly code
2628
-- quizzes.js -- quizly quiz collection in JSON format
2729

30+
The content files for the quizly component must stored in the course's _static folder.
31+
Download the following file and unzip it in COURSE/_static, where COURSE is your course:
32+
https://github.com/ram8647/quizly/blob/35ee7c945e6f240450f46f41ad9c80735215b5e0/quizly-runestone.zip
33+
2834
runestone/quizly/test -- some test code
2935
-- _sources -- test files
3036
-- Quizly
@@ -41,10 +47,6 @@ The files that need to be coded by the developer
4147
Th script that runs during runestone build. Runestone build parses the
4248
source document and translates the directive and its options into a QuizlyNode.
4349

44-
- Copies resource files from quizly/js to the project/_static folder, from where
45-
they are copied to build/quizly/_static during build, where they are used by
46-
the _sources web pages.
47-
4850
- QuizlyNode -- defines the node. The only option needed for this is the quizname,
4951
which is parsed from the directive.
5052

@@ -73,8 +75,8 @@ quizly.js contains the following methods and functions:
7375
-- class Quizly extends RunestoneBase -- constructs a Quizly object that holds the
7476
data from the exercise. Calls renderQuiz() method.
7577

76-
-- getIFrame() -- extracts the iframe from the fully instantiated html code produced
77-
by quizly.py and contained in QuizlyNode.
78+
-- getIFrameAndQuizname() -- extracts the iframe from the fully instantiated html code
79+
produced by quizly.py and contained in QuizlyNode. And gets the specific quizname.
7880

7981
-- renderQuizly() -- renders the quizly iframe inside a container <div>.
8082

runestone/quizly/quizly.py

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,20 @@
1414
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1515
#
1616

17-
# This files runs during runestone build. It generates the node data
17+
# This file runs during runestone build. It generates the node data
1818
# that is used to render the component by the quizly.js script.
1919

2020
# Note: An import entry for quizly must be included in runestone/__init__.py
2121

22+
# Note: The content files for the quizly component must stored in the
23+
# course's _static folder. Download the following file and unzip it in _static:
24+
# https://github.com/ram8647/quizly/blob/35ee7c945e6f240450f46f41ad9c80735215b5e0/quizly-runestone.zip
25+
#
26+
2227
__author__ = "rmorelli"
2328

2429
# Debug flags
25-
DEBUG = True
30+
DEBUG = False
2631
VERBOSE = False
2732

2833
import os, shutil
@@ -42,56 +47,6 @@
4247
</div>
4348
"""
4449

45-
# Resource files should be stored in the X/_static directory, from where they
46-
# will be automatically copied into build/x/_static, where 'x' is the project name
47-
STATIC_DIR = "./_static"
48-
49-
# Copy the resource files into the _static folder, maintaining proper folder hierarchy
50-
# The resources should be organized as follows:
51-
# _static
52-
# |-quizly
53-
# |- all_appinventor.js - compressed js files
54-
# |- all_blockly.js - compressed js files
55-
# |- all_quizly.js - compressed js files
56-
# |- quizme-helper.js - main source code
57-
# |- quizzes.js - quizly quizzes
58-
# |- index.html - container for the iframe
59-
# |- blockly.html - blockly iframe
60-
# |- main.css
61-
# |- media - folder of images, etc.
62-
# Perhaps there's a runestone routine to copy files?
63-
# TODO: Test this with MobileCSP units
64-
# def copyfiles():
65-
# CURR_DIR = os.path.dirname(os.path.realpath(__file__))
66-
# QUIZLY_DIR = STATIC_DIR+'/quizly'
67-
# MEDIA_DIR = QUIZLY_DIR+'/media'
68-
# if not os.path.exists(QUIZLY_DIR):
69-
# print('Missing directory ' + QUIZLY_DIR) if DEBUG else None
70-
# # shutil.rmtree(QUIZLY_DIR)
71-
# # os.mkdir(QUIZLY_DIR, mode=0o755)
72-
# # os.mkdir(QUIZLY_DIR+'/media', mode=0o755)
73-
# js_folder = Path(CURR_DIR).glob('js/*.js')
74-
# html_folder = Path(CURR_DIR).glob('js/*.html')
75-
# media_folder = Path(CURR_DIR).glob('js/media/*')
76-
# css_folder = Path(CURR_DIR).glob('js/*.css')
77-
# files = [x for x in js_folder]
78-
# print('Copying resource files to ' + STATIC_DIR) if VERBOSE else None
79-
# for f in files:
80-
# print(str(f) + ' --> ' + QUIZLY_DIR) if VERBOSE else None
81-
# shutil.copy(f, QUIZLY_DIR)
82-
# files = [x for x in css_folder]
83-
# for f in files:
84-
# print(str(f) + ' --> ' + QUIZLY_DIR) if VERBOSE else None
85-
# shutil.copy(f, QUIZLY_DIR)
86-
# files = [x for x in html_folder]
87-
# for f in files:
88-
# print(str(f) + ' --> ' + QUIZLY_DIR) if VERBOSE else None
89-
# shutil.copy(f, QUIZLY_DIR)
90-
# files = [x for x in media_folder]
91-
# for f in files:
92-
# print(str(f) + ' --> ' + MEDIA_DIR) if VERBOSE else None
93-
# shutil.copy(f, MEDIA_DIR)
94-
9550
# Define the quizly directive
9651
def setup(app):
9752
app.add_directive("quizly", Quizly)
@@ -126,7 +81,6 @@ def visit_quizly_node(self, node):
12681
print('DEBUG: visit_quizly_node options = ' + str(node.runestone_options)) if DEBUG else None
12782

12883
res = node.template % (node.runestone_options)
129-
# copyfiles() # Copy resource files
13084
print('DEBUG: visit_quizly_node res = ' + res) if DEBUG else None
13185
self.body.append(res)
13286

0 commit comments

Comments
 (0)