Annotation of loncom/homework/structuretags.pm, revision 1.56

1.34      albertel    1: # The LearningOnline Network with CAPA 
                      2: # definition of tags that give a structure to a document
1.33      albertel    3: # 2/19 Guy
1.44      ng          4: # 6/26/2001 fixed extra web display at end of <web></web> tags
1.54      www         5: # 8/17 Gerd Kortemeyer
                      6: 
1.1       albertel    7: package Apache::structuretags; 
                      8: 
                      9: use strict;
                     10: use Apache::lonnet;
                     11: 
                     12: sub BEGIN {
1.48      albertel   13:   &Apache::lonxml::register('Apache::structuretags',('block','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','startouttext','endouttext'));
1.37      albertel   14: #  &Apache::lonxml::register_insert('problem','',('part','postanswerdate','preduedate'))
1.10      albertel   15: }
                     16: 
                     17: sub start_web {
1.40      albertel   18:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.10      albertel   19:   my $bodytext=&Apache::lonxml::get_all_text("/web",$$parser[$#$parser]);
1.19      albertel   20:   if ($target eq 'web') {
                     21:     return $bodytext;
                     22:   } 
                     23:   return '';
1.10      albertel   24: }
                     25: 
                     26: sub end_web {
1.44      ng         27:     return '';
1.10      albertel   28: }
                     29: 
                     30: sub start_tex {
1.40      albertel   31:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.10      albertel   32:   my $bodytext=&Apache::lonxml::get_all_text("/tex",$$parser[$#$parser]);
1.19      albertel   33:   if ($target eq 'tex') {
                     34:     return $bodytext
                     35:   }
1.10      albertel   36:   return '';
                     37: }
                     38: 
                     39: sub end_tex {
1.44      ng         40:     return '';
1.9       albertel   41: }
                     42: 
1.48      albertel   43: sub page_start {
                     44:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                     45:   my $result=&Apache::londefdef::start_html($target,$token,$tagstack,$parstack,$parser,$safeeval);
                     46:   my $head_tag_start='<head>'.&Apache::lonxml::registerurl();
                     47:   my $body_tag_start='<body onLoad="'.&Apache::lonxml::loadevents().'" '.
1.50      albertel   48: 	  'onUnload="'.&Apache::lonxml::unloadevents().'" ';
                     49:   my $background=&Apache::lonxml::get_param('background',$parstack,$safeeval);
                     50:   if ($background) {
                     51:     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
                     52:                                         $background;
                     53:     $body_tag_start.='background="'.$background.'" ';
                     54:   } else {
                     55:     my $bgcolor=&Apache::lonxml::get_param('bgcolor',$parstack,$safeeval);
                     56:     if ($bgcolor) {
                     57:       $body_tag_start.='bgcolor="'.$bgcolor.'" ';
                     58:     } else {
                     59:       $body_tag_start.='bgcolor="#ffffff"';
                     60:     }
                     61:   }
                     62:   $body_tag_start.='>';
1.48      albertel   63:   return ($result,$head_tag_start,$body_tag_start);
                     64: }
                     65: 
1.9       albertel   66: sub start_problem {
1.40      albertel   67:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.19      albertel   68: 
                     69: #intialize globals
                     70:   $Apache::inputtags::part='0';
                     71:   @Apache::inputtags::responselist = ();
1.51      albertel   72:   @Apache::inputtags::previous=();
1.42      albertel   73:   $Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type');
                     74:   &Apache::lonxml::debug("Found this to be of type :$Apache::lonhomework::type:");
                     75:   if ($Apache::lonhomework::type eq '') {
1.53      albertel   76:     my $uri=$ENV{'request.uri'};
                     77:     if ($uri=~/\.(\w+)$/) {
                     78:       $Apache::lonhomework::type=$1;
                     79:       &Apache::lonxml::debug("Using type of $1");
                     80:     } else {
                     81:       $Apache::lonhomework::type='problem';
                     82:       &Apache::lonxml::debug("Using default type, problem, :$uri:");
                     83:     }
1.42      albertel   84:   }
1.19      albertel   85: #adeed vars to the scripting enviroment
                     86:   my $expression='$external::part='.$Apache::inputtags::part.';';
                     87:   &Apache::run::run($expression,$safeeval);
1.22      albertel   88:   my $status;
1.55      www        89:   my $accessmsg;
1.36      albertel   90: 
1.41      albertel   91:   #should get back a <html> or the neccesary stuff to start XML/MathML
1.48      albertel   92:   my ($result,$head_tag_start,$body_tag_start)=
                     93:     &page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
1.36      albertel   94: 
1.34      albertel   95:   if ($target eq 'web' || $target eq 'grade') {
1.55      www        96:     ($status,$accessmsg) = &Apache::lonhomework::check_access('0');
1.22      albertel   97:     push (@Apache::inputtags::status,$status);
1.24      albertel   98:     my $expression='$external::datestatus="'.$status.'";';
                     99:     $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.0.solved"}.'";';
                    100:     &Apache::run::run($expression,$safeeval);
1.54      www       101:     if (( $status eq 'CLOSED' ) ||
                    102:         ( $status eq 'UNCHECKEDOUT') ||
                    103:         ( $status eq 'BANNED')) {
1.21      albertel  104:       my $bodytext=&Apache::lonxml::get_all_text("/problem",$$parser[$#$parser]);
                    105:       if ( $target eq "web" ) {
1.41      albertel  106: 	$result.= $head_tag_start.'</head>';
1.54      www       107:         my $msg=$body_tag_start.
                    108: 	    '<h1>Not open to be viewed</h1>';
                    109:         if ($status eq 'CLOSED') {
1.55      www       110: 	    $msg.='The problem '.$accessmsg;
1.54      www       111: 	} elsif ($status eq 'UNCHECKEDOUT') {
1.56    ! www       112:             $msg.=(<<ENDCHECKOUT);
        !           113: <h2>The resource needs to be checked out</h2>
        !           114: As a resource gets checked out, a unique timestamped ID is given to it, and a
        !           115: permanent record is left in the system.<p />
        !           116: <font color=red>
        !           117: Checking out resources is subject to course policies, and may exclude future
        !           118: credit even if done erroneously.<p />
        !           119: </font>  
        !           120: <form method=post>
        !           121: <input type=submit name="does_checkout" 
        !           122: value="Check out Problem for Viewing" />
        !           123: </form>
        !           124: ENDCHECKOUT
1.54      www       125:         }
                    126: 	return $result.$msg.'<br />';
1.21      albertel  127:       }
1.41      albertel  128:     }
1.21      albertel  129:   }
1.19      albertel  130:   if ($target eq 'web') {
1.39      albertel  131:     my $name= &Apache::lonxml::get_param('name',$parstack,$safeeval);
1.30      albertel  132:     if ($name eq '') { 
                    133:       $name=&Apache::lonnet::EXT('resource.title');
                    134:       if ($name eq 'con_lost') { $name = ''; }
                    135:     }
                    136:     $Apache::lonhomework::name=$name;
1.22      albertel  137:     if ($status eq 'CAN_ANSWER') {
                    138:       # create a page header and exit
1.41      albertel  139:       $result.="$head_tag_start<title>$name</title></head>\n
                    140:               $body_tag_start\n
1.36      albertel  141:               <form name=\"lonhomework\" method=\"POST\" action=\"".$ENV{'request.uri'}."\">".
                    142: 		'<input type="hidden" name="submitted" value="yes" />';
                    143:       if ($ENV{'request.state'} eq "construct") {
                    144: 	$result.='<input type="hidden" name="problemmode" value="View" />
                    145:                  <input type="submit" name="problemmode" value="Edit" /><hr />';
                    146:       }
                    147:       return $result;
1.29      albertel  148:     } elsif ($status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER' || $status eq 'CLOSED') {
1.41      albertel  149:       return $result.$head_tag_start."<title>$name</title></head>\n$body_tag_start\n";
1.22      albertel  150:     }
                    151:   }
1.34      albertel  152:   if ($target eq 'edit') {
1.41      albertel  153:     $result.=$head_tag_start."</head>".$body_tag_start.
                    154:       '<form name="lonhomework" method="POST" action="'.$ENV{'request.uri'}.'">
                    155:        <input type="hidden" name="submitted" value="edit" />
                    156:        <input type="hidden" name="problemmode" value="Edit" />
                    157:        <input type="submit" name="problemmode" value="View" />
                    158:        <input type="submit" name="Undo" value="undo" /> <hr />
1.49      albertel  159:        <input type="submit" name="submit" value="Submit Changes" /><br />
1.41      albertel  160:       ';
1.39      albertel  161:     my $temp=&Apache::edit::insertlist($target,$token);
1.36      albertel  162:     $result.=$temp;
                    163:     return $result;
1.34      albertel  164:   }
1.37      albertel  165:   if ($target eq 'modified') {
                    166:     $result=$token->[4];
                    167:     $result.=&Apache::edit::handle_insert();
                    168:     return $result;
                    169:   }
1.19      albertel  170:   return '';
1.9       albertel  171: }
                    172: 
                    173: sub end_problem {
1.40      albertel  174:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.16      albertel  175:   my $result='';
1.24      albertel  176:   my $status=$Apache::inputtags::status['-1'];
1.40      albertel  177:   if ($target eq 'grade' || $target eq 'web' ) {
1.28      albertel  178:     if ( $target eq 'grade' && $Apache::inputtags::part eq '0' &&
                    179:        $status eq 'CAN_ANSWER') {
1.19      albertel  180:       # if part is zero, no <part>s existed, so we need to the grading
                    181:       &Apache::inputtags::grade;
                    182:     } elsif ($Apache::inputtags::part eq '0') {
                    183:       # if part is zero, no <part>s existed, so we need show the current 
                    184:       # grading status
1.20      albertel  185:       $result.= &Apache::inputtags::gradestatus($Apache::inputtags::part);
1.41      albertel  186:     }
1.22      albertel  187:     if ($target eq 'web') { 
                    188:       if ($status eq 'CAN_ANSWER') {
                    189: 	$result.="</form></body>\n"; 
1.28      albertel  190:       } elsif ($status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER') {
1.41      albertel  191: 	$result.="</body>\n";
                    192:       }
1.50      albertel  193:       $result.=&Apache::lonxml::xmlend();
1.22      albertel  194:     }
1.41      albertel  195:   }
1.34      albertel  196:   if ($target eq 'meta') {
1.18      albertel  197:     if ($Apache::inputtags::part eq '0') {
1.16      albertel  198:       $result=&Apache::response::mandatory_part_meta;
                    199:     }
                    200:   }
1.34      albertel  201:   if ($target eq 'edit') {
                    202:     &Apache::lonxml::debug("in end_problem with $target, edit");
1.48      albertel  203:     $result='<br /><input type="submit" name="submit" value="Submit Changes" />';
                    204:   }
                    205:   return $result;
                    206: }
                    207: 
                    208: sub start_library {
                    209:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                    210:   my ($result,$head_tag_start,$body_tag_start)=
                    211:     &page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
                    212:   if ($target eq 'edit') {
                    213:     $result.=$head_tag_start."</head>".$body_tag_start.
                    214:       '<form name="lonhomework" method="POST" action="'.$ENV{'request.uri'}.'">
                    215:        <input type="hidden" name="submitted" value="edit" />
                    216:        <input type="hidden" name="problemmode" value="Edit" />
                    217:        <input type="submit" name="problemmode" value="View" />
                    218:        <input type="submit" name="Undo" value="undo" /> <hr />
                    219:       ';
                    220:     my $temp=&Apache::edit::insertlist($target,$token);
                    221:     $result.=$temp;
                    222:     return $result;
                    223:   }
                    224:   if ($target eq 'modified') {
                    225:     $result=$token->[4];
                    226:     $result.=&Apache::edit::handle_insert();
                    227:     return $result;
                    228:   }
                    229:   return '';
                    230: }
                    231: 
                    232: sub end_library {
                    233:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                    234:   my $result='';
                    235:   if ($target eq 'edit') {
1.34      albertel  236:     $result='<br /><input type="submit" name="submit" value="Submit Changes" />';
                    237:   }
1.16      albertel  238:   return $result;
1.1       albertel  239: }
                    240: 
                    241: sub start_block {
1.40      albertel  242:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.1       albertel  243: 
1.38      albertel  244:   if ($target eq 'web' || $target eq 'grade') {
                    245:     my $code = @$parstack[$#$parstack];
                    246:     $code =~ s/\"//g;
                    247:     $code .=';return $condition;';
                    248:     #  print "<br />$code<br />";
                    249:     my $result = &Apache::run::run($code,$safeeval);
                    250:     &Apache::lonxml::debug("block :$code: returned :$result:");
                    251:     if ( ! $result ) { 
                    252:       my $skip=&Apache::lonxml::get_all_text("/block",$$parser[$#$parser]);
                    253:       &Apache::lonxml::debug("skipping ahead :$skip: $$parser[$#$parser]");
                    254:     }
1.1       albertel  255:   }
                    256:   return "";
                    257: }
                    258: 
                    259: sub end_block {
1.38      albertel  260:   return '';
1.4       tsai      261: }
                    262: 
                    263: sub start_while {
1.40      albertel  264:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.4       tsai      265: 
                    266:   my $code = @$parstack[$#$parstack];
                    267:   $code =~ s/\"//g;
                    268:   $code .=';return $condition;';
                    269: 
1.5       tsai      270:   push( @Apache::structuretags::whileconds, $code); 
1.4       tsai      271:   my $result = &Apache::run::run($code,$safeeval);
                    272:   my $bodytext=$$parser[$#$parser]->get_text("/while");
1.5       tsai      273:   push( @Apache::structuretags::whilebody, $bodytext);
                    274:   if ( $result ) { 
1.8       albertel  275:     &Apache::lonxml::newparser($parser,\$bodytext);
1.4       tsai      276:   }
                    277:   return "";
                    278: }
                    279: 
                    280: sub end_while {
1.40      albertel  281:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.5       tsai      282:   my $code = pop @Apache::structuretags::whileconds;
                    283:   my $bodytext = pop @Apache::structuretags::whilebody;
                    284:   my $result = &Apache::run::run($code,$safeeval);
                    285:   if ( $result ) { 
1.8       albertel  286:     &Apache::lonxml::newparser($parser,\$bodytext);
1.5       tsai      287:   } 
                    288:   return "";
1.1       albertel  289: }
1.6       tsai      290: 
                    291: # <randomlist> 
                    292: #  <tag1>..</tag1>
                    293: #  <tag2>..</tag2>
                    294: #  <tag3>..</tag3>
                    295: #  ... 
                    296: # </randomlist>
                    297: sub start_randomlist {
1.40      albertel  298:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.9       albertel  299:   my $body= &Apache::lonxml::get_all_text("/randomlist",$$parser[$#$parser]);
1.6       tsai      300:   my $b_parser= HTML::TokeParser->new(\$body);
                    301:   my $b_tok;
                    302:   my @randomlist;
                    303:   my $list_item;
                    304: 
                    305:   while($b_tok = $b_parser->get_token() ) {
                    306:     if($b_tok->[0] eq 'S') { # start tag
                    307:     # get content of the tag until matching end tag
                    308:     # get all text upto the matching tag
                    309:     # and push the content into @randomlist
1.9       albertel  310:       $list_item = &Apache::lonxml::get_all_text('/'.$b_tok->[1],$b_parser);
1.7       tsai      311:       $list_item = "$b_tok->[4]"."$list_item"."</$b_tok->[1]>";
1.6       tsai      312:       push(@randomlist,$list_item);
1.32      albertel  313:    #  print "<br /><b>START-TAG $b_tok->[1], $b_tok->[4], $list_item</b>";
1.6       tsai      314:     }
                    315:     if($b_tok->[0] eq 'T') { # text
                    316:     # what to do with text in between tags?
1.32      albertel  317:       #  print "<b>TEXT $b_tok->[1]</b><br />";
1.6       tsai      318:     }
                    319:     # if($b_tok->[0] eq 'E') { # end tag, should not happen
1.32      albertel  320:       #  print "<b>END-TAG $b_tok->[1]</b><br />";
1.6       tsai      321:     # }
                    322:   }
1.7       tsai      323:   my @idx_arr = (0 .. $#randomlist);
                    324:   &Apache::structuretags::shuffle(\@idx_arr);
                    325:   my $bodytext = '';
                    326:   for(0 .. $#randomlist) {
                    327:     $bodytext .= "$randomlist[ $idx_arr[$_] ]";
                    328:   }
1.8       albertel  329: 
                    330:   &Apache::lonxml::newparser($parser,\$bodytext);
1.6       tsai      331:   return "";
1.7       tsai      332: }
                    333: 
                    334: sub shuffle {
                    335:     my $a=shift;
                    336:     my $i;
1.52      albertel  337:     &Apache::response::setrandomnumber();
1.7       tsai      338:     for($i=@$a;--$i;) {
                    339:       my $j=int rand($i+1);
                    340:       next if $i == $j;
                    341:       @$a[$i,$j] = @$a[$j,$i];
                    342:     }
1.6       tsai      343: }
                    344: 
                    345: sub end_randomlist {
1.46      albertel  346:   return '';
1.6       tsai      347: }
                    348: 
1.11      albertel  349: sub start_part {
1.40      albertel  350:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.39      albertel  351:   my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
1.47      albertel  352:   if ($id eq '') { $id = $Apache::lonxml::curdepth; }
1.14      albertel  353:   $Apache::inputtags::part=$id;
1.18      albertel  354:   @Apache::inputtags::responselist = ();
1.51      albertel  355:   @Apache::inputtags::previous=();
1.15      www       356:   if ($target eq 'meta') {
1.16      albertel  357:     return &Apache::response::mandatory_part_meta;
1.37      albertel  358:   } elsif ($target eq 'web' || $target eq 'grade') {
1.55      www       359:     my ($status,$accessmsg) = &Apache::lonhomework::check_access($id);
1.23      albertel  360:     push (@Apache::inputtags::status,$status);
                    361:     my $expression='$external::datestatus="'.$status.'";';
                    362:     $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$id.solved"}.'";';
                    363:     &Apache::run::run($expression,$safeeval);
                    364:     if ( $status eq 'CLOSED' ) {
1.21      albertel  365:       my $bodytext=&Apache::lonxml::get_all_text("/part",$$parser[$#$parser]);
                    366:       if ( $target eq "web" ) {
1.55      www       367: 	return "<br />Part is not open to be viewed. It $accessmsg<br />";
1.21      albertel  368:       }
                    369:     }
1.15      www       370:   }
1.19      albertel  371:   return '';
1.11      albertel  372: }
                    373: 
                    374: sub end_part {
1.40      albertel  375:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.18      albertel  376:   &Apache::lonxml::debug("in end_part $target ");
1.28      albertel  377:   my $status=$Apache::inputtags::status['-1'];
1.23      albertel  378:   pop @Apache::inputtags::status;
1.19      albertel  379:   if ( $target eq 'meta' ) { return ''; }
1.37      albertel  380:   if ( $target eq 'grade' && $status eq 'CAN_ANSWER') {
                    381:     return &Apache::inputtags::grade;
1.28      albertel  382:   }
1.37      albertel  383:   if ($target eq 'web') {
                    384:     return &Apache::inputtags::gradestatus($Apache::inputtags::part);
                    385:   }
                    386:   return '';
1.11      albertel  387: }
1.1       albertel  388: 
1.25      albertel  389: sub start_preduedate {
1.40      albertel  390:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.34      albertel  391:   if ($target eq 'web' || $target eq 'grade') {
1.29      albertel  392:     if ($Apache::inputtags::status['-1'] ne 'CAN_ANSWER' &&
                    393: 	$Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER' ) {
1.26      albertel  394:       &Apache::lonxml::get_all_text("/preduedate",$$parser[$#$parser]);
1.24      albertel  395:     }
                    396:   }
                    397:   return '';
                    398: }
                    399: 
1.25      albertel  400: sub end_preduedate {
1.24      albertel  401:   return '';
                    402: }
                    403: 
1.25      albertel  404: sub start_postanswerdate {
1.40      albertel  405:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.34      albertel  406:   if ($target eq 'web' || $target eq 'grade') {
1.24      albertel  407:     if ($Apache::inputtags::status['-1'] ne 'SHOW_ANSWER') {
1.26      albertel  408:       &Apache::lonxml::get_all_text("/postanswerdate",$$parser[$#$parser]);
1.24      albertel  409:     }
                    410:   }
                    411:   return '';
                    412: }
                    413: 
1.25      albertel  414: sub end_postanswerdate {
1.24      albertel  415:   return '';
                    416: }
                    417: 
1.25      albertel  418: sub start_notsolved {
1.40      albertel  419:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.34      albertel  420:   if ($target eq 'web' || $target eq 'grade') {
1.24      albertel  421:     my $gradestatus=$Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"};
                    422:     &Apache::lonxml::debug("not solved has :$gradestatus:");
                    423:     if ($gradestatus =~ /^correct/) {
                    424:       &Apache::lonxml::debug("skipping");
1.26      albertel  425:       &Apache::lonxml::get_all_text("/notsolved",$$parser[$#$parser]);
1.24      albertel  426:     }
                    427:   }
                    428:   return '';
                    429: }
                    430: 
1.25      albertel  431: sub end_notsolved {
1.24      albertel  432:   return '';
                    433: }
                    434: 
                    435: sub start_solved {
1.40      albertel  436:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.34      albertel  437:   if ($target eq 'web' || $target eq 'grade') {
1.24      albertel  438:     my $gradestatus=$Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"};
                    439:     if ($gradestatus !~ /^correct/) {
                    440:       &Apache::lonxml::get_all_text("/solved",$$parser[$#$parser]);
                    441:     }
                    442:   }
                    443:   return '';
                    444: }
                    445: 
                    446: sub end_solved {
                    447:   return '';
                    448: }
1.34      albertel  449: 
                    450: sub start_startouttext {
1.40      albertel  451:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.35      albertel  452:   my @result=(''.'');
                    453:   if ($target eq 'edit' || $target eq 'modified' ) { @result=('','no'); }
                    454:   return (@result);
1.34      albertel  455: }
                    456: sub end_startouttext {
1.40      albertel  457:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.34      albertel  458:   my $result='';
1.35      albertel  459:   my $text='';
                    460: 
1.34      albertel  461:   if ($target eq 'edit') {
1.35      albertel  462:     $text=&Apache::lonxml::get_all_text("endouttext",$$parser[$#$parser]);
1.43      albertel  463:     $result.=&Apache::edit::start_table($token)."<tr><td>Text Block</td>
1.42      albertel  464: <td>Delete:".
                    465:   &Apache::edit::deletelist($target,$token)
                    466:   ."</td>
                    467: <td>".
                    468:   &Apache::edit::insertlist($target,$token).
                    469:     "</td>
                    470: </tr><tr><td colspan=\"3\">\n".
1.45      albertel  471: 	&Apache::edit::editfield($token->[1],$text,"",50,4);
1.35      albertel  472:   }
                    473:   if ($target eq 'modified') {
                    474:     $text=&Apache::lonxml::get_all_text("endouttext",$$parser['-1']);
                    475:     $result='<startouttext />'.&Apache::edit::modifiedfield();
1.34      albertel  476:   }
                    477:   return $result;
                    478: }
                    479: sub start_endouttext {
1.40      albertel  480:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.34      albertel  481:   my $result='';
1.43      albertel  482:   if ($target eq "edit" ) { $result="</td></tr>".&Apache::edit::end_table()."\n"; }
1.35      albertel  483:   if ($target eq "modified") { $result='<endouttext />'; }
1.34      albertel  484:   return $result;
                    485: }
                    486: sub end_endouttext {
1.40      albertel  487:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.35      albertel  488:   my @result=('','');
                    489:   if ($target eq "edit" || $target eq 'modified') { @result=('','no'); }
                    490:   return (@result);
1.34      albertel  491: }
1.45      albertel  492: sub delete_startouttext {
                    493:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                    494: #  my $text=&Apache::lonxml::get_all_text("endouttext",$$parser['-1']);
                    495:   my $text=$$parser['-1']->get_text("/endouttext");
                    496:   my $token=$$parser['-1']->get_token();
                    497:   &Apache::lonxml::debug("Deleting :$text: and :$token->[0]:$token->[1]:$token->[2]: for startouttext");
                    498:   &Apache::lonxml::end_tag($tagstack,$parstack,$token);
                    499:   # Deleting 2 parallel tag pairs, but we need the numbers later to look like 
                    500:   # they did the last time round
                    501:   &Apache::lonxml::increasedepth($token);
                    502:   &Apache::lonxml::decreasedepth($token);
                    503:   return 1;
                    504: }
1.34      albertel  505: 
1.1       albertel  506: 1;
                    507: __END__

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