diff --git a/htdocs/js/PGProblemEditor/pgproblemeditor.js b/htdocs/js/PGProblemEditor/pgproblemeditor.js index 70c6be34f6..7d5759f9c8 100644 --- a/htdocs/js/PGProblemEditor/pgproblemeditor.js +++ b/htdocs/js/PGProblemEditor/pgproblemeditor.js @@ -272,6 +272,19 @@ .then((data) => { if (data.error) throw new Error(data.error); if (!data.result_data) throw new Error('An invalid response was received.'); + if (data.result_data.errors) { + renderArea.innerHTML = + '
PGML conversion errors:
' + + '' +
+ data.result_data.errors
+ .replace(/^[\s\S]*Begin Error Output Stream\n\n/, '')
+ .replace(/\n\d*: To save a full \.LOG file rerun with -g/, '') +
+ '';
+
+ showMessage('Errors occurred when converting code to PGML.', false);
+ return;
+ }
if (request_object.pgCode === data.result_data.pgmlCode) {
showMessage('There were no changes to the code.', true);
} else {
@@ -279,6 +292,7 @@
else document.getElementById('problemContents').value = data.result_data.pgmlCode;
saveTempFile();
showMessage('Successfully converted code to PGML', true);
+ if (!(renderArea.firstChild instanceof HTMLIFrameElement)) render();
}
})
.catch((err) => showMessage(`Error: ${err?.message ?? err}`));
diff --git a/lib/WebworkWebservice/ProblemActions.pm b/lib/WebworkWebservice/ProblemActions.pm
index a93babdf56..f58460857d 100644
--- a/lib/WebworkWebservice/ProblemActions.pm
+++ b/lib/WebworkWebservice/ProblemActions.pm
@@ -159,13 +159,11 @@ sub tidyPGCode {
sub convertCodeToPGML {
my ($invocant, $self, $params) = @_;
- my $code = $params->{pgCode};
return {
- ra_out => { pgmlCode => convertToPGML($code) },
+ ra_out => convertToPGML($params->{pgCode}),
text => 'Converted to PGML'
};
-
}
sub runPGCritic {