--- loncom/homework/edit.pm 2003/10/15 21:19:46 1.57.2.3
+++ loncom/homework/edit.pm 2007/10/03 00:24:48 1.112
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# edit mode helpers
#
-# $Id: edit.pm,v 1.57.2.3 2003/10/15 21:19:46 albertel Exp $
+# $Id: edit.pm,v 1.112 2007/10/03 00:24:48 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,14 +25,16 @@
#
# http://www.lon-capa.org/
#
-# 3/20 Guy
-# 01/10/02 Matthew
-# 03/06/02 Matthew
+
package Apache::edit;
use strict;
-use Apache::lonnet();
+use Apache::lonnet;
use HTML::Entities();
+use Apache::lonlocal;
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
+
# Global Vars
# default list of colors to use in editing
@@ -45,313 +47,443 @@ $Apache::edit::bgimgsrc='';
$Apache::edit::bgimgsrccurdepth='';
sub initialize_edit {
- $Apache::edit::colordepth=0;
- @Apache::edit::inserttag=();
+ $Apache::edit::colordepth=0;
+ @Apache::edit::inserttag=();
}
sub tag_start {
- my ($target,$token,$description) = @_;
- my $result='';
- if ($target eq "edit") {
- my $tag=$token->[1];
- if (!$description) {
- $description=&Apache::lonxml::description($token);
- if (!$description) { $description="<$tag>"; }
- }
- $result.= &start_table($token)."
$description |
-Delete".
- &deletelist($target,$token)
- ." |
-".
- &insertlist($target,$token).&end_row().&start_spanning_row();
+ my ($target,$token,$description) = @_;
+ my $result='';
+ if ($target eq "edit") {
+ my $tag=$token->[1];
+ if (!$description) {
+ $description=&Apache::lonxml::description($token);
+ if (!$description) { $description="<$tag>"; }
+ }
+ $result.= &start_table($token)." |
$description |
+ Delete".
+ &deletelist($target,$token)
+ ." |
+ ".
+ &insertlist($target,$token);
# | ".
# &movebuttons($target,$token).
# " |
\n";
- }
- return $result;
+ my @help = Apache::lonxml::helpinfo($token);
+ if ($help[0]) {
+ $result .= ' | ' .
+ Apache::loncommon::help_open_topic(@help);
+ } else { $result .= " | "; }
+ $result .= &end_row().&start_spanning_row();
+ }
+ return $result;
}
sub tag_end {
- my ($target,$token,$description) = @_;
- my $result='';
- if ($target eq 'edit') {
- $result.=" |
".&end_table()."\n";
- }
- return $result;
+ my ($target,$token,$description) = @_;
+ my $result='';
+ if ($target eq 'edit') {
+ $result.="".&end_table()."\n";
+ }
+ return $result;
}
sub start_table {
- my ($token)=@_;
- my $tag = $token->[1];
- my $tagnum;
- foreach my $namespace (reverse @Apache::lonxml::namespace) {
- my $testtag=$namespace.'::'.$tag;
- $tagnum=$Apache::lonxml::insertlist{"$testtag.num"};
- if (defined($tagnum)) { last; }
- }
- if (!defined ($tagnum)) { $tagnum=$Apache::lonxml::insertlist{"$tag.num"}; }
- my $color = $Apache::lonxml::insertlist{"$tagnum.color"};
- if (!defined($color)) {
- $color = $Apache::edit::colorlist[$Apache::edit::colordepth];
- }
- $Apache::edit::colordepth++;
- push(@Apache::edit::inserttag,$token->[1]);
- my $result='';
- $result.='
';
- return $result;
+ my ($token)=@_;
+ my $tag = &Apache::lonxml::get_tag($token);
+
+ my $color = $Apache::lonxml::insertlist{"$tag.color"};
+ &Apache::lonxml::debug(" $tag -- $color");
+ if (!defined($color)) {
+ $color = $Apache::edit::colorlist[$Apache::edit::colordepth];
+ }
+ $Apache::edit::colordepth++;
+ push(@Apache::edit::inserttag,$token->[1]);
+ my $result='';
+ $result.='
';
+ return $result;
}
sub end_table {
- $Apache::edit::colordepth--;
- my $result='
';
- $result.="";
-
- my ($tagname,$closingtag);
- if (defined($Apache::edit::inserttag[-2])) {
- $tagname=$Apache::edit::inserttag[-2];
- } else {$tagname='problem';}
- if (defined($Apache::edit::inserttag[-1])) {
- $closingtag=$Apache::edit::inserttag[-1];
- }
- $result.=&innerinsertlist('edit',$tagname,$closingtag).
- " |
";
- pop(@Apache::edit::inserttag);
- return $result;
+ $Apache::edit::colordepth--;
+ my $result='
';
+ $result.='';
+
+ my ($tagname,$closingtag);
+ if (defined($Apache::edit::inserttag[-2])) {
+ $tagname=$Apache::edit::inserttag[-2];
+ } else {
+ if ($Apache::lonhomework::parsing_a_task) {
+ $tagname='Task';
+ } else {
+ $tagname='problem';
+ }
+ }
+ if (defined($Apache::edit::inserttag[-1])) {
+ $closingtag=$Apache::edit::inserttag[-1];
+ }
+ $result.=&innerinsertlist('edit',$tagname,$closingtag).
+ " |
";
+ my $last = pop(@Apache::edit::inserttag);
+ return $result;
}
-sub start_spanning_row { return '';}
+sub start_spanning_row { return ' |
';}
sub start_row { return ' |
'; }
sub end_row { return ' |
'; }
sub movebuttons {
- my ($target,$token) = @_;
- my $result='';
- $result.='';
- return $result;
+ my ($target,$token) = @_;
+ my $result='';
+ $result.='';
+ return $result;
}
sub deletelist {
- my ($target,$token) = @_;
- my $result = "