Annotation of loncom/homework/edit.pm, revision 1.120

1.1       albertel    1: # The LearningOnline Network with CAPA 
                      2: # edit mode helpers
1.25      albertel    3: #
1.120   ! bisitz      4: # $Id: edit.pm,v 1.119 2008/12/10 21:02:01 raeburn Exp $
1.25      albertel    5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
1.82      www        28: 
1.117     jms        29: =head1 NAME
                     30: 
                     31: Apache::edit - edit mode helpers
                     32: 
                     33: =head1 SYNOPSIS
                     34: 
                     35: Invoked by many homework and xml related modules.
                     36: 
                     37:  &Apache::edit::SUBROUTINENAME(ARGUMENTS);
                     38: 
                     39: =head1 INTRODUCTION
                     40: 
                     41: This module outputs HTML syntax helpful for the rendering of edit
                     42: mode interfaces.
                     43: 
                     44: This is part of the LearningOnline Network with CAPA project
                     45: described at http://www.lon-capa.org.
                     46: 
1.118     jms        47: =head1 SUBROUTINES
1.117     jms        48: 
                     49: =over 4
                     50: 
1.118     jms        51: =item initialize_edit() 
1.117     jms        52: 
1.118     jms        53: initialize edit (set colordepth to zero)
1.117     jms        54: 
1.118     jms        55: =item tag_start($target,$token,$description)
1.117     jms        56: 
1.118     jms        57: provide deletion and insertion lists
1.117     jms        58: for the manipulation of a start tag; return a scalar string
                     59: 
1.118     jms        60: =item tag_end($target,$token,$description)
1.117     jms        61: 
1.118     jms        62: ending syntax corresponding to
1.117     jms        63: &tag_start. return a scalar string.
                     64: 
1.118     jms        65: =item  start_table($token)
1.117     jms        66: 
1.118     jms        67: start table; update colordepth; return scalar string.
1.117     jms        68: 
1.118     jms        69: =item end_table()
1.117     jms        70: 
1.118     jms        71: reduce color depth; end table; return scalar string
1.117     jms        72: 
1.118     jms        73: =item start_spanning_row()
1.117     jms        74: 
1.118     jms        75: start a new table row spanning the 'edit' environment.
1.117     jms        76: 
1.118     jms        77: =item start_row()
1.117     jms        78: 
1.118     jms        79: start a new table row and element. 
1.117     jms        80: 
1.118     jms        81: =item end_row() 
1.117     jms        82: 
1.118     jms        83: end current table element and row.
1.117     jms        84: 
1.118     jms        85: =item movebuttons($target,$token)
1.117     jms        86: 
1.118     jms        87: move-up and move-down buttons; return scalar string
1.117     jms        88: 
1.118     jms        89: =item deletelist($target,$token)
1.117     jms        90: 
1.118     jms        91: provide a yes option in an HTML select element; return scalar string
1.117     jms        92: 
1.118     jms        93: =item handle_delete($space,$target,$token,$tagstack,$parstack,$parser,$safeeval,
                     94: $style)
1.117     jms        95: 
1.118     jms        96: respond to a user delete request by passing relevant stack
1.117     jms        97: and array information to various rendering functions; return a scalar string
                     98: 
1.118     jms        99: =item get_insert_list($token)
                    100: 
                    101: provide an insertion list based on possibilities from lonxml; return a scalar string
1.117     jms       102: 
1.118     jms       103: =item insertlist($target,$token)
1.117     jms       104: 
1.118     jms       105: api that uses get_insert_list; return a scalar string
1.117     jms       106: 
1.118     jms       107: =item handleinsert($token)
1.117     jms       108: 
1.118     jms       109: provide an insertion list based on possibilities from lonxml; return a scalar string
1.117     jms       110: 
1.118     jms       111: =item get_insert_list($token)
1.117     jms       112: 
1.118     jms       113: provide an insertion list based on possibilities from lonxml; return a scalar string
1.117     jms       114: 
1.118     jms       115: =item browse($elementname)
1.117     jms       116: 
1.118     jms       117: provide a link which will open up the filesystem browser (lonindexer) and, once a file is selected, place the result in the form element $elementname.
1.117     jms       118: 
1.118     jms       119: =item search($elementname)
1.117     jms       120: 
1.118     jms       121: provide a link which will open up the filesystem searcher (lonsearchcat) and, once a file is selected, place the result in the form element $elementname.
                    122: 
                    123: =item editline(tag,data,description,size)
                    124: 
                    125: Provide a <input type="text" ../> for single-line text entry.  This is to be used for text enclosed by tags, not arguements/parameters associated with a tag.
1.117     jms       126: 
                    127: =back
                    128: 
                    129: =cut
                    130: 
1.1       albertel  131: package Apache::edit; 
                    132: 
                    133: use strict;
1.92      albertel  134: use Apache::lonnet;
1.32      albertel  135: use HTML::Entities();
1.71      www       136: use Apache::lonlocal;
1.102     www       137: use lib '/home/httpd/lib/perl/';
                    138: use LONCAPA;
                    139:  
1.1       albertel  140: 
1.10      albertel  141: # Global Vars
                    142: # default list of colors to use in editing
                    143: @Apache::edit::colorlist=('#ffffff','#ff0000','#00ff00','#0000ff','#0ff000','#000ff0','#f0000f');
                    144: # depth of nesting of edit
                    145: $Apache::edit::colordepth=0;
1.38      www       146: @Apache::edit::inserttag=();
1.49      www       147: # image-type responses: active background image and curdepth at definition
                    148: $Apache::edit::bgimgsrc='';
                    149: $Apache::edit::bgimgsrccurdepth='';
1.10      albertel  150: 
                    151: sub initialize_edit {
1.63      albertel  152:     $Apache::edit::colordepth=0;
                    153:     @Apache::edit::inserttag=();
1.10      albertel  154: }
                    155: 
