Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 5 additions & 44 deletions htdocs/js/PGProblemEditor/pgproblemeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,51 +344,11 @@
}

const actionView = document.getElementById('view');
const editorForm = document.getElementById('editor');

// Make sure this is reset on each click so that a new window isn't always opened once that has been done once.
if (editorForm) editorForm.target = '_self';

if (actionView && actionView.classList.contains('active')) {
if (document.getElementById('newWindowView')?.checked) {
document.getElementById('revert-tab')?.classList.remove('disabled');
document.getElementById('revert-to-tmp-container')?.classList.remove('d-none');
const revertRadio = document.getElementById('action_revert_type_revert_id');
if (revertRadio && revertRadio.disabled) {
revertRadio.disabled = false;
revertRadio.checked = true;
}

// Add the temporary file coloring and change the current file to the saved file.
document.querySelectorAll('.set-file-info').forEach((nfo) => nfo.classList.add('temporaryFile'));
for (const currentFile of document.querySelectorAll('.current-file')) {
currentFile.textContent = currentFile.dataset.tmpFile;
}

if (editorForm) editorForm.target = 'WW_View';
} else {
e.preventDefault();
await render();

saveTempFile();
}
}

const actionSave = document.getElementById('save');
if (
actionSave &&
actionSave.classList.contains('active') &&
document.getElementById('newWindowSave')?.checked &&
editorForm
) {
if (document.getElementById('backupFile')?.checked) {
document.getElementById('show-backups-comment')?.classList.remove('d-none');
const deleteBackupCheck = document.getElementById('deleteBackup');
if (deleteBackupCheck) deleteBackupCheck.disabled = false;
}
document.getElementById('revert-tab')?.classList.remove('disabled');

editorForm.target = 'WW_View';
e.preventDefault();
await render();
saveTempFile();
}

const actionHardcopy = document.getElementById('hardcopy');
Expand Down Expand Up @@ -671,7 +631,8 @@
if (fileType === 'hardcopy_header') {
renderArea.innerHTML =
'<div class="alert alert-danger p-1 m-2 fw-bold">' +
'Hardcopy header contents can only be viewed in a new window.</div>';
'Hardcopy header contents cannot be viewed in the problem editor. ' +
'Use "Generate Hardcopy" to view the contents.</div>';
resolve();
return;
}
Expand Down
15 changes: 6 additions & 9 deletions lib/WeBWorK/Authz.pm
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,11 @@ sub checkSet ($self) {

# First check to see if we have to worried about set-level access restrictions.
return 0
unless grep {/^$node_name$/}
unless grep { $node_name eq $_ }
(qw(
problem_list
problem_detail
show_me_another
gateway_quiz
gateway_quiz_version
proctored_gateway_quiz
Expand All @@ -215,9 +216,6 @@ sub checkSet ($self) {
if ($set && $set->set_id eq $setName && $set->user_id eq $effectiveUserName && $set->version_id == $setVersion)
{
# If we have all of this, then we can just use this set and skip the rest.
} elsif ($setName eq 'Undefined_Set' && $self->hasPermissions($userName, 'access_instructor_tools')) {
# This is the case of previewing a problem from a 'try it' link.
return 0;
} else {
if ($db->existsSetVersion($effectiveUserName, $setName, $setVersion)) {
$set = $db->getMergedSetVersion($effectiveUserName, $setName, $setVersion);
Expand All @@ -241,10 +239,6 @@ sub checkSet ($self) {
} else {
if ($db->existsUserSet($effectiveUserName, $setName)) {
$set = $db->getMergedSet($effectiveUserName, $setName);
} elsif ($setName eq 'Undefined_Set' && $self->hasPermissions($userName, 'access_instructor_tools')) {
# This is the case of the library browser, when we don't actually have a set to look at. This only
# happens for instructor tool users.
return 0;
} else {
return $c->maketext('Requested set "[_1]" is not assigned to user [_2].', $setName, $effectiveUserName);
}
Expand Down Expand Up @@ -301,7 +295,10 @@ sub checkSet ($self) {
}

# Check to be sure that gateways are being sent to the correct content generator.
if (defined $set->assignment_type && $set->assignment_type =~ /gateway/ && $node_name eq 'problem_detail') {
if (defined $set->assignment_type
&& $set->assignment_type =~ /gateway/
&& ($node_name eq 'problem_detail' || $node_name eq 'show_me_another'))
{
return $c->maketext(
'Requested set "[_1]" is a test but the regular homework assignment content '
. 'generator [_2] was called. Try re-entering the set from the problem sets listing page.',
Expand Down
Loading