--- loncom/interface/lonhelper.pm 2006/05/15 22:01:12 1.149 +++ loncom/interface/lonhelper.pm 2006/12/18 21:48:47 1.160 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # .helper XML handler to implement the LON-CAPA helper # -# $Id: lonhelper.pm,v 1.149 2006/05/15 22:01:12 foxr Exp $ +# $Id: lonhelper.pm,v 1.160 2006/12/18 21:48:47 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -81,25 +81,28 @@ State tags are also required to have an human name of the state, and will be displayed as the header on top of the screen for the user. +State tags may also optionally have an attribute "help" which should be +the filename of a help file, this will add a blue ? to the title. + =head2 Example Helper Skeleton An example of the tags so far: - + -Of course this does nothing. In order for the wizard to do something, it is -necessary to put actual elements into the wizard. Documentation for each +Of course this does nothing. In order for the helper to do something, it is +necessary to put actual elements into the helper. Documentation for each of these elements follows. =head1 Creating a Helper With Code, Not XML -In some situations, such as the printing wizard (see lonprintout.pm), +In some situations, such as the printing helper (see lonprintout.pm), writing the helper in XML would be too complicated, because of scope issues or the fact that the code actually outweighs the XML. It is possible to create a helper via code, though it is a little odd. @@ -183,7 +186,9 @@ use Apache::File; use Apache::lonxml; use Apache::lonlocal; use Apache::lonnet; +use Apache::longroup; use Apache::lonselstudent; +use LONCAPA; # Register all the tags with the helper, so the helper can # push and pop them @@ -332,7 +337,8 @@ sub start_state { } Apache::lonhelper::state->new($token->[2]{'name'}, - $token->[2]{'title'}); + $token->[2]{'title'}, + $token->[2]{'help'}); return ''; } @@ -362,6 +368,7 @@ use Apache::loncommon; use Apache::File; use Apache::lonlocal; use Apache::lonnet; +use LONCAPA; sub new { my $proto = shift; @@ -467,9 +474,8 @@ sub _saveVars { sub _varsInFile { my $self = shift; my @vars = (); - for my $key (keys %{$self->{VARS}}) { - push @vars, &Apache::lonnet::escape($key) . '=' . - &Apache::lonnet::escape($self->{VARS}->{$key}); + for my $key (keys(%{$self->{VARS}})) { + push(@vars, &escape($key) . '=' . &escape($self->{VARS}->{$key})); } return join ('&', @vars); } @@ -484,7 +490,7 @@ sub declareVar { $self->{VARS}->{$var} = ''; } - my $envname = 'form.' . $var . '.forminput'; + my $envname = 'form.' . $var . '_forminput'; if (defined($env{$envname})) { if (ref($env{$envname})) { $self->{VARS}->{$var} = join('|||', @{$env{$envname}}); @@ -575,6 +581,7 @@ sub display { # Phase 4: Display. my $stateTitle=&mt($state->title()); + my $stateHelp= $state->help(); my $browser_searcher_js = ' - + RADIO $env{'form.condition'} = !$self->{'toponly'}; @@ -2341,7 +2524,8 @@ sub render { my ($course_personnel, $current_members, $expired_members, - $future_members) = &Apache::lonselstudent::get_people_in_class(); + $future_members) = + &Apache::lonselstudent::get_people_in_class($env{'request.course.sec'}); @@ -2354,6 +2538,7 @@ sub render { # Current personel + $result .= '

'.&mt('Select Currently Enrolled Students and Active Course Personnel').'

'; $result .= &Apache::lonselstudent::render_student_list( $current_members, "helpform", "current", @@ -2365,10 +2550,12 @@ sub render { # If activeonly is not set then we can also give the expired students: # - if (!$self->{'activeonly'} && ((scalar @$expired_members) > 0)) { + if (!$self->{'activeonly'} && ((scalar(@$future_members)) > 0)) { # And future. + $result .= '

'.&mt('Select Future Enrolled Students and Future Course Personnel').'

'; + $result .= &Apache::lonselstudent::render_student_list( $future_members, "helpform", "future", @@ -2376,8 +2563,11 @@ sub render { $self->{'multichoice'}, $self->{'variable'}, 0); + } + if (!$self->{'activeonly'} && ((scalar(@$expired_members)) > 0)) { # Past + $result .= '

'.&mt('Select Previously Enrolled Students and Inactive Course Personnel').'

