Skip to content

Commit 7df0708

Browse files
drgrice1pstaabp
authored andcommitted
Improvements to showing the deprecated macros warning.
Only parse the macro file list if the PGcore object is in the result. Also, remove the `p` tags and tweak the style of the html generated to display the deprecated macros list to get consistent spacing.
1 parent 44cce4c commit 7df0708

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

htdocs/js/PGProblemEditor/pgproblemeditor.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,13 +514,13 @@
514514
}
515515
if (data.deprecated_macros?.length) {
516516
const container = document.createElement('div');
517-
container.classList.add('alert', 'alert-danger', 'mx-2');
517+
container.classList.add('alert', 'alert-danger', 'mx-2', 'p-2');
518518
container.innerHTML =
519-
'<p>Warning!! This problem uses the following deprecated macros:</p>' +
520-
'<ul class="mb-0">' +
519+
'Warning!! This problem uses the following deprecated macros:' +
520+
'<ul class="my-1">' +
521521
data.deprecated_macros.reduce((acc, item) => `${acc}<li>${item}</li>`, '') +
522-
'</ul><p>If this is an OPL problem, please report this issue to the OPL. ' +
523-
'If this is a custom problem, please update the problem to use modern macros.</p>';
522+
'</ul>If this is an OPL problem, please report this issue to the OPL. ' +
523+
'If this is a custom problem, please update the problem to use modern macros.';
524524
iframe.after(container);
525525
}
526526

htdocs/js/RenderProblem/renderproblem.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@
7979
}
8080
if (data.deprecated_macros?.length) {
8181
const container = document.createElement('div');
82-
container.classList.add('alert', 'alert-danger');
82+
container.classList.add('alert', 'alert-danger', 'p-2');
8383
container.innerHTML =
84-
'<p>Warning!! This problem uses the following deprecated macros:</p>' +
85-
'<ul class="mb-0">' +
84+
'Warning!! This problem uses the following deprecated macros:' +
85+
'<ul class="my-1">' +
8686
data.deprecated_macros.reduce((acc, item) => `${acc}<li>${item}</li>`, '') +
87-
'</ul><p>If this is an OPL problem, please report this issue to the OPL. ' +
88-
'If this is a custom problem, please update the problem to use modern macros.</p>';
87+
'</ul>If this is an OPL problem, please report this issue to the OPL. ' +
88+
'If this is a custom problem, please update the problem to use modern macros.';
8989
iframe.after(container);
9090
}
9191
iFrameResize(

lib/WeBWorK/Utils/Rendering.pm

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -253,19 +253,12 @@ sub renderPG ($c, $effectiveUser, $set, $problem, $psvn, $formFields, $translati
253253
flags => $pg->{flags},
254254
};
255255

256-
# get a list of the deprecated macros
257-
my @deprecated_macros;
258-
for (keys %{ $pg->{pgcore}{PG_loadMacros}{macroFileList} }) {
259-
my @dirs = split('/', $_);
260-
push(@deprecated_macros, $dirs[-1]) if $dirs[-2] eq 'deprecated';
261-
}
262-
263256
if (ref($pg->{pgcore}) eq 'PGcore') {
264257
$ret->{internal_debug_messages} = $pg->{pgcore}->get_internal_debug_messages;
265258
$ret->{warning_messages} = $pg->{pgcore}->get_warning_messages();
266259
$ret->{debug_messages} = $pg->{pgcore}->get_debug_messages();
267-
$ret->{deprecated_macros} = \@deprecated_macros;
268-
$ret->{PG_ANSWERS_HASH} = {
260+
261+
$ret->{PG_ANSWERS_HASH} = {
269262
map {
270263
$_ => {
271264
response_obj => unbless($pg->{pgcore}{PG_ANSWERS_HASH}{$_}->response_obj),
@@ -279,6 +272,14 @@ sub renderPG ($c, $effectiveUser, $set, $problem, $psvn, $formFields, $translati
279272
keys %{ $pg->{pgcore}{PG_alias}{resource_list} }
280273
};
281274
$ret->{PERSISTENCE_HASH} = $pg->{pgcore}{PERSISTENCE_HASH};
275+
276+
# Get a list of the deprecated macros used in the problem.
277+
my @deprecated_macros;
278+
for (keys %{ $pg->{pgcore}{PG_loadMacros}{macroFileList} }) {
279+
my @dirs = split('/', $_);
280+
push(@deprecated_macros, $dirs[-1]) if $dirs[-2] eq 'deprecated';
281+
}
282+
$ret->{deprecated_macros} = \@deprecated_macros;
282283
}
283284

284285
# Save the problem source. This is used by Caliper::Entity. Why?

0 commit comments

Comments
 (0)