Skip to content

Make Caliper an optionally loaded plugin that interfaces with webwork2 via hooks. - #3124

Open
drgrice1 wants to merge 1 commit into
openwebwork:developfrom
drgrice1:caliper-plugin
Open

Make Caliper an optionally loaded plugin that interfaces with webwork2 via hooks.#3124
drgrice1 wants to merge 1 commit into
openwebwork:developfrom
drgrice1:caliper-plugin

Conversation

@drgrice1

Copy link
Copy Markdown
Member

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.

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 in localOverrides.conf appropriately. See the README.md file it includes for more details. Its only dependencies are Mojolicious and Mojo::SQLite.
CaliperDashboard.zip

…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.
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.

1 participant