Skip to content

Commit 9232eb2

Browse files
committed
Fix some issues with sample problem documentation generation.
When I updated the sample problem documentation to use CodeMirror 6, apparently prettier accidentally ran on the `problem-template.mt` file (due to the format on save feature in my editor). Since that is a Mojolicious template file, prettier does not do the right thing, and messed that file up pretty well. So this fixes the resulting issues. Also, fix several typos in the sample problems that have a PODLINK or PROBLINK that have incorrect macro or sample problem file names. These cause "use of unitialized value" warnings when the `parse-problem-doc.pl` script is executed. These warnings also occur when loading these sample problems via webwork2. Finally, switch the sample problem templates to using the same version of Bootstrap that webwork2 uses.
1 parent 0c7f42d commit 9232eb2

File tree

9 files changed

+97
-102
lines changed

9 files changed

+97
-102
lines changed

tutorial/sample-problems/Geometry/LineSegmentGraphTool.pg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#:% type = Sample
1616
#:% subject = [geometry]
1717
#:% categories = [graph, graphtool]
18-
#:% see_also = [VectorGraphTool.pg, TriangleGraphTool.pg, QuadrilateralGraphTool.pg]
18+
#:% see_also = [GraphToolVectors.pg, TriangleGraphTool.pg, QuadrilateralGraphTool.pg]
1919

2020
#:% section = preamble
2121
#: Load the PODLINK('parserGraphTool.pl') macro to be able to use the GraphTool.

tutorial/sample-problems/Parametric/Spacecurve.pg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ loadMacros('PGstandard.pl', 'PGML.pl', 'parserMultiAnswer.pl', 'PGcourse.pl');
2323
$showPartialCorrectAnswers = 0;
2424

2525
#:% section = setup
26-
#: The PODLINK('MultiAnswer') is used to check the answers together since they
27-
#: are interdependent.
26+
#: The PODLINK('parserMultiAnswer.pl') is used to check the answers together
27+
#: since they are interdependent.
2828
#:
2929
#: The option `singleResult => 1` is used since it doesn't make sense to say
3030
#: that `x(t)` is correct but `z(t)` is incorrect since they depend on one

tutorial/sample-problems/ProblemTechniques/FormattingDecimals.pg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');
4949
#: `useBaseTenLog` flag is 0, and the `log` function is the natural logarithm.
5050
#:
5151
#: If a function for log base 2 (or another base) is needed see
52-
#: PROBLINK('AddingFunctions.pg') for how to define and add a new function
52+
#: PROBLINK('DefiningFunctions.pg') for how to define and add a new function
5353
#: to the context so that students can enter it in their answers.
5454
Context()->variables->set(x => { limits => [ 0.1, 4 ] });
5555

tutorial/sample-problems/ProblemTechniques/Multianswer.pg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#:% categories = [multianswer]
1818

1919
#:% section = preamble
20-
#: Load the PODLINK('parserMultianswer.pl') which provides the `MultiAnswer`
20+
#: Load the PODLINK('parserMultiAnswer.pl') which provides the `MultiAnswer`
2121
#: method.
2222
DOCUMENT();
2323
loadMacros('PGstandard.pl', 'PGML.pl', 'parserMultiAnswer.pl', 'PGcourse.pl');

tutorial/sample-problems/VectorCalc/VectorLineSegment1.pg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#:% see_also = [VectorParametricLine.pg, VectorLineSegment2.pg]
2121

2222
#:% section = preamble
23-
#: The PODLINK('parseParametricLine.pl') macro provides the `ParametricLine`
23+
#: The PODLINK('parserParametricLine.pl') macro provides the `ParametricLine`
2424
#: function which us used to check the answer. The
2525
#: PODLINK('parserMultiAnswer.pl') macro is needed since the answers are
2626
#: interdependent.

tutorial/sample-problems/VectorCalc/VectorLineSegment2.pg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#:% see_also = [VectorParametricLine.pg, VectorLineSegment1.pg]
2121

