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

1.1       albertel    1: # The LearningOnline Network with CAPA 
                      2: # edit mode helpers
1.25      albertel    3: #
1.124   ! bisitz      4: # $Id: edit.pm,v 1.123 2009/06/28 19:40:41 www 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">';
1.124   ! bisitz    205:     $result.='<table bgcolor="'.$color.'" width="97%" border="0" cellspacing="3" cellpadding="2">';
1.63      albertel  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.124   ! bisitz    233: sub start_spanning_row { return '<tr><td colspan="5" bgcolor="#F0F0F0">';}
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: 
1.123     www       615: sub insert_reactionhint {
                    616:     return '
                    617: <reactionhint>
                    618: </reactionhint>';
                    619: }
                    620: 
                    621: sub insert_organichint {
                    622:     return '
                    623: <organichint>
                    624: </organichint>';
                    625: }
                    626: 
1.46      albertel  627: sub insert_stringhint {
1.63      albertel  628:     return '
1.46      albertel  629: <stringhint>
                    630: </stringhint>';
                    631: }
                    632: 
                    633: sub insert_formulahint {
1.63      albertel  634:     return '
1.46      albertel  635: <formulahint>
                    636: </formulahint>';
1.37      albertel  637: }
                    638: 
                    639: sub insert_radiobuttonhint {
1.63      albertel  640:     return '
1.37      albertel  641: <radiobuttonhint>
                    642: </radiobuttonhint>';
1.50      albertel  643: }
                    644: 
                    645: sub insert_optionhint {
1.63      albertel  646:     return '
1.50      albertel  647: <optionhint>
                    648: </optionhint>';
1.22      albertel  649: }
1.21      albertel  650: 
1.23      albertel  651: sub insert_startouttext {
1.78      www       652:     return "<startouttext /><endouttext />";
1.23      albertel  653: }
                    654: 
                    655: sub insert_script {
1.78      www       656:     return "\n<script type=\"loncapa/perl\"></script>";
1.23      albertel  657: }
                    658: 
1.98      albertel  659: sub js_change_detection {
                    660:     my $unsaved=&mt("There are unsaved changes");
                    661:     return (<<SCRIPT);
                    662: <script type="text/javascript">
                    663: var clean = true;
                    664: var is_submit = false;
1.99      albertel  665: var still_ask = false;
1.98      albertel  666: function compareForm(event_) {
                    667:         if (!event_ && window.event) {
                    668:           event_ = window.event;
                    669:         }
1.99      albertel  670: 	if ((!is_submit || (is_submit && still_ask)) && !clean) {
                    671: 	    still_ask = false;
                    672: 	    is_submit = false;
1.98      albertel  673:             event_.returnValue = "$unsaved";
                    674:             return "$unsaved";
                    675:         }
                    676: }
                    677: function unClean() {
                    678:      clean=false;
                    679: }
                    680: window.onbeforeunload = compareForm;
                    681: </script>
                    682: SCRIPT
                    683: }
                    684: 
                    685: sub form_change_detection {
                    686:     return ' onsubmit="is_submit=true;" ';
                    687: }
                    688: 
                    689: sub element_change_detection {
                    690:     return ' onchange="unClean();" ';
                    691: }
                    692: 
1.99      albertel  693: sub submit_ask_anyway {
1.113     raeburn   694:     my ($extra_action) = @_;
                    695:     return ' onclick="still_ask=true;'.$extra_action.'" ';
1.99      albertel  696: }
                    697: 
1.25      albertel  698: sub textarea_sizes {
1.63      albertel  699:     my ($data)=@_;
                    700:     my $count=0;
                    701:     my $maxlength=-1;
                    702:     foreach (split ("\n", $$data)) {
                    703: 	$count+=int(length($_)/79);
                    704: 	$count++;
                    705: 	if (length($_) > $maxlength) { $maxlength = length($_); }
                    706:     }
                    707:     my $rows = $count;
                    708:     my $cols = $maxlength;
                    709:     return ($rows,$cols);
1.25      albertel  710: }
                    711: 