1.1       albertel  156: sub tag_start {
1.63      albertel  157:     my ($target,$token,$description) = @_;
                    158:     my $result='';
                    159:     if ($target eq "edit") {
                    160: 	my $tag=$token->[1];
                    161: 	if (!$description) {
                    162: 	    $description=&Apache::lonxml::description($token);
                    163: 	    if (!$description) { $description="&lt;$tag&gt;"; }
                    164: 	}
                    165: 	$result.= &start_table($token)."<tr><td>$description</td>
1.116     bisitz    166:                       <td>".&mt('Delete?').' '.
1.63      albertel  167: 		      &deletelist($target,$token)
                    168: 		      ."</td>
                    169:                        <td>".
                    170: 		       &insertlist($target,$token);
1.27      matthew   171: #<td>". 
1.22      albertel  172: #  &movebuttons($target,$token).
                    173: #    "</tr><tr><td colspan=\"3\">\n";
1.66      matthew   174: 	my @help = Apache::lonxml::helpinfo($token);
1.63      albertel  175: 	if ($help[0]) {
1.88      albertel  176: 	    $result .= '</td><td align="right" valign="top">' .
                    177: 		Apache::loncommon::help_open_topic(@help);
                    178: 	} else { $result .= "</td><td>&nbsp;"; }
1.63      albertel  179: 	$result .= &end_row().&start_spanning_row();
                    180:     }
                    181:     return $result;
1.1       albertel  182: }
                    183: 
                    184: sub tag_end {
1.63      albertel  185:     my ($target,$token,$description) = @_;
                    186:     my $result='';
                    187:     if ($target eq 'edit') {
                    188: 	$result.="</td></tr>".&end_table()."\n";
                    189:     }
                    190:     return $result;
1.4       albertel  191: }
1.1       albertel  192: 
1.10      albertel  193: sub start_table {
1.63      albertel  194:     my ($token)=@_;
1.104     albertel  195:     my $tag = &Apache::lonxml::get_tag($token);
                    196:     
                    197:     my $color = $Apache::lonxml::insertlist{"$tag.color"};
                    198:     &Apache::lonxml::debug(" $tag -- $color");
1.63      albertel  199:     if (!defined($color)) {
                    200: 	$color = $Apache::edit::colorlist[$Apache::edit::colordepth];
                    201:     }
                    202:     $Apache::edit::colordepth++;
                    203:     push(@Apache::edit::inserttag,$token->[1]);
                    204:     my $result='<div align="right">';
                    205:     $result.='<table bgcolor="'.$color.'" width="97%" border="0" cellspacing="5" cellpadding="3">';
                    206:     return $result;
1.10      albertel  207: }
                    208: 
                    209: sub end_table {
1.63      albertel  210:     $Apache::edit::colordepth--;
                    211:     my $result='</table></div>';
1.94      albertel  212:     $result.='<div align="left"><table><tr><td>';
1.63      albertel  213: 
                    214:     my ($tagname,$closingtag);
                    215:     if (defined($Apache::edit::inserttag[-2])) {
                    216: 	$tagname=$Apache::edit::inserttag[-2];
1.105     albertel  217:     } else {
                    218: 	if ($Apache::lonhomework::parsing_a_task) {
                    219: 	    $tagname='Task';
                    220: 	} else {
                    221: 	    $tagname='problem';
                    222: 	}
                    223:     }
1.63      albertel  224:     if (defined($Apache::edit::inserttag[-1])) {
                    225: 	$closingtag=$Apache::edit::inserttag[-1];
                    226:     }
                    227:     $result.=&innerinsertlist('edit',$tagname,$closingtag).
1.94      albertel  228: 	"</td></tr></table></div>";
1.105     albertel  229:     my $last = pop(@Apache::edit::inserttag);
1.63      albertel  230:     return $result;
1.10      albertel  231: }
                    232: 
1.115     raeburn   233: sub start_spanning_row { return '<tr><td colspan="5" bgcolor="#DDDDDD">';}
1.41      www       234: sub start_row          { return '<tr><td bgcolor="#DDDDDD">';            }
1.27      matthew   235: sub end_row            { return '</td></tr>';          }
                    236: 
1.22      albertel  237: sub movebuttons {
1.63      albertel  238:     my ($target,$token) = @_;
                    239:     my $result='<input type="submit" name="moveup.'.
                    240: 	$Apache::lonxml::curdepth.'" value="Move Up" />';
                    241:     $result.='<input type="submit" name="movedown.'.
                    242: 	$Apache::lonxml::curdepth.'" value="Move Down" />';
                    243:     return $result;
1.22      albertel  244: }
                    245: 
1.8       albertel  246: sub deletelist {
1.63      albertel  247:     my ($target,$token) = @_;
                    248:     my $result = "<select name=\"delete_$Apache::lonxml::curdepth\">
1.14      albertel  249: <option></option>
1.116     bisitz    250: <option>".&mt('yes')."</option>
1.8       albertel  251: </select>";
1.63      albertel  252:     return $result;
1.8       albertel  253: }
                    254: 
