version 1.63, 2003/09/08 21:22:15
|
version 1.77, 2004/01/14 22:59:18
|
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 300 sub insert_numericalresponse {
|
<numericalresponse answer=""> |
<numericalresponse answer=""> |
<textline /> |
<textline /> |
<hintgroup> |
<hintgroup> |
|
<startouttext/> |
|
<endouttext /> |
</hintgroup> |
</hintgroup> |
</numericalresponse>'; |
</numericalresponse>'; |
} |
} |
Line 301 sub insert_stringresponse {
|
Line 311 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 330 sub insert_imageresponse {
|
<foilgroup> |
<foilgroup> |
</foilgroup> |
</foilgroup> |
<hintgroup> |
<hintgroup> |
|
<startouttext/> |
|
<endouttext /> |
</hintgroup> |
</hintgroup> |
</imageresponse>'; |
</imageresponse>'; |
} |
} |
Line 328 sub insert_optionresponse {
|
Line 342 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 408 sub insert_matchresponse {
|
</itemgroup> |
</itemgroup> |
</foilgroup> |
</foilgroup> |
<hintgroup> |
<hintgroup> |
|
<startouttext/> |
|
<endouttext /> |
</hintgroup> |
</hintgroup> |
</matchresponse>'; |
</matchresponse>'; |
} |
} |
Line 374 sub insert_hintpart {
|
Line 424 sub insert_hintpart {
|
</hintpart>'; |
</hintpart>'; |
} |
} |
|
|
|
sub insert_hintgroup { |
|
return ' |
|
<hintgroup> |
|
<startouttext/> |
|
<endouttext /> |
|
</hintgroup>'; |
|
} |
|
|
sub insert_numericalhint { |
sub insert_numericalhint { |
return ' |
return ' |
<numericalhint> |
<numericalhint> |
Line 453 sub editfield {
|
Line 511 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 519 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 529 sub checked_arg {
|
Line 590 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 619 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 569 sub select_arg {
|
Line 630 sub select_arg {
|
my $optionlist=""; |
my $optionlist=""; |
my $selected=$token->[2]{$name}; |
my $selected=$token->[2]{$name}; |
foreach my $option (@$list) { |
foreach my $option (@$list) { |
my $value; |
my ($text,$value); |
if ( ref($option) eq 'ARRAY') { |
if ( ref($option) eq 'ARRAY') { |
$value='value="'.$$option[0].'"'; |
$value='value="'.$$option[0].'"'; |
$option=$$option[1]; |
$text=$$option[1]; |
|
$option=$$option[0]; |
} else { |
} else { |
|
$text=$option; |
$value='value="'.$option.'"'; |
$value='value="'.$option.'"'; |
} |
} |
if ( $selected eq $option ) { |
if ( $selected eq $option ) { |
$optionlist.="<option $value selected=\"on\">$option</option>\n"; |
$optionlist.="<option $value selected=\"on\">$text</option>\n"; |
} else { |
} else { |
$optionlist.="<option $value >$option</option>\n"; |
$optionlist.="<option $value >$text</option>\n"; |
} |
} |
} |
} |
$result.='<nobr>'.$description.' <select name="'. |
$result.='<nobr>'.$description.' <select name="'. |
Line 596 sub select_or_text_arg {
|
Line 659 sub select_or_text_arg {
|
my $found=0; |
my $found=0; |
my $selected=$token->[2]{$name}; |
my $selected=$token->[2]{$name}; |
foreach my $option (@$list) { |
foreach my $option (@$list) { |
my $value; |
my ($text,$value); |
if ( ref($option) eq 'ARRAY') { |
if ( ref($option) eq 'ARRAY') { |
$value='value="'.$$option[0].'"'; |
$value='value="'.$$option[0].'"'; |
$option=$$option[1]; |
$text=$$option[1]; |
|
$option=$$option[0]; |
} else { |
} else { |
|
$text=$option; |
$value='value="'.$option.'"'; |
$value='value="'.$option.'"'; |
} |
} |
if ( $selected eq $option ) { |
if ( $selected eq $option ) { |
$optionlist.="<option $value selected=\"on\">$option</option>\n"; |
$optionlist.="<option $value selected=\"on\">$text</option>\n"; |
$found=1; |
$found=1; |
} else { |
} else { |
$optionlist.="<option $value>$option</option>\n"; |
$optionlist.="<option $value>$text</option>\n"; |
} |
} |
} |
} |
$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 625 sub select_or_text_arg {
|
Line 690 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 673 ENDBUTTON
|
Line 739 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) |
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 721 ENDBUTTON
|
Line 803 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 730 sub search {
|
Line 812 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; |
} |
} |