[LON-CAPA-cvs] cvs: loncom /cgi imagechoice.pl /homework edit.pm imageresponse.pm randomlabel.pm
www
lon-capa-cvs@mail.lon-capa.org
Tue, 06 May 2003 11:54:09 -0000
This is a MIME encoded message
--www1052222049
Content-Type: text/plain
www Tue May 6 07:54:09 2003 EDT
Modified files:
/loncom/cgi imagechoice.pl
/loncom/homework edit.pm imageresponse.pm randomlabel.pm
Log:
Fix Browse and Search to target id_curdepth instead of curdepth.id (???)
in attribute mode.
Enable clickable coordinate input.
--www1052222049
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20030506075409.txt"
Index: loncom/cgi/imagechoice.pl
diff -u loncom/cgi/imagechoice.pl:1.2 loncom/cgi/imagechoice.pl:1.3
--- loncom/cgi/imagechoice.pl:1.2 Sat Apr 19 19:52:37 2003
+++ loncom/cgi/imagechoice.pl Tue May 6 07:54:08 2003
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
-# $Id: imagechoice.pl,v 1.2 2003/04/19 23:52:37 www Exp $
+# $Id: imagechoice.pl,v 1.3 2003/05/06 11:54:08 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -46,19 +46,19 @@
if ((defined($data{'x'})) && (defined($data{'y'}))) {
my $output='';
if ($data{'formwidth'}) {
- $output.='parent.'.$data{'formname'}.'.'.$data{'formwidth'}.
+ $output.='opener.document.forms.'.$data{'formname'}.'.'.$data{'formwidth'}.
'.value=document.pickimg.width;';
}
if ($data{'formheight'}) {
- $output.='parent.'.$data{'formname'}.'.'.$data{'formheight'}.
+ $output.='opener.document.forms.'.$data{'formname'}.'.'.$data{'formheight'}.
'.value=document.pickimg.height;';
}
if ($data{'formx'}) {
- $output.='parent.'.$data{'formname'}.'.'.$data{'formx'}.
+ $output.='opener.document.forms.'.$data{'formname'}.'.'.$data{'formx'}.
'.value='.$data{'x'}.';';
}
if ($data{'formy'}) {
- $output.='parent.'.$data{'formname'}.'.'.$data{'formy'}.
+ $output.='opener.document.forms.'.$data{'formname'}.'.'.$data{'formy'}.
'.value='.$data{'y'}.';';
}
print <<"ENDSUBM";
@@ -68,6 +68,7 @@
<script>
function submitthis() {
$output
+ self.close();
}
</script>
<body bgcolor="#FFFFFF" onLoad="submitthis()">
Index: loncom/homework/edit.pm
diff -u loncom/homework/edit.pm:1.48 loncom/homework/edit.pm:1.49
--- loncom/homework/edit.pm:1.48 Sun May 4 18:14:53 2003
+++ loncom/homework/edit.pm Tue May 6 07:54:08 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# edit mode helpers
#
-# $Id: edit.pm,v 1.48 2003/05/04 22:14:53 albertel Exp $
+# $Id: edit.pm,v 1.49 2003/05/06 11:54:08 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -40,6 +40,9 @@
# depth of nesting of edit
$Apache::edit::colordepth=0;
@Apache::edit::inserttag=();
+# image-type responses: active background image and curdepth at definition
+$Apache::edit::bgimgsrc='';
+$Apache::edit::bgimgsrccurdepth='';
sub initialize_edit {
$Apache::edit::colordepth=0;
@@ -565,6 +568,64 @@
return $result;
}
+#----------------------------------------------------- image coordinates
+# single image coordinates, x, y
+sub entercoords {
+ my ($idx,,$idy,$mode,$width,$height) = @_;
+ unless ($Apache::edit::bgimgsrc) { return ''; }
+ if ($idx) { $idx.='_'; }
+ if ($idy) { $idy.='_'; }
+ my $bgfile=&Apache::lonnet::escape($Apache::edit::bgimgsrc);
+ my $form = 'lonhomework';
+ my $element;
+ if (! defined($mode) || $mode eq 'attribute') {
+ $element = &Apache::lonnet::escape("$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) {
+ $formheight='&formheight='.$height.'_'.$Apache::edit::bgimgsrccurdepth;
+ }
+ my $formwidth='';
+ if ($width) {
+ $formwidth='&formwidth='.$width.'_'.$Apache::edit::bgimgsrccurdepth;
+ }
+ 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) {
+ $formheight='&formheight='.$height.'_'.$Apache::edit::bgimgsrccurdepth;
+ }
+ my $formwidth='';
+ if ($width) {
+ $formwidth='&formwidth='.$width.'_'.$Apache::edit::bgimgsrccurdepth;
+ }
+ my $result = <<"ENDBUTTON";
+<a href="/cgi-bin/imagechoice.pl?mode=pair&formname=$form&file=$bgfile$formheight$formwidth"
+target="imagechoice">Click Coordinate Pair</a>
+ENDBUTTON
+ return $result;
+}
#----------------------------------------------------- browse
sub browse {
# insert a link to call up the filesystem browser (lonindexer)
@@ -572,7 +633,7 @@
my $form = 'lonhomework';
my $element;
if (! defined($mode) || $mode eq 'attribute') {
- $element = &Apache::lonnet::escape("$Apache::lonxml::curdepth.$id");
+ $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);
@@ -586,9 +647,15 @@
#----------------------------------------------------- browse
sub search {
# insert a link to call up the filesystem browser (lonindexer)
- $_ = shift;
+ my ($id, $mode) = @_;
my $form = 'lonhomework';
- my $element = &Apache::lonnet::escape("$Apache::lonxml::curdepth.$_");
+ 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 $result = <<"ENDBUTTON";
<a href=\"javascript:opensearcher('$form','$element')\"\>Search</a>
ENDBUTTON
Index: loncom/homework/imageresponse.pm
diff -u loncom/homework/imageresponse.pm:1.26 loncom/homework/imageresponse.pm:1.27
--- loncom/homework/imageresponse.pm:1.26 Mon May 5 18:36:54 2003
+++ loncom/homework/imageresponse.pm Tue May 6 07:54:08 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# image click response style
#
-# $Id: imageresponse.pm,v 1.26 2003/05/05 22:36:54 albertel Exp $
+# $Id: imageresponse.pm,v 1.27 2003/05/06 11:54:08 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -281,6 +281,9 @@
&Apache::lonxml::startredirection;
} elsif ($target eq 'edit') {
my $bgimg=&Apache::lonxml::get_all_text('/image',$parser);
+ $Apache::edit::bgimgsrc=$bgimg;
+ $Apache::edit::bgimgsrcdepth=$Apache::lonxml::curdepth;
+
$result=&Apache::edit::tag_start($target,$token,'Clickable Image').
&Apache::edit::editline($token->[1],$bgimg,'Image Source File',40);
$result.=&Apache::edit::browse(undef,'textnode').' ';
@@ -356,8 +359,8 @@
$path = $1.'/';
}
my $newsrc = $src;
- $newsrc =~ s/(\.gif|\.jpg)$/\.eps/i;
- $file=~s/(\.gif|\.jpg)$/\.eps/i;
+ $newsrc =~ s/(\.gif|\.jpg|\.jpeg)$/\.eps/i;
+ $file=~s/(\.gif|\.jpg|\.jpeg)$/\.eps/i;
#do we have any specified size of the picture?
my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval);
my $TeXheight = &Apache::lonxml::get_param('TeXheight',$parstack,$safeeval);
@@ -394,6 +397,7 @@
my $coords=&Apache::lonxml::get_all_text('/rectangle',$parser);
$result=&Apache::edit::tag_start($target,$token,'Rectangle').
&Apache::edit::editline($token->[1],$coords,'Coordinate Pairs',40).
+ &Apache::edit::entercoordpair(undef,'textnode').
&Apache::edit::end_row();
} elsif ($target eq "modified") {
my $coords=&Apache::lonxml::get_all_text('/rectangle',$parser);
Index: loncom/homework/randomlabel.pm
diff -u loncom/homework/randomlabel.pm:1.43 loncom/homework/randomlabel.pm:1.44
--- loncom/homework/randomlabel.pm:1.43 Fri Feb 7 17:03:21 2003
+++ loncom/homework/randomlabel.pm Tue May 6 07:54:08 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# random labelling tool
#
-# $Id: randomlabel.pm,v 1.43 2003/02/07 22:03:21 albertel Exp $
+# $Id: randomlabel.pm,v 1.44 2003/05/06 11:54:08 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -139,6 +139,9 @@
}
} elsif ($target eq 'edit') {
$result.=&Apache::edit::tag_start($target,$token);
+ $Apache::edit::bgimgsrc=
+ &Apache::lonxml::get_param('bgimg',$parstack,$safeeval);
+ $Apache::edit::bgimgsrccurdepth=$Apache::lonxml::curdepth;
$result.=&Apache::edit::text_arg('Image:','bgimg',$token,75).' ';
$result.=&Apache::edit::browse('bgimg').' ';
$result.=&Apache::edit::search('bgimg').'<br />'.
@@ -345,6 +348,7 @@
$result.=&Apache::edit::tag_start($target,$token);
$result.=&Apache::edit::text_arg('X:','x',$token,4).
&Apache::edit::text_arg('Y:','y',$token,4).
+ &Apache::edit::entercoords('x','y','attribute','width','height').' '.
&Apache::edit::text_arg('Value:','value',$token).
&Apache::edit::end_row();
$result.=&Apache::edit::end_table;
--www1052222049--