Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 80 additions & 6 deletions htdocs/js/Problem/problem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@
&.partially-correct::before {
content: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='black' stroke='none'><path d='M7.938 2.016A.13.13 0 0 1 8.002 2a.13.13 0 0 1 .063.016.146.146 0 0 1 .054.057l6.857 11.667c.036.06.035.124.002.183a.163.163 0 0 1-.054.06.116.116 0 0 1-.066.017H1.146a.115.115 0 0 1-.066-.017.163.163 0 0 1-.054-.06.176.176 0 0 1 .002-.183L7.884 2.073a.147.147 0 0 1 .054-.057zm1.044-.45a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566z'/><path d='M7.002 12a1 1 0 1 1 2 0 1 1 0 0 1-2 0zM7.1 5.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995z'/></svg>");
}

&.unknown::before {
content: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='white'><circle cx='6' cy='6' r='4.5'/><text x='50%' y='50%' text-anchor='middle' fill='white' font-size='7px' dy='.3em'>?</text></svg>");
}
}

&.with-message::before {
Expand All @@ -163,7 +167,7 @@
left: 100%;
border: 1px solid black;
border-radius: 50%;
background-color: var(--bs-warning);
background-color: #ffc107;
padding: 0.25rem;
animation: flash-in 0.75s;

Expand All @@ -181,6 +185,75 @@
}
}

/* Feedback button colors. */
.btn-correct {
--bs-btn-color: #fff;
--bs-btn-bg: #198754;
--bs-btn-border-color: #198754;
--bs-btn-hover-color: #fff;
--bs-btn-hover-bg: #157347;
--bs-btn-hover-border-color: #146c43;
--bs-btn-focus-shadow-rgb: 60, 153, 110;
--bs-btn-active-color: #fff;
--bs-btn-active-bg: #146c43;
--bs-btn-active-border-color: #13653f;
--bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
--bs-btn-disabled-color: #fff;
--bs-btn-disabled-bg: #198754;
--bs-btn-disabled-border-color: #198754;
}

.btn-incorrect {
--bs-btn-color: #fff;
--bs-btn-bg: #dc3545;
--bs-btn-border-color: #dc3545;
--bs-btn-hover-color: #fff;
--bs-btn-hover-bg: #bb2d3b;
--bs-btn-hover-border-color: #b02a37;
--bs-btn-focus-shadow-rgb: 225, 83, 97;
--bs-btn-active-color: #fff;
--bs-btn-active-bg: #b02a37;
--bs-btn-active-border-color: #a52834;
--bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
--bs-btn-disabled-color: #fff;
--bs-btn-disabled-bg: #dc3545;
--bs-btn-disabled-border-color: #dc3545;
}

.btn-partially-correct {
--bs-btn-color: #000;
--bs-btn-bg: #ffc107;
--bs-btn-border-color: #ffc107;
--bs-btn-hover-color: #000;
--bs-btn-hover-bg: #ffca2c;
--bs-btn-hover-border-color: #ffc720;
--bs-btn-focus-shadow-rgb: 217, 164, 6;
--bs-btn-active-color: #000;
--bs-btn-active-bg: #ffcd39;
--bs-btn-active-border-color: #ffc720;
--bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
--bs-btn-disabled-color: #000;
--bs-btn-disabled-bg: #ffc107;
--bs-btn-disabled-border-color: #ffc107;
}

.btn-preview {
--bs-btn-color: #000;
--bs-btn-bg: #0dcaf0;
--bs-btn-border-color: #0dcaf0;
--bs-btn-hover-color: #000;
--bs-btn-hover-bg: #31d2f2;
--bs-btn-hover-border-color: #25cff2;
--bs-btn-focus-shadow-rgb: 11, 172, 204;
--bs-btn-active-color: #000;
--bs-btn-active-bg: #3dd5f3;
--bs-btn-active-border-color: #25cff2;
--bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
--bs-btn-disabled-color: #000;
--bs-btn-disabled-bg: #0dcaf0;
--bs-btn-disabled-border-color: #0dcaf0;
}

.radio-buttons-container,
.checkboxes-container {
max-width: calc(100% - 1rem - 25px);
Expand Down Expand Up @@ -256,7 +329,7 @@
.popover-header {
text-align: center;
cursor: pointer;
--bs-popover-header-bg: var(--bs-info);
--bs-popover-header-bg: #0dcaf0;
--bs-popover-header-color: white;

.btn-close {
Expand All @@ -268,21 +341,22 @@

&.correct {
.popover-header {
--bs-popover-header-bg: var(--bs-success);
--bs-popover-header-bg: #198754;
--bs-popover-header-color: white;
}
}

&.incorrect {
.popover-header {
--bs-popover-header-bg: var(--bs-danger);
--bs-popover-header-bg: #dc3545;
--bs-popover-header-color: white;
}
}

&.partially-correct {
&.partially-correct,
&.unknown {
.popover-header {
--bs-popover-header-bg: var(--bs-warning);
--bs-popover-header-bg: #ffc107;
--bs-popover-header-color: black;
}
}
Expand Down
29 changes: 23 additions & 6 deletions macros/PG.pl
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,12 @@ =head2 ENDDOCUMENT

=item *

C<btnClass>: This is the bootstrap button class added to the feedback button.
By default it is "btn-info", "btn-success", "btn-danger", or "btn-warning"
C<btnClass>: This is the button class added to the feedback button. These are
based on bootstrap button styles, but are custom styles for the feedback
buttons to allow clients to theme the bootstrap buttons without changing the
feedback styles. By default it is "btn-preview" (coppied from btn-info),
"btn-correct" (coppied from btn-success), "btn-incorrect" (coppied from
btn-danger), or "btn-partially-correct" (coppied from btn-warning)
depending on the status of the answer and the type of submission.

=item *
Expand Down Expand Up @@ -1059,7 +1063,7 @@ sub ENDDOCUMENT {
my %options = (
resultTitle => maketext('Answer Preview'),
resultClass => '',
btnClass => 'btn-info',
btnClass => 'btn-preview',
btnAddClass => 'ms-2',
feedbackElements => Mojo::Collection->new,
insertElement => undef,
Expand Down Expand Up @@ -1108,15 +1112,28 @@ sub ENDDOCUMENT {
} elsif ($answerScore >= 1) {
$options{resultTitle} = maketext('Correct');
$options{resultClass} = 'correct';
$options{btnClass} = 'btn-success';
$options{btnClass} = 'btn-correct';
} elsif ($answerScore == 0) {
$options{resultTitle} = maketext('Incorrect');
$options{resultClass} = 'incorrect';
$options{btnClass} = 'btn-danger';
$options{btnClass} = 'btn-incorrect';
} else {
$options{resultTitle} = maketext('[_1]% correct', round($answerScore * 100));
$options{resultClass} = 'partially-correct';
$options{btnClass} = 'btn-warning';
$options{btnClass} = 'btn-partially-correct';
}
} elsif ($rh_envir->{showAttemptResults} && !$PG->{flags}{showPartialCorrectAnswers}) {
# Partially correct feedback is not being shown, but this is not a preview, so make the
# feedback look different than a preview. If the problem score is zero, everything is
# incorrect, so mark the whole problem as incorrect. Otherwise mark it as unknown correctness.
if ($problemResult->{score}) {
$options{resultTitle} = maketext('Unknown');
$options{resultClass} = 'unknown';
$options{btnClass} = 'btn-partially-correct';
} else {
$options{resultTitle} = maketext('Incorrect');
$options{resultClass} = 'incorrect';
$options{btnClass} = 'btn-incorrect';
}
}

Expand Down