'; $result .= &Apache::lonselstudent::render_student_list($expired_members, "helpform", "past", @@ -2395,7 +2585,7 @@ sub render { sub postprocess { my $self = shift; - my $result = $env{'form.' . $self->{'variable'} . '.forminput'}; + my $result = $env{'form.' . $self->{'variable'} . '_forminput'}; if (!$result && !$self->{'emptyallowed'}) { if ($self->{'coursepersonnel'}) { $self->{ERROR_MSG} = @@ -2580,7 +2770,7 @@ sub render { function checkall(value, checkName) { for (i=0; i" . "{'multichoice'} && $choices == 0) { $result .= ' checked="checked"'; @@ -2758,7 +2948,7 @@ sub fileState { sub postprocess { my $self = shift; - my $result = $env{'form.' . $self->{'variable'} . '.forminput'}; + my $result = $env{'form.' . $self->{'variable'} . '_forminput'}; if (!$result) { $self->{ERROR_MSG} = 'You must choose at least one file '. 'to continue.'; @@ -2848,7 +3038,7 @@ sub start_section { return if ($token->[2]{'onlysections'}); # add in groups to the end of the list - my %curr_groups = &Apache::loncommon::coursegroups(); + my %curr_groups = &Apache::longroup::coursegroups(); foreach my $group_name (sort(keys(%curr_groups))) { push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]); } @@ -2912,7 +3102,7 @@ sub start_group { # Populate the CHOICES element my %choices; - my %curr_groups = &Apache::loncommon::coursegroups(); + my %curr_groups = &Apache::longroup::coursegroups(); foreach my $group_name (sort {lc($a) cmp lc($b)} (keys(%curr_groups))) { push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]); } @@ -2994,7 +3184,7 @@ sub render { $result .= '

' . $self->{ERROR_MSG} . '

'; } - $result .= '{'variable'} . '_forminput"'; if (defined($self->{'size'})) { $result .= ' size="' . $self->{'size'} . '"'; @@ -3127,7 +3317,8 @@ sub start_clause { die 'Error in clause of condition, Perl said: ' . $@ if $@; if (!&$clause($helper, $paramHash)) { # Discard all text until the /condition. - &Apache::lonxml::get_all_text('/condition', $parser); + my $end_tag = $paramHash->{SKIPTAG} || '/condition'; + &Apache::lonxml::get_all_text($end_tag, $parser); } } @@ -3332,7 +3523,7 @@ sub overrideForm { package Apache::lonhelper::parmwizfinal; -# This is the final state for the parmwizard. It is not generally useful, +# This is the final state for the parm helper. It is not generally useful, # so it is not perldoc'ed. It does its own processing. # It is represented with , and # should later be moved to lonparmset.pm . @@ -3400,8 +3591,10 @@ sub render { if ($vars->{GRANULARITY} eq 'whole_course') { $resourceString .= '
  • '.&mt('for all resources in the course').'
  • '; if ($vars->{TARGETS} eq 'course') { - $level = 11; # general course, see lonparmset.pm perldoc + $level = 14; # general course, see lonparmset.pm perldoc } elsif ($vars->{TARGETS} eq 'section') { + $level = 9; + } elsif ($vars->{TARGETS} eq 'group') { $level = 6; } else { $level = 3; @@ -3416,8 +3609,10 @@ sub render { $symb = $res->symb(); $resourceString .= '
  • '.&mt('for the map named [_1]',"$title").'
  • '; if ($vars->{TARGETS} eq 'course') { - $level = 10; # general course, see lonparmset.pm perldoc + $level = 13; # general course, see lonparmset.pm perldoc } elsif ($vars->{TARGETS} eq 'section') { + $level = 8; + } elsif ($vars->{TARGETS} eq 'group') { $level = 5; } else { $level = 2; @@ -3433,8 +3628,10 @@ sub render { my $title = $res->compTitle(); $resourceString .= '
  • '.&mt('for the resource named [_1] part [_2]',"$title","$part").'
  • '; if ($vars->{TARGETS} eq 'course') { - $level = 7; # general course, see lonparmset.pm perldoc + $level = 10; # general course, see lonparmset.pm perldoc } elsif ($vars->{TARGETS} eq 'section') { + $level = 7; + } elsif ($vars->{TARGETS} eq 'group') { $level = 4; } else { $level = 1;