Skip to content

Commit ed884fb

Browse files
committed
iss1211 - Documentation
1 parent a624e95 commit ed884fb

File tree

5 files changed

+54
-10
lines changed

5 files changed

+54
-10
lines changed

db/mobile.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
'delegate' => 'CoreQuestionDelegate',
3232
'method' => 'stack_view',
3333
'styles' => [
34-
'url' => $CFG->wwwroot . '/question/type/stack/mobile.css?v=2024091200',
34+
'url' => $CFG->wwwroot . '/question/type/stack/mobile.css',
3535
'version' => 2024080200,
3636
],
3737
],

doc/en/Developer/Moodle_app.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Moodle App compatibility
2+
3+
The following files have been added to make STACK compatible with the Moodle App:
4+
5+
## Files
6+
7+
### db/mobile.php
8+
Sets up a Moodle webservice to serve STACK questions to the app. Points to the mobile CSS file. Update the version here if you update the CSS.
9+
10+
### classes/output/monile.php
11+
Points the Moodle webservice to the ionic template and javascript files. (Worth changing the JS to the unminified version while developing.)
12+
13+
### mobile.css
14+
Mostly a straight copy of styles.css with a few extra classes. Also moves pix references to within STACK due to relative URL issues.
15+
16+
### mobile/stack.html
17+
Ionic template to build the question. This is very basic as we are essentially just filtering the original in-browser HTML. Because STACK questions are so complicated and can have elements in any order we can't do anything clever here.
18+
19+
### mobile/stack.js, mobile/stack.min.js
20+
The complicated bit. The Moodle App receives a JSON object with the original HTML of the question, metadata and script code. This is then inspected by stack.js. Plain radio, dropdown and checkbox elements are replaced by native elements. Code for iFrames is extracted, updated and then used to create the iFrames. Inputs are initialised.
21+
22+
The code includes large chunks of duplicate code from input.js and stackjsvle.js with updates due to requiring different element selectors for the native elements. Because the JS is served to the App as part of the webservice, even a way to split it up into separate files is currently obscure, let alone modularising it so we can use the same code in STACK and the App.
23+
24+
`uglifyjs stack.js > stack.min.js`
25+
26+
### app.feature, jsx_app_test.feature
27+
Behat tests for all input types and a basic JSX test.
28+
29+
## Running locally
30+
31+
- Clone the app repository.
32+
`npm install`
33+
`npm start`
34+
- Close the browser window that opens automatically and instead start chromium:
35+
`chromium --allow-file-access-from-files --disable-web-security --disable-site-isolation-trials --allow-running-insecure-content --no-referrers --unlimited-storage --ignore-certificate-errors --disable-infobars --user-data-dir=~/.chromium-dev-data`
36+
- Go to `localhost:8100`
37+
38+
## Known issues
39+
- GeoGebra not yet tested due to local setup issues.

doc/meta_en.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,11 @@
872872
"description":"Maxima has a very wide range of optional packages. Read about options for adding more Maxima packages to your installation of STACK."
873873
},
874874
{
875+
"file":"Moodle_app.md",
876+
"title":"Maintaining Moodle App compatibility - STACK Documentation",
877+
"description":"A rundown of the files which allow STACK to operate in the Moodle App."
878+
},
879+
{
875880
"file":"Parser.md",
876881
"title":"Building the parser",
877882
"description":"This document describes the design of the parser for dealing with students' answers and Maxima statements."
@@ -1102,7 +1107,7 @@
11021107
"title":"Vector Calculus - STACK Documentation",
11031108
"description":"This page provides advice for writing STACK questions in vector calculus."
11041109
}
1105-
]
1110+
]
11061111
}
11071112
]
11081113
}

mobile/stack.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,16 @@ var result = {
170170
iframe += 'false';
171171
}
172172
const args = JSON.parse('[' + iframe + ']');
173-
// Scripts are now being loaded cross origin and Chrome complains.
173+
// Load included style sheet separately due to relative location issues.
174174
const baseRef = siteUrl + "/question/type/stack/corsscripts/cors.php?name=";
175175
args[1] = args[1].replace(baseRef + 'sortable.min.css" rel="stylesheet">',
176-
baseRef + 'sortable.min.css" crossorigin="anonymous" rel="stylesheet">'
177-
+ '<link rel="stylesheet" crossorigin="anonymous" href="' + baseRef + 'styles.css"></link>');
176+
baseRef + 'sortable.min.css" rel="stylesheet">'
177+
+ '<link rel="stylesheet" href="' + baseRef + 'styles.css"></link>');
178+
// Scripts are now being loaded cross origin and Chrome complains.
179+
// It may just be a dev environment issue.
178180
args[1] = args[1].replace(/<img/g, '<img crossorigin=\'anonymous\'');
179-
args[1] = args[1].replace(baseRef + 'geogebracore.js"', baseRef + 'geogebracore.js" crossorigin="anonymous"');
180-
args[1] = args[1].replace(baseRef + 'jsxgraph.min.css"', baseRef + 'jsxgraph.min.css" crossorigin="anonymous"');
181-
args[1] = args[1].replace(baseRef + 'jsxgraphcore.min.js"',
182-
baseRef + 'jsxgraphcore.min.js" crossorigin="anonymous"');
181+
args[1] = args[1].replace(/<script/g, '<script crossorigin=\'anonymous\'');
182+
args[1] = args[1].replace(/<link/g, '<link crossorigin=\'anonymous\'');
183183
iframesArgs.push(args);
184184
}
185185

mobile/stack.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)