1.32      albertel  712: sub editline {
1.31      matthew   713:     my ($tag,$data,$description,$size)=@_;
1.81      albertel  714:     $data=&HTML::Entities::encode($data,'<>&"');
1.112     albertel  715:     if ($description) { $description=$description."<br />"; }
1.98      albertel  716:     my $change_code = &element_change_detection();
1.31      matthew   717:     my $result = <<"END";
                    718: $description
                    719: <input type="text" name="homework_edit_$Apache::lonxml::curdepth" 
1.98      albertel  720:        value="$data" size="$size" $change_code />
1.31      matthew   721: END
                    722:     return $result;
                    723: }
                    724: 
1.2       albertel  725: sub editfield {
1.82      www       726:     my ($tag,$data,$description,$minwidth,$minheight,$usehtmlarea)=@_;
1.22      albertel  727: 
1.63      albertel  728:     my ($rows,$cols)=&textarea_sizes(\$data);
1.84      www       729:     if (&Apache::lonhtmlcommon::htmlareabrowser() &&
                    730: 	!&Apache::lonhtmlcommon::htmlareablocked()) {
                    731: 	$rows+=7;      # make room for HTMLarea
                    732: 	$minheight+=7; # make room for HTMLarea
                    733:     }
1.63      albertel  734:     if ($cols > 80) { $cols = 80; }
                    735:     if ($cols < $minwidth ) { $cols = $minwidth; }
                    736:     if ($rows < $minheight) { $rows = $minheight; }
1.112     albertel  737:     if ($description) { $description=$description."<br />"; }
1.82      www       738:     if ($usehtmlarea) {
1.101     albertel  739: 	&Apache::lonhtmlcommon::add_htmlareafields('homework_edit_'.
                    740: 						   $Apache::lonxml::curdepth);
1.82      www       741:     }
1.105     albertel  742:     # remove typesetting whitespace from between data and the end tag
                    743:     # to make the edit look prettier
                    744:     $data =~ s/\n?[ \t]*$//;
                    745: 
1.103     albertel  746:     return $description."\n".'<textarea style="width:100%" rows="'.$rows.
1.63      albertel  747: 	'" cols="'.$cols.'" name="homework_edit_'.
1.82      www       748: 	$Apache::lonxml::curdepth.'" id="homework_edit_'.
1.98      albertel  749: 	$Apache::lonxml::curdepth.'" '.&element_change_detection().'>'.
1.85      www       750: 	&HTML::Entities::encode($data,'<>&"').'</textarea>'.
                    751: 	($usehtmlarea?&Apache::lonhtmlcommon::spelllink('lonhomework',
                    752: 			 'homework_edit_'.$Apache::lonxml::curdepth):'')."\n";
1.2       albertel  753: }
                    754: 
                    755: sub modifiedfield {
1.70      albertel  756:     my ($endtag,$parser) = @_;
1.63      albertel  757:     my $result;
1.92      albertel  758:     $result=$env{"form.homework_edit_$Apache::lonxml::curdepth"};
1.70      albertel  759:     my $bodytext=&Apache::lonxml::get_all_text($endtag,$parser);
                    760:     # textareas throw away intial \n 
1.105     albertel  761:     if ($bodytext=~/^\n/) {
                    762: 	$result="\n".$result;
                    763:     }
                    764:     # if there is typesetting whitespace from between the data and the end tag
                    765:     # restore to keep the source looking pretty
                    766:     if ($bodytext =~ /(\n?[ \t]*)$/) {
                    767: 	$result .= $1;
                    768:     }
1.63      albertel  769:     return $result;
1.2       albertel  770: }
                    771: 
1.15      albertel  772: # Returns a 1 if the token has been modified and you should rebuild the tag
1.12      albertel  773: # side-effects, will modify the $token if new values are found
                    774: sub get_new_args {
1.61      albertel  775:     my ($token,$parstack,$safeeval,@args)=@_;
                    776:     my $rebuild=0;
                    777:     foreach my $arg (@args) {
1.63      albertel  778: 	#just want the string that it was set to
                    779: 	my $value=$token->[2]->{$arg};
                    780: 	my $element=&html_element_name($arg);
1.92      albertel  781: 	my $newvalue=$env{"form.$element"};
1.63      albertel  782: 	&Apache::lonxml::debug("for:$arg: cur is :$value: new is :$newvalue:");
                    783: 	if (defined($newvalue) && $value ne $newvalue) {
                    784: 	    if (ref($newvalue) eq 'ARRAY') {
                    785: 		$token->[2]->{$arg}=join(',',@$newvalue);
                    786: 	    } else {
                    787: 		$token->[2]->{$arg}=$newvalue;
                    788: 	    }
1.79      albertel  789: 	    $rebuild=1;
1.111     albertel  790: 	    # add new attributes to the of the attribute seq
                    791: 	    if (!grep { $arg eq $_ } (@{ $token->[3] })) {
                    792: 		push(@{ $token->[3] },$arg);
                    793: 	    }
1.79      albertel  794: 	} elsif (!defined($newvalue) && defined($value)) {
                    795: 	    delete($token->[2]->{$arg});
1.63      albertel  796: 	    $rebuild=1;
1.61      albertel  797: 	}
1.12      albertel  798:     }
1.63      albertel  799:     return $rebuild;
1.12      albertel  800: }
                    801: 