2222
#:% section = preamble
23-
#: The PODLINK('parseVectorUtils.pl') macro is loaded for the
23+
#: The PODLINK('parserVectorUtils.pl') macro is loaded for the
2424
#: `non_zero_point3D` and `non_zero_vector3D` methods.
2525
DOCUMENT();
2626
loadMacros('PGstandard.pl', 'PGML.pl', 'parserVectorUtils.pl', 'PGcourse.pl');

tutorial/sample-problems/VectorCalc/VectorParametricLine.pg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#:% see_also = [VectorLineSegment1.pg, VectorLineSegment2.pg]
2121

2222
#:% section = preamble
23-
#: The PODLINK('parseVectorUtils.pl') macro provides the `non_zero_point3D` and
24-
#: `non_zero_vector3D` methods. The macro PODLINK('parseParametricLine.pl')
23+
#: The PODLINK('parserVectorUtils.pl') macro provides the `non_zero_point3D` and
24+
#: `non_zero_vector3D` methods. The macro PODLINK('parserParametricLine.pl')
2525
#: provides the `ParametricLine` function used for the answer.
2626
DOCUMENT();
2727
loadMacros(

tutorial/templates/general-layout.mt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta charset="utf-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>PG Sample Problems</title>
8-
<link href="https://cdn.jsdelivr.net/npm/[email protected].0/dist/css/bootstrap.min.css" rel="stylesheet">
8+
<link href="https://cdn.jsdelivr.net/npm/[email protected].3/dist/css/bootstrap.min.css" rel="stylesheet">
99
<style>
1010
.navbar {
1111
height: 70px;
@@ -26,7 +26,7 @@
2626
}
2727
}
2828
</style>
29-
<script src="https://cdn.jsdelivr.net/npm/[email protected].0/dist/js/bootstrap.bundle.min.js" defer></script>
29+
<script src="https://cdn.jsdelivr.net/npm/[email protected].3/dist/js/bootstrap.bundle.min.js" defer></script>
3030
</head>
3131

3232
<body>
Lines changed: 86 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,111 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="utf-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title><%= $filename %></title>
73

8-
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
9-
<script
10-
src="https://cdn.jsdelivr.net/npm/@openwebwork/[email protected]/dist/pg-codemirror-editor.js"
11-
defer
12-
></script>
13-
<link rel="stylesheet" href="<%= $pg_doc_home %>/sample-problem.css" />
14-
</head>
4+
<head>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title><%= $filename %></title>
158

16-
% # Default explanations % my $default = { % preamble => 'These standard macros need to be loaded.', % setup =>
17-
'This perl code sets up the problem.', % statement => 'This is the problem statement in PGML.', % answer => 'This is
18-
used for answer checking.', % solution => 'A solution should be provided here.' % };
9+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
10+
<script
11+
src="https://cdn.jsdelivr.net/npm/@openwebwork/[email protected]/dist/pg-codemirror-editor.js"
12+
defer></script>
13+
<link rel="stylesheet" href="<%= $pg_doc_home %>/sample-problem.css">
14+
</head>
1915

