version 1.65, 2003/09/17 15:44:19
|
version 1.80, 2004/02/17 22:02:43
|
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 67 sub tag_start {
|
Line 68 sub tag_start {
|
#<td>". |
#<td>". |
# &movebuttons($target,$token). |
# &movebuttons($target,$token). |
# "</tr><tr><td colspan=\"3\">\n"; |
# "</tr><tr><td colspan=\"3\">\n"; |
my @help;# = Apache::lonxml::helpinfo($token); |
my @help = Apache::lonxml::helpinfo($token); |
if ($help[0]) { |
if ($help[0]) { |
$result .= '<td align="right" valign="top">' . |
$result .= '<td align="right" valign="top">' . |
Apache::loncommon::help_open_topic(@help) . |
Apache::loncommon::help_open_topic(@help) . |
Line 273 sub handle_insertafter {
|
Line 274 sub handle_insertafter {
|
return $result; |
return $result; |
} |
} |
|
|
|
sub insert_img { |
|
return ' |
|
<img />'; |
|
} |
|
|
sub insert_responseparam { |
sub insert_responseparam { |
return ' |
return ' |
<responseparam />'; |
<responseparam />'; |
Line 283 sub insert_formularesponse {
|
Line 289 sub insert_formularesponse {
|
<formularesponse answer="" samples=""> |
<formularesponse answer="" samples=""> |
<textline /> |
<textline /> |
<hintgroup> |
<hintgroup> |
|
<startouttext /><endouttext /> |
</hintgroup> |
</hintgroup> |
</formularesponse>'; |
</formularesponse>'; |
} |
} |
Line 292 sub insert_numericalresponse {
|
Line 299 sub insert_numericalresponse {
|
<numericalresponse answer=""> |
<numericalresponse answer=""> |
<textline /> |
<textline /> |
<hintgroup> |
<hintgroup> |
|
<startouttext /><endouttext /> |
</hintgroup> |
</hintgroup> |
</numericalresponse>'; |
</numericalresponse>'; |
} |
} |
Line 301 sub insert_stringresponse {
|
Line 309 sub insert_stringresponse {
|
<stringresponse answer="" type=""> |
<stringresponse answer="" type=""> |
<textline /> |
<textline /> |
<hintgroup> |
<hintgroup> |
|
<startouttext /><endouttext /> |
</hintgroup> |
</hintgroup> |
</stringresponse>'; |
</stringresponse>'; |
} |
} |
Line 318 sub insert_imageresponse {
|
Line 327 sub insert_imageresponse {
|
<foilgroup> |
<foilgroup> |
</foilgroup> |
</foilgroup> |
<hintgroup> |
<hintgroup> |
|
<startouttext /><endouttext /> |
</hintgroup> |
</hintgroup> |
</imageresponse>'; |
</imageresponse>'; |
} |
} |
Line 328 sub insert_optionresponse {
|
Line 338 sub insert_optionresponse {
|
<foilgroup options=""> |
<foilgroup options=""> |
</foilgroup> |
</foilgroup> |
<hintgroup> |
<hintgroup> |
|
<startouttext /><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 /><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 /><endouttext /> |
</hintgroup> |
</hintgroup> |
</rankresponse>'; |
</rankresponse>'; |
} |
} |
Line 360 sub insert_matchresponse {
|
Line 399 sub insert_matchresponse {
|
</itemgroup> |
</itemgroup> |
</foilgroup> |
</foilgroup> |
<hintgroup> |
<hintgroup> |
|
<startouttext /><endouttext /> |
</hintgroup> |
</hintgroup> |
</matchresponse>'; |
</matchresponse>'; |
} |
} |
Line 374 sub insert_hintpart {
|
Line 414 sub insert_hintpart {
|
</hintpart>'; |
</hintpart>'; |
} |
} |
|
|
|
sub insert_hintgroup { |
|
return ' |
|
<hintgroup> |
|
<startouttext /><endouttext /> |
|
</hintgroup>'; |
|
} |
|
|
sub insert_numericalhint { |
sub insert_numericalhint { |
return ' |
return ' |
<numericalhint> |
<numericalhint> |
Line 405 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 453 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 461 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 482 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 529 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 558 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.' <input name="'.&html_element_name($name). |
$result=&mt($description).' <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 616 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 629 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 |
<select name="$selectelement" |
<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 649 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 662 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; |
|
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) |
my ($id, $mode) = @_; |
my ($id, $mode, $titleid) = @_; |
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("$id\_$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 $titleelement; |
|
if ($titleid) { |
|
$titleelement=",'','','".&Apache::lonnet::escape("$titleid\_$Apache::lonxml::curdepth")."'"; |
} |
} |
my $result = <<"ENDBUTTON"; |
my $result = <<"ENDBUTTON"; |
<a href=\"javascript:openbrowser('$form','$element')\"\>Select</a> |
<a href=\"javascript:openbrowser('$form','$element'$titleelement)\"\>Select</a> |
ENDBUTTON |
ENDBUTTON |
return $result; |
return $result; |
} |
} |
Line 725 ENDBUTTON
|
Line 800 ENDBUTTON
|
#----------------------------------------------------- browse |
#----------------------------------------------------- browse |
sub search { |
sub search { |
# insert a link to call up the filesystem browser (lonindexer) |
# insert a link to call up the filesystem browser (lonindexer) |
my ($id, $mode) = @_; |
my ($id, $mode, $titleid) = @_; |
my $form = 'lonhomework'; |
my $form = 'lonhomework'; |
my $element; |
my $element; |
if (! defined($mode) || $mode eq 'attribute') { |
if (! defined($mode) || $mode eq 'attribute') { |
Line 734 sub search {
|
Line 809 sub search {
|
$element = &Apache::lonnet::escape('homework_edit_'. |
$element = &Apache::lonnet::escape('homework_edit_'. |
$Apache::lonxml::curdepth); |
$Apache::lonxml::curdepth); |
} |
} |
|
my $titleelement; |
|
if ($titleid) { |
|
$titleelement=",'".&Apache::lonnet::escape("$titleid\_$Apache::lonxml::curdepth")."'"; |
|
} |
my $result = <<"ENDBUTTON"; |
my $result = <<"ENDBUTTON"; |
<a href=\"javascript:opensearcher('$form','$element')\"\>Search</a> |
<a href=\"javascript:opensearcher('$form','$element'$titleelement)\"\>Search</a> |
ENDBUTTON |
ENDBUTTON |
return $result; |
return $result; |
} |
} |