Diff for /loncom/homework/edit.pm between versions 1.76 and 1.81

version 1.76, 2004/01/12 19:53:54 version 1.81, 2004/03/30 08:20:49
Line 289  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 300  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 311  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 330  sub insert_imageresponse { Line 327  sub insert_imageresponse {
     <foilgroup>      <foilgroup>
     </foilgroup>      </foilgroup>
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </imageresponse>';  </imageresponse>';
 }  }
Line 342  sub insert_optionresponse { Line 338  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 348  sub insert_organicresponse {
 <organicresponse>  <organicresponse>
     <textline />      <textline />
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </organicresponse>';  </organicresponse>';
 }  }
Line 371  sub insert_radiobuttonresponse { Line 365  sub insert_radiobuttonresponse {
     <foilgroup>      <foilgroup>
     </foilgroup>      </foilgroup>
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </radiobuttonresponse>';  </radiobuttonresponse>';
 }  }
Line 382  sub insert_reactionresponse { Line 375  sub insert_reactionresponse {
 <reactionresponse>  <reactionresponse>
     <textline />      <textline />
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </reactionresponse>';  </reactionresponse>';
 }  }
Line 394  sub insert_rankresponse { Line 386  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 399  sub insert_matchresponse {
       </itemgroup>        </itemgroup>
     </foilgroup>      </foilgroup>
     <hintgroup>      <hintgroup>
     <startouttext/>      <startouttext /><endouttext />
     <endouttext />  
     </hintgroup>      </hintgroup>
 </matchresponse>';  </matchresponse>';
 }  }
Line 427  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 463  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 486  sub textarea_sizes { Line 475  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 507  sub editfield { Line 496  sub editfield {
     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.'">'.   $Apache::lonxml::curdepth.'">'.
  &HTML::Entities::encode($data).'</textarea>'."\n";   &HTML::Entities::encode($data,'<>&"').'</textarea>'."\n";
 }  }
   
 sub modifiedfield {  sub modifiedfield {
Line 543  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 711  ENDSELECTORTYPE Line 703  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 716  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;
     if ($height) {      my %data=("imagechoice.$id.type"      =>'point',
  $formheight='&formheight='.$height.'_'.$Apache::edit::bgimgsrccurdepth;        "imagechoice.$id.formname"  =>$form,
     }        "imagechoice.$id.formx"     =>"$idx$element",
     my $formwidth='';        "imagechoice.$id.formy"     =>"$idy$element",
     if ($width) {        "imagechoice.$id.file"      =>$bgfile,
  $formwidth='&formwidth='.$width.'_'.$Apache::edit::bgimgsrccurdepth;        "imagechoice.$id.formcoord" =>$element);
     }  
     my $result = <<"ENDBUTTON";  
 <a href="/cgi-bin/imagechoice.pl?formname=$form&file=$bgfile&formx=$idx$element&formy=$idy$element$formheight$formwidth"  
 target="imagechoice">Click Coordinates</a>  
 ENDBUTTON  
     return $result;  
 }  
   
 # coordinate pair (x1,y1)-(x2,y2)  
 sub entercoordpair {  
     my ($id,$mode,$width,$height) = @_;  
     unless ($Apache::edit::bgimgsrc) { return ''; }  
     my $bgfile=&Apache::lonnet::escape($Apache::edit::bgimgsrc);  
     my $form    = 'lonhomework';  
     my $element;  
     if (! defined($mode) || $mode eq 'attribute') {  
         $element = &Apache::lonnet::escape("$id\_$Apache::lonxml::curdepth");  
     } elsif ($mode eq 'textnode') {  # for data between <tag> ... </tag>  
         $element = &Apache::lonnet::escape('homework_edit_'.  
                                            $Apache::lonxml::curdepth);  
     }  
     my $formheight='';  
     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="Click Coordinates";
 target="imagechoice">Click Coordinate Pair</a>      my $result='<a href="/adm/imagechoice?token='.$id.'" target="imagechoice">'.$text.'</a>';
 ENDBUTTON  
     return $result;      return $result;
 }  }
   
 # coordinate polygon (x1,y1)-(x2,y2)...  # coordinates (x1,y1)-(x2,y2)...
 sub entercoordpolygon {  # 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 ''; }
     &Apache::lonnet::logthis($Apache::edit::bgimgsrc);  
     my $bgfile=&Apache::lonnet::escape(&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$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 $id=$Apache::lonxml::curdepth;      my $id=$Apache::lonxml::curdepth;
     my %data=("imagechoice.$id.mode"      =>'polygon',      my %data=("imagechoice.$id.type"      =>$type,
       "imagechoice.$id.formname"  =>$form,        "imagechoice.$id.formname"  =>$form,
       "imagechoice.$id.file"      =>$bgfile,        "imagechoice.$id.file"      =>$bgfile,
       "imagechoice.$id.formcoord" =>$element);        "imagechoice.$id.formcoord" =>$element);
Line 796  sub entercoordpolygon { Line 765  sub entercoordpolygon {
     $Apache::edit::bgimgsrccurdepth;      $Apache::edit::bgimgsrccurdepth;
     }      }
     &Apache::lonnet::appenv(%data);      &Apache::lonnet::appenv(%data);
     my $result='<a href="/adm/imagechoice?token='.$id.'" target="imagechoice">Create Polygon Data</a>';      my $text="Enter Coordinates";
       if ($type eq 'polygon') { $text='Create Polygon Data'; }
       my $result='<a href="/adm/imagechoice?token='.$id.'" target="imagechoice">'.$text.'</a>';
     return $result;      return $result;
 }  }
   

Removed from v.1.76  
changed lines
  Added in v.1.81


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