1.14      albertel  255: sub handle_delete {
1.92      albertel  256:     if (!$env{"form.delete_$Apache::lonxml::curdepth"}) { return ''; }
1.63      albertel  257:     my ($space,$target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
                    258:     my $result=0;
                    259:     if ($space) {
                    260: 	my $sub1="$space\:\:delete_$token->[1]";
                    261: 	{
                    262: 	    no strict 'refs';
                    263: 	    if (defined &$sub1) {
                    264: 		$result=&$sub1($target,$token,$tagstack,$parstack,$parser,$safeeval,$style);
                    265: 	    }
                    266: 	}
                    267:     }
                    268:     if (!$result) {
                    269: 	my $endtag='/'.$token->[1];
1.97      albertel  270: 	my $bodytext=&Apache::lonxml::get_all_text($endtag,$parser,$style);
1.63      albertel  271: 	$$parser['-1']->get_token();
                    272: 	&Apache::lonxml::debug("Deleting :$bodytext: for $token->[1]");
                    273: 	&Apache::lonxml::end_tag($tagstack,$parstack,$token);
                    274:     }
                    275:     return 1;
1.14      albertel  276: }
                    277: 
1.7       albertel  278: sub get_insert_list {
1.63      albertel  279:     my ($tagname) = @_;
                    280:     my $result='';
1.104     albertel  281:     my @tags= ();
1.63      albertel  282:     #&Apache::lonxml::debug("keys ".join("\n",sort(keys(%Apache::lonxml::insertlist))));
                    283:     if ($Apache::lonxml::insertlist{"$tagname.which"}) {
1.104     albertel  284: 	push (@tags, @{ $Apache::lonxml::insertlist{"$tagname.which"} });
1.63      albertel  285:     }
                    286:     foreach my $namespace (@Apache::lonxml::namespace) {
                    287: 	if ($Apache::lonxml::insertlist{"$namespace".'::'."$tagname.which"}) {
1.104     albertel  288: 	    push (@tags, @{ $Apache::lonxml::insertlist{"$namespace".'::'."$tagname.which"} });
1.63      albertel  289: 	}
                    290:     }
1.104     albertel  291:     if (@tags) {
1.63      albertel  292: 	my %options;
1.104     albertel  293: 	foreach my $tag (@tags) {
                    294: 	    my $descrip=$Apache::lonxml::insertlist{"$tag.description"};
                    295: 	    my $tagnum =$Apache::lonxml::insertlist{"$tag.num"};
1.63      albertel  296: 	    $options{$descrip} ="<option value=\"$tagnum\">".
                    297: 		$descrip."</option>\n";
                    298: 	}
                    299: 	foreach my $option (sort(keys(%options))) {$result.=$options{$option};}
1.88      albertel  300: 	if ($result) { $result='<option selected="selected"></option>'.$result; }
1.63      albertel  301:     }
                    302:     return $result;
1.5       albertel  303: }
                    304: 
1.4       albertel  305: sub insertlist {
1.63      albertel  306:     my ($target,$token) = @_;
                    307:     return &innerinsertlist($target,$token->[1]);
1.38      www       308: }
                    309: 
                    310: sub innerinsertlist {
1.63      albertel  311:     my ($target,$tagname,$closingtag) = @_;
                    312:     my $result;
                    313:     my $after='';
                    314:     if ($closingtag) {
                    315: 	$after='_after_'.$closingtag; 
                    316:     }
                    317:     if ($target eq 'edit') {
                    318: 	my $optionlist= &get_insert_list($tagname);
                    319: 	if ($optionlist) {
1.116     bisitz    320: 	    $result = &mt('Insert:')."
1.63      albertel  321:             <select name=\"insert$after\_$Apache::lonxml::curdepth\">
                    322:                   $optionlist
                    323:             </select>"
                    324: 	} else {
                    325: 	    $result="&nbsp;";
                    326: 	}
1.6       albertel  327:     }
1.63      albertel  328:     return $result;
1.6       albertel  329: }
                    330: 
1.7       albertel  331: sub handle_insert {
1.92      albertel  332:     if ($env{"form.insert_$Apache::lonxml::curdepth"} eq '') { return ''; }
                    333:     my $tagnum = $env{"form.insert_$Apache::lonxml::curdepth"};
1.104     albertel  334:     return &do_insert($tagnum);
1.38      www       335: }
                    336: 
                    337: sub handle_insertafter {
1.63      albertel  338:     my $tagname=shift;
1.104     albertel  339:     if ($env{"form.insert_after_$tagname\_$Apache::lonxml::curdepth"} eq '') {
                    340: 	return '';
                    341:     }
                    342:     my $tagnum =$env{"form.insert_after_$tagname\_$Apache::lonxml::curdepth"};
1.105     albertel  343:     return &do_insert($tagnum,1);
1.104     albertel  344: }
                    345: 
                    346: sub do_insert {
1.105     albertel  347:     my ($tagnum,$after) = @_;
1.63      albertel  348:     my $result;
1.104     albertel  349: 
                    350:     my $newtag = $Apache::lonxml::insertlist{"$tagnum.tag"};
                    351:     my $func   = $Apache::lonxml::insertlist{"$newtag.function"};
1.63      albertel  352:     if ($func eq 'default') {
                    353: 	my $namespace;
                    354: 	if ($newtag =~ /::/) { ($namespace,$newtag) = split(/::/,$newtag); }
1.105     albertel  355: 	my $depth = scalar(@Apache::lonxml::depthcounter);
                    356: 	$depth -- if ($after);
                    357: 	my $inset = "\t"x$depth;
                    358: 	$result.="\n$inset<$newtag>\n$inset</$newtag>";
1.38      www       359:     } else {
1.63      albertel  360: 	if (defined(&$func)) {
                    361: 	    {
                    362: 		no strict 'refs';
                    363: 		$result.=&$func();
                    364: 	    }
                    365: 	} else {
1.104     albertel  366: 	    &Apache::lonxml::error("Unable to insert tag $newtag, $func was not defined. ($tagnum)");
1.63      albertel  367: 	}
1.5       albertel  368:     }
1.63      albertel  369:     return $result;
1.69      albertel  370: }
                    371: 
                    372: sub insert_img {
                    373:     return '
                    374:     <img />';
1.16      albertel  375: }
                    376: 
                    377: sub insert_responseparam {
1.63      albertel  378:     return '
1.16      albertel  379:     <responseparam />';
1.5       albertel  380: }
                    381: 
1.87      albertel  382: sub insert_parameter {
                    383:     return '
                    384:     <parameter />';
                    385: }
                    386: 
1.24      albertel  387: sub insert_formularesponse {
1.63      albertel  388:     return '
1.24      albertel  389: <formularesponse answer="" samples="">
1.86      albertel  390:     <responseparam description="Numerical Tolerance" type="tolerance" default="0.00001" name="tol" />
                    391:     <textline size="25"/>
1.24      albertel  392:     <hintgroup>
1.78      www       393:     <startouttext /><endouttext />
1.24      albertel  394:     </hintgroup>
                    395: </formularesponse>';
                    396: }
                    397: 
1.15      albertel  398: sub insert_numericalresponse {
1.63      albertel  399:     return '
1.15      albertel  400: <numericalresponse answer="">
1.90      www       401: <responseparam type="tolerance" default="5%" name="tol" description="Numerical Tolerance" />
                    402: <responseparam name="sig" type="int_range,0-16" default="0,15" description="Significant Figures" />
1.15      albertel  403:     <textline />
                    404:     <hintgroup>
1.78      www       405:     <startouttext /><endouttext />
1.15      albertel  406:     </hintgroup>
                    407: </numericalresponse>';
                    408: }
                    409: 
1.96      albertel  410: sub insert_customresponse {
1.95      albertel  411:     return '
1.96      albertel  412: <customresponse>
1.95      albertel  413:     <answer type="loncapa/perl">
                    414:     </answer>
                    415:     <textline />
                    416:     <hintgroup>
                    417:     <startouttext /><endouttext />
                    418:     </hintgroup>
1.96      albertel  419: </customresponse>';
1.95      albertel  420: }
                    421: 
1.96      albertel  422: sub insert_customresponse_answer {
1.95      albertel  423:     return '
                    424:     <answer type="loncapa/perl">
                    425:     </answer>
                    426: ';
                    427: }
                    428: 
1.106     albertel  429: sub insert_customhint {
                    430:     return '
                    431:         <customhint>
                    432:             <answer type="loncapa/perl">
                    433:             </answer>
                    434:         </customhint>';
                    435: }
                    436: 
                    437: sub insert_customhint_answer {
                    438:     return '
                    439:             <answer type="loncapa/perl">
                    440:             </answer>
                    441: ';
                    442: }
                    443: 
                    444: sub insert_mathresponse {
                    445:     return '
                    446: <mathresponse>
                    447:     <answer>
                    448:     </answer>
                    449:     <textline />
                    450:     <hintgroup>
                    451:         <startouttext />
                    452:         <endouttext />
                    453:     </hintgroup>
                    454: </mathresponse>';
                    455: }
                    456: 
                    457: sub insert_mathresponse_answer {
                    458:     return '
                    459:     <answer>
                    460:     </answer>
                    461: ';
                    462: }
                    463: 
                    464: sub insert_mathhint {
                    465:     return '
                    466:         <mathhint>
                    467:             <answer>
                    468:             </answer>
                    469:         </mathhint>';
                    470: }
                    471: 
                    472: sub insert_mathhint_answer {
                    473:     return '
                    474:             <answer>
                    475:             </answer>
                    476: ';
                    477: }
                    478: 
1.18      albertel  479: sub insert_stringresponse {
1.63      albertel  480:     return '
1.18      albertel  481: <stringresponse answer="" type="">
                    482:     <textline />
                    483:     <hintgroup>
1.78      www       484:     <startouttext /><endouttext />
1.18      albertel  485:     </hintgroup>
                    486: </stringresponse>';
1.36      albertel  487: }
                    488: 
                    489: sub insert_essayresponse {
1.63      albertel  490:     return '
1.36      albertel  491: <essayresponse>
                    492:     <textfield></textfield>
                    493: </essayresponse>';
1.54      albertel  494: }
                    495: 
                    496: sub insert_imageresponse {
1.63      albertel  497:     return '
1.54      albertel  498: <imageresponse max="1">
                    499:     <foilgroup>
1.89      albertel  500:       <foil>
                    501:       </foil>
1.54      albertel  502:     </foilgroup>
                    503:     <hintgroup>
1.78      www       504:     <startouttext /><endouttext />
1.54      albertel  505:     </hintgroup>
                    506: </imageresponse>';
1.18      albertel  507: }
                    508: 
1.7       albertel  509: sub insert_optionresponse {
1.63      albertel  510:     return '
1.7       albertel  511: <optionresponse max="10">
                    512:     <foilgroup options="">
1.89      albertel  513:       <foil>
                    514:          <startouttext /><endouttext />
                    515:       </foil>
1.7       albertel  516:     </foilgroup>
1.14      albertel  517:     <hintgroup>
1.78      www       518:     <startouttext /><endouttext />
1.14      albertel  519:     </hintgroup>
1.7       albertel  520: </optionresponse>';
1.1       albertel  521: }
                    522: 
1.72      albertel  523: sub insert_organicresponse {
                    524:     return '
                    525: <organicresponse>
                    526:     <textline />
                    527:     <hintgroup>
1.78      www       528:     <startouttext /><endouttext />
1.72      albertel  529:     </hintgroup>
                    530: </organicresponse>';
                    531: }
                    532: 
                    533: sub insert_organicstructure {
                    534:     return '
                    535: <organicstructure />
                    536: ';
                    537: }
                    538: 
1.23      albertel  539: sub insert_radiobuttonresponse {
1.63      albertel  540:     return '
1.23      albertel  541: <radiobuttonresponse max="10">
                    542:     <foilgroup>
1.89      albertel  543:       <foil>
                    544:          <startouttext /><endouttext />
                    545:       </foil>
1.23      albertel  546:     </foilgroup>
                    547:     <hintgroup>
1.78      www       548:     <startouttext /><endouttext />
1.23      albertel  549:     </hintgroup>
                    550: </radiobuttonresponse>';
1.72      albertel  551: }
                    552: 
                    553: sub insert_reactionresponse {
                    554:     return '
                    555: <reactionresponse>
                    556:     <textline />
                    557:     <hintgroup>
1.78      www       558:     <startouttext /><endouttext />
1.72      albertel  559:     </hintgroup>
                    560: </reactionresponse>';
1.43      albertel  561: }
                    562: 
                    563: sub insert_rankresponse {
1.63      albertel  564:     return '
1.43      albertel  565: <rankresponse max="10">
                    566:     <foilgroup options="">
1.89      albertel  567:       <foil>
                    568:          <startouttext /><endouttext />
                    569:       </foil>
1.43      albertel  570:     </foilgroup>
                    571:     <hintgroup>
1.78      www       572:     <startouttext /><endouttext />
1.43      albertel  573:     </hintgroup>
                    574: </rankresponse>';
1.23      albertel  575: }
                    576: 
1.44      albertel  577: sub insert_matchresponse {
1.63      albertel  578:     return '
1.44      albertel  579: <matchresponse max="10">
                    580:     <foilgroup options="">
                    581:       <itemgroup>
                    582:       </itemgroup>
1.89      albertel  583:       <foil>
                    584:          <startouttext /><endouttext />
                    585:       </foil>
1.44      albertel  586:     </foilgroup>
                    587:     <hintgroup>
1.78      www       588:     <startouttext /><endouttext />
1.44      albertel  589:     </hintgroup>
                    590: </matchresponse>';
                    591: }
                    592: 
1.21      albertel  593: sub insert_displayduedate { return '<displayduedate />'; }
                    594: sub insert_displaytitle   { return '<displaytitle />'; }
1.22      albertel  595: sub insert_hintpart {
1.63      albertel  596:     return '
1.22      albertel  597: <hintpart on="default">
1.90      www       598:     <startouttext/><endouttext />
1.22      albertel  599: </hintpart>';
1.67      albertel  600: }
                    601: 
                    602: sub insert_hintgroup {
                    603:   return '
                    604: <hintgroup>
1.78      www       605:     <startouttext /><endouttext />
1.67      albertel  606: </hintgroup>';
1.22      albertel  607: }
                    608: 
                    609: sub insert_numericalhint {
1.63      albertel  610:     return '
1.22      albertel  611: <numericalhint>
                    612: </numericalhint>';
1.46      albertel  613: }
                    614: 
                    615: sub insert_stringhint {
1.63      albertel  616:     return '
1.46      albertel  617: <stringhint>
                    618: </stringhint>';
                    619: }
                    620: 
                    621: sub insert_formulahint {
1.63      albertel  622:     return '
1.46      albertel  623: <formulahint>
                    624: </formulahint>';
1.37      albertel  625: }
                    626: 
                    627: sub insert_radiobuttonhint {
1.63      albertel  628:     return '
1.37      albertel  629: <radiobuttonhint>
                    630: </radiobuttonhint>';
1.50      albertel  631: }
                    632: 
                    633: sub insert_optionhint {
1.63      albertel  634:     return '
1.50      albertel  635: <optionhint>
                    636: </optionhint>';
1.22      albertel  637: }
1.21      albertel  638: 
1.23      albertel  639: sub insert_startouttext {
1.78      www       640:     return "<startouttext /><endouttext />";
1.23      albertel  641: }
                    642: 
                    643: sub insert_script {
1.78      www       644:     return "\n<script type=\"loncapa/perl\"></script>";
1.23      albertel  645: }
                    646: 
1.98      albertel  647: sub js_change_detection {
                    648:     my $unsaved=&mt("There are unsaved changes");
                    649:     return (<<SCRIPT);
                    650: <script type="text/javascript">
                    651: var clean = true;
                    652: var is_submit = false;
1.99      albertel  653: var still_ask = false;
1.98      albertel  654: function compareForm(event_) {
                    655:         if (!event_ && window.event) {
                    656:           event_ = window.event;
                    657:         }
1.99      albertel  658: 	if ((!is_submit || (is_submit && still_ask)) && !clean) {
                    659: 	    still_ask = false;
                    660: 	    is_submit = false;
1.98      albertel  661:             event_.returnValue = "$unsaved";
                    662:             return "$unsaved";
                    663:         }
                    664: }
                    665: function unClean() {
                    666:      clean=false;
                    667: }
                    668: window.onbeforeunload = compareForm;
                    669: </script>
                    670: SCRIPT
                    671: }
                    672: 
                    673: sub form_change_detection {
                    674:     return ' onsubmit="is_submit=true;" ';
                    675: }
                    676: 
                    677: sub element_change_detection {
                    678:     return ' onchange="unClean();" ';
                    679: }
                    680: 
1.99      albertel  681: sub submit_ask_anyway {
1.113     raeburn   682:     my ($extra_action) = @_;
                    683:     return ' onclick="still_ask=true;'.$extra_action.'" ';
1.99      albertel  684: }
                    685: 
1.25      albertel  686: sub textarea_sizes {
1.63      albertel  687:     my ($data)=@_;
                    688:     my $count=0;
                    689:     my $maxlength=-1;
                    690:     foreach (split ("\n", $$data)) {
                    691: 	$count+=int(length($_)/79);
                    692: 	$count++;
                    693: 	if (length($_) > $maxlength) { $maxlength = length($_); }
                    694:     }
                    695:     my $rows = $count;
                    696:     my $cols = $maxlength;
                    697:     return ($rows,$cols);
1.25      albertel  698: }
                    699: 
1.32      albertel  700: sub editline {
1.31      matthew   701:     my ($tag,$data,$description,$size)=@_;
1.81      albertel  702:     $data=&HTML::Entities::encode($data,'<>&"');
1.112     albertel  703:     if ($description) { $description=$description."<br />"; }
1.98      albertel  704:     my $change_code = &element_change_detection();
1.31      matthew   705:     my $result = <<"END";
                    706: $description
                    707: <input type="text" name="homework_edit_$Apache::lonxml::curdepth" 
1.98      albertel  708:        value="$data" size="$size" $change_code />
1.31      matthew   709: END
                    710:     return $result;
                    711: }
                    712: 
1.2       albertel  713: sub editfield {
1.82      www       714:     my ($tag,$data,$description,$minwidth,$minheight,$usehtmlarea)=@_;
1.22      albertel  715: 
1.63      albertel  716:     my ($rows,$cols)=&textarea_sizes(\$data);
1.84      www       717:     if (&Apache::lonhtmlcommon::htmlareabrowser() &&
                    718: 	!&Apache::lonhtmlcommon::htmlareablocked()) {
                    719: 	$rows+=7;      # make room for HTMLarea
                    720: 	$minheight+=7; # make room for HTMLarea
                    721:     }
1.63      albertel  722:     if ($cols > 80) { $cols = 80; }
                    723:     if ($cols < $minwidth ) { $cols = $minwidth; }
                    724:     if ($rows < $minheight) { $rows = $minheight; }
1.112     albertel  725:     if ($description) { $description=$description."<br />"; }
1.82      www       726:     if ($usehtmlarea) {
1.101     albertel  727: 	&Apache::lonhtmlcommon::add_htmlareafields('homework_edit_'.
                    728: 						   $Apache::lonxml::curdepth);
1.82      www       729:     }
1.105     albertel  730:     # remove typesetting whitespace from between data and the end tag
                    731:     # to make the edit look prettier
                    732:     $data =~ s/\n?[ \t]*$//;
                    733: 
1.103     albertel  734:     return $description."\n".'<textarea style="width:100%" rows="'.$rows.
1.63      albertel  735: 	'" cols="'.$cols.'" name="homework_edit_'.
1.82      www       736: 	$Apache::lonxml::curdepth.'" id="homework_edit_'.
1.98      albertel  737: 	$Apache::lonxml::curdepth.'" '.&element_change_detection().'>'.
1.85      www       738: 	&HTML::Entities::encode($data,'<>&"').'</textarea>'.
                    739: 	($usehtmlarea?&Apache::lonhtmlcommon::spelllink('lonhomework',
                    740: 			 'homework_edit_'.$Apache::lonxml::curdepth):'')."\n";
1.2       albertel  741: }
                    742: 
                    743: sub modifiedfield {
1.70      albertel  744:     my ($endtag,$parser) = @_;
1.63      albertel  745:     my $result;
1.92      albertel  746:     $result=$env{"form.homework_edit_$Apache::lonxml::curdepth"};
1.70      albertel  747:     my $bodytext=&Apache::lonxml::get_all_text($endtag,$parser);
                    748:     # textareas throw away intial \n 
1.105     albertel  749:     if ($bodytext=~/^\n/) {
                    750: 	$result="\n".$result;
                    751:     }
                    752:     # if there is typesetting whitespace from between the data and the end tag
                    753:     # restore to keep the source looking pretty
                    754:     if ($bodytext =~ /(\n?[ \t]*)$/) {
                    755: 	$result .= $1;
                    756:     }
1.63      albertel  757:     return $result;
1.2       albertel  758: }
                    759: 
1.15      albertel  760: # Returns a 1 if the token has been modified and you should rebuild the tag
1.12      albertel  761: # side-effects, will modify the $token if new values are found
                    762: sub get_new_args {
1.61      albertel  763:     my ($token,$parstack,$safeeval,@args)=@_;
                    764:     my $rebuild=0;
                    765:     foreach my $arg (@args) {
1.63      albertel  766: 	#just want the string that it was set to
                    767: 	my $value=$token->[2]->{$arg};
                    768: 	my $element=&html_element_name($arg);
1.92      albertel  769: 	my $newvalue=$env{"form.$element"};
1.63      albertel  770: 	&Apache::lonxml::debug("for:$arg: cur is :$value: new is :$newvalue:");
                    771: 	if (defined($newvalue) && $value ne $newvalue) {
                    772: 	    if (ref($newvalue) eq 'ARRAY') {
                    773: 		$token->[2]->{$arg}=join(',',@$newvalue);
                    774: 	    } else {
                    775: 		$token->[2]->{$arg}=$newvalue;
                    776: 	    }
1.79      albertel  777: 	    $rebuild=1;
1.111     albertel  778: 	    # add new attributes to the of the attribute seq
                    779: 	    if (!grep { $arg eq $_ } (@{ $token->[3] })) {
                    780: 		push(@{ $token->[3] },$arg);
                    781: 	    }
1.79      albertel  782: 	} elsif (!defined($newvalue) && defined($value)) {
                    783: 	    delete($token->[2]->{$arg});
1.63      albertel  784: 	    $rebuild=1;
1.61      albertel  785: 	}
1.12      albertel  786:     }
1.63      albertel  787:     return $rebuild;
1.12      albertel  788: }
                    789: 
1.15      albertel  790: # looks for /> on start tags
1.12      albertel  791: sub rebuild_tag {
1.63      albertel  792:     my ($token) = @_;
                    793:     my $result;
                    794:     if ($token->[0] eq 'S') {
                    795: 	$result = '<'.$token->[1];
1.109     albertel  796: 	foreach my $attribute (@{ $token->[3] }) {
                    797: 	    my $value = $token->[2]{$attribute};
1.111     albertel  798: 	    next if ($value eq '');
1.109     albertel  799: 	    $value =~s/^\s+|\s+$//g;
                    800: 	    $value =~s/\"//g;
                    801: 	    &Apache::lonxml::debug("setting :$attribute: to  :$value:");
                    802: 	    $result.=' '.$attribute.'="'.$value.'"';
1.63      albertel  803: 	}
                    804: 	if ($token->[4] =~ m:/>$:) {
                    805: 	    $result.=' />';
                    806: 	} else {
                    807: 	    $result.='>';
                    808: 	}
                    809:     } elsif ( $token->[0] eq 'E' ) {
                    810: 	$result = '</'.$token->[1].'>';
1.12      albertel  811:     }
1.63      albertel  812:     return $result;
1.12      albertel  813: }
1.13      albertel  814: 
1.47      matthew   815: sub html_element_name {
                    816:     my ($name) = @_;
1.48      albertel  817:     return $name.'_'.$Apache::lonxml::curdepth;
                    818: }
                    819: 
                    820: sub hidden_arg {
                    821:     my ($name,$token) = @_;
                    822:     my $result;
                    823:     my $arg=$token->[2]{$name};
                    824:     $result='<input name="'.&html_element_name($name).
                    825: 	'" type="hidden" value="'.$arg.'" />';
1.61      albertel  826:     return $result;
                    827: }
                    828: 
                    829: sub checked_arg {
                    830:     my ($description,$name,$list,$token) = @_;
                    831:     my $result;
                    832:     my $optionlist="";
                    833:     my $allselected=$token->[2]{$name};
1.71      www       834:     $result=&mt($description);
1.61      albertel  835:     foreach my $option (@$list) {
                    836: 	my ($value,$text);
                    837: 	if ( ref($option) eq 'ARRAY') {
                    838: 	    $value='value="'.$$option[0].'"';
                    839: 	    $text=$$option[1];
                    840: 	    $option=$$option[0];
                    841: 	} else {
                    842: 	    $text=$option;
                    843: 	    $value='value="'.$option.'"';
                    844: 	}
1.119     raeburn   845: 	$result.='<span class="LC_nobreak"><label><input type="checkbox" '.$value.' name="'.
                    846: 	    &html_element_name($name).'"';
1.61      albertel  847: 	foreach my $selected (split(/,/,$allselected)) {
                    848: 	    if ( $selected eq $option ) {
1.119     raeburn   849: 		$result.=' checked="checked" ';
1.61      albertel  850: 		last;
                    851: 	    }
                    852: 	}
1.119     raeburn   853: 	$result.=&element_change_detection().' />'.$text.'</label></span>'."\n";
1.61      albertel  854:     }
1.48      albertel  855:     return $result;
1.47      matthew   856: }
                    857: 
1.13      albertel  858: sub text_arg {
1.63      albertel  859:     my ($description,$name,$token,$size) = @_;
                    860:     my $result;
                    861:     if (!defined $size) { $size=20; }
                    862:     my $arg=$token->[2]{$name};
1.71      www       863:     $result=&mt($description).'&nbsp;<input name="'.&html_element_name($name).
1.98      albertel  864: 	'" type="text" value="'.$arg.'" size="'.$size.'" '.
                    865: 	&element_change_detection().'/>';
1.119     raeburn   866:     return '<span class="LC_nobreak">'.$result.'</span>';
1.13      albertel  867: }
                    868: 
                    869: sub select_arg {
1.39      albertel  870:     my ($description,$name,$list,$token) = @_;
                    871:     my $result;
                    872:     my $optionlist="";
                    873:     my $selected=$token->[2]{$name};
                    874:     foreach my $option (@$list) {
1.64      albertel  875: 	my ($text,$value);
1.39      albertel  876: 	if ( ref($option) eq 'ARRAY') {
1.93      albertel  877: 	    $value='value="'.&HTML::Entities::encode($$option[0]).'"';
1.64      albertel  878: 	    $text=$$option[1];
                    879: 	    $option=$$option[0];
1.39      albertel  880: 	} else {
1.64      albertel  881: 	    $text=$option;
1.93      albertel  882: 	    $value='value="'.&HTML::Entities::encode($option,'\'"&<>').'"';
1.39      albertel  883: 	}
                    884: 	if ( $selected eq $option ) {
1.116     bisitz    885: 	    $optionlist.="<option $value selected=\"selected\">".&mt($text)."</option>\n";
1.39      albertel  886: 	} else {
1.116     bisitz    887: 	    $optionlist.="<option $value >".&mt($text)."</option>\n";
1.39      albertel  888: 	}
1.13      albertel  889:     }
1.120   ! bisitz    890:     $result.='<span class="LC_nobreak">'.&mt($description).'&nbsp;<select name="'.
1.98      albertel  891: 	&html_element_name($name).'" '.&element_change_detection().' >
1.13      albertel  892:        '.$optionlist.'
1.119     raeburn   893:       </select></span>';
1.39      albertel  894:     return $result;
1.13      albertel  895: }
                    896: 
1.19      albertel  897: sub select_or_text_arg {
1.39      albertel  898:     my ($description,$name,$list,$token,$size) = @_;
                    899:     my $result;
                    900:     my $optionlist="";
                    901:     my $found=0;
                    902:     my $selected=$token->[2]{$name};
                    903:     foreach my $option (@$list) {
1.64      albertel  904: 	my ($text,$value);
1.39      albertel  905: 	if ( ref($option) eq 'ARRAY') {
1.93      albertel  906: 	    $value='value="'.&HTML::Entities::encode($$option[0]).'"';
1.64      albertel  907: 	    $text=$$option[1];
                    908: 	    $option=$$option[0];
1.39      albertel  909: 	} else {
1.64      albertel  910: 	    $text=$option;
1.93      albertel  911: 	    $value='value="'.&HTML::Entities::encode($option,'\'"&<>').'"';
1.39      albertel  912: 	}
                    913: 	if ( $selected eq $option ) {
1.88      albertel  914: 	    $optionlist.="<option $value selected=\"selected\">$text</option>\n";
1.39      albertel  915: 	    $found=1;
                    916: 	} else {
1.64      albertel  917: 	    $optionlist.="<option $value>$text</option>\n";
1.39      albertel  918: 	}
                    919:     }
1.60      www       920:     $optionlist.="<option value=\"TYPEDINVALUE\"".
1.88      albertel  921:  	((!$found)?' selected="selected"':'').
1.73      www       922:  	">".&mt('Type-in value')."</option>\n";
1.60      www       923: #
1.98      albertel  924:     my $change_code=&element_change_detection();
1.60      www       925:     my $element=&html_element_name($name);
                    926:     my $selectelement='select_list_'.$element;
                    927:     my $typeinelement='type_in_'.$element;
                    928:     my $typeinvalue=($found?'':$selected);
                    929: #
                    930:     my $hiddenvalue='this.form.'.$element.'.value';
                    931:     my $selectedindex='this.form.'.$selectelement.'.selectedIndex';
                    932:     my $selectedvalue='this.form.'.$selectelement.
                    933: 	     '.options['.$selectedindex.'].value';
                    934:     my $typedinvalue='this.form.'.$typeinelement.'.value';
                    935:     my $selecttypeinindex='this.form.'.$selectelement.'.options.length';
1.71      www       936:     $description=&mt($description);
1.60      www       937: #
                    938:     return (<<ENDSELECTORTYPE);
1.119     raeburn   939: <span class="LC_nobreak">
1.60      www       940: $description
                    941: &nbsp;<select name="$selectelement"
1.74      albertel  942: onChange="if ($selectedvalue!='TYPEDINVALUE') { $hiddenvalue=$selectedvalue; $typedinvalue=''; }" >
1.60      www       943: $optionlist
                    944: </select>
                    945: <input type="text" size="$size" name="$typeinelement"
                    946:        value="$typeinvalue" 
                    947: onChange="$hiddenvalue=$typedinvalue;"
                    948: onFocus="$selectedindex=$selecttypeinindex-1;" />
1.98      albertel  949: <input type="hidden" name="$element" value="$selected" $change_code />
1.119     raeburn   950: </span>
1.60      www       951: ENDSELECTORTYPE
1.19      albertel  952: }
1.29      matthew   953: 
1.49      www       954: #----------------------------------------------------- image coordinates
                    955: # single image coordinates, x, y 
                    956: sub entercoords {
1.80      albertel  957:     my ($idx,$idy,$mode,$width,$height) = @_;
1.49      www       958:     unless ($Apache::edit::bgimgsrc) { return ''; }
                    959:     if ($idx) { $idx.='_'; }
                    960:     if ($idy) { $idy.='_'; }
1.102     www       961:     my $bgfile=&escape(&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$Apache::edit::bgimgsrc));
1.49      www       962:     my $form    = 'lonhomework';
                    963:     my $element;
                    964:     if (! defined($mode) || $mode eq 'attribute') {
1.102     www       965:         $element = &escape("$Apache::lonxml::curdepth");
1.49      www       966:     } elsif ($mode eq 'textnode') {  # for data between <tag> ... </tag>
1.102     www       967:         $element = &escape('homework_edit_'.
1.49      www       968:                                            $Apache::lonxml::curdepth);
                    969:     }
1.80      albertel  970:     my $id=$Apache::lonxml::curdepth;
                    971:     my %data=("imagechoice.$id.type"      =>'point',
                    972: 	      "imagechoice.$id.formname"  =>$form,
                    973: 	      "imagechoice.$id.formx"     =>"$idx$element",
                    974: 	      "imagechoice.$id.formy"     =>"$idy$element",
                    975: 	      "imagechoice.$id.file"      =>$bgfile,
                    976: 	      "imagechoice.$id.formcoord" =>$element);
1.49      www       977:     if ($height) {
1.80      albertel  978: 	$data{"imagechoice.$id.formheight"}=$height.'_'.
                    979: 	    $Apache::edit::bgimgsrccurdepth;
1.49      www       980:     }
                    981:     if ($width) {
1.80      albertel  982: 	$data{"imagechoice.$id.formwidth"}=$width.'_'.
                    983: 	    $Apache::edit::bgimgsrccurdepth;
1.49      www       984:     }
1.114     raeburn   985:     &Apache::lonnet::appenv(\%data);
1.80      albertel  986:     my $text="Click Coordinates";
                    987:     my $result='<a href="/adm/imagechoice?token='.$id.'" target="imagechoice">'.$text.'</a>';
1.49      www       988:     return $result;
                    989: }
                    990: 
