--- loncom/interface/lonhelper.pm 2004/04/22 14:43:16 1.74 +++ loncom/interface/lonhelper.pm 2005/01/16 08:20:38 1.93 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # .helper XML handler to implement the LON-CAPA helper # -# $Id: lonhelper.pm,v 1.74 2004/04/22 14:43:16 matthew Exp $ +# $Id: lonhelper.pm,v 1.93 2005/01/16 08:20:38 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -585,30 +585,6 @@ sub display { $result .= < - $loncapaHelper: $helperTitle @@ -1198,6 +1174,13 @@ sub end_choice { return ''; } +{ + # used to generate unique id attributes for tags. + # internal use only. + my $id = 0; + sub new_id { return $id++; } +} + sub render { my $self = shift; my $var = $self->{'variable'}; @@ -1280,14 +1263,16 @@ BUTTONS my $type = "radio"; if ($self->{'multichoice'}) { $type = 'checkbox'; } foreach my $choice (@{$self->{CHOICES}}) { + my $id = &new_id(); $result .= "\n \n"; $result .= "&"') + HTML::Entities::encode($choice->[1],"<>&\"'") . "'"; if ($checkedChoices{$choice->[1]}) { $result .= " checked "; } + $result .= qq{id="$id"}; my $choiceLabel = $choice->[0]; if ($choice->[4]) { # if we need to evaluate this choice $choiceLabel = "sub { my $helper = shift; my $state = shift;" . @@ -1295,8 +1280,8 @@ BUTTONS $choiceLabel = eval($choiceLabel); $choiceLabel = &$choiceLabel($helper, $self); } - &Apache::lonnet::logthis("TITLE TRANSLATION >$choiceLabel<"); - $result .= "/> " . &mtn($choiceLabel) . "\n"; + $result .= "/> ".qq{\n"; } $result .= "\n\n\n"; $result .= $buttons; @@ -1439,7 +1424,7 @@ sub render { $result .= "&\"'"); + if($option_vars) { + foreach my $option_var (@$option_vars) { + $col .= + " "; + } + } + + $col .= "&"') - . "' />"; - return $col; + $col .= "value='" . $resource_name . "' />"; + return $result.$col; } }; @@ -2077,7 +2124,7 @@ sub start_student { $helper->declareVar($paramHash->{'variable'}); $paramHash->{'multichoice'} = $token->[2]{'multichoice'}; $paramHash->{'coursepersonnel'} = $token->[2]{'coursepersonnel'}; - $paramHash->{'sctiveonly'} = $token->[2]{'activeonly'}; + $paramHash->{'activeonly'} = $token->[2]{'activeonly'}; if (defined($token->[2]{'nextstate'})) { $paramHash->{NEXTSTATE} = $token->[2]{'nextstate'}; } @@ -2114,7 +2161,9 @@ sub render { for (i=0; i @@ -2130,19 +2186,33 @@ SCRIPT my %lt=&Apache::lonlocal::texthash( 'ocs' => "Select Only Current Students", + 'ues' => "Unselect Expired Students", 'sas' => "Select All Students", 'uas' => "Unselect All Students", - 'sfsg' => "Select for Section/Group", + 'sfsg' => "Select Current Students for Section/Group", 'ufsg' => "Unselect for Section/Group"); $buttons = < - - - - -  - + + + + + + + + + + + + + + + + + + +


 

