Diff for /loncom/interface/Attic/lonwizard.pm between versions 1.12 and 1.13

version 1.12, 2003/02/21 21:27:28 version 1.13, 2003/02/27 19:42:59
Line 626  If there is only one choice, the state w Line 626  If there is only one choice, the state w
   
 =over 4  =over 4
   
 =item overridden method B<new>(parentLonWizReference, stateName, stateTitle, messageBefore, messageAfter, nextState, varName, choiceHash): messageBefore is the HTML text that will be displayed before the choice display, messageAfter will display after. Keys will be sorted according to human name. nextState is the state to proceed to after the choice. varName is the name of the wizard var to store the computer_name answer in. choiceHash is the hash described above. It is optional because you may override it.  =item overridden method B<new>(parentLonWizReference, stateName, stateTitle, messageBefore, messageAfter, nextState, varName, choiceHash, multichoice): messageBefore is the HTML text that will be displayed before the choice display, messageAfter will display after. Keys will be sorted according to human name. nextState is the state to proceed to after the choice. varName is the name of the wizard var to store the computer_name answer in. choiceHash is the hash described above. It is optional because you may override it. multichoice is true if the user can make multiple choices, false otherwise. (Multiple choices will be seperated with ||| in the wizard variable.
   
 =back  =back
   
Line 642  sub new { Line 642  sub new {
     $self->{NEXT_STATE} = shift;      $self->{NEXT_STATE} = shift;
     $self->{VAR_NAME} = shift;      $self->{VAR_NAME} = shift;
     $self->{CHOICE_HASH} = shift;      $self->{CHOICE_HASH} = shift;
       $self->{MULTICHOICE} = shift;
     $self->{NO_CHOICES} = 0;      $self->{NO_CHOICES} = 0;
           
     return $self;      return $self;
Line 686  sub render { Line 687  sub render {
     my $self = shift;      my $self = shift;
     my $result = "";      my $result = "";
     my $var = $self->{VAR_NAME};      my $var = $self->{VAR_NAME};
       my $buttons = '';
   
       if ($self->{MULTICHOICE}) {
           $result = <<SCRIPT;
   <script>
       function checkall(value) {
    for (i=0; i<document.forms.wizform.elements.length; i++) {
               document.forms.wizform.elements[i].checked=value;
           }
       }
   </script>
   SCRIPT
           $buttons = <<BUTTONS;
   <input type="button" onclick="checkall(true)" value="Select All" />
   <input type="button" onclick="checkall(false)" value="Unselect All" />
   <br />
   BUTTONS
       }
           
     if (defined $self->{ERROR_MSG}) {      if (defined $self->{ERROR_MSG}) {
         $result .= '<font color="#FF0000">' . $self->{ERROR_MSG} . '</font><br /><br />';          $result .= '<font color="#FF0000">' . $self->{ERROR_MSG} . '</font><br /><br />';
     }      }
Line 695  sub render { Line 714  sub render {
  $result .= $self->{MESSAGE_BEFORE} . '<br /><br />';   $result .= $self->{MESSAGE_BEFORE} . '<br /><br />';
     }      }
   
       $result .= $buttons;
   
     my $choices = $self->{CHOICE_HASH};      my $choices = $self->{CHOICE_HASH};
     my @keys = keys (%$choices);      my @keys = keys (%$choices);
   
     $result .= "<select name=\"$var.forminput\" size=\"10\">\n";      my $multichoice = '';
       if ($self->{MULTICHOICE}) {
           $multichoice = 'multichoice="true" ';
       }
   
       my $type = "radio";
       if ($self->{MULTICHOICE}) { $type = 'checkbox'; }
     foreach (@keys)      foreach (@keys)
     {      {
  $result .= "<option value=\"" . HTML::Entities::encode($choices->{$_})           
             . "\">" . HTML::Entities::encode($_) . "</option>\n";          $result .= "<input type='$type' name='" .
               $self->{VAR_NAME} . '.forminput' .
               "' value=\"" . 
               HTML::Entities::encode($choices->{$_}) 
               . "\"/> " . HTML::Entities::encode($_) . "<br />\n";
     }      }
     $result .= "</select>\n\n";  
   
     if (defined $self->{MESSAGE_AFTER})      if (defined $self->{MESSAGE_AFTER})
     {      {
Line 744  Each choice may have arbitrary HTML asso Line 774  Each choice may have arbitrary HTML asso
   
 =over 4  =over 4
   
 =item overridden method B<new>(parentLonWizReference, stateName, stateTitle, varName, choiceList, messageBefore, messageAfter): varName is the name of the wizard variable the state will set with the choice made. choiceHash is list reference of a list of list references to three element lists, where the first element is what the wizard var varName will be set to, the second is the HTML that will be displayed for that choice, and the third is the destination state. messageBefore is an optional HTML string that will be placed before the message, messageAfter an optional HTML string that will be placed before.  =item overridden method B<new>(parentLonWizReference, stateName, stateTitle, varName, choiceList, messageBefore, messageAfter): varName is the name of the wizard variable the state will set with the choice made. choiceHash is list reference of a list of list references to three element lists, where the first element is what the wizard var varName will be set to, the second is the HTML that will be displayed for that choice, and the third is the destination state. The special setting 'ILLEGAL' can be used in the first place to state that it is not a legal chocie (see lonprintout.pm for real-life usage of that). messageBefore is an optional HTML string that will be placed before the message, messageAfter an optional HTML string that will be placed before.
   
 An example of a legit choiceList: C<my $choicelist = [ ["flunk", "Flunk Student", "FLUNK_STATE"], ["pass", "Pass Student", "PASS_STATE"] ];>  Note that ILLEGAL is desirable because some choices may not always be good choices, but they should not necessarily disappear with no explanantion of why they are no good. In lonprintout.pm, for instance, the choice "Problems from current sequence" may be no good because there are no problems in the sequence, but it should not silently disappear; it should announce that there are no problems in the sequence.
   
   An example of a legit choiceList: C<my $choicelist = [ ["flunk", "Flunk Student", "FLUNK_STATE"], ["pass", "Pass Student", "PASS_STATE"]  ];>
   
 =back  =back
   
Line 1230  sub postprocess { Line 1262  sub postprocess {
 # it renders the same states, so it doesn't go in just this state, and  # it renders the same states, so it doesn't go in just this state, and
 # you can lean on the browser back button to make sure it all chains  # you can lean on the browser back button to make sure it all chains
 # correctly.  # correctly.
   # Either that, or force all folders open and don't allow the user
   # to close them.
   
 sub render {  sub render {
     my $self = shift;      my $self = shift;
Line 1299  Note this state will not automatically a Line 1333  Note this state will not automatically a
   
 This is generally intended for use on a specific sequence, not the entire course, as for technical reasons the user can't open and close folders, so they must all be shown as open. To fix this would require making the folders image form submitters and remembering the selected state of each resource, which is not impossible but is too much error-prone work to do until it seems many people will want that feature.  This is generally intended for use on a specific sequence, not the entire course, as for technical reasons the user can't open and close folders, so they must all be shown as open. To fix this would require making the folders image form submitters and remembering the selected state of each resource, which is not impossible but is too much error-prone work to do until it seems many people will want that feature.
   
   Note this class is generally useful for multi-choice selections, by overridding "determineChoices" to return the choice hash.
   
 =over 4  =over 4
   
 =item overridden method B<new>(parentLonWizReference, stateName, stateTitle, messageBefore, messageAfter, nextState, varName, filterFunction, choiceFunction, map): Arguments like resource_choice. map is the ID number of a specific map that, if given is all that will be shown to the user, instead of the whole course.  =item overridden method B<new>(parentLonWizReference, stateName, stateTitle, messageBefore, messageAfter, nextState, varName, filterFunction, choiceFunction, map): Arguments like resource_choice. map is the ID number of a specific map that, if given is all that will be shown to the user, instead of the whole course.
Line 1421  sub new { Line 1457  sub new {
     my $proto = shift;      my $proto = shift;
     my $class = ref($proto) || $proto;      my $class = ref($proto) || $proto;
     my $self = bless $proto->SUPER::new(shift, shift, shift, shift,      my $self = bless $proto->SUPER::new(shift, shift, shift, shift,
                                         shift, shift, shift);                                          shift, shift, shift, undef, shift);
     return $self;      return $self;
 }  }
   

Removed from v.1.12  
changed lines
  Added in v.1.13


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>