1.77      albertel  991: # coordinates (x1,y1)-(x2,y2)...
                    992: # mode can be either box, or polygon
                    993: sub entercoord {
                    994:     my ($idx,$mode,$width,$height,$type) = @_;
1.49      www       995:     unless ($Apache::edit::bgimgsrc) { return ''; }
1.102     www       996:     my $bgfile=&escape(&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$Apache::edit::bgimgsrc));
1.75      albertel  997:     my $form    = 'lonhomework';
                    998:     my $element;
                    999:     if (! defined($mode) || $mode eq 'attribute') {
1.102     www      1000:         $element = &escape("$idx\_$Apache::lonxml::curdepth");
1.75      albertel 1001:     } elsif ($mode eq 'textnode') {  # for data between <tag> ... </tag>
1.102     www      1002:         $element = &escape('homework_edit_'.
1.75      albertel 1003:                                            $Apache::lonxml::curdepth);
                   1004:     }
1.76      albertel 1005:     my $id=$Apache::lonxml::curdepth;
1.77      albertel 1006:     my %data=("imagechoice.$id.type"      =>$type,
1.76      albertel 1007: 	      "imagechoice.$id.formname"  =>$form,
                   1008: 	      "imagechoice.$id.file"      =>$bgfile,
                   1009: 	      "imagechoice.$id.formcoord" =>$element);
