Diff for /loncom/homework/edit.pm between versions 1.69 and 1.79

version 1.69, 2003/10/24 21:45:32 version 1.79, 2004/02/13 21:12:54
Line 33  package Apache::edit; Line 33  package Apache::edit;
 use strict;  use strict;
 use Apache::lonnet();  use Apache::lonnet();
 use HTML::Entities();  use HTML::Entities();
   use Apache::lonlocal;
   
 # Global Vars  # Global Vars
 # default list of colors to use in editing  # default list of colors to use in editing
Line 288  sub insert_formularesponse { Line 289  sub insert_formularesponse {
 <formularesponse answer="" samples="">  <formularesponse answer="" samples="">
     <textline />      <textline />
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </formularesponse>';  </formularesponse>';
 }  }
Line 299  sub insert_numericalresponse { Line 299  sub insert_numericalresponse {
 <numericalresponse answer="">  <numericalresponse answer="">
     <textline />      <textline />
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </numericalresponse>';  </numericalresponse>';
 }  }
Line 310  sub insert_stringresponse { Line 309  sub insert_stringresponse {
 <stringresponse answer="" type="">  <stringresponse answer="" type="">
     <textline />      <textline />
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </stringresponse>';  </stringresponse>';
 }  }
Line 329  sub insert_imageresponse { Line 327  sub insert_imageresponse {
     <foilgroup>      <foilgroup>
     </foilgroup>      </foilgroup>
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </imageresponse>';  </imageresponse>';
 }  }
Line 341  sub insert_optionresponse { Line 338  sub insert_optionresponse {
     <foilgroup options="">      <foilgroup options="">
     </foilgroup>      </foilgroup>
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </optionresponse>';  </optionresponse>';
 }  }
   
   sub insert_organicresponse {
       return '
   <organicresponse>
       <textline />
       <hintgroup>
       <startouttext /><endouttext />
       </hintgroup>
   </organicresponse>';
   }
   
   sub insert_organicstructure {
       return '
   <organicstructure />
   ';
   }
   
 sub insert_radiobuttonresponse {  sub insert_radiobuttonresponse {
     return '      return '
 <radiobuttonresponse max="10">  <radiobuttonresponse max="10">
     <foilgroup>      <foilgroup>
     </foilgroup>      </foilgroup>
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </radiobuttonresponse>';  </radiobuttonresponse>';
 }  }
   
   sub insert_reactionresponse {
       return '
   <reactionresponse>
       <textline />
       <hintgroup>
       <startouttext /><endouttext />
       </hintgroup>
   </reactionresponse>';
   }
   
 sub insert_rankresponse {  sub insert_rankresponse {
     return '      return '
 <rankresponse max="10">  <rankresponse max="10">
     <foilgroup options="">      <foilgroup options="">
     </foilgroup>      </foilgroup>
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </rankresponse>';  </rankresponse>';
 }  }
Line 379  sub insert_matchresponse { Line 399  sub insert_matchresponse {
       </itemgroup>        </itemgroup>
     </foilgroup>      </foilgroup>
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </matchresponse>';  </matchresponse>';
 }  }
