Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A Collection of Minor Enhancements #11

Merged
merged 8 commits into from
Jun 11, 2023

Conversation

drdrew42
Copy link
Sponsor Member

@drdrew42 drdrew42 commented Feb 27, 2023

A Collection of Minor Features

CSS PostMessage (currently only applied to jwe_secure format)

A parent page loading rendered html into an iframe may now send requests via postMessage to update the CSS of the iframe content. This is useful for any LMS looking to embed WeBWorK content in order to achieve style consistency with the parent page. From the perspective of the parent page, the interaction should be established as follows:

    window.addEventListener('message', (event) => { 
        if (event.data === 'loaded') {
            const cssUpdates = {
                elements: [
                    {
                        selector: 'input[name="submitAnswers"]',
                        style: 'pointer-events: none;opacity: 0.5 !important',
                        class: 'btn-small btn-primary'
                    }, {
                        selector: 'input[name="previewAnswers"]',
                        class: 'btn-small btn-primary'
                    }
                ],
                templates: [
                    '.btn-primary:not(:hover) {background-color: #0058E6 !important;}',
                    '.btn-primary:hover, .btn-primary:focus {color: #0058E6 !important;background-color: white !important;}'
                ]
            };
            event.source.postMessage(JSON.stringify(cssUpdates), event.origin);
        }
    });

New Endpoints

Clone and Delete endpoints are added for management of private/ content. Delete does exactly what you might expect, deleting files and empty folders. Clone is a little more nuanced. The expectation is that a problem (and any of its static assets) is stored in its own folder, and the clone endpoint duplicates that folder and its immediate children into a new folder as a child of private/.

I'm not super-thrilled with the prospect of using the renderer as a library manager, but it is a necessary interim step in the time before OPLv3 is ready for prime-time.

Expand the Catalogue Endpoint

Previously, the catalogue endpoint would give an array of pg files contained in the requested file path. Now, the catalogue endpoint returns an array of all children (not just pg files). This is helpful for finding the location of static assets such as images.

Fix sessionJWT Interaction

Before this PR, sessionJWT would restore previous answers into their corresponding answer blanks -- but the AttemptsTable would be empty (no rows), although "Results for this submission" would appear. Now the AttemptsTable is populated, and the answer blanks now receive css styling for correct/incorrect status (assuming showPartialCorrectAnswers).

Newly added are request params to skip the AttemptsTable (hideAttemptsTable), or when showing the table, hideMessages will skip the Message column. Already existing, but should be added to the readme, is showPartialCorrectAnswers which can override a problem's settings to show or hide individual correct/incorrect responses within the problem.

@drdrew42 drdrew42 changed the title Expand catalog A Collection of Minor Enhancements Mar 9, 2023
@drdrew42 drdrew42 force-pushed the expand-catalog branch 2 times, most recently from c4e76ed to 90d91a9 Compare May 9, 2023 16:43
Copy link
Sponsor Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request looks good. Should we merge this since #14 is built on top of this?

@drdrew42 drdrew42 merged commit 481d26f into openwebwork:develop Jun 11, 2023
@drdrew42 drdrew42 deleted the expand-catalog branch June 11, 2023 18:14
@drdrew42
Copy link
Sponsor Member Author

Excellent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants