Skip to content

Commit

Permalink
Set definition file handling improvements.
Browse files Browse the repository at this point in the history
The set definition utility methods in ProblemSetList.pm have been moved
into a separate file.  The new file is `lib/WeBWorK/File/SetDef.pm`.
The methods in this file do the same things that the previous methods in
`lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm` with some
improvements. This separates the set definition file handling from the
content generator user interface code.

The `readSetDef` no long returns a reference to a messy array of
disorganized data.  Instead it returns a reference to a hash whose keys
give information as to what the data fields are. Using this hash in the
method itself also facilitates a much cleaner way to extract the data
from a set definition file than the massive `if .. elsif ..` mess from
before.

Note that if dates are out of order, instead of just leaving them and
warning about it, the defaults relative to the due date are used just as
they would be when creating a new set.  If the due date is not defined,
then one week from the current time be used.  The messages about these
dates being out of order in the file are still shown though.

Another big improvement is that `warn` is never used in the file.
Instead any of those previous warnings are returned in a reference to an
array.  Each element of the array is also an array reference whose
contents are suitable for passing to maketext.  This is one of the
needed steps toward removing the global warning handler.

To accommodate more complex warning messages the `addgoodmessage` and
`addbadmessage` methods need to be placed in a `div` container with the
"alert" role instead of a `p`.  Visibly this makes no difference.  Using
this the warnings from before are now in the alert messages returned
from the SetDef.pm methods.
  • Loading branch information
drgrice1 committed Aug 20, 2023
1 parent 07dd8fd commit 7d0cc85
Show file tree
Hide file tree
Showing 5 changed files with 830 additions and 848 deletions.
2 changes: 1 addition & 1 deletion htdocs/themes/math4/math4.scss
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ h2.page-title {
gap: 0.25rem;
margin: 0 0 0.5rem;

p {
div {
margin: 0;
}
}
Expand Down
6 changes: 4 additions & 2 deletions lib/WeBWorK/ContentGenerator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,9 @@ message() template escape handler.

sub addgoodmessage ($c, $message) {
$c->addmessage($c->tag(
'p',
'div',
class => 'alert alert-success alert-dismissible fade show ps-1 py-1',
role => 'alert',
$c->c(
$message,
$c->tag(
Expand All @@ -290,8 +291,9 @@ message() template escape handler.

sub addbadmessage ($c, $message) {
$c->addmessage($c->tag(
'p',
'div',
class => 'alert alert-danger alert-dismissible fade show ps-1 py-1',
role => 'alert',
$c->c(
$message,
$c->tag(
Expand Down
Loading

0 comments on commit 7d0cc85

Please sign in to comment.