1.75      albertel 1010:     if ($height) {
1.76      albertel 1011: 	$data{"imagechoice.$id.formheight"}=$height.'_'.
                   1012: 	    $Apache::edit::bgimgsrccurdepth;
1.75      albertel 1013:     }
                   1014:     if ($width) {
1.76      albertel 1015: 	$data{"imagechoice.$id.formwidth"}=$width.'_'.
                   1016: 	    $Apache::edit::bgimgsrccurdepth;
1.75      albertel 1017:     }
1.114     raeburn  1018:     &Apache::lonnet::appenv(\%data);
1.77      albertel 1019:     my $text="Enter Coordinates";
                   1020:     if ($type eq 'polygon') { $text='Create Polygon Data'; }
                   1021:     my $result='<a href="/adm/imagechoice?token='.$id.'" target="imagechoice">'.$text.'</a>';
1.49      www      1022:     return $result;
                   1023: }
1.76      albertel 1024: 
                   1025: sub deletecoorddata {
                   1026:     &Apache::lonnet::delenv("imagechoice\\.");
                   1027: }
                   1028: 
1.29      matthew  1029: #----------------------------------------------------- browse
                   1030: sub browse {
                   1031:     # insert a link to call up the filesystem browser (lonindexer)
1.107     banghart 1032:     my ($id, $mode, $titleid, $only) = @_;
1.29      matthew  1033:     my $form    = 'lonhomework';
1.42      matthew  1034:     my $element;
                   1035:     if (! defined($mode) || $mode eq 'attribute') {
1.102     www      1036:         $element = &escape("$id\_$Apache::lonxml::curdepth");
1.42      matthew  1037:     } elsif ($mode eq 'textnode') {  # for data between <tag> ... </tag>
1.102     www      1038:         $element = &escape('homework_edit_'.
1.68      albertel 1039:                                            $Apache::lonxml::curdepth);	
                   1040:     }
                   1041:     my $titleelement;
                   1042:     if ($titleid) {
1.107     banghart 1043: 	$titleelement=",'$only','','".&escape("$titleid\_$Apache::lonxml::curdepth")."'";
1.108     banghart 1044:     } else {
                   1045:         $titleelement=",'$only'";
1.42      matthew  1046:     }
1.29      matthew  1047:     my $result = <<"ENDBUTTON";
1.68      albertel 1048: <a href=\"javascript:openbrowser('$form','$element'$titleelement)\"\>Select</a>
1.29      matthew  1049: ENDBUTTON
                   1050:     return $result;
                   1051: }
                   1052: 
