--- loncom/interface/lonhelper.pm 2004/09/24 19:49:12 1.87
+++ loncom/interface/lonhelper.pm 2005/01/05 12:07:27 1.91
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# .helper XML handler to implement the LON-CAPA helper
#
-# $Id: lonhelper.pm,v 1.87 2004/09/24 19:49:12 matthew Exp $
+# $Id: lonhelper.pm,v 1.91 2005/01/05 12:07:27 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1267,7 +1267,7 @@ BUTTONS
$result .= "
\n \n";
$result .= " &"')
+ HTML::Entities::encode($choice->[1],"<>&\"'")
. "'";
if ($checkedChoices{$choice->[1]}) {
$result .= " checked ";
@@ -1424,7 +1424,7 @@ sub render {
$result .= "\n";
foreach my $choice (@{$self->{CHOICES}}) {
$result .= "&"')
+ HTML::Entities::encode($choice->[1],"<>&\"'")
. "'";
if ($checkedChoices{$choice->[1]}) {
$result .= " selected";
@@ -1760,7 +1760,7 @@ BEGIN {
&Apache::lonhelper::register('Apache::lonhelper::resource',
('resource', 'filterfunc',
'choicefunc', 'valuefunc',
- 'mapurl'));
+ 'mapurl','option'));
}
sub new {
@@ -1865,6 +1865,42 @@ sub start_mapurl {
sub end_mapurl { return ''; }
+
+sub start_option {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ if (!defined($paramHash->{OPTION_TEXTS})) {
+ $paramHash->{OPTION_TEXTS} = [ ];
+ $paramHash->{OPTION_VARS} = [ ];
+
+ }
+ # OPTION_TEXTS is a list of the text attribute
+ # values used to create column headings.
+ # OPTION_VARS is a list of the variable names, used to create the checkbox
+ # inputs.
+ # We're ok with empty elements. as place holders
+ # Although the 'variable' element should really exist.
+ #
+
+ my $option_texts = $paramHash->{OPTION_TEXTS};
+ my $option_vars = $paramHash->{OPTION_VARS};
+ push(@$option_texts, $token->[2]{'text'});
+ push(@$option_vars, $token->[2]{'variable'});
+
+ # Need to create and declare the option variables as well to make them
+ # persistent.
+ #
+ my $varname = $token->[2]{'variable'};
+ $helper->declareVar($varname);
+
+
+ return '';
+}
+
+sub end_option {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ return '';
+}
+
# A note, in case I don't get to this before I leave.
# If someone complains about the "Back" button returning them
# to the previous folder state, instead of returning them to
@@ -1916,10 +1952,13 @@ BUTTONS
$result .= $buttons;
- my $filterFunc = $self->{FILTER_FUNC};
- my $choiceFunc = $self->{CHOICE_FUNC};
- my $valueFunc = $self->{VALUE_FUNC};
- my $multichoice = $self->{'multichoice'};
+ my $filterFunc = $self->{FILTER_FUNC};
+ my $choiceFunc = $self->{CHOICE_FUNC};
+ my $valueFunc = $self->{VALUE_FUNC};
+ my $multichoice = $self->{'multichoice'};
+ my $option_vars = $self->{OPTION_VARS};
+ my $option_texts = $self->{OPTION_TEXTS};
+ my $headings_done = 0;
# Evaluate the map url as needed
my $mapUrl;
@@ -1937,15 +1976,40 @@ BUTTONS
my $checked = 0;
my $renderColFunc = sub {
my ($resource, $part, $params) = @_;
+ my $result = "";
+
+ if(!$headings_done) {
+ if ($option_texts) {
+ foreach my $text (@$option_texts) {
+ $result .= "$text ";
+ }
+ }
+ $result .= "Select ";
+ $result .= " "; # Close off the extra row and start a new one.
+ $headings_done = 1;
+ }
my $inputType;
if ($multichoice) { $inputType = 'checkbox'; }
else {$inputType = 'radio'; }
if (!&$choiceFunc($resource)) {
- return ' ';
+ $result .= ' ';
+ return $result;
} else {
- my $col = " &\"'");
+ if($option_vars) {
+ foreach my $option_var (@$option_vars) {
+ $col .=
+ " ";
+ }
+ }
+
+ $col .= " &"')
- . "' /> ";
- return $col;
+ $col .= "value='" . $resource_name . "' />";
+ return $result.$col;
}
};
@@ -2217,7 +2279,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], "<>&\"'")
. "' />"
. HTML::Entities::encode($choice->[1],'<>&"')
. " "
@@ -2533,7 +2598,7 @@ BUTTONS
my $id = &new_id();
$result .= ' " .
" &"').
+ . ".forminput' ".qq{id="$id"}." value='" . HTML::Entities::encode($fileName,"<>&\"'").
"'";
if (!$self->{'multichoice'} && $choices == 0) {
$result .= ' checked';
@@ -3147,7 +3212,6 @@ sub render {
my $res = $navmap->getByMapPc($vars->{RESOURCE_ID});
my $title = $res->compTitle();
$symb = $res->symb();
- $navmap->untieHashes();
$resourceString .= ''.&mt('for the map named [_1]',"$title ").' ';
$level = 8;
$affectedResourceId = $vars->{RESOURCE_ID};
@@ -3157,7 +3221,6 @@ sub render {
my $res = $navmap->getById($vars->{RESOURCE_ID});
$symb = $res->symb();
my $title = $res->compTitle();
- $navmap->untieHashes();
$resourceString .= ''.&mt('for the resource named [_1]',"$title ").' ';
$level = 7;
$affectedResourceId = $vars->{RESOURCE_ID};
@@ -3217,7 +3280,7 @@ sub render {
$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();
@@ -3229,9 +3292,9 @@ sub render {
$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