Skip to content

Commit

Permalink
give feedback popover a header when preview
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Jordan committed Dec 3, 2023
1 parent df6513e commit f94e5c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
7 changes: 7 additions & 0 deletions htdocs/js/Problem/problem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@
cursor: pointer;
}

&.preview {
.popover-header {
--bs-popover-header-bg: var(--bs-info);
--bs-popover-header-color: white;
}
}

&.correct {
.popover-header {
--bs-popover-header-bg: var(--bs-success);
Expand Down
15 changes: 7 additions & 8 deletions macros/PG.pl
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,8 @@ =head2 ENDDOCUMENT
=item *
C<resultClass>: This is the CSS class that is added to each answer input in the
response group. By default it is set to the empty string, "correct",
"incorrect", or "partially-correct" depending on the status of the answer and
response group. By default it is set to "preview", "correct", "incorrect",
or "partially-correct" depending on the status of the answer and
the type of submission.
=item *
Expand Down Expand Up @@ -1022,7 +1022,7 @@ sub ENDDOCUMENT {

my %options = (
resultTitle => maketext('Preview'),
resultClass => '',
resultClass => 'preview',
btnClass => 'btn-info',
btnAddClass => 'ms-1',
feedbackElements => Mojo::Collection->new,
Expand Down Expand Up @@ -1126,11 +1126,10 @@ sub ENDDOCUMENT {
if $options{insertElement} && $options{insertElement}->attr->{'data-feedback-insert-method'};
}

# Add the correct/incorrect/partially-correct class and
# Add the preview/correct/incorrect/partially-correct class and
# aria-described by attribute to the feedback elements.
for (@{ $options{feedbackElements} }) {
$_->attr(class => join(' ', $options{resultClass}, $_->attr->{class} || ()))
if $options{resultClass};
$_->attr(class => join(' ', $options{resultClass}, $_->attr->{class} || ()));
$_->attr('aria-describedby' => "ww-feedback-$answerLabel");
}

Expand Down Expand Up @@ -1191,12 +1190,12 @@ sub ENDDOCUMENT {
. ($rh_envir->{showMessages} && $ansHash->{ans_message} ? ' with-message' : ''),
'aria-label' => $options{resultTitle},
data => {
$showResults && $options{resultTitle} ? (bs_title => $options{resultTitle}) : (),
bs_title => $options{resultTitle},
bs_toggle => 'popover',
bs_trigger => 'click',
bs_placement => 'bottom',
bs_html => 'true',
bs_custom_class => join(' ', 'ww-feedback-popover', $options{resultClass} || ()),
bs_custom_class => join(' ', 'ww-feedback-popover', $options{resultClass}),
bs_fallback_placements => '[]',
bs_content => Mojo::DOM->new_tag(
'div',
Expand Down

0 comments on commit f94e5c1

Please sign in to comment.