Skip to content

Commit 90ead28

Browse files
author
oscarlevin via GitHub Actions
committed
Update css and js for CDN
1 parent 32d1abd commit 90ead28

2 files changed

Lines changed: 24 additions & 10 deletions

File tree

dist/_static/pretext/js/pretext-webwork/2.19/pretext-webwork.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ async function handleWW(ww_id, action) {
7777
url = new URL(ww_domain + '/webwork2/render_rpc');
7878
}
7979
let formData = new FormData();
80+
let generatedPG = 'generated/webwork/pg/';
81+
if (runestone_logged_in) {
82+
generatedPG = `/ns/books/published/${eBookConfig.basecourse}/${generatedPG}`;
83+
}
8084

8185
if (action == 'check' || action =='reveal') {
8286
const iframe = ww_container.querySelector('.problem-iframe');
@@ -87,14 +91,14 @@ async function handleWW(ww_id, action) {
8791
formData.set('WWcorrectAnsOnly', "1");
8892
}
8993
if (ww_origin == 'generated') {
90-
const rawProblemSource = await fetch('generated/webwork/pg/' + ww_problemSource).then((r) => r.text());
94+
const rawProblemSource = await fetch(generatedPG + ww_problemSource).then((r) => r.text());
9195
formData.set("rawProblemSource", rawProblemSource);
9296
}
9397
else if (ww_origin == 'webwork2') formData.set("sourceFilePath", ww_sourceFilePath);
9498
} else {
9599
formData.set("problemSeed", ww_container.dataset.current_seed);
96100
if (ww_origin == 'generated') {
97-
const rawProblemSource = await fetch('generated/webwork/pg/' + ww_problemSource).then((r) => r.text());
101+
const rawProblemSource = await fetch(generatedPG + ww_problemSource).then((r) => r.text());
98102
formData.set("rawProblemSource", rawProblemSource);
99103
}
100104
else if (ww_origin == 'webwork2') formData.set("sourceFilePath", ww_sourceFilePath);
@@ -323,7 +327,10 @@ async function handleWW(ww_id, action) {
323327
// Runestone trigger
324328
$("body").trigger('runestone_ww_check', data)
325329
}
326-
330+
let courseUrlBase = '';
331+
if (runestone_logged_in){
332+
courseUrlBase = '/ns/books/published/' + eBookConfig.basecourse + '/';
333+
}
327334
let iframeContents = '<!DOCTYPE html><head>' +
328335
'<script src="' + ww_domain + '/webwork2_files/node_modules/jquery/dist/jquery.min.js"></script>' +
329336
`<script>
@@ -377,7 +384,7 @@ async function handleWW(ww_id, action) {
377384
};
378385
</script>` +
379386
'<script src="' + ww_domain + '/webwork2_files/node_modules/mathjax/es5/tex-chtml.js" id="MathJax-script" defer></script>' +
380-
'<script src="_static/pretext/js/lib/knowl.js" defer></script>' +
387+
`<script src="${courseUrlBase}_static/pretext/js/lib/knowl.js" defer></script>` +
381388
'<link rel="stylesheet" href="' + ww_domain + '/webwork2_files/node_modules/bootstrap/dist/css/bootstrap.min.css"/>' +
382389
'<script src="' + ww_domain + '/webwork2_files/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js" defer></script>';
383390

@@ -401,7 +408,7 @@ async function handleWW(ww_id, action) {
401408
}
402409

403410
iframeContents +=
404-
'<link rel="stylesheet" href="_static/pretext/css/theme.css"/>' +
411+
`<link rel="stylesheet" href="${courseUrlBase}_static/pretext/css/theme.css"/>` +
405412
'<script src="' + ww_domain + '/webwork2_files/node_modules/iframe-resizer/js/iframeResizer.contentWindow.min.js"></script>' +
406413
`<style>
407414
html { overflow-y: hidden; }

dist/_static/pretext/js/pretext-webwork/2.20/pretext-webwork.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ async function handleWW(ww_id, action) {
7777
url = new URL(ww_domain + '/webwork2/render_rpc');
7878
}
7979
let formData = new FormData();
80+
let generatedPG = 'generated/webwork/pg/';
81+
if (runestone_logged_in) {
82+
generatedPG = `/ns/books/published/${eBookConfig.basecourse}/${generatedPG}`;
83+
}
8084

8185
if (action == 'check' || action =='reveal') {
8286
const iframe = ww_container.querySelector('.problem-iframe');
@@ -87,14 +91,14 @@ async function handleWW(ww_id, action) {
8791
formData.set('WWcorrectAnsOnly', "1");
8892
}
8993
if (ww_origin == 'generated') {
90-
const rawProblemSource = await fetch('generated/webwork/pg/' + ww_problemSource).then((r) => r.text());
94+
const rawProblemSource = await fetch(generatedPG + ww_problemSource).then((r) => r.text());
9195
formData.set("rawProblemSource", rawProblemSource);
9296
}
9397
else if (ww_origin == 'webwork2') formData.set("sourceFilePath", ww_sourceFilePath);
9498
} else {
9599
formData.set("problemSeed", ww_container.dataset.current_seed);
96100
if (ww_origin == 'generated') {
97-
const rawProblemSource = await fetch('generated/webwork/pg/' + ww_problemSource).then((r) => r.text());
101+
const rawProblemSource = await fetch(generatedPG + ww_problemSource).then((r) => r.text());
98102
formData.set("rawProblemSource", rawProblemSource);
99103
}
100104
else if (ww_origin == 'webwork2') formData.set("sourceFilePath", ww_sourceFilePath);
@@ -323,7 +327,10 @@ async function handleWW(ww_id, action) {
323327
// Runestone trigger
324328
$("body").trigger('runestone_ww_check', data)
325329
}
326-
330+
let courseUrlBase = '';
331+
if (runestone_logged_in){
332+
courseUrlBase = '/ns/books/published/' + eBookConfig.basecourse + '/';
333+
}
327334
let iframeContents = '<!DOCTYPE html><head>' +
328335
'<script src="' + ww_domain + '/webwork2_files/node_modules/jquery/dist/jquery.min.js"></script>' +
329336
`<script>
@@ -377,7 +384,7 @@ async function handleWW(ww_id, action) {
377384
};
378385
</script>` +
379386
'<script src="' + ww_domain + '/webwork2_files/node_modules/mathjax/es5/tex-chtml.js" id="MathJax-script" defer></script>' +
380-
'<script src="_static/pretext/js/lib/knowl.js" defer></script>' +
387+
`<script src="${courseUrlBase}_static/pretext/js/lib/knowl.js" defer></script>` +
381388
'<link rel="stylesheet" href="' + ww_domain + '/webwork2_files/node_modules/bootstrap/dist/css/bootstrap.min.css"/>' +
382389
'<script src="' + ww_domain + '/webwork2_files/node_modules/bootstrap/dist/js/bootstrap.bundle.min.js" defer></script>';
383390

@@ -401,7 +408,7 @@ async function handleWW(ww_id, action) {
401408
}
402409

403410
iframeContents +=
404-
'<link rel="stylesheet" href="_static/pretext/css/theme.css"/>' +
411+
`<link rel="stylesheet" href="${courseUrlBase}_static/pretext/css/theme.css"/>` +
405412
'<script src="' + ww_domain + '/webwork2_files/node_modules/iframe-resizer/js/iframeResizer.contentWindow.min.js"></script>' +
406413
`<style>
407414
html { overflow-y: hidden; }

0 commit comments

Comments
 (0)