Skip to content

Commit b6f36b2

Browse files
committed
Implement suggestions made in my review of openwebwork#2266
This uses `flex` rules to make the category input groups behave better. The categories are wrapped in a div with fixed width. The width is chosen to be as small as possible such that the input groups do not wrap. Thus this dispenses with trying to make the category widths match the scrolling record list which really wasn't working. `flex-wrap` is used with "around" justification. So at extra large window widths all three categories will be in the same row. However, when the categories don't fit, they wrap. The justification gives nicer positioning in any case. I merged the input texts, removed capitalization, and changed some of the wording in a few cases. For example, I don't think that the "Library Browser Exercises" is good. I think the reference to the library browser is unnecessary, and using "exercises" instead of "problems" is inconsistent the wording used everywhere else in webwork2. The other changes made are more explicit in the comments made in my review.
1 parent 35cf980 commit b6f36b2

File tree

10 files changed

+199
-223
lines changed

10 files changed

+199
-223
lines changed

lib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616
package WeBWorK::ContentGenerator::Instructor::ProblemSetDetail;
1717
use Mojo::Base 'WeBWorK::ContentGenerator', -signatures;
1818

19-
use Exporter qw(import);
20-
2119
=head1 NAME
2220
2321
WeBWorK::ContentGenerator::Instructor::ProblemSetDetail - Edit general set and
2422
specific user/set information as well as problem information
2523
2624
=cut
2725

26+
use Exporter qw(import);
27+
2828
use WeBWorK::Utils qw(cryptPassword jitar_id_to_seq seq_to_jitar_id x format_set_name_internal format_set_name_display);
2929
use WeBWorK::Utils::Instructor qw(assignProblemToAllSetUsers addProblemToSet);
3030

31-
our @EXPORT_OK = ('FIELD_PROPERTIES');
31+
our @EXPORT_OK = qw(FIELD_PROPERTIES);
3232

3333
# These constants determine which fields belong to what type of record.
3434
use constant SET_FIELDS => [

lib/WeBWorK/HTML/ScrollingRecordList.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ sub scrollingRecordList ($options, @records) {
7575
}
7676

7777
$formattedRecords = formatRecords(
78+
$c,
7879
$c->param("$name!format") || $options{default_format},
7980
sortRecords(
8081
$c->param("$name!sort") || $options{default_sort} || (@$sorts ? $sorts->[0][1] : ''),

lib/WeBWorK/Utils/FilterRecords.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use warnings;
5151
use Carp;
5252

5353
use WeBWorK::Utils qw(sortByName);
54-
use WeBWorK::ContentGenerator::Instructor::ProblemSetDetail qw/FIELD_PROPERTIES/;
54+
use WeBWorK::ContentGenerator::Instructor::ProblemSetDetail qw(FIELD_PROPERTIES);
5555

5656
our @EXPORT_OK = qw(
5757
getFiltersForClass
@@ -118,7 +118,7 @@ sub getFiltersForClass {
118118

119119
if (keys %visibles > 1) {
120120
for my $vis (sortByName(undef, keys %visibles)) {
121-
push @filters, [ ($vis ? 'Visible' : "Not Visible") => "visible:$vis" ];
121+
push @filters, [ ($vis ? 'Visible' : 'Not Visible') => "visible:$vis" ];
122122
}
123123
}
124124
}

lib/WeBWorK/Utils/FormatRecords.pm

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use warnings;
5555

5656
use Carp;
5757

58-
use WeBWorK::Utils qw/format_set_name_display formatDateTime/;
58+
use WeBWorK::Utils qw/format_set_name_display/;
5959
use WeBWorK::ContentGenerator::Instructor::ProblemSetDetail qw/FIELD_PROPERTIES/;
6060

6161
our @EXPORT_OK = qw(
@@ -115,9 +115,9 @@ use constant PRESET_FORMATS => {
115115
field_order => [qw/assignment_type set_id due_date/],
116116
format_function => sub {
117117
join('',
118-
FIELD_PROPERTIES()->{assignment_type}{labels}{ $_[0] },
119-
': ', format_set_name_display($_[1]),
120-
', ', formatDateTime($_[2]));
118+
FIELD_PROPERTIES()->{assignment_type}{labels}{ $_[1] },
119+
': ', format_set_name_display($_[2]),
120+
', ', $_[0]->formatDateTime($_[3]));
121121
}
122122
}
123123
],
@@ -126,15 +126,17 @@ use constant PRESET_FORMATS => {
126126
name => 'due_date: set_id',
127127
field_order => [qw/due_date set_id/],
128128
format_function => sub {
129-
join('', formatDateTime($_[0]), ': ', format_set_name_display($_[1]));
129+
join('', $_[0]->formatDateTime($_[1]), ': ', format_set_name_display($_[2]));
130130
}
131131
}
132132
],
133133
[
134134
'sid' => {
135135
name => 'set_id',
136136
field_order => [qw/set_id/],
137-
format_function => \&format_set_name_display
137+
format_function => sub {
138+
return format_set_name_display($_[1]);
139+
}
138140
}
139141
],
140142
],
@@ -173,23 +175,24 @@ sub getFormatsForClass {
173175
return \@presets;
174176
}
175177

176-
=item formatRecords($preset_format, @records)
178+
=item formatRecords($c, $preset_format, @records)
177179
178180
Given the name of a preset format and an array of database records, returns a
179181
reference to a list of two element lists. The first element in each list is a
180182
formatted string representing the record, and the second element is a string
181183
that is obtained by joining the key fields of the database record with
182184
exclamation marks.
183185
184-
The C<$preset_format> must be provided. It must either be one of the presets
185-
defined above, or the name of a field in the database record class.
186+
The arguments C<$c> and C<$preset_format> must be provided. C<$c> must be a
187+
C<WeBWorK::Controller> object, and C<$preset_format> must either be one of the
188+
presets defined above, or the name of a field in the database record class.
186189
187190
=back
188191
189192
=cut
190193

191194
sub formatRecords {
192-
my ($preset_format, @records) = @_;
195+
my ($c, $preset_format, @records) = @_;
193196

194197
return unless @records;
195198

@@ -233,8 +236,13 @@ sub formatRecords {
233236
if ($format_function) {
234237
# If a format_function was passed, then call it on each record.
235238
for my $value (@records) {
236-
push(@formattedRecords,
237-
[ $format_function->(map { $value->$_ } @field_order), join('!', map { $value->$_ } @keyfields) ]);
239+
push(
240+
@formattedRecords,
241+
[
242+
$format_function->($c, map { $value->$_ } @field_order),
243+
join('!', map { $value->$_ } @keyfields)
244+
]
245+
);
238246
}
239247
} else {
240248
# Otherwise, use sprintf and format_string.

0 commit comments

Comments
 (0)