1.15      albertel  802: # looks for /> on start tags
1.12      albertel  803: sub rebuild_tag {
1.63      albertel  804:     my ($token) = @_;
                    805:     my $result;
                    806:     if ($token->[0] eq 'S') {
                    807: 	$result = '<'.$token->[1];
1.109     albertel  808: 	foreach my $attribute (@{ $token->[3] }) {
                    809: 	    my $value = $token->[2]{$attribute};
1.111     albertel  810: 	    next if ($value eq '');
1.109     albertel  811: 	    $value =~s/^\s+|\s+$//g;
                    812: 	    $value =~s/\"//g;
                    813: 	    &Apache::lonxml::debug("setting :$attribute: to  :$value:");
                    814: 	    $result.=' '.$attribute.'="'.$value.'"';
1.63      albertel  815: 	}
                    816: 	if ($token->[4] =~ m:/>$:) {
                    817: 	    $result.=' />';
                    818: 	} else {
                    819: 	    $result.='>';
                    820: 	}
                    821:     } elsif ( $token->[0] eq 'E' ) {
                    822: 	$result = '</'.$token->[1].'>';
1.12      albertel  823:     }
1.63      albertel  824:     return $result;
1.12      albertel  825: }
1.13      albertel  826: 
1.47      matthew   827: sub html_element_name {
                    828:     my ($name) = @_;
1.48      albertel  829:     return $name.'_'.$Apache::lonxml::curdepth;
                    830: }
                    831: 
                    832: sub hidden_arg {
                    833:     my ($name,$token) = @_;
                    834:     my $result;
                    835:     my $arg=$token->[2]{$name};
                    836:     $result='<input name="'.&html_element_name($name).
                    837: 	'" type="hidden" value="'.$arg.'" />';
1.61      albertel  838:     return $result;
                    839: }
                    840: 
                    841: sub checked_arg {
                    842:     my ($description,$name,$list,$token) = @_;
                    843:     my $result;
                    844:     my $optionlist="";
                    845:     my $allselected=$token->[2]{$name};
1.71      www       846:     $result=&mt($description);
1.61      albertel  847:     foreach my $option (@$list) {
                    848: 	my ($value,$text);
                    849: 	if ( ref($option) eq 'ARRAY') {
                    850: 	    $value='value="'.$$option[0].'"';
                    851: 	    $text=$$option[1];
                    852: 	    $option=$$option[0];
                    853: 	} else {
                    854: 	    $text=$option;
                    855: 	    $value='value="'.$option.'"';
                    856: 	}
1.119     raeburn   857: 	$result.='<span class="LC_nobreak"><label><input type="checkbox" '.$value.' name="'.
                    858: 	    &html_element_name($name).'"';
1.61      albertel  859: 	foreach my $selected (split(/,/,$allselected)) {
                    860: 	    if ( $selected eq $option ) {
1.119     raeburn   861: 		$result.=' checked="checked" ';
1.61      albertel  862: 		last;
                    863: 	    }
                    864: 	}
1.119     raeburn   865: 	$result.=&element_change_detection().' />'.$text.'</label></span>'."\n";
1.61      albertel  866:     }
1.48      albertel  867:     return $result;
1.47      matthew   868: }
                    869: 
