ngandrass / moodle-quiz_archiver

Archives quiz attempts as PDF and HTML files for long-term storage independent of Moodle
GNU General Public License v3.0
5 stars 3 forks source link

Add cli script to install webservice, user and role. #15

Closed melanietreitinger closed 3 months ago

melanietreitinger commented 4 months ago

CLI script to install the webservice - including user and role - automatically.

ngandrass commented 4 months ago

That's a great contribution! Thanks a lot for your work 🎉

I think it would be a good idea to extend this CLI script to also set the corresponding configuration options within the quiz_archiver plugin. This way we should be able to reduce the setup steps significantly. Maybe we could even extend this further by creating an "Autoconfigure" button on the plugins settings page.

Without wanting to unnecessarily delay this, I'd still would like to do all these changes in a single coordinated move. This saves us a lot of README back and forth, and should confuse users a little less. I'll look into this the next days and keep you posted 😃

ngandrass commented 4 months ago

I made some adjustments to the script and added automatic configuration of the quiz archiver plugin settings for the webservice and the user. See added commits for more details :)

Next up is the integration into the Moodle Plugin itself. It would probably be good to add an "Autoconfigure"-Button to the settings page, that is disabled once webservice settings are entered.

melanietreitinger commented 4 months ago

Thansk a lot for refining this script, that looks great and is very inspiring! I'm looking forward to the button - although you will have to change the script from CLI to "normal". 🙃

ngandrass commented 4 months ago

[...] although you will have to change the script from CLI to "normal". 🙃

I just started to move the whole setup functionality into a local class of the plugin. From here on I'll add proper permission checks so that only site admins can execute it. I'll keep the CLI script available but simply rely on the implementation within the local plugin class.

This way we get the best of both worlds: Simpler configuration using the Moodle GUI and support for automatic configuration, e.g., within CI jobs :+1:

ngandrass commented 4 months ago

I now successfully moved all routines into an autoinstall local class and prepared for integration into the plugin settings page.

Currently outstanding tasks:

ngandrass commented 4 months ago

Quick update: I created a basic form (not yet pretty 😅) that allows to trigger the automatic installation from the plugins page within the admin UI. This still needs some more work, but technically works.

I'll have to get some other tasks done and will come back to finish this after the upcoming Moodle conference in Leipzig :)

Here are some screenshots of how it looks now:

CLI: image image

Moodle Admin UI: image image image image

ngandrass commented 4 months ago

We are getting there. I completed all open tasks, updated the README file and created unit tests for the auto-config routines.

Are you able to test, if the current version of this feature works for you? If so, I'd like to finally merge it 👍

melanietreitinger commented 4 months ago

Very cool - I hope we can test this next week. 👍

ngandrass commented 4 months ago

Just two small notes:

ngandrass commented 3 months ago

@melanietreitinger Have you been able to test the latest version of this feature?

melanietreitinger commented 3 months ago

Hi @ngandrass! We testet this feature - everything went well! 😍

We have some remarks regarding the displayed messages:

1) Installation of the plugin: when the plugin is installed, there should be a hint on the admin settings overview page that there is an auto-installer and that all settings regarding the webservice can be left empty for the moment.

2) After the autoinstaller has finished the error oder success message should be displayed more distinguished (perhaps bold).

3) There should be a hint that the admin settings page should be reloaded (or the reload should be performed automatically) - or we don't open a new window and can simply return to the then newly configured admin settings page 🤔.

(A "bonus feature" might be the auto-detection of the docker url which then could be filled in already when starting the auto-installer. 😁)

ngandrass commented 3 months ago

Thanks for your suggestions! :+1:

  1. IIRC there even is a possibility to display some text during the installation dialog but I do not remember on which plugin I've seen this before. I'll look around a bit :)
  2. Good idea!
  3. We could replace the "autoinstall opens in new tab" behavior with a normal redirection and include a "back to plugin config page" button. That should eliminate the need for extra instructions.

Regarding the auto-detection of docker URLs: I don't know how the plugin should determine the worker URL reliably. I could try probing some common names during installation but this will most likely not work reliably. Do you have any idea on how this could work?

ngandrass commented 3 months ago

I implemented suggestions 1 to 3 and prepared for release.

The autoinstall dialog is now opened within the same tab as the plugin settings page and redirects back to it, hereby eliminating the need for additional information about the required page refresh. Additionally the result is now displayed with a bold font:

Screenshot_20240409_110324

At the first installation, an info message is displayed, allowing the user to directly choose between automatic installation of manual configuration (via the plugin settings page):

Screenshot_20240409_120407

I'll finalize this now and create a new release. Thanks a lot for your work and active collaboration with this PR