Diff for /loncom/homework/edit.pm between versions 1.72 and 1.85

version 1.72, 2003/11/24 21:54:39 version 1.85, 2004/07/27 23:35:33
Line 25 Line 25
 #  #
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
 # 3/20 Guy  
 # 01/10/02 Matthew  
 # 03/06/02 Matthew  
 package Apache::edit;   package Apache::edit; 
   
 use strict;  use strict;
Line 289  sub insert_formularesponse { Line 287  sub insert_formularesponse {
 <formularesponse answer="" samples="">  <formularesponse answer="" samples="">
     <textline />      <textline />
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </formularesponse>';  </formularesponse>';
 }  }
Line 300  sub insert_numericalresponse { Line 297  sub insert_numericalresponse {
 <numericalresponse answer="">  <numericalresponse answer="">
     <textline />      <textline />
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </numericalresponse>';  </numericalresponse>';
 }  }
Line 311  sub insert_stringresponse { Line 307  sub insert_stringresponse {
 <stringresponse answer="" type="">  <stringresponse answer="" type="">
     <textline />      <textline />
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </stringresponse>';  </stringresponse>';
 }  }
Line 330  sub insert_imageresponse { Line 325  sub insert_imageresponse {
     <foilgroup>      <foilgroup>
     </foilgroup>      </foilgroup>
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </imageresponse>';  </imageresponse>';
 }  }
Line 342  sub insert_optionresponse { Line 336  sub insert_optionresponse {
     <foilgroup options="">      <foilgroup options="">
     </foilgroup>      </foilgroup>
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </optionresponse>';  </optionresponse>';
 }  }
Line 353  sub insert_organicresponse { Line 346  sub insert_organicresponse {
 <organicresponse>  <organicresponse>
     <textline />      <textline />
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </organicresponse>';  </organicresponse>';
 }  }
Line 371  sub insert_radiobuttonresponse { Line 363  sub insert_radiobuttonresponse {
     <foilgroup>      <foilgroup>
     </foilgroup>      </foilgroup>
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </radiobuttonresponse>';  </radiobuttonresponse>';
 }  }
Line 382  sub insert_reactionresponse { Line 373  sub insert_reactionresponse {
 <reactionresponse>  <reactionresponse>
     <textline />      <textline />
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </reactionresponse>';  </reactionresponse>';
 }  }
Line 394  sub insert_rankresponse { Line 384  sub insert_rankresponse {
     <foilgroup options="">      <foilgroup options="">
     </foilgroup>      </foilgroup>
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </rankresponse>';  </rankresponse>';
 }  }
Line 408  sub insert_matchresponse { Line 397  sub insert_matchresponse {
       </itemgroup>        </itemgroup>
     </foilgroup>      </foilgroup>
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </matchresponse>';  </matchresponse>';
 }  }
