Skip to content

Commit

Permalink
Small change to the help wording and fix comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
pstaabp committed Mar 30, 2024
1 parent 2e4e025 commit 6b91afd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
29 changes: 14 additions & 15 deletions htdocs/js/PGProblemEditor/pgproblemeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,7 @@

// Send a request to the server to perltidy the current PG code in the CodeMirror editor.
const tidyPGCode = () => {
const request_object = {
user: document.getElementById('hidden_user')?.value,
courseID: document.getElementsByName('courseID')[0]?.value,
key: document.getElementById('hidden_key')?.value
};
const request_object = { courseID: document.getElementsByName('courseID')[0]?.value };

const user = document.getElementsByName('user')[0];
if (user) request_object.user = user.value;
Expand Down Expand Up @@ -154,17 +150,18 @@
.catch((err) => showMessage(`Error: ${err?.message ?? err}`));
};

// Send a request to the server to convert_to_PGML the current PG code in the CodeMirror editor.
// Send a request to the server to convert the current PG code in the CodeMirror editor.
const convertCodeToPGML = () => {
const request_object = {
user: document.getElementById('hidden_user')?.value,
courseID: document.getElementsByName('courseID')[0]?.value,
key: document.getElementById('hidden_key')?.value
};
const request_object = { courseID: document.getElementsByName('courseID')[0]?.value };

const user = document.getElementsByName('user')[0];
if (user) request_object.user = user.value;
const sessionKey = document.getElementsByName('key')[0];
if (sessionKey) request_object.key = sessionKey.value;

request_object.rpc_command = 'convertCodeToPGML';
request_object.pgCode = webworkConfig?.pgCodeMirror?.getValue()
?? document.getElementById('problemContents')?.value ?? '';
request_object.pgCode =
webworkConfig?.pgCodeMirror?.getValue() ?? document.getElementById('problemContents')?.value ?? '';

fetch(webserviceURL, { method: 'post', mode: 'same-origin', body: new URLSearchParams(request_object) })
.then((response) => response.json())
Expand All @@ -184,9 +181,11 @@
document.getElementById('take_action')?.addEventListener('click', async (e) => {
if (document.getElementById('current_action')?.value === 'format_code') {
e.preventDefault();
if (document.querySelector('input[name="action.format_code"]:checked').value == "tidyPGCode") {
if (document.querySelector('input[name="action.format_code"]:checked').value == 'tidyPGCode') {
tidyPGCode();
} else if (document.querySelector('input[name="action.format_code"]:checked').value == "convertCodeToPGML") {
} else if (
document.querySelector('input[name="action.format_code"]:checked').value == 'convertCodeToPGML'
) {
convertCodeToPGML();
}
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
. 'in the problem code to PGML and updates the loadMacros to include PGML and drop others. '
. 'This can be used as a first pass of the conversion, however the author will still need '
. 'to ensure the problem functions. One area of attention should be the answer blanks, '
. 'which are not automatically converted with the proper variable.') =%>"
. 'which may not be converted correctly.') =%>"
data-bs-placement="top" data-bs-toggle="popover" role="button">
<i aria-hidden="true" class="icon fas fa-question-circle" data-alt="Help Icon"></i>
<span class="sr-only-glyphicon">Help Icon</span>
Expand Down

0 comments on commit 6b91afd

Please sign in to comment.