20-
<body>
21-
<div class="container-fluid p-3">
22-
<div class="row">
23-
<div class="col">
24-
<h1><%= $name %></h1>
25-
<p><%= $description %></p>
26-
</div>
27-
<div class="col text-end">
28-
<a href="<%= $pg_doc_home =%>/../">Return to the PG docs home</a>
29-
</div>
16+
% # Default explanations
17+
% my $default = {
18+
% preamble => 'These standard macros need to be loaded.',
19+
% setup => 'This perl code sets up the problem.',
20+
% statement => 'This is the problem statement in PGML.',
21+
% answer => 'This is used for answer checking.',
22+
% solution => 'A solution should be provided here.'
23+
% };
24+
25+
<body>
26+
<div class="container-fluid p-3">
27+
<div class="row">
28+
<div class="col">
29+
<h1><%= $name %></h1>
30+
<p><%= $description %></p>
3031
</div>
31-
<div class="row">
32-
<div class="col">
33-
<h2>Complete Code</h2>
34-
<p>Download file: <a href="<%= $filename =%>"><%= $filename =%></a></p>
35-
</div>
36-
% if (scalar(@{$metadata->{$filename}{macros}}) > 0 ) {
32+
<div class="col text-end">
33+
<a href="<%= $pg_doc_home =%>/../">Return to the PG docs home</a>
34+
</div>
35+
</div>
36+
<div class="row">
37+
<div class="col">
38+
<h2>Complete Code</h2>
39+
<p>Download file: <a href="<%= $filename =%>"><%= $filename =%></a></p>
40+
</div>
41+
% if (scalar(@{$metadata->{$filename}{macros}}) > 0 ) {
3742
<div class="col">
3843
<h2>POD for Macro Files</h2>
3944
<ul>
40-
% for my $macro (@{$metadata->{$filename}{macros}}) { % if ($macro_locations->{$macro}) {
41-
<li><a href="<%= $pod_root %>/<%= $macro_locations->{$macro} %>"><%= $macro =%></a></li>
42-
% } else {
43-
<li class="text-danger"><%= $macro %></li>
44-
% } % }
45-
</ul>
46-
</div>
47-
%} % if ($metadata->{$filename}{related} && scalar(@{$metadata->{$filename}{related}}) > 0) {
48-
<div class="col">
49-
<h2>See Also</h2>
50-
<ul>
51-
% for (@{$metadata->{$filename}{related}}) {
52-
<li>
53-
<a href="<%= $pg_doc_home =%>/<%= $metadata->{$_}{dir} =%>/<%= $_ =~ s/.pg$//r =%>.html">
54-
<%= $metadata->{$_}{name} =%></a
55-
>
56-
</li>
45+
% for my $macro (@{$metadata->{$filename}{macros}}) {
46+
% if ($macro_locations->{$macro}) {
47+
<li><a href="<%= $pod_root %>/<%= $macro_locations->{$macro} %>"><%= $macro =%></a></li>
48+
% } else {
49+
<li class="text-danger"><%= $macro %></li>
50+
% }
5751
% }
5852
</ul>
5953
</div>
6054
% }
55+
% if ($metadata->{$filename}{related} && scalar(@{$metadata->{$filename}{related}}) > 0) {
56+
<div class="col">
57+
<h2>See Also</h2>
58+
<ul>
59+
% for (@{$metadata->{$filename}{related}}) {
60+
<li>
61+
<a href="<%= $pg_doc_home =%>/<%= $metadata->{$_}{dir} =%>/<%= $_ =~ s/.pg$//r =%>.html">
62+
<%= $metadata->{$_}{name} =%>
63+
</a>
64+
</li>
65+
% }
66+
</ul>
6167
</div>
62-
<div class="row">
63-
<div class="col text-center"><h2 class="fw-bold fs-3">PG problem file</h2></div>
64-
<div class="col text-center"><h2 class="fw-bold fs-3">Explanation</h2></div>
65-
</div>
66-
% for (@$blocks) {
68+
% }
69+
</div>
70+
<div class="row">
71+
<div class="col text-center"><h2 class="fw-bold fs-3">PG problem file</h2></div>
72+
<div class="col text-center"><h2 class="fw-bold fs-3">Explanation</h2></div>
73+
</div>
74+
% for (@$blocks) {
6775
<div class="row">
6876
<div class="col-sm-12 col-md-6 order-md-first order-last p-0 position-relative overflow-x-hidden">
69-
<button
70-
class="clipboard-btn btn btn-sm btn-secondary position-absolute top-0 end-0 me-1 mt-1 z-1"
71-
type="button"
72-
data-code="<%== $_->{code} %>"
73-
aria-label="copy to clipboard"
74-
>
75-
<svg
76-
xmlns="http://www.w3.org/2000/svg"
77-
width="16"
78-
height="16"
79-
fill="currentColor"
80-
class="bi bi-clipboard-fill"
81-
viewBox="0 0 16 16"
82-
>
83-
<path
84-
fill-rule="evenodd"
85-
d="M10 1.5a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-1Zm-5 0A1.5 1.5 0 0 1 6.5 0h3A1.5 1.5 0 0 1 11 1.5v1A1.5 1.5 0 0 1 9.5 4h-3A1.5 1.5 0 0 1 5 2.5v-1Zm-2 0h1v1A2.5 2.5 0 0 0 6.5 5h3A2.5 2.5 0 0 0 12 2.5v-1h1a2 2 0 0 1 2 2V14a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V3.5a2 2 0 0 1 2-2Z"
86-
/>
77+
<button class="clipboard-btn btn btn-sm btn-secondary position-absolute top-0 end-0 me-1 mt-1 z-1"
78+
type="button" data-code="<%== $_->{code} %>" aria-label="copy to clipboard">
79+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
80+
class="bi bi-clipboard-fill" viewBox="0 0 16 16">
81+
<path fill-rule="evenodd" d="M10 1.5a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-1Zm-5 0A1.5 1.5 0 0 1 6.5 0h3A1.5 1.5 0 0 1 11 1.5v1A1.5 1.5 0 0 1 9.5 4h-3A1.5 1.5 0 0 1 5 2.5v-1Zm-2 0h1v1A2.5 2.5 0 0 0 6.5 5h3A2.5 2.5 0 0 0 12 2.5v-1h1a2 2 0 0 1 2 2V14a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V3.5a2 2 0 0 1 2-2Z"/>
8782
</svg>
8883
</button>
89-
<pre class="PGCodeMirror m-0 h-100 p-3 border border-secondary overflow-x-scroll">
90-
<%== $_->{code} %>
91-
</pre
92-
>
84+
<pre class="PGCodeMirror m-0 h-100 p-3 border border-secondary overflow-x-scroll"><%== $_->{code} %></pre>
9385
</div>
94-
<div
95-
class="explanation <%= $_->{section} %> col-sm-12 col-md-6 order-md-last order-first p-3 border border-dark"
96-
>
86+
<div class="explanation <%= $_->{section} %> col-sm-12 col-md-6 order-md-last order-first p-3 border border-dark">
9787
<p><b><%= ucfirst($_->{section}) %></b></p>
98-
% if ($_->{doc}) { <%= $_->{doc} %> %} else { <%= $default->{$_->{section}} %> %}
88+
% if ($_->{doc}) {
89+
<%= $_->{doc} %>
90+
% } else {
91+
<%= $default->{$_->{section}} %>
92+
% }
9993
</div>
10094
</div>
101-
% }
102-
</div>
95+
% }
96+
</div>
97+
98+
<script type="module">
99+
for (const pre of document.body.querySelectorAll('pre.PGCodeMirror')) {
100+
PGCodeMirrorEditor.runMode(pre.textContent, pre);
101+
}
103102

104-
<script type="module">
105-
for (const pre of document.body.querySelectorAll('pre.PGCodeMirror')) {
106-
PGCodeMirrorEditor.runMode(pre.textContent, pre);
107-
}
103+
for (const btn of document.querySelectorAll('.clipboard-btn')) {
104+
if (navigator.clipboard)
105+
btn.addEventListener('click', () => navigator.clipboard.writeText(btn.dataset.code));
106+
else btn?.remove();
107+
}
108+
</script>
109+
</body>
108110

109-
for (const btn of document.querySelectorAll('.clipboard-btn')) {
110-
if (navigator.clipboard)
111-
btn.addEventListener('click', () => navigator.clipboard.writeText(btn.dataset.code));
112-
else btn?.remove();
113-
}
114-
</script>
115-
</body>
116111
</html>

0 commit comments

Comments
 (0)