Line 427  sub insert_hintpart { Line 415  sub insert_hintpart {
 sub insert_hintgroup {  sub insert_hintgroup {
   return '    return '
 <hintgroup>  <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
 </hintgroup>';  </hintgroup>';
 }  }
   
Line 463  sub insert_optionhint { Line 450  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 486  sub textarea_sizes { Line 473  sub textarea_sizes {
   
 sub editline {  sub editline {
     my ($tag,$data,$description,$size)=@_;      my ($tag,$data,$description,$size)=@_;
     $data=&HTML::Entities::encode($data);      $data=&HTML::Entities::encode($data,'<>&"');
     if ($description) { $description="<br />".$description."<br />"; }      if ($description) { $description="<br />".$description."<br />"; }
     my $result = <<"END";      my $result = <<"END";
 $description  $description
Line 497  END Line 484  END
 }  }
   
 sub editfield {  sub editfield {
     my ($tag,$data,$description,$minwidth,$minheight)=@_;      my ($tag,$data,$description,$minwidth,$minheight,$usehtmlarea)=@_;
   
     my ($rows,$cols)=&textarea_sizes(\$data);      my ($rows,$cols)=&textarea_sizes(\$data);
       if (&Apache::lonhtmlcommon::htmlareabrowser() &&
    !&Apache::lonhtmlcommon::htmlareablocked()) {
    $rows+=7;      # make room for HTMLarea
    $minheight+=7; # make room for HTMLarea
       }
     if ($cols > 80) { $cols = 80; }      if ($cols > 80) { $cols = 80; }
     if ($cols < $minwidth ) { $cols = $minwidth; }      if ($cols < $minwidth ) { $cols = $minwidth; }
     if ($rows < $minheight) { $rows = $minheight; }      if ($rows < $minheight) { $rows = $minheight; }
     if ($description) { $description="<br />".$description."<br />"; }      if ($description) { $description="<br />".$description."<br />"; }
       if ($usehtmlarea) {
    push @Apache::lonxml::htmlareafields,'homework_edit_'.
       $Apache::lonxml::curdepth;
       }
     return $description."\n".'&nbsp;&nbsp;&nbsp;<textarea rows="'.$rows.      return $description."\n".'&nbsp;&nbsp;&nbsp;<textarea rows="'.$rows.
  '" cols="'.$cols.'" name="homework_edit_'.   '" cols="'.$cols.'" name="homework_edit_'.
    $Apache::lonxml::curdepth.'" id="homework_edit_'.
  $Apache::lonxml::curdepth.'">'.   $Apache::lonxml::curdepth.'">'.
  &HTML::Entities::encode($data).'</textarea>'."\n";   &HTML::Entities::encode($data,'<>&"').'</textarea>'.
    ($usehtmlarea?&Apache::lonhtmlcommon::spelllink('lonhomework',
    'homework_edit_'.$Apache::lonxml::curdepth):'')."\n";
 }  }
   
 sub modifiedfield {  sub modifiedfield {
Line 543  sub get_new_args { Line 542  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 677  sub select_or_text_arg { Line 679  sub select_or_text_arg {
     }      }
     $optionlist.="<option value=\"TYPEDINVALUE\"".      $optionlist.="<option value=\"TYPEDINVALUE\"".
   ((!$found)?' selected="on"':'').    ((!$found)?' selected="on"':'').
   ">".&mt('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 696  sub select_or_text_arg { Line 698  sub select_or_text_arg {
 <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 711  ENDSELECTORTYPE Line 713  ENDSELECTORTYPE
 #----------------------------------------------------- image coordinates  #----------------------------------------------------- image coordinates
 # single image coordinates, x, y   # single image coordinates, x, y 
 sub entercoords {  sub entercoords {
     my ($idx,,$idy,$mode,$width,$height) = @_;      my ($idx,$idy,$mode,$width,$height) = @_;
     unless ($Apache::edit::bgimgsrc) { return ''; }      unless ($Apache::edit::bgimgsrc) { return ''; }
     if ($idx) { $idx.='_'; }      if ($idx) { $idx.='_'; }
     if ($idy) { $idy.='_'; }      if ($idy) { $idy.='_'; }
     my $bgfile=&Apache::lonnet::escape($Apache::edit::bgimgsrc);      my $bgfile=&Apache::lonnet::escape(&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$Apache::edit::bgimgsrc));
     my $form    = 'lonhomework';      my $form    = 'lonhomework';
     my $element;      my $element;
     if (! defined($mode) || $mode eq 'attribute') {      if (! defined($mode) || $mode eq 'attribute') {
Line 724  sub entercoords { Line 726  sub entercoords {
         $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"      =>'point',
         "imagechoice.$id.formname"  =>$form,
         "imagechoice.$id.formx"     =>"$idx$element",
         "imagechoice.$id.formy"     =>"$idy$element",
         "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?formname=$form&file=$bgfile&formx=$idx$element&formy=$idy$element$formheight$formwidth"      my $text="Click Coordinates";
 target="imagechoice">Click Coordinates</a>      my $result='<a href="/adm/imagechoice?token='.$id.'" target="imagechoice">'.$text.'</a>';
 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));
     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.72  
changed lines
  Added in v.1.85


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