Line 398  sub insert_hintpart { Line 417  sub insert_hintpart {
 sub insert_hintgroup {  sub insert_hintgroup {
   return '    return '
 <hintgroup>  <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
 </hintgroup>';  </hintgroup>';
 }  }
   
Line 434  sub insert_optionhint { Line 452  sub insert_optionhint {
 }  }
   
 sub insert_startouttext {  sub insert_startouttext {
     return "<startouttext />\n<endouttext />";      return "<startouttext /><endouttext />";
 }  }
   
 sub insert_script {  sub insert_script {
     return "\n<script type=\"loncapa/perl\">\n</script>";      return "\n<script type=\"loncapa/perl\"></script>";
 }  }
   
 sub textarea_sizes {  sub textarea_sizes {
Line 482  sub editfield { Line 500  sub editfield {
 }  }
   
 sub modifiedfield {  sub modifiedfield {
     my ($token) = @_;      my ($endtag,$parser) = @_;
     my $result;      my $result;
 #  foreach my $envkey (sort keys %ENV) {  #  foreach my $envkey (sort keys %ENV) {
 #    &Apache::lonxml::debug("$envkey ---- $ENV{$envkey}");  #    &Apache::lonxml::debug("$envkey ---- $ENV{$envkey}");
Line 490  sub modifiedfield { Line 508  sub modifiedfield {
 #  &Apache::lonxml::debug("I want homework_edit_$Apache::lonxml::curdepth");  #  &Apache::lonxml::debug("I want homework_edit_$Apache::lonxml::curdepth");
 #  &Apache::lonxml::debug($ENV{"form.homework_edit_$Apache::lonxml::curdepth"});  #  &Apache::lonxml::debug($ENV{"form.homework_edit_$Apache::lonxml::curdepth"});
     $result=$ENV{"form.homework_edit_$Apache::lonxml::curdepth"};      $result=$ENV{"form.homework_edit_$Apache::lonxml::curdepth"};
       my $bodytext=&Apache::lonxml::get_all_text($endtag,$parser);
       # textareas throw away intial \n 
       if ($bodytext=~/^\n/) { $result="\n".$result; }
     return $result;      return $result;
 }  }
   
Line 511  sub get_new_args { Line 532  sub get_new_args {
  $token->[2]->{$arg}=$newvalue;   $token->[2]->{$arg}=$newvalue;
     }      }
     $rebuild=1;      $rebuild=1;
    } elsif (!defined($newvalue) && defined($value)) {
       delete($token->[2]->{$arg});
       $rebuild=1;
  }   }
     }      }
     return $rebuild;      return $rebuild;
Line 558  sub checked_arg { Line 582  sub checked_arg {
     my $result;      my $result;
     my $optionlist="";      my $optionlist="";
     my $allselected=$token->[2]{$name};      my $allselected=$token->[2]{$name};
     $result=$description;      $result=&mt($description);
     foreach my $option (@$list) {      foreach my $option (@$list) {
  my ($value,$text);   my ($value,$text);
  if ( ref($option) eq 'ARRAY') {   if ( ref($option) eq 'ARRAY') {
Line 587  sub text_arg { Line 611  sub text_arg {
     my $result;      my $result;
     if (!defined $size) { $size=20; }      if (!defined $size) { $size=20; }
     my $arg=$token->[2]{$name};      my $arg=$token->[2]{$name};
     $result=$description.'&nbsp;<input name="'.&html_element_name($name).      $result=&mt($description).'&nbsp;<input name="'.&html_element_name($name).
  '" type="text" value="'.$arg.'" size="'.$size.'" />';   '" type="text" value="'.$arg.'" size="'.$size.'" />';
     return '<nobr>'.$result.'</nobr>';      return '<nobr>'.$result.'</nobr>';
 }  }
Line 645  sub select_or_text_arg { Line 669  sub select_or_text_arg {
     }      }
     $optionlist.="<option value=\"TYPEDINVALUE\"".      $optionlist.="<option value=\"TYPEDINVALUE\"".
   ((!$found)?' selected="on"':'').    ((!$found)?' selected="on"':'').
   ">Type in value</option>\n";    ">".&mt('Type-in value')."</option>\n";
 #  #
     my $element=&html_element_name($name);      my $element=&html_element_name($name);
     my $selectelement='select_list_'.$element;      my $selectelement='select_list_'.$element;
Line 658  sub select_or_text_arg { Line 682  sub select_or_text_arg {
      '.options['.$selectedindex.'].value';       '.options['.$selectedindex.'].value';
     my $typedinvalue='this.form.'.$typeinelement.'.value';      my $typedinvalue='this.form.'.$typeinelement.'.value';
     my $selecttypeinindex='this.form.'.$selectelement.'.options.length';      my $selecttypeinindex='this.form.'.$selectelement.'.options.length';
       $description=&mt($description);
 #  #
     return (<<ENDSELECTORTYPE);      return (<<ENDSELECTORTYPE);
 <nobr>  <nobr>
 $description  $description
 &nbsp;<select name="$selectelement"  &nbsp;<select name="$selectelement"
 onChange="if ($selectedvalue!='TYPEDINVALUE') { $hiddenvalue=$selectedvalue; $typedinvalue=''; }"  onChange="if ($selectedvalue!='TYPEDINVALUE') { $hiddenvalue=$selectedvalue; $typedinvalue=''; }" >
 $optionlist  $optionlist
 </select>  </select>
 <input type="text" size="$size" name="$typeinelement"  <input type="text" size="$size" name="$typeinelement"
Line 706  ENDBUTTON Line 731  ENDBUTTON
     return $result;      return $result;
 }  }
   
 # coordinate pair (x1,y1)-(x2,y2)  # coordinates (x1,y1)-(x2,y2)...
 sub entercoordpair {  # mode can be either box, or polygon
     my ($id,$mode,$width,$height) = @_;  sub entercoord {
       my ($idx,$mode,$width,$height,$type) = @_;
     unless ($Apache::edit::bgimgsrc) { return ''; }      unless ($Apache::edit::bgimgsrc) { return ''; }
     my $bgfile=&Apache::lonnet::escape($Apache::edit::bgimgsrc);      my $bgfile=&Apache::lonnet::escape(&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$Apache::edit::bgimgsrc));
       &Apache::lonnet::logthis($Apache::edit::bgfile);
     my $form    = 'lonhomework';      my $form    = 'lonhomework';
     my $element;      my $element;
     if (! defined($mode) || $mode eq 'attribute') {      if (! defined($mode) || $mode eq 'attribute') {
         $element = &Apache::lonnet::escape("$id\_$Apache::lonxml::curdepth");          $element = &Apache::lonnet::escape("$idx\_$Apache::lonxml::curdepth");
     } elsif ($mode eq 'textnode') {  # for data between <tag> ... </tag>      } elsif ($mode eq 'textnode') {  # for data between <tag> ... </tag>
         $element = &Apache::lonnet::escape('homework_edit_'.          $element = &Apache::lonnet::escape('homework_edit_'.
                                            $Apache::lonxml::curdepth);                                             $Apache::lonxml::curdepth);
     }      }
     my $formheight='';      my $id=$Apache::lonxml::curdepth;
       my %data=("imagechoice.$id.type"      =>$type,
         "imagechoice.$id.formname"  =>$form,
         "imagechoice.$id.file"      =>$bgfile,
         "imagechoice.$id.formcoord" =>$element);
     if ($height) {      if ($height) {
  $formheight='&formheight='.$height.'_'.$Apache::edit::bgimgsrccurdepth;   $data{"imagechoice.$id.formheight"}=$height.'_'.
       $Apache::edit::bgimgsrccurdepth;
     }      }
     my $formwidth='';  
     if ($width) {      if ($width) {
  $formwidth='&formwidth='.$width.'_'.$Apache::edit::bgimgsrccurdepth;   $data{"imagechoice.$id.formwidth"}=$width.'_'.
       $Apache::edit::bgimgsrccurdepth;
     }      }
     my $result = <<"ENDBUTTON";      &Apache::lonnet::appenv(%data);
 <a href="/cgi-bin/imagechoice.pl?mode=pair&formname=$form&file=$bgfile$formheight$formwidth&formcoord=$element"      my $text="Enter Coordinates";
 target="imagechoice">Click Coordinate Pair</a>      if ($type eq 'polygon') { $text='Create Polygon Data'; }
 ENDBUTTON      my $result='<a href="/adm/imagechoice?token='.$id.'" target="imagechoice">'.$text.'</a>';
     return $result;      return $result;
 }  }
   
   sub deletecoorddata {
       &Apache::lonnet::delenv("imagechoice\\.");
   }
   
 #----------------------------------------------------- browse  #----------------------------------------------------- browse
 sub browse {  sub browse {
     # insert a link to call up the filesystem browser (lonindexer)      # insert a link to call up the filesystem browser (lonindexer)

Removed from v.1.69  
changed lines
  Added in v.1.79


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