[LON-CAPA-cvs] cvs: loncom /interface lonhelper.pm

bowersj2 lon-capa-cvs@mail.lon-capa.org
Wed, 14 May 2003 18:58:21 -0000


bowersj2		Wed May 14 14:58:21 2003 EDT

  Modified files:              
    /loncom/interface	lonhelper.pm 
  Log:
  No longer pass things on the querystring. Seems to be working.
  
  
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.27 loncom/interface/lonhelper.pm:1.28
--- loncom/interface/lonhelper.pm:1.27	Mon May 12 15:33:57 2003
+++ loncom/interface/lonhelper.pm	Wed May 14 14:58:21 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.27 2003/05/12 19:33:57 bowersj2 Exp $
+# $Id: lonhelper.pm,v 1.28 2003/05/14 18:58:21 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -344,8 +344,6 @@
 
     $self->{TITLE} = shift;
     
-    Apache::loncommon::get_unprocessed_cgi($ENV{QUERY_STRING});
-
     # If there is a state from the previous form, use that. If there is no
     # state, use the start state parameter.
     if (defined $ENV{"form.CURRENT_STATE"})
@@ -461,7 +459,11 @@
 
     my $envname = 'form.' . $var . '.forminput';
     if (defined($ENV{$envname})) {
-        $self->{VARS}->{$var} = $ENV{$envname};
+        if (ref($ENV{$envname})) {
+            $self->{VARS}->{$var} = join('|||', @{$ENV{$envname}});
+        } else {
+            $self->{VARS}->{$var} = $ENV{$envname};
+        }
     }
 }
 
@@ -545,7 +547,7 @@
     </head>
     $bodytag
 HEADER
-    if (!$state->overrideForm()) { $result.="<form name='helpform' method='GET'>"; }
+    if (!$state->overrideForm()) { $result.="<form name='helpform' method='POST'>"; }
     $result .= <<HEADER;
         <table border="0"><tr><td>
         <h2><i>$stateTitle</i></h2>
@@ -682,6 +684,7 @@
     push @{$self->{ELEMENTS}}, $element;
 }
 
+use Data::Dumper;
 sub render {
     my $self = shift;
     my @results = ();
@@ -689,6 +692,7 @@
     for my $element (@{$self->{ELEMENTS}}) {
         push @results, $element->render();
     }
+
     return join("\n", @results);
 }
 
@@ -701,23 +705,8 @@
 
 =head2 Element Base Class
 
-The Apache::lonhelper::element base class provides support methods for
-the elements to use, such as a multiple value processer.
-
-B<Methods>:
-
-=over 4
-
-=item * process_multiple_choices(formName, varName): Process the form 
-element named "formName" and place the selected items into the helper 
-variable named varName. This is for things like checkboxes or 
-multiple-selection listboxes where the user can select more then 
-one entry. The selected entries are delimited by triple pipes in 
-the helper variables, like this:  
-
- CHOICE_1|||CHOICE_2|||CHOICE_3
-
-=back
+The Apache::lonhelper::element base class provides support for elements
+and defines some generally useful tags for use in elements.
 
 B<finalcode tag>
 
@@ -831,28 +820,6 @@
     return 0;
 }
 
-sub process_multiple_choices {
-    my $self = shift;
-    my $formname = shift;
-    my $var = shift;
-
-    # Must extract values from data directly, as there
-    # may be more then one.
-    my @values;
-    for my $formparam (split (/&/, $ENV{QUERY_STRING})) {
-        my ($name, $value) = split(/=/, $formparam);
-        if ($name ne $formname) {
-            next;
-        }
-        $value =~ tr/+/ /;
-        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
-        push @values, $value;
-    }
-    $helper->{VARS}->{$var} = join('|||', @values);
-    
-    return;
-}
-
 1;
 
 package Apache::lonhelper::message;
@@ -1205,9 +1172,8 @@
         return 0;
     }
 
-    if ($self->{'multichoice'}) {
-        $self->process_multiple_choices($self->{'variable'}.'.forminput',
-                                        $self->{'variable'});
+    if (ref($chosenValue)) {
+        $helper->{VARS}->{$self->{'variable'}} = join('|||', @$chosenValue);
     }
 
     if (defined($self->{NEXTSTATE})) {
@@ -1693,11 +1659,6 @@
 sub postprocess {
     my $self = shift;
 
-    if ($self->{'multichoice'}) {
-        $self->process_multiple_choices($self->{'variable'}.'.forminput',
-                                        $self->{'variable'});
-    }
-
     if ($self->{'multichoice'} && !$helper->{VARS}->{$self->{'variable'}}) {
         $self->{ERROR_MSG} = 'You must choose at least one resource to continue.';
         return 0;
@@ -1855,10 +1816,6 @@
         return 0;
     }
 
-    if ($self->{'multichoice'}) {
-        $self->process_multiple_choices($self->{'variable'}.'.forminput',
-                                        $self->{'variable'});
-    }
     if (defined($self->{NEXTSTATE})) {
         $helper->changeState($self->{NEXTSTATE});
     }
@@ -2143,10 +2100,6 @@
         return 0;
     }
 
-    if ($self->{'multichoice'}) {
-        $self->process_multiple_choices($self->{'variable'}.'.forminput',
-                                        $self->{'variable'});
-    }
     if (defined($self->{NEXTSTATE})) {
         $helper->changeState($self->{NEXTSTATE});
     }