1.30      matthew  1053: #----------------------------------------------------- browse
                   1054: sub search {
                   1055:     # insert a link to call up the filesystem browser (lonindexer)
1.68      albertel 1056:     my ($id, $mode, $titleid) = @_;
1.30      matthew  1057:     my $form    = 'lonhomework';
1.49      www      1058:     my $element;
                   1059:     if (! defined($mode) || $mode eq 'attribute') {
1.102     www      1060:         $element = &escape("$id\_$Apache::lonxml::curdepth");
1.49      www      1061:     } elsif ($mode eq 'textnode') {  # for data between <tag> ... </tag>
1.102     www      1062:         $element = &escape('homework_edit_'.
1.49      www      1063:                                            $Apache::lonxml::curdepth);
                   1064:     }
1.68      albertel 1065:     my $titleelement;
                   1066:     if ($titleid) {
1.102     www      1067: 	$titleelement=",'".&escape("$titleid\_$Apache::lonxml::curdepth")."'";
1.68      albertel 1068:     }
1.30      matthew  1069:     my $result = <<"ENDBUTTON";
1.68      albertel 1070: <a href=\"javascript:opensearcher('$form','$element'$titleelement)\"\>Search</a>
1.30      matthew  1071: ENDBUTTON
                   1072:     return $result;
                   1073: }
                   1074: 
                   1075: 
1.1       albertel 1076: 1;
                   1077: __END__
1.26      harris41 1078: 
                   1079: 

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