Make Caliper an optionally loaded plugin that interfaces with webwork2 via hooks. - #3124
Open
drgrice1 wants to merge 1 commit into
Open
Make Caliper an optionally loaded plugin that interfaces with webwork2 via hooks.#3124drgrice1 wants to merge 1 commit into
drgrice1 wants to merge 1 commit into
Conversation
…2 via hooks.
This means that the Caliper code does not need to be directly in the
primary webwork2 code, and those that don't use Caliper don't have to
even have it checking to see if it is enabled. Just leave the
`Mojolicious::WeBWorK::Plugin::Caliper` plugin commented out in
`webwork2.mojolicious.yml`. If you want to allow the usage of Caliper on
your server, then uncomment that plugin. Caliper can be configured per
course in `course.conf` files if the plugin is enabled.
This `hook` approach is also extendable. Other plugins, even those not
directly in the webwork2 repository could utilize these hooks. The
hooks added in this pull request are when user logs in or out, when an
answer is submitted in a regular assignment, and when a page change,
preview, or submission occurs in a test. Additional hooks could also be
added for further extendability with plugins in the future.
The `$caliper{base_url}` option no longer exists. Those using Caliper
just need to make sure that the `$server_root_url` and `$webwork_url`
are set correctly in `site.conf`. The point is that anyone using
webwork2 should do that anyway, so the `$caliper{base_url}` setting was
redundant.
The Caliper packages are heavily updated. The packages all use
signatures. Instead of passing both the course environment and database
handle everywhere, just pass the controller which has both of those. In
addition, doing so gives access to do things better. For example, the
environment variable usage (`HTTP_X_FORWARDED_FOR`, `REMOTE_ADDR`,
`HTTP_CLIENT_IP`, `HTTP_USER_AGENT`, and `HTTP_HOST` in
`Caliper/Entity.pm` and `HTTP_REFERER` in `Caliper/Event.pm`) was
clearly broken and not working since the switch to Mojolicious. Since
the controller is now available in those places the things those
environment variables used to provide with modperl and apache can now be
obtained from the controller.
`Mojo::UserAgent` is used instead of `HTTP::Async`. This is the only
place that the outdated and unmaintained `HTTP::Async` package is used.
So drop that dependency.
The UUIDs used now use `create_uuid_as_string` from the `UUID::Tiny`
package, instead of the `Data::UUID` package and essentially
`Data::UUID->new->create_str`. This is done for two reasons. First,
this is the only use of this dependency. So that is another dependency
not needed by webwork2. Second, the Caliper specification recommends
using version 4 UUIDs and `Data::UUID` does not generate version 4
UUIDs, but `UUID::Tiny` does.
The problem source is no longer sent in Caliper events. That really
should never have been done. That is a large amount of data and is not
needed. This means that even those that do not use Caliper have to
endure the additional server load required to transmit that back from
the rendering process to the main process. It also makes the Caliper
events much larger in size than they should be. The source file is still
sent and that really should be all that is needed. The source can be
looked up in the file.
Other than not sending the problem source, everything else sent by the
Caliper implementation is the same. So the implementation still meets
the 1EdTech Caliper specification as much as it did before (the problem
source is certainly not something the specification insists on or is
even considered in the specification). See https://www.imsglobal.org/spec/caliper/v1p2.
drgrice1
force-pushed
the
caliper-plugin
branch
from
August 10, 2026 18:01
ac30d8b to
8bc853c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This means that the Caliper code does not need to be directly in the primary webwork2 code, and those that don't use Caliper don't have to even have it checking to see if it is enabled. Just leave the
Mojolicious::WeBWorK::Plugin::Caliperplugin commented out inwebwork2.mojolicious.yml. If you want to allow the usage of Caliper on your server, then uncomment that plugin. Caliper can be configured per course incourse.conffiles if the plugin is enabled.This
hookapproach is also extendable. Other plugins, even those not directly in the webwork2 repository could utilize these hooks. The hooks added in this pull request are when user logs in or out, when an answer is submitted in a regular assignment, and when a page change, preview, or submission occurs in a test. Additional hooks could also be added for further extendability with plugins in the future.The
$caliper{base_url}option no longer exists. Those using Caliper just need to make sure that the$server_root_urland$webwork_urlare set correctly insite.conf. The point is that anyone using webwork2 should do that anyway, so the$caliper{base_url}setting was redundant.The Caliper packages are heavily updated. The packages all use signatures. Instead of passing both the course environment and database handle everywhere, just pass the controller which has both of those. In addition, doing so gives access to do things better. For example, the environment variable usage (
HTTP_X_FORWARDED_FOR,REMOTE_ADDR,HTTP_CLIENT_IP,HTTP_USER_AGENT, andHTTP_HOSTinCaliper/Entity.pmandHTTP_REFERERinCaliper/Event.pm) was clearly broken and not working since the switch to Mojolicious. Since the controller is now available in those places the things those environment variables used to provide with modperl and apache can now be obtained from the controller.Mojo::UserAgentis used instead ofHTTP::Async. This is the only place that the outdated and unmaintainedHTTP::Asyncpackage is used. So drop that dependency.The UUIDs used now use
create_uuid_as_stringfrom theUUID::Tinypackage, instead of theData::UUIDpackage and essentiallyData::UUID->new->create_str. This is done for two reasons. First, this is the only use of this dependency. So that is another dependency not needed by webwork2. Second, the Caliper specification recommends using version 4 UUIDs andData::UUIDdoes not generate version 4 UUIDs, butUUID::Tinydoes.The problem source is no longer sent in Caliper events. That really should never have been done. That is a large amount of data and is not needed. This means that even those that do not use Caliper have to endure the additional server load required to transmit that back from the rendering process to the main process. It also makes the Caliper events much larger in size than they should be. The source file is still sent and that really should be all that is needed. The source can be looked up in the file.
Other than not sending the problem source, everything else sent by the Caliper implementation is the same. So the implementation still meets the 1EdTech Caliper specification as much as it did before (the problem source is certainly not something the specification insists on or is even considered in the specification). See https://www.imsglobal.org/spec/caliper/v1p2.
I have attached a Perl Mojolicious app that can be used to test the webwork2 Caliper implementation. It will work with both this pull request and the current implementation in the develop or main branches. To use it extract the zip archive, and in the directory created execute
morbo script/CaliperDashboard -l http://*:5000. You can change the port if needed. You will also need to set the Caliper settings inlocalOverrides.confappropriately. See theREADME.mdfile it includes for more details. Its only dependencies areMojoliciousandMojo::SQLite.CaliperDashboard.zip