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

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

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