1.13      albertel  870: sub text_arg {
1.63      albertel  871:     my ($description,$name,$token,$size) = @_;
                    872:     my $result;
                    873:     if (!defined $size) { $size=20; }
                    874:     my $arg=$token->[2]{$name};
1.71      www       875:     $result=&mt($description).'&nbsp;<input name="'.&html_element_name($name).
1.98      albertel  876: 	'" type="text" value="'.$arg.'" size="'.$size.'" '.
                    877: 	&element_change_detection().'/>';
1.119     raeburn   878:     return '<span class="LC_nobreak">'.$result.'</span>';
1.13      albertel  879: }
                    880: 
                    881: sub select_arg {
1.39      albertel  882:     my ($description,$name,$list,$token) = @_;
                    883:     my $result;
                    884:     my $optionlist="";
                    885:     my $selected=$token->[2]{$name};
1.121     raeburn   886:     if (ref($list) eq 'ARRAY') {
                    887:         foreach my $option (@{$list}) {
                    888: 	    my ($text,$value);
                    889: 	    if (ref($option) eq 'ARRAY') {
                    890: 	        $value='value="'.&HTML::Entities::encode($option->[0]).'"';
                    891: 	        $text=$option->[1];
                    892: 	        $option=$option->[0];
                    893: 	    } else {
                    894: 	        $text=$option;
                    895: 	        $value='value="'.&HTML::Entities::encode($option,'\'"&<>').'"';
                    896: 	    }
                    897: 	    if ( $selected eq $option ) {
                    898: 	        $optionlist.="<option $value selected=\"selected\">".&mt($text)."</option>\n";
                    899: 	    } else {
                    900: 	        $optionlist.="<option $value >".&mt($text)."</option>\n";
                    901: 	    }
                    902:         }
1.13      albertel  903:     }
1.120     bisitz    904:     $result.='<span class="LC_nobreak">'.&mt($description).'&nbsp;<select name="'.
1.98      albertel  905: 	&html_element_name($name).'" '.&element_change_detection().' >
1.13      albertel  906:        '.$optionlist.'
1.119     raeburn   907:       </select></span>';
1.39      albertel  908:     return $result;
1.13      albertel  909: }
                    910: 
1.19      albertel  911: sub select_or_text_arg {
1.39      albertel  912:     my ($description,$name,$list,$token,$size) = @_;
                    913:     my $result;
                    914:     my $optionlist="";
                    915:     my $found=0;
                    916:     my $selected=$token->[2]{$name};
1.121     raeburn   917:     if (ref($list) eq 'ARRAY') {
                    918:         foreach my $option (@{$list}) {
                    919: 	    my ($text,$value);
                    920: 	    if (ref($option) eq 'ARRAY') {
                    921: 	        $value='value="'.&HTML::Entities::encode($option->[0]).'"';
                    922: 	        $text=$option->[1];
                    923: 	        $option=$option->[0];
                    924: 	    } else {
                    925: 	        $text=$option;
                    926: 	        $value='value="'.&HTML::Entities::encode($option,'\'"&<>').'"';
                    927: 	    }
                    928: 	    if ( $selected eq $option ) {
                    929: 	        $optionlist.="<option $value selected=\"selected\">$text</option>\n";
                    930: 	        $found=1;
                    931: 	    } else {
                    932: 	        $optionlist.="<option $value>$text</option>\n";
                    933: 	    }
                    934:         }
1.39      albertel  935:     }
1.60      www       936:     $optionlist.="<option value=\"TYPEDINVALUE\"".
1.88      albertel  937:  	((!$found)?' selected="selected"':'').
1.73      www       938:  	">".&mt('Type-in value')."</option>\n";
1.60      www       939: #
1.98      albertel  940:     my $change_code=&element_change_detection();
1.60      www       941:     my $element=&html_element_name($name);
                    942:     my $selectelement='select_list_'.$element;
                    943:     my $typeinelement='type_in_'.$element;
                    944:     my $typeinvalue=($found?'':$selected);
                    945: #
                    946:     my $hiddenvalue='this.form.'.$element.'.value';
                    947:     my $selectedindex='this.form.'.$selectelement.'.selectedIndex';
                    948:     my $selectedvalue='this.form.'.$selectelement.
                    949: 	     '.options['.$selectedindex.'].value';
                    950:     my $typedinvalue='this.form.'.$typeinelement.'.value';
                    951:     my $selecttypeinindex='this.form.'.$selectelement.'.options.length';
1.71      www       952:     $description=&mt($description);
1.60      www       953: #
                    954:     return (<<ENDSELECTORTYPE);
1.119     raeburn   955: <span class="LC_nobreak">
1.60      www       956: $description
                    957: &nbsp;<select name="$selectelement"
1.74      albertel  958: onChange="if ($selectedvalue!='TYPEDINVALUE') { $hiddenvalue=$selectedvalue; $typedinvalue=''; }" >
1.60      www       959: $optionlist
                    960: </select>
                    961: <input type="text" size="$size" name="$typeinelement"
                    962:        value="$typeinvalue" 
                    963: onChange="$hiddenvalue=$typedinvalue;"
                    964: onFocus="$selectedindex=$selecttypeinindex-1;" />
1.98      albertel  965: <input type="hidden" name="$element" value="$selected" $change_code />
1.119     raeburn   966: </span>
1.60      www       967: ENDSELECTORTYPE
1.19      albertel  968: }
1.29      matthew   969: 
1.49      www       970: #----------------------------------------------------- image coordinates
                    971: # single image coordinates, x, y 
                    972: sub entercoords {
1.80      albertel  973:     my ($idx,$idy,$mode,$width,$height) = @_;
1.49      www       974:     unless ($Apache::edit::bgimgsrc) { return ''; }
                    975:     if ($idx) { $idx.='_'; }
                    976:     if ($idy) { $idy.='_'; }
1.102     www       977:     my $bgfile=&escape(&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$Apache::edit::bgimgsrc));
1.49      www       978:     my $form    = 'lonhomework';
                    979:     my $element;
                    980:     if (! defined($mode) || $mode eq 'attribute') {
1.102     www       981:         $element = &escape("$Apache::lonxml::curdepth");
1.49      www       982:     } elsif ($mode eq 'textnode') {  # for data between <tag> ... </tag>
1.102     www       983:         $element = &escape('homework_edit_'.
1.49      www       984:                                            $Apache::lonxml::curdepth);
                    985:     }
