{'multichoice'} && !$checked) {
+ if (%defaultUsers) {
+ my $user=$choice->[0];
+ if (exists($defaultUsers{$user})) {
+ $result .= " checked='checked' ";
+ $checked = 1;
+ }
+ } elsif (!$self->{'multichoice'} && !$checked) {
$result .= " checked='checked' ";
$checked = 1;
}
@@ -2364,8 +2476,51 @@ BUTTONS
}
$result .= "\n\n";
- $result .= $buttons;
-
+ $result .= $buttons;
+ #
+ # now add the fancy section choice... first enumerate the sections:
+ if ($self->{'multichoice'}) {
+ my %sections;
+ for my $key (@keys) {
+ my $section_name = $classlist->{$key}->[$section];
+ if ($section_name ne "") {
+ $sections{$section_name} = 1;
+ }
+ }
+ # The variable $choice_widget will have the html to make the choice
+ # selector.
+ my $size=5;
+ if (scalar(keys(%sections)) < 5) {
+ $size=scalar(keys(%sections));
+ }
+ my $choice_widget = '\n";
+
+ # Build a table without any borders to contain the section based
+ # selection:
+
+ my $section_selectors =<
+
+ For Sections: | $choice_widget |
+ |
+ |
+ |
+
+
+ |
+ |
+
+
+SECTIONSELECT
+ $result .= $section_selectors;
+ }
return $result;
}
@@ -2373,9 +2528,14 @@ sub postprocess {
my $self = shift;
my $result = $env{'form.' . $self->{'variable'} . '.forminput'};
- if (!$result) {
- $self->{ERROR_MSG} =
- &mt('You must choose at least one student to continue.');
+ if (!$result && !$self->{'emptyallowed'}) {
+ if ($self->{'coursepersonnel'}) {
+ $self->{ERROR_MSG} =
+ &mt('You must choose at least one user to continue.');
+ } else {
+ $self->{ERROR_MSG} =
+ &mt('You must choose at least one student to continue.');
+ }
return 0;
}
@@ -2547,7 +2707,8 @@ sub render {
if ($self->{'multichoice'}) {
$result = <
SCRIPT
my %lt=&Apache::lonlocal::texthash(
@@ -2818,6 +2980,73 @@ sub end_section {
}
1;
+package Apache::lonhelper::group;
+
+=pod
+
+=head2 Element: groupX
+
+ allows the user to choose one or more groups from the current course.
+
+It takes the standard attributes "variable", "multichoice", and "nextstate", meaning what they do for most other elements.
+
+=cut
+
+no strict;
+@ISA = ("Apache::lonhelper::choices");
+use strict;
+
+BEGIN {
+ &Apache::lonhelper::register('Apache::lonhelper::group',
+ ('group'));
+}
+
+sub new {
+ my $ref = Apache::lonhelper::choices->new();
+ bless($ref);
+}
+
+sub start_group {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+
+ if ($target ne 'helper') {
+ return '';
+ }
+
+ $paramHash->{CHOICES} = [];
+
+ $paramHash->{'variable'} = $token->[2]{'variable'};
+ $helper->declareVar($paramHash->{'variable'});
+ $paramHash->{'multichoice'} = $token->[2]{'multichoice'};
+ if (defined($token->[2]{'nextstate'})) {
+ $paramHash->{NEXTSTATE} = $token->[2]{'nextstate'};
+ }
+
+ # Populate the CHOICES element
+ my %choices;
+
+ my $numgroups;
+ my %curr_groups;
+ if (&Apache::loncommon::coursegroups(\%curr_groups)) {
+ foreach my $group_name (keys %curr_groups) {
+ $choices{$group_name} = $group_name;
+ }
+ }
+ foreach my $group_name (sort(keys(%choices))) {
+ push @{$paramHash->{CHOICES}}, [$group_name, $group_name];
+ }
+}
+
+sub end_group {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+
+ if ($target ne 'helper') {
+ return '';
+ }
+ Apache::lonhelper::group->new();
+}
+1;
+
package Apache::lonhelper::string;
=pod
@@ -3199,8 +3428,11 @@ sub render {
}
my $previous = HTML::Entities::encode(&mt("<- Previous"), '<>&"');
my $next = HTML::Entities::encode(&mt("Next ->"), '<>&"');
+ my $target = " target='loncapaclient'";
+ if (($env{'browser.interface'} eq 'textual') ||
+ ($env{'environment.remote'} eq 'off')) { $target=''; }
$result .= "\n" .
- " |