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

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

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