1.80      albertel  986:     my $id=$Apache::lonxml::curdepth;
                    987:     my %data=("imagechoice.$id.type"      =>'point',
                    988: 	      "imagechoice.$id.formname"  =>$form,
                    989: 	      "imagechoice.$id.formx"     =>"$idx$element",
                    990: 	      "imagechoice.$id.formy"     =>"$idy$element",
                    991: 	      "imagechoice.$id.file"      =>$bgfile,
                    992: 	      "imagechoice.$id.formcoord" =>$element);
1.49      www       993:     if ($height) {
1.80      albertel  994: 	$data{"imagechoice.$id.formheight"}=$height.'_'.
                    995: 	    $Apache::edit::bgimgsrccurdepth;
1.49      www       996:     }
                    997:     if ($width) {
1.80      albertel  998: 	$data{"imagechoice.$id.formwidth"}=$width.'_'.
                    999: 	    $Apache::edit::bgimgsrccurdepth;
1.49      www      1000:     }
1.114     raeburn  1001:     &Apache::lonnet::appenv(\%data);
1.80      albertel 1002:     my $text="Click Coordinates";
                   1003:     my $result='<a href="/adm/imagechoice?token='.$id.'" target="imagechoice">'.$text.'</a>';
1.49      www      1004:     return $result;
                   1005: }
                   1006: 
1.77      albertel 1007: # coordinates (x1,y1)-(x2,y2)...
                   1008: # mode can be either box, or polygon
                   1009: sub entercoord {
                   1010:     my ($idx,$mode,$width,$height,$type) = @_;
1.49      www      1011:     unless ($Apache::edit::bgimgsrc) { return ''; }
1.102     www      1012:     my $bgfile=&escape(&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$Apache::edit::bgimgsrc));
1.75      albertel 1013:     my $form    = 'lonhomework';
                   1014:     my $element;
                   1015:     if (! defined($mode) || $mode eq 'attribute') {
1.102     www      1016:         $element = &escape("$idx\_$Apache::lonxml::curdepth");
1.75      albertel 1017:     } elsif ($mode eq 'textnode') {  # for data between <tag> ... </tag>
1.102     www      1018:         $element = &escape('homework_edit_'.
1.75      albertel 1019:                                            $Apache::lonxml::curdepth);
                   1020:     }