BUTTONS } @@ -2202,7 +2272,6 @@ BUTTONS } my $name = $self->{'coursepersonnel'} ? &mt('Name') : &mt('Student Name'); - &Apache::lonnet::logthis("THE NAME IS >$name<"); my $type = 'radio'; if ($self->{'multichoice'}) { $type = 'checkbox'; } $result .= "\n"; @@ -2222,7 +2291,10 @@ BUTTONS $checked = 1; } $result .= - " value='" . HTML::Entities::encode($choice->[0] . ':' . $choice->[2] . ':' . $choice->[1] . ':' . $choice->[3],'<>&"') + " value='" . HTML::Entities::encode($choice->[0] . ':' + .$choice->[2] . ':' + .$choice->[1] . ':' + .$choice->[3], "<>&\"'") . "' />" . + $result .= "/>" . "" . "" . "\n"; $choices++; @@ -2563,10 +2644,14 @@ sub fileState { my $constructionSpaceDir = shift; my $file = shift; + my ($uname,$udom)=($ENV{'user.name'},$ENV{'user.domain'}); + if ($ENV{'request.role'}=~/^ca\./) { + (undef,$udom,$uname)=split(/\//,$ENV{'request.role'}); + } my $docroot = $Apache::lonnet::perlvar{'lonDocRoot'}; my $subdirpart = $constructionSpaceDir; - $subdirpart =~ s/^\/home\/$ENV{'user.name'}\/public_html//; - my $resdir = $docroot . '/res/' . $ENV{'user.domain'} . '/' . $ENV{'user.name'} . + $subdirpart =~ s/^\/home\/$uname\/public_html//; + my $resdir = $docroot . '/res/' . $udom . '/' . $uname . $subdirpart; my @constructionSpaceFileStat = stat($constructionSpaceDir . '/' . $file); @@ -2695,6 +2780,7 @@ string honors the validation function, i no strict; @ISA = ("Apache::lonhelper::element"); use strict; +use Apache::lonlocal; BEGIN { &Apache::lonhelper::register('Apache::lonhelper::string', @@ -2813,6 +2899,8 @@ be able to call methods on it. =cut +use Apache::lonlocal; + BEGIN { &Apache::lonhelper::register('Apache::lonhelper::general', 'exec', 'condition', 'clause', @@ -2934,6 +3022,9 @@ will make a "Finish Helper" button that which is useful for the Course Initialization helper so the users never see the old values taking effect. +If the parameter "restartCourse" is not true a 'Finish' Button will be +presented that takes the user back to whatever was defined as + =cut no strict; @@ -3031,8 +3122,12 @@ sub render { $result .= ''; } + my $actionURL = $self->{EXIT_PAGE}; + my $targetURL = ''; + my $finish=&mt('Finish'); if ($self->{'restartCourse'}) { - my $targetURL = '/adm/menu'; + my $actionURL = '/adm/roles'; + $targetURL = '/adm/menu'; if ($ENV{'course.'.$ENV{'request.course.id'}.'.url'}=~/^uploaded/) { $targetURL = '/adm/coursedocs'; } else { @@ -3041,25 +3136,24 @@ sub render { if ($ENV{'course.'.$ENV{'request.course.id'}.'.clonedfrom'}) { $targetURL = '/adm/parmset?overview=1'; } - my $previous = HTML::Entities::encode(&mt("<- Previous"), '<>&"'); - my $next = HTML::Entities::encode(&mt("Next ->"), '<>&"'); - $result .= "
\n" . - "
\n" . - "" . - "" . - "\n" . - "\n\n" . - "
"; + my $finish=&mt('Finish Course Initialization'); } + my $previous = HTML::Entities::encode(&mt("<- Previous"), '<>&"'); + my $next = HTML::Entities::encode(&mt("Next ->"), '<>&"'); + $result .= "
\n" . + "
\n" . + "" . + "" . + "\n" . + "\n\n" . + "
"; return $result; } sub overrideForm { - my $self = shift; - return $self->{'restartCourse'}; + return 1; } 1; @@ -3126,7 +3220,7 @@ sub render { # Print the granularity, depending on the action if ($vars->{GRANULARITY} eq 'whole_course') { - $resourceString .= '
  • '.&mt('for').' '.&mt('all resources in the course').'
  • '; + $resourceString .= '
  • '.&mt('for all resources in the course').'
  • '; $level = 9; # general course, see lonparmset.pm perldoc $affectedResourceId = "0.0"; $symb = 'a'; @@ -3136,8 +3230,7 @@ sub render { my $res = $navmap->getByMapPc($vars->{RESOURCE_ID}); my $title = $res->compTitle(); $symb = $res->symb(); - $navmap->untieHashes(); - $resourceString .= "
  • for the map named $title
  • "; + $resourceString .= '
  • '.&mt('for the map named [_1]',"$title").'
  • '; $level = 8; $affectedResourceId = $vars->{RESOURCE_ID}; $paramlevel = 'map'; @@ -3146,8 +3239,7 @@ sub render { my $res = $navmap->getById($vars->{RESOURCE_ID}); $symb = $res->symb(); my $title = $res->compTitle(); - $navmap->untieHashes(); - $resourceString .= "
  • for the resource named $title
  • "; + $resourceString .= '
  • '.&mt('for the resource named [_1]',"$title").'
  • '; $level = 7; $affectedResourceId = $vars->{RESOURCE_ID}; $paramlevel = 'full'; @@ -3200,13 +3292,13 @@ sub render { # Print targets if ($vars->{TARGETS} eq 'course') { - $result .= '
  • '.&mt('for').' '.&mt('all students in course').'
  • '; + $result .= '
  • '.&mt('for all students in course').'
  • '; } elsif ($vars->{TARGETS} eq 'section') { my $section = $vars->{SECTION_NAME}; - $result .= "
  • ".&mt('for section')." $section
  • "; + $result .= '
  • '.&mt('for section [_1]',"$section").'
  • '; $level -= 3; $result .= "&"') . "' />\n"; + HTML::Entities::encode($section,"'<>&\"") . "' />\n"; } else { # FIXME: This is probably wasteful! Store the name! my $classlist = Apache::loncoursedata::get_classlist(); @@ -3214,20 +3306,18 @@ sub render { # Chop off everything after the last colon (section) $username = substr($username, 0, rindex($username, ':')); my $name = $classlist->{$username}->[6]; - $result .= "
  • ".&mt('for')." $name
  • "; + $result .= '
  • '.&mt('for [_1]',"$name").'
  • '; $level -= 6; my ($uname, $udom) = split /:/, $vars->{USER_NAME}; $result .= "&"') . "' />\n"; + HTML::Entities::encode($uname,"'<>&\"") . "' />\n"; $result .= "&"') . "' />\n"; + HTML::Entities::encode($udom,"'<>&\"") . "' />\n"; } # Print value if ($vars->{ACTION_TYPE} ne 'tries' && $vars->{ACTION_TYPE} ne 'weight') { - $result .= "
  • ".&mt('to')." " . ctime($vars->{PARM_DATE}) . " (" . - Apache::lonnavmaps::timeToHumanString($vars->{PARM_DATE}) - . ")
  • \n"; + $result .= '
  • '.&mt('to [_1] ([_2])',"".ctime($vars->{PARM_DATE})."",Apache::lonnavmaps::timeToHumanString($vars->{PARM_DATE}))."
  • \n"; } # print pres_marker
    " . HTML::Entities::encode($choice->[1],'<>&"') . "" @@ -2390,6 +2462,13 @@ sub start_filefilter { sub end_filefilter { return ''; } +{ + # used to generate unique id attributes for tags. + # internal use only. + my $id=0; + sub new_id { return $id++;} +} + sub render { my $self = shift; my $result = ''; @@ -2476,7 +2555,7 @@ BUTTONS } # Sort the fileList into order - @fileList = sort @fileList; + @fileList = sort {lc($a) cmp lc($b)} @fileList; $result .= $buttons; @@ -2528,14 +2607,16 @@ BUTTONS if ($status eq 'Published' && $helper->{VARS}->{'construction'}) { $onclick = 'onclick="a=1" '; } + my $id = &new_id(); $result .= '
    " . "&"'). + . ".forminput' ".qq{id="$id"}." value='" . HTML::Entities::encode($fileName,"<>&\"'"). "'"; if (!$self->{'multichoice'} && $choices == 0) { $result .= ' checked'; } - $result .= "/>" . $file . "". + qq{$title$status