Skip to content

Commit e9ef2fa

Browse files
authored
Merge pull request #2624 from somiaj/alt-text-histograms
Add alt text to histograms on stats page.
2 parents 0422220 + 434685b commit e9ef2fa

File tree

4 files changed

+49
-8
lines changed

4 files changed

+49
-8
lines changed

lib/WeBWorK/ContentGenerator/Instructor/Stats.pm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ sub build_bar_chart ($c, $data, %options) {
550550
mainTitle => 'ERROR: This must be set',
551551
xTitle => '',
552552
yTitle => '',
553+
descText => '',
553554
barWidth => 22,
554555
barSep => 4,
555556
barFill => 'rgb(0,153,198)',
@@ -585,6 +586,7 @@ sub build_bar_chart ($c, $data, %options) {
585586
);
586587

587588
# Main graph setup.
589+
$svg->desc()->cdata($opts{descText});
588590
$svg->rect(
589591
id => "bar_graph_window_$id",
590592
x => 0,
@@ -711,9 +713,11 @@ sub build_bar_chart ($c, $data, %options) {
711713
for (0 .. $n) {
712714
my $xPos = $opts{leftMargin} + $_ * $barWidth + $opts{barSep};
713715
my $yHeight = int($opts{plotHeight} * $data->[$_] / $opts{yMax} + 0.5);
716+
my $tag = @{ $opts{barLinks} } ? $svg->anchor(-href => "$opts{barLinks}->[$_]") : $svg;
717+
714718
if ($opts{isJitarSet} && $opts{jitarBars}->[$_] > 0) {
715719
my $jHeight = int($opts{plotHeight} * $opts{jitarBars}->[$_] / $opts{yMax} + 0.5);
716-
$svg->rect(
720+
$tag->rect(
717721
x => $xPos,
718722
y => $opts{topMargin} + $opts{plotHeight} - $jHeight,
719723
width => $opts{barWidth} + $opts{barSep},
@@ -724,7 +728,6 @@ sub build_bar_chart ($c, $data, %options) {
724728
class => 'bar_graph_bar',
725729
);
726730
}
727-
my $tag = @{ $opts{barLinks} } ? $svg->anchor(-href => $opts{barLinks}->[$_]) : $svg;
728731
$tag->rect(
729732
x => $xPos,
730733
y => $opts{topMargin} + $opts{plotHeight} - $yHeight,

templates/ContentGenerator/Instructor/Stats/problem_stats.html.ep

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,36 @@
1111
</div>
1212
%
1313
% # Histogram of total scores.
14+
% my $bucketLabels = [ '90-100', '80-89', '70-79', '60-69', '50-59', '40-49', '30-39', '20-29', '10-19', '0-9' ];
1415
<%= $c->build_bar_chart(
15-
[ @$buckets ],
16-
xAxisLabels => [ '90-100', '80-89', '70-79', '60-69', '50-59', '40-49', '30-39', '20-29', '10-19', '0-9' ],
16+
$buckets,
17+
xAxisLabels => $bucketLabels,
1718
yMax => 5 * $maxCount,
1819
yAxisLabels => [ map { $_ * $maxCount } 0 .. 5 ],
1920
mainTitle => maketext('Active Students Problem [_1] Grades', $c->{prettyID}),
2021
xTitle => maketext('Percent Ranges'),
2122
yTitle => maketext('Number of Students'),
23+
descText => $isJitarSet && $topLevelJitar
24+
? maketext(
25+
'Histogram showing the percent grade of active students for problem [_1] and the adjusted '
26+
. 'percent grade with review. The number of students in each percent range is: [_2]. '
27+
. 'The number of students in each percent range after review is: [_3].',
28+
$c->{prettyID},
29+
join(', ', map { "$bucketLabels->[$_]:$buckets->[$_]" } 0 .. scalar(@$buckets) - 1),
30+
join(', ', map { "$bucketLabels->[$_]:$jitarBars->[$_]" } 0 .. scalar(@$buckets) - 1)
31+
)
32+
: maketext(
33+
'Histogram showing the grades of active students for problem [_1], where the number of '
34+
. 'students in each percent range is: [_2]',
35+
$c->{prettyID},
36+
join(', ', map { "$bucketLabels->[$_]:$buckets->[$_]" } 0 .. scalar(@$buckets) - 1),
37+
),
2238
barWidth => 35,
2339
barSep => 5,
2440
isPercent => 0,
2541
leftMargin => 40 + 5 * length(5 * $maxCount),
2642
isJitarSet => ($isJitarSet && $topLevelJitar),
27-
jitarBars => [ reverse(@$jitarBars) ],
43+
jitarBars => $jitarBars,
2844
) =%>
2945
%
3046
% # Display overall statistics
@@ -64,7 +80,7 @@
6480
% my @tableData = ($problemScores);
6581
% if ($isJitarSet && $topLevelJitar) {
6682
% push(@tableHeaders, maketext('% Score with Review'));
67-
% push(@tableData, [ map { sprintf('%0.0f', 100 * $_) } @$adjustedScores ]);
83+
% push(@tableData, [ map { sprintf('%0.0f', $_) } @$adjustedScores ]);
6884
% }
6985
% my $successIndexHeader = begin
7086
<%= maketext('Success Index') =%>

templates/ContentGenerator/Instructor/Stats/set_stats.html.ep

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,19 @@
8484
<h2><%= maketext('Overall Results') %></h2>
8585
%
8686
% # Histogram of total scores.
87+
% my $bucketLabels = [ '90-100', '80-89', '70-79', '60-69', '50-59', '40-49', '30-39', '20-29', '10-19', '0-9' ];
8788
<%= $c->build_bar_chart(
8889
$buckets,
89-
xAxisLabels => [ '90-100', '80-89', '70-79', '60-69', '50-59', '40-49', '30-39', '20-29', '10-19', '0-9' ],
90+
xAxisLabels => $bucketLabels,
9091
yMax => 5 * $maxCount,
9192
yAxisLabels => [ map { $_ * $maxCount } 0 .. 5 ],
9293
mainTitle => maketext('Overall Set Grades'),
9394
xTitle => maketext('Percent Ranges'),
9495
yTitle => maketext('Number of Students'),
96+
descText => maketext(
97+
'Histogram showing the overall set grades, where the number of students in each percent range is: [_1].',
98+
join(', ', map { "$bucketLabels->[$_]:$buckets->[$_]" } 0 .. scalar(@$buckets) - 1)
99+
),
95100
barWidth => 35,
96101
barSep => 5,
97102
isPercent => 0,
@@ -146,6 +151,23 @@
146151
xAxisLabels => $svgProblemLabels,
147152
mainTitle => maketext('Grade of Active Students'),
148153
xTitle => maketext('Problem Number'),
154+
descText => $isJitarSet
155+
? maketext(
156+
'Bar chart showing the average percent grade of active students for each problem and the adjusted '
157+
. 'percent grade on top level problems with review. The average percent grade (as a decimal) for '
158+
. 'each problem is: [_1]. The adjusted percent grade for top level problems with review is: [_2].',
159+
join(', ', map { "$svgProblemLabels->[$_]:$svgProblemData->[$_]" } 0 .. scalar(@$svgProblemData) - 1),
160+
join(
161+
', ',
162+
map { $jitarBars->[$_] < 0 ? () : "$svgProblemLabels->[$_]:$jitarBars->[$_]" }
163+
0 .. scalar(@$svgProblemData) - 1
164+
)
165+
)
166+
: maketext(
167+
'Bar chart showing the average percent grade of active students for each problem, '
168+
. 'where the average percent grade (as a decimal) for each problem is: [_1].',
169+
join(', ', map { "$svgProblemLabels->[$_]:$svgProblemData->[$_]" } 0 .. scalar(@$svgProblemData) - 1)
170+
),
149171
isJitarSet => $isJitarSet,
150172
jitarBars => $isJitarSet ? $jitarBars : [],
151173
barLinks => [ map { $_->{statsLink} } @$problems ],

templates/ContentGenerator/ProblemSet/problem_list.html.ep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
bs_placement => 'top',
2424
bs_toggle => 'popover',
2525
bs_content => maketext(
26-
q{The adjusted status of a problem is the larger of the problem's status and}
26+
q{The adjusted status of a problem is the larger of the problem's status and }
2727
. 'the weighted average of the status of those problems which count '
2828
. 'toward the parent grade.'
2929
)

0 commit comments

Comments
 (0)