1.76      albertel 1021:     my $id=$Apache::lonxml::curdepth;
1.77      albertel 1022:     my %data=("imagechoice.$id.type"      =>$type,
1.76      albertel 1023: 	      "imagechoice.$id.formname"  =>$form,
                   1024: 	      "imagechoice.$id.file"      =>$bgfile,
                   1025: 	      "imagechoice.$id.formcoord" =>$element);
1.75      albertel 1026:     if ($height) {
1.76      albertel 1027: 	$data{"imagechoice.$id.formheight"}=$height.'_'.
                   1028: 	    $Apache::edit::bgimgsrccurdepth;
1.75      albertel 1029:     }
                   1030:     if ($width) {
1.76      albertel 1031: 	$data{"imagechoice.$id.formwidth"}=$width.'_'.
                   1032: 	    $Apache::edit::bgimgsrccurdepth;
1.75      albertel 1033:     }
1.114     raeburn  1034:     &Apache::lonnet::appenv(\%data);
1.77      albertel 1035:     my $text="Enter Coordinates";
                   1036:     if ($type eq 'polygon') { $text='Create Polygon Data'; }
                   1037:     my $result='<a href="/adm/imagechoice?token='.$id.'" target="imagechoice">'.$text.'</a>';
1.49      www      1038:     return $result;
                   1039: }
1.76      albertel 1040: 
                   1041: sub deletecoorddata {
1.122     raeburn  1042:     &Apache::lonnet::delenv('imagechoice.');
1.76      albertel 1043: }
                   1044: 
1.29      matthew  1045: #----------------------------------------------------- browse
                   1046: sub browse {
                   1047:     # insert a link to call up the filesystem browser (lonindexer)
1.107     banghart 1048:     my ($id, $mode, $titleid, $only) = @_;
1.29      matthew  1049:     my $form    = 'lonhomework';
1.42      matthew  1050:     my $element;
                   1051:     if (! defined($mode) || $mode eq 'attribute') {
1.102     www      1052:         $element = &escape("$id\_$Apache::lonxml::curdepth");
1.42      matthew  1053:     } elsif ($mode eq 'textnode') {  # for data between <tag> ... </tag>
1.102     www      1054:         $element = &escape('homework_edit_'.
1.68      albertel 1055:                                            $Apache::lonxml::curdepth);	
                   1056:     }
                   1057:     my $titleelement;
                   1058:     if ($titleid) {
1.107     banghart 1059: 	$titleelement=",'$only','','".&escape("$titleid\_$Apache::lonxml::curdepth")."'";
1.108     banghart 1060:     } else {
                   1061:         $titleelement=",'$only'";
1.42      matthew  1062:     }
1.29      matthew  1063:     my $result = <<"ENDBUTTON";
1.68      albertel 1064: <a href=\"javascript:openbrowser('$form','$element'$titleelement)\"\>Select</a>
1.29      matthew  1065: ENDBUTTON
                   1066:     return $result;
                   1067: }
                   1068: 
1.30      matthew  1069: #----------------------------------------------------- browse
                   1070: sub search {
                   1071:     # insert a link to call up the filesystem browser (lonindexer)
1.68      albertel 1072:     my ($id, $mode, $titleid) = @_;
1.30      matthew  1073:     my $form    = 'lonhomework';
1.49      www      1074:     my $element;
                   1075:     if (! defined($mode) || $mode eq 'attribute') {
1.102     www      1076:         $element = &escape("$id\_$Apache::lonxml::curdepth");
1.49      www      1077:     } elsif ($mode eq 'textnode') {  # for data between <tag> ... </tag>
1.102     www      1078:         $element = &escape('homework_edit_'.
1.49      www      1079:                                            $Apache::lonxml::curdepth);
                   1080:     }
1.68      albertel 1081:     my $titleelement;
                   1082:     if ($titleid) {
1.102     www      1083: 	$titleelement=",'".&escape("$titleid\_$Apache::lonxml::curdepth")."'";
1.68      albertel 1084:     }
1.30      matthew  1085:     my $result = <<"ENDBUTTON";
1.68      albertel 1086: <a href=\"javascript:opensearcher('$form','$element'$titleelement)\"\>Search</a>
1.30      matthew  1087: ENDBUTTON
                   1088:     return $result;
                   1089: }
                   1090: 
                   1091: 
1.1       albertel 1092: 1;
                   1093: __END__
1.26      harris41 1094: 
                   1095: 

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