Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to using bootstrap alerts for problem messages.
Browse files Browse the repository at this point in the history
Dispense with the ResultsWithError and ResultsWithoutError classes, and
instead use bootstrap alerts with the alert-danger and alert-sucess
classes.

Also remove the unused `$pg{options}{correct_answer}` and
`$pg{options}{incorrect_answer}` variables from defaults.config.
drgrice1 committed Oct 5, 2023

Verified

This commit was signed with the committer’s verified signature.
1 parent bebb833 commit 4737a17
Showing 4 changed files with 15 additions and 21 deletions.
6 changes: 0 additions & 6 deletions conf/defaults.config
Original file line number Diff line number Diff line change
@@ -1045,12 +1045,6 @@ $pg{options}{showEvaluatedAnswers} = 1;
# propogate to the main process. So this really should never be set to 0.
$pg{options}{catchWarnings} = 1;

# decorations for correct input blanks -- apparently you can't define and name attribute collections in a .css file
$pg{options}{correct_answer} = "{border-width:2;border-style:solid;border-color:#8F8}"; #matches resultsWithOutError class in math2.css

# decorations for incorrect input blanks
$pg{options}{incorrect_answer} = "{border-width:2;border-style:solid;border-color:#F55}"; #matches resultsWithError class in math2.css

##### Settings for various display modes

# "images" mode has several settings:
6 changes: 3 additions & 3 deletions lib/WeBWorK/ContentGenerator/Problem.pm
Original file line number Diff line number Diff line change
@@ -1469,7 +1469,7 @@ sub output_summary ($c) {
@$output,
$c->tag(
'div',
class => 'ResultsWithError d-inline-block mb-2',
class => 'alert alert-danger d-inline-block mb-2 p-1',
$c->maketext('ANSWERS ONLY CHECKED -- ANSWERS NOT RECORDED')
),
$c->attemptResults($pg)
@@ -1479,7 +1479,7 @@ sub output_summary ($c) {
@$output,
$c->tag(
'div',
class => 'ResultsWithError d-inline-block mb-2',
class => 'alert alert-danger d-inline-block mb-2 p-1',
$c->maketext('PREVIEW ONLY -- ANSWERS NOT RECORDED')
),
);
@@ -1489,7 +1489,7 @@ sub output_summary ($c) {
@$output,
$c->tag(
'div',
class => 'ResultsWithError d-inline-block mb-2',
class => 'alert alert-danger d-inline-block mb-2 p-1',
$c->maketext(
'ATTEMPT NOT ACCEPTED -- Please submit answers again (or request new version if neccessary).')
)
8 changes: 4 additions & 4 deletions lib/WeBWorK/ContentGenerator/ShowMeAnother.pm
Original file line number Diff line number Diff line change
@@ -510,7 +510,7 @@ sub output_summary ($c) {
),
$c->tag(
'div',
class => 'ResultsAlert',
class => 'alert alert-warning p-1',
$c->maketext(q{Remember to return to your original problem when you're finished here!})
)
);
@@ -524,7 +524,7 @@ sub output_summary ($c) {
@$output,
$c->tag(
'div',
class => 'ResultsAlert',
class => 'alert alert-warning p-1',
$c->maketext(
'You are only allowed to click on Show Me Another [quant,_1,time,times] per problem. '
. '[_2] Close this tab, and return to the original problem.',
@@ -538,7 +538,7 @@ sub output_summary ($c) {
@$output,
$c->tag(
'div',
class => 'ResultsAlert',
class => 'alert alert-warning p-1',
$c->maketext(
'You must attempt this problem [quant,_1,time,times] before Show Me Another is available.',
$showMeAnother{TriesNeeded}
@@ -553,7 +553,7 @@ sub output_summary ($c) {
@$output,
$c->tag(
'div',
class => 'ResultsAlert',
class => 'alert alert-warning p-1',
$c->maketext(
'WeBWorK was unable to generate a different version of this problem. '
. 'Close this tab, and return to the original problem.'
16 changes: 8 additions & 8 deletions templates/ContentGenerator/GatewayQuiz.html.ep
Original file line number Diff line number Diff line change
@@ -115,17 +115,17 @@
% my $numProbPerPage = $c->{set}->problems_per_page;
%
% if ($c->{will}{recordAnswers}) {
% my $divClass = 'ResultsWithoutError';
% my $divClass = 'alert-success';
% my $recdMsg = '';
% for (@{ $c->{scoreRecordedMessage} }) {
% if ($_ ne 'recorded') {
% $recdMsg = $_;
% $divClass = 'ResultsWithError';
% $divClass = 'alert-danger';
% last;
% }
% }
%
<div class="<%= $divClass . ' mb-3' %>">
<div class="<%= "alert $divClass mb-3 p-1" %>">
% # A handy noun for when referring to a test.
% my $testNoun = ($c->{set}->attempts_per_version || 0) > 1 ? maketext('submission') : maketext('test');
% my $testNounNum =
@@ -256,11 +256,11 @@
% }
%
% if ($timeLeft < 60 && $timeLeft > 0 && !$authz->hasPermissions($userID, 'record_answers_when_acting_as_student')) {
<div class="ResultsWithError d-inline-block mb-2">
<div class="alert alert-danger d-inline-block mb-2 p-1">
<strong><%= maketext('You have less than 1 minute to complete this test.') %></strong>
</div>
% } elsif ($timeLeft <= 0 && !$authz->hasPermissions($userID, 'record_answers_when_acting_as_student')) {
<div class="ResultsWithError d-inline-block mb-2">
<div class="alert alert-danger d-inline-block mb-2 p-1">
<strong>
<%= maketext('You are out of time!')
. (
@@ -499,19 +499,19 @@
%
% if ($c->{submitAnswers}) {
% if ($c->{scoreRecordedMessage}[ $probOrder->[$i] ] ne 'recorded') {
% $recordMessage = tag('div', class => 'ResultsWithError d-inline-block mb-2',
% $recordMessage = tag('div', class => 'alert alert-dangeer d-inline-block mb-2 p-1',
% maketext('ANSWERS NOT RECORDED -- [_1]', $c->{scoreRecordedMessage}[ $probOrder->[$i] ])
% );
% }
% $resultsTable = $c->attemptResults($pg);
% } elsif ($c->{will}{checkAnswers} || $c->{will}{showProblemGrader}) {
% $recordMessage = tag('div', class => 'ResultsWithError d-inline-block mb-2',
% $recordMessage = tag('div', class => 'alert alert-danger d-inline-block mb-2 p-1',
% maketext('ANSWERS ONLY CHECKED -- ANSWERS NOT RECORDED')
% );
%
% $resultsTable = $c->attemptResults($pg);
% } elsif ($c->{previewAnswers}) {
% $recordMessage = tag('div', class => 'ResultsWithError d-inline-block mb-2',
% $recordMessage = tag('div', class => 'alert alert-danger d-inline-block mb-2 p-1',
% maketext('PREVIEW ONLY -- ANSWERS NOT RECORDED')
% );
% }

0 comments on commit 4737a17

Please sign in to comment.