Annotation of loncom/homework/structuretags.pm, revision 1.281
1.34 albertel 1: # The LearningOnline Network with CAPA
2: # definition of tags that give a structure to a document
1.74 albertel 3: #
1.281 ! albertel 4: # $Id: structuretags.pm,v 1.280 2005/02/25 04:56:05 albertel Exp $
1.74 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.254 www 28: ###
1.54 www 29:
1.133 sakharuk 30:
1.1 albertel 31: package Apache::structuretags;
32:
33: use strict;
34: use Apache::lonnet;
1.101 sakharuk 35: use Apache::File();
1.147 www 36: use Apache::lonmenu;
1.210 albertel 37: use Apache::lonlocal;
1.231 sakharuk 38: use Apache::lonxml;
1.267 albertel 39: use Time::HiRes qw( gettimeofday tv_interval );
1.78 harris41 40: BEGIN {
1.248 albertel 41: &Apache::lonxml::register('Apache::structuretags',('block','languageblock','instructorcomment','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','problemtype','startouttext','endouttext','simpleeditbutton','definetag'));
1.10 albertel 42: }
43:
44: sub start_web {
1.159 albertel 45: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.200 albertel 46: my $bodytext=&Apache::lonxml::get_all_text("/web",$parser);
47: if ($target eq 'web') {
48: return $bodytext;
1.159 albertel 49: }
50: return '';
1.10 albertel 51: }
52:
53: sub end_web {
1.44 ng 54: return '';
1.10 albertel 55: }
56:
57: sub start_tex {
1.159 albertel 58: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.198 sakharuk 59: my $result='';
1.200 albertel 60: my $bodytext=&Apache::lonxml::get_all_text("/tex",$parser);
61: if ($target eq 'tex') {
62: return $bodytext.' ';
1.159 albertel 63: }
1.198 sakharuk 64: return $result;;
1.10 albertel 65: }
66:
67: sub end_tex {
1.44 ng 68: return '';
1.9 albertel 69: }
70:
1.48 albertel 71: sub page_start {
1.159 albertel 72: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
73: my %found;
1.207 albertel 74: foreach my $taginside (@$tagstack) {
1.159 albertel 75: foreach my $taglookedfor ('html','body','form') {
76: if ($taginside =~ /^$taglookedfor$/i) {$found{$taglookedfor} = 1;}
77: }
78: }
79:
80: my $result;
81: my $head_tag_start;
82: if (!defined($found{'html'})) {
83: $result=&Apache::londefdef::start_html($target,$token,$tagstack,
84: $parstack,$parser,$safeeval);
1.254 www 85: $head_tag_start='<head>'.&Apache::lonmenu::registerurl(undef,$target).
1.261 www 86: &Apache::lonhtmlcommon::htmlareaheaders().
1.270 albertel 87: &Apache::lonhtmlcommon::spellheader().
88: &Apache::lonxml::fontsettings();
1.159 albertel 89: }
90: my $body_tag_start;
1.272 albertel 91: if (!defined($found{'body'}) && $ENV{'request.state'} eq 'construct'
92: && $ENV{'environment.remote'} eq 'off') {
93: $body_tag_start=&Apache::loncommon::bodytag();
1.274 albertel 94: $body_tag_start.=&Apache::lonxml::message_location();
1.272 albertel 95: } elsif (!defined($found{'body'})) {
1.270 albertel 96: $body_tag_start='<body onload="'.&Apache::lonmenu::loadevents().'" '.
97: 'onunload="'.&Apache::lonmenu::unloadevents().'" ';
1.159 albertel 98: my $background=&Apache::lonxml::get_param('background',$parstack,
99: $safeeval);
1.199 www 100: if ($ENV{'browser.imagesuppress'} eq 'on') { $background=''; }
1.159 albertel 101: if ($background) {
102: $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
103: $background;
104: $body_tag_start.='background="'.$background.'" ';
105: } else {
106: my $bgcolor=&Apache::lonxml::get_param('bgcolor',$parstack,
107: $safeeval);
1.199 www 108: if (($bgcolor) && ($ENV{'browser.blackwhite'} ne 'on')) {
1.159 albertel 109: $body_tag_start.='bgcolor="'.$bgcolor.'" ';
110: } else {
111: $body_tag_start.='bgcolor="#ffffff"';
112: }
1.199 www 113: }
114: if ($ENV{'browser.fontenhance'} eq 'on') {
115: $body_tag_start.=' style="font-size: x-large;" ';
1.159 albertel 116: }
117: $body_tag_start.='>'.&Apache::lonmenu::menubuttons(undef,$target,1);
1.281 ! albertel 118: if ($ENV{'environment.texengine'} eq 'jsMath') {
! 119: $body_tag_start.='<script type="text/javascript">
! 120: function NoFontMessage () {}
! 121: </script>'."\n".
! 122: '<script src="/adm/jsMath/jsMath.js"></script>'."\n";
! 123: }
1.159 albertel 124: if ($target eq 'web' && $ENV{'request.state'} ne 'construct') {
1.165 albertel 125: my ($symb,undef,undef,undef,$publicuser)=
126: &Apache::lonxml::whichuser();
127: if ($symb eq '' && !$publicuser) {
1.159 albertel 128: my $help = &Apache::loncommon::help_open_topic("Ambiguous_Reference");
1.211 albertel 129: $help=&mt("Browsing resource, all submissions are temporary.")."<br />";
1.159 albertel 130: $body_tag_start.=$help;
131: }
132: }
1.245 albertel 133: $body_tag_start.=&Apache::lonxml::message_location();
1.159 albertel 134: }
135: my $form_tag_start;
136: if (!defined($found{'form'})) {
1.281 ! albertel 137: $form_tag_start='<form name="lonhomework" enctype="multipart/form-data" method="POST" action="';
1.271 albertel 138: my $uri=$ENV{'request.uri'};
139: if ($ENV{'request.enc'}) { $uri=&Apache::lonenc::encrypted($uri); }
140: $form_tag_start.=$uri.'">';
1.159 albertel 141: }
142: return ($result,$head_tag_start,$body_tag_start,$form_tag_start);
1.105 albertel 143: }
144:
1.141 matthew 145: #use Time::HiRes();
1.105 albertel 146: sub get_resource_name {
1.159 albertel 147: my ($parstack,$safeeval)=@_;
1.204 albertel 148: if (defined($Apache::lonhomework::name)) {
149: return $Apache::lonhomework::name;
150: }
1.279 albertel 151: my ($symb)=&Apache::lonxml::whichuser();
152: my $name=&Apache::lonnet::gettitle($symb);
1.159 albertel 153: if ($name eq '') {
154: $name=&Apache::lonnet::EXT('resource.title');
155: if ($name eq 'con_lost') { $name = ''; }
156: }
1.204 albertel 157: if ($name!~/\S+/) {
158: $name=$ENV{'request.uri'};
1.205 albertel 159: $name=~s-.*/([^/]+)$-$1-;
1.204 albertel 160: }
1.159 albertel 161: $Apache::lonhomework::name=$name;
162: return $name;
1.105 albertel 163: }
164:
165: sub setup_rndseed {
1.159 albertel 166: my ($safeeval)=@_;
167: my $rndseed;
1.162 albertel 168: my ($symb)=&Apache::lonxml::whichuser();
1.247 albertel 169: if ($ENV{'request.state'} eq "construct" || $symb eq '' ||
170: $Apache::lonhomework::history{'resource.CODE'}) {
1.159 albertel 171: $rndseed=$ENV{'form.rndseed'};
172: if (!$rndseed) {
1.162 albertel 173: $rndseed=$Apache::lonhomework::history{'rndseed'};
174: if (!$rndseed) {
175: $rndseed=time;
176: }
1.237 albertel 177: $ENV{'form.rndseed'}=$rndseed;
1.162 albertel 178: }
1.210 albertel 179: if ($ENV{'form.resetdata'} eq &mt('New Problem Variation') ||
180: $ENV{'form.newrandomization'} eq &mt('New Randomization')) {
1.190 albertel 181: srand(time);
182: $rndseed=int(rand(2100000000));
1.159 albertel 183: $ENV{'form.rndseed'}=$rndseed;
1.180 albertel 184: delete($ENV{'form.resetdata'});
185: delete($ENV{'form.newrandomization'});
1.159 albertel 186: }
1.187 albertel 187: if (defined($rndseed) && $rndseed ne int($rndseed)) {
188: $rndseed=join(',',&Math::Random::random_seed_from_phrase($rndseed));
189: }
1.247 albertel 190: if ($Apache::lonhomework::history{'resource.CODE'}) {
191: $rndseed=&Apache::lonnet::rndseed();
192: }
1.221 albertel 193: if ($safeeval) {
194: &Apache::lonxml::debug("Setting rndseed to $rndseed");
1.250 albertel 195: &Apache::run::run('$external::randomseed="'.$rndseed.'";',$safeeval);
1.221 albertel 196: }
1.159 albertel 197: }
198: return $rndseed;
1.105 albertel 199: }
200:
1.268 albertel 201: sub remember_problem_state {
202: return '
203: <input type="hidden" name="problemstate" value="'.$ENV{'form.problemstate'}.'" />
204: <input type="hidden" name="problemtype" value="'.$ENV{'form.problemtype'}.'" />
205: <input type="hidden" name="problemstatus" value="'.$ENV{'form.problemstatus'}.'" />';
206: }
207:
1.105 albertel 208: sub problem_edit_header {
1.268 albertel 209: return '<input type="hidden" name="submitted" value="edit" />'.
210: &Apache::structuretags::remember_problem_state().'
1.210 albertel 211: <input type="hidden" name="problemmode" value="'.&mt('Edit').'" />
1.243 matthew 212: <input type="submit" name="problemmode" accesskey="d" value="'.&mt('Discard Edits and View').'" />
213: <input type="submit" name="problemmode" accesskey="x" value="'.&mt('EditXML').'" />
214: <input type="submit" name="Undo" accesskey="u" value="'.&mt('undo').'" /> <hr />
215: <input type="submit" name="submit" accesskey="s" value="'.&mt('Submit Changes and Edit').'" />
216: <input type="submit" name="submit" accesskey="v" value="'.&mt('Submit Changes and View').'" /><table><tr><td>'.
1.260 albertel 217: &Apache::loncommon::help_open_menu('','Problem Editing Help','Problem_Editor_XML_Index','',5,'Authoring',undef,undef,undef,'Problem Editing Help')
218: .'</td></tr></table>'.
1.228 www 219: '<table border="0"><tr><td bgcolor="#DDDDDD">';
1.105 albertel 220: }
221:
222: sub problem_edit_footer {
1.210 albertel 223: return '</td></tr></table><br /><input type="submit" name="submit" value="'.&mt('Submit Changes and Edit').'" />
1.255 www 224: <input type="submit" name="submit" value="'.&mt('Submit Changes and View').'" />'.
225: &Apache::lonhtmlcommon::htmlareaselectactive(@Apache::lonxml::htmlareafields).
1.280 albertel 226: "\n</form>\n".&Apache::loncommon::endbodytag()."\n</html>";
1.105 albertel 227: }
228:
1.235 albertel 229: sub option {
230: my ($value,$name) = @_;
231: my $result ="<option value='".$value."' ";
232: if ($ENV{'form.'.$name} eq $value) {
233: $result.=" selected='on' ";
234: }
235: $result.='>';
236: return $result;
237: }
238:
1.105 albertel 239: sub problem_web_to_edit_header {
1.159 albertel 240: my ($rndseed)=@_;
1.210 albertel 241: my $result.='<input type="hidden" name="problemmode" value="'.&mt('View').'" />
1.243 matthew 242: <input type="submit" name="problemmode" accesskey="e" value="'.&mt('Edit').'" />
243: <input type="submit" name="problemmode" accesskey="x" value="'.&mt('EditXML').'" />
244: <input type="submit" name="newrandomization" accesskey="a" value="'.&mt('New Randomization').'" />
245: <input type="submit" name="resetdata" accesskey="r" value="'.&mt('Reset Submissions').'" />
1.210 albertel 246: <nobr><input type="submit" name="changerandseed" value="'.&mt('Change Random Seed To:').'" />
1.270 albertel 247: <input type="text" name="rndseed" size="10" value="'.
1.175 albertel 248: $rndseed.'"
1.270 albertel 249: onchange="javascript:document.lonhomework.changerandseed.click()" /></nobr>
1.281 ! albertel 250: <label><input type="checkbox" name="showallfoils" ';
1.159 albertel 251: if (defined($ENV{'form.showallfoils'})) { $result.='checked="on"'; }
1.228 www 252: $result.= ' />'.&mt(' Show All Foils').
253: &Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems').
1.281 ! albertel 254: '</label><hr />';
1.235 albertel 255: $result.="
256: <nobr>
257: Problem Status:
258: <select name='problemstate'>
1.270 albertel 259: <option value=''></option>
1.235 albertel 260: ".&option('CLOSED' ,'problemstate').&mt("Closed")."</option>
261: ".&option('CAN_ANSWER' ,'problemstate').&mt("Answerable")."</option>
262: ".&option('CANNOT_ANSWER_tries' ,'problemstate').&mt("Open with full tries")."</option>
263: ".&option('CANNOT_ANSWER_correct','problemstate').&mt("Open and correct")."</option>
264: ".&option('SHOW_ANSWER' ,'problemstate').&mt("Show Answer")."</option>
265: </select>
266: </nobr>
267: <nobr>
268: Problem Type:
269: <select name='problemtype'>
1.270 albertel 270: <option value=''></option>
1.242 albertel 271: ".&option('exam' ,'problemtype').&mt("Exam Problem")."</option>
272: ".&option('problem','problemtype').&mt("Homework problem")."</option>
273: ".&option('survey' ,'problemtype').&mt("Survey Question")."</option>
1.235 albertel 274: </select>
275: </nobr>
276: <nobr>
277: Feedback Mode:
278: <select name='problemstatus'>
279: <option value=''></option>
1.242 albertel 280: ".&option('yes','problemstatus').&mt("Show Feedback")."</option>
281: ".&option('no', 'problemstatus').&mt("Don't Show Feedback")."</option>
1.235 albertel 282: </select>
283: </nobr>
1.242 albertel 284: <input type='submit' name='changeproblemmode' value='".&mt("Change")."' />
1.235 albertel 285: <hr />";
1.159 albertel 286: my $numtoanalyze=$ENV{'form.numtoanalyze'};
1.176 albertel 287: if (!$numtoanalyze) { $numtoanalyze=20; }
1.210 albertel 288: $result.= '<input type="submit" name="problemmode" value='.
289: &mt('"Calculate answers').'" /> for
1.136 albertel 290: <input type="text" name="numtoanalyze" value="'.
1.210 albertel 291: $numtoanalyze.'" size="5" /> '.&mt('versions of this problem').
292: '.'.&Apache::loncommon::help_open_topic("Analyze_Problem",
1.176 albertel 293: '',undef,undef,300).
1.210 albertel 294: '<hr />';
1.159 albertel 295: return $result;
1.48 albertel 296: }
297:
1.65 albertel 298: sub initialize_storage {
1.159 albertel 299: %Apache::lonhomework::results=();
1.162 albertel 300: %Apache::lonhomework::history=();
1.159 albertel 301: my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
1.162 albertel 302: if ($ENV{'request.state'} eq 'construct' || $symb eq '') {
1.159 albertel 303: %Apache::lonhomework::history=
304: &Apache::lonnet::tmprestore($ENV{'request.uri'},'',$domain,$name);
305: my ($temp)=keys %Apache::lonhomework::history ;
306: &Apache::lonxml::debug("Return message of $temp");
307: } else {
308: %Apache::lonhomework::history=
309: &Apache::lonnet::restore($symb,$courseid,$domain,$name);
310: }
311: #ignore error conditions
1.67 albertel 312: my ($temp)=keys %Apache::lonhomework::history ;
1.159 albertel 313: if ($temp =~ m/^error:.*/) { %Apache::lonhomework::history=(); }
1.65 albertel 314: }
315:
316: # -------------------------------------------------------------finalize_storage
317: # Stores away the result has to a student's environment
318: # checks form.grade_ for specific values, other wises stores
319: # to the running users environment
320: sub finalize_storage {
1.159 albertel 321: my $result;
322: my ($temp) = keys %Apache::lonhomework::results;
323: if ( $temp ne '' ) {
324: my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
1.162 albertel 325: if ($ENV{'request.state'} eq 'construct' || $symb eq '') {
326: $Apache::lonhomework::results{'rndseed'}=$ENV{'form.rndseed'};
1.159 albertel 327: $result=&Apache::lonnet::tmpstore(\%Apache::lonhomework::results,
328: $ENV{'request.uri'},'',$domain,$name);
329: &Apache::lonxml::debug('Construct Store return message:'.$result);
330: } else {
331: $result=&Apache::lonnet::cstore(\%Apache::lonhomework::results,
332: $symb,$courseid,$domain,$name);
333: &Apache::lonxml::debug('Store return message:'.$result);
334: }
1.67 albertel 335: }
1.159 albertel 336: return $result;
1.65 albertel 337: }
338:
339: sub checkout_msg {
1.211 albertel 340: my %lt=&Apache::lonlocal::texthash(
341: 'resource'=>'The resource needs to be checked out',
342: 'id_expln'=>'As a resource gets checked out, a unique timestamped ID is given to it, and a permanent record is left in the system.',
343: 'warning'=>'Checking out resources is subject to course policies, and may exclude future credit even if done erroneously.',
344: 'checkout'=>'Check out Exam for Viewing',
345: 'checkout?'=>'Check out Exam?');
1.159 albertel 346: return (<<ENDCHECKOUT);
1.211 albertel 347: <h2>$lt{'resource'}</h2>
348: <p>$lt{'id_expln'}</p>
349: <font color="red">
350: <p>$lt{'warning'}</p>
1.91 albertel 351: </font>
1.281 ! albertel 352: <form name="checkout" method="POST" action="$ENV{'request.uri'}">
1.91 albertel 353: <input type="hidden" name="doescheckout" value="yes" />
1.211 albertel 354: <input type="button" name="checkoutbutton" value="$lt{'checkout'}" onClick="javascript:if (confirm('$lt{'checkout?'}')) { document.checkout.submit(); }" />
1.65 albertel 355: </form>
356: ENDCHECKOUT
357: }
358:
1.252 albertel 359: sub firstaccess_msg {
1.253 albertel 360: my ($time,$symb)=@_;
361: my ($map)=&Apache::lonnet::decode_symb($symb);
362: my $foldertitle=&Apache::lonnet::gettitle($map);
363: &Apache::lonxml::debug("map is $map title is $foldertitle");
1.252 albertel 364: return (<<ENDCHECKOUT);
1.253 albertel 365: <h2>The resources in "$foldertitle" are open for a limited time. Once you click the 'Show Resource' button below you have $time to complete all resources "$foldertitle".</h2>
1.281 ! albertel 366: <form name="markaccess" method="POST" action="$ENV{'request.uri'}">
1.252 albertel 367: <input type="hidden" name="markaccess" value="yes" />
368: <input type="button" name="accessbutton" value="Show Resource" onClick="javascript:if (confirm('Start Timer?')) { document.markaccess.submit(); }" />
369: </form>
370: ENDCHECKOUT
371: }
372:
1.204 albertel 373: sub init_problem_globals {
374: my ($type)=@_;
375: #initialize globals
376: if ($type eq 'problem') {
377: $Apache::inputtags::part='0';
378: @Apache::inputtags::partlist=('0');
1.266 albertel 379: $Apache::lonhomework::problemstatus=&get_problem_status('0');
380: $Apache::lonhomework::ignore_response_errors=0;
381: } elsif ($type eq 'library') {
1.204 albertel 382: $Apache::inputtags::part='';
383: @Apache::inputtags::partlist=();
384: $Apache::lonhomework::problemstatus='';
1.266 albertel 385: $Apache::lonhomework::ignore_response_errors=1;
1.204 albertel 386: }
387: @Apache::inputtags::responselist = ();
388: @Apache::inputtags::importlist = ();
389: @Apache::inputtags::previous=();
390: @Apache::inputtags::previous_version=();
391: $Apache::structuretags::printanswer='No';
392: @Apache::structuretags::whileconds=();
393: @Apache::structuretags::whilebody=();
394: @Apache::structuretags::whileline=();
395: $Apache::lonhomework::scantronmode=0;
396: undef($Apache::lonhomework::name);
397:
398: }
399:
400: sub reset_problem_globals {
401: my ($type)=@_;
402: undef(%Apache::lonhomework::history);
403: undef(%Apache::lonhomework::results);
404: undef($Apache::inputtags::part);
1.208 albertel 405: #don't undef this, lonhomework.pm takes care of this, we use this to
406: #detect if we try to do 2 problems in one file
407: # undef($Apache::lonhomework::parsing_a_problem);
1.204 albertel 408: undef($Apache::lonhomework::name);
409: }
410:
1.241 albertel 411: sub set_problem_state {
1.240 albertel 412: my ($part)=@_;
413: if ($ENV{'form.problemstate'} eq 'CANNOT_ANSWER_correct') {
414: $Apache::lonhomework::history{"resource.$part.solved"}=
415: 'correct_by_student';
416: }
417: }
418:
1.241 albertel 419: sub get_problem_status {
420: my ($part)=@_;
1.267 albertel 421: my $problem_status;
1.241 albertel 422: if ($ENV{'request.state'} eq 'construct' &&
423: defined($ENV{'form.problemstatus'})) {
424: $problem_status=$ENV{'form.problemstatus'};
1.267 albertel 425: } else {
426: $problem_status=&Apache::lonnet::EXT("resource.$part.problemstatus");
427: &Apache::lonxml::debug("problem status for $part is $problem_status");
428: &Apache::lonxml::debug("env probstat is ".$ENV{'form.problemstatus'});
1.241 albertel 429: }
430: return $problem_status;
431: }
432:
1.9 albertel 433: sub start_problem {
1.159 albertel 434: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.19 albertel 435:
1.184 albertel 436: if ( $Apache::inputtags::part ne '' ||
437: $Apache::lonhomework::parsing_a_problem) {
438: &Apache::lonxml::error('Only one <problem> allowed in a .problem file');
439: #my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser);
1.159 albertel 440: return '';
441: }
1.184 albertel 442:
443: $Apache::lonhomework::parsing_a_problem=1;
1.204 albertel 444: &init_problem_globals('problem');
1.166 albertel 445:
446: if (defined($ENV{'scantron.maxquest'})) {
447: $Apache::lonhomework::scantronmode=1;
448: }
1.161 albertel 449:
1.246 albertel 450: &initialize_storage();
1.159 albertel 451: if ($target ne 'analyze') {
452: if ($target eq 'web') {
453: &Apache::lonhomework::showhash(%Apache::lonhomework::history);
1.238 albertel 454: }
1.241 albertel 455: if ($ENV{'request.state'} eq 'construct') { &set_problem_state('0'); }
1.159 albertel 456: $Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type');
1.237 albertel 457: if (($ENV{'request.state'} eq 'construct') &&
458: defined($ENV{'form.problemtype'})) {
459: $Apache::lonhomework::type=$ENV{'form.problemtype'};
460: }
1.240 albertel 461: &Apache::lonxml::debug("Found this to be of type :$Apache::ltonhomework::type:");
1.159 albertel 462: }
1.164 albertel 463: if ($Apache::lonhomework::type eq '' ) {
1.159 albertel 464: my $uri=$ENV{'request.uri'};
465: if ($uri=~/\.(\w+)$/) {
466: $Apache::lonhomework::type=$1;
467: &Apache::lonxml::debug("Using type of $1");
468: } else {
469: $Apache::lonhomework::type='problem';
470: &Apache::lonxml::debug("Using default type, problem, :$uri:");
471: }
1.87 albertel 472: }
1.58 www 473:
1.159 albertel 474: #added vars to the scripting enviroment
1.213 albertel 475: my $expression='$external::part=\''.$Apache::inputtags::part.'\';';
1.248 albertel 476: $expression.='$external::type=\''.$Apache::lonhomework::type.'\';';
1.24 albertel 477: &Apache::run::run($expression,$safeeval);
1.159 albertel 478: my $status;
479: my $accessmsg;
480:
481: #should get back a <html> or the neccesary stuff to start XML/MathML
482: my ($result,$head_tag_start,$body_tag_start,$form_tag_start)=
483: &page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
484: if ($target eq 'tex' and $ENV{'request.symb'} =~ m/\.page_/) {$result='';}
485:
486: if ($target eq 'analyze') { my $rndseed=&setup_rndseed($safeeval); }
487: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
488: $target eq 'tex') {
489: #handle exam checkout
490: if ($Apache::lonhomework::type eq 'exam') {
491: my $token=
492: $Apache::lonhomework::history{"resource.0.outtoken"};
493: if (($ENV{'form.doescheckout'}) && (!$token)) {
494: $token=&Apache::lonxml::maketoken();
495: $Apache::lonhomework::history{"resource.0.outtoken"}=
496: $token;
497: }
498: $body_tag_start.=&Apache::lonxml::printtokenheader($target,$token);
1.142 albertel 499: }
1.252 albertel 500: if ($ENV{'form.markaccess'}) {
501: &Apache::lonnet::set_first_access('map');
502: }
1.159 albertel 503: #handle rand seed in construction space
504: my $rndseed=&setup_rndseed($safeeval);
1.162 albertel 505: my ($symb)=&Apache::lonxml::whichuser();
1.163 albertel 506: if ($ENV{'request.state'} ne "construct" && $symb eq '') {
1.162 albertel 507: $form_tag_start.='<input type="hidden" name="rndseed" value="'.
508: $rndseed.'" />'.
509: '<input type="submit" name="resetdata"
1.211 albertel 510: value="'.&mt('New Problem Variation').'" />'.
1.164 albertel 511: '<input type="hidden" name="username"
1.267 albertel 512: value="'.$ENV{'form.username'}.'" />';
513: if ($ENV{'user.adv'}) {
514: $form_tag_start.=
515: ' <input type="checkbox" name="showallfoils" ';
516: if (defined($ENV{'form.showallfoils'})) {
517: $form_tag_start.='checked="on"';
518: }
519: $form_tag_start.= ' />'.&mt(' Show All Foils');
520: }
521: $form_tag_start.='<hr />';
1.162 albertel 522: }
1.159 albertel 523: ($status,$accessmsg) = &Apache::lonhomework::check_access('0');
524: push (@Apache::inputtags::status,$status);
525: my $expression='$external::datestatus="'.$status.'";';
526: $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.0.solved"}.'";';
527: &Apache::run::run($expression,$safeeval);
528: &Apache::lonxml::debug("Got $status");
529: if (( $status eq 'CLOSED' ) ||
530: ( $status eq 'UNCHECKEDOUT') ||
1.252 albertel 531: ( $status eq 'NOT_YET_VIEWED') ||
1.159 albertel 532: ( $status eq 'BANNED') ||
1.216 albertel 533: ( $status eq 'UNAVAILABLE') ||
534: ( $status eq 'INVALID_ACCESS')) {
1.159 albertel 535: my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser);
536: if ( $target eq "web" ) {
537: $result.= $head_tag_start.'</head>';
538: my $msg=$body_tag_start;
539: if ($status eq 'UNAVAILABLE') {
1.245 albertel 540: $msg.='<h1>'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'</h1>';
1.253 albertel 541: } elsif ($status ne 'NOT_YET_VIEWED') {
1.245 albertel 542: $msg.='<h1>'.&mt('Not open to be viewed').'</h1>';
1.159 albertel 543: }
1.216 albertel 544: if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') {
1.159 albertel 545: $msg.='The problem '.$accessmsg;
546: } elsif ($status eq 'UNCHECKEDOUT') {
547: $msg.=&checkout_msg;
1.252 albertel 548: } elsif ($status eq 'NOT_YET_VIEWED') {
1.253 albertel 549: $msg.=&firstaccess_msg($accessmsg,$symb);
1.159 albertel 550: }
551: $result.=$msg.'<br />';
552: } elsif ($target eq 'tex') {
553: $result.='\begin{document}\noindent \vskip 1 mm \begin{minipage}{\textwidth}\vskip 0 mm';
554: if ($status eq 'UNAVAILABLE') {
1.211 albertel 555: $result.=&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'\vskip 0 mm ';
1.159 albertel 556: } else {
1.211 albertel 557: $result.=&mt('Problem is not open to be viewed. It')." $accessmsg \\vskip 0 mm ";
1.159 albertel 558: }
559: }
560: } elsif ($target eq 'web') {
561: my $name= &get_resource_name($parstack,$safeeval);
1.227 albertel 562: $result.="$head_tag_start<title>$name</title></head>
1.158 sakharuk 563: $body_tag_start \n $form_tag_start".
1.227 albertel 564: '<input type="hidden" name="submitted" value="yes" />';
565: # create a page header and exit
566: if ($ENV{'request.state'} eq "construct") {
567: $result.= &problem_web_to_edit_header($ENV{'form.rndseed'});
568: }
569: # if we are viewing someone else preserve that info
570: if (defined $ENV{'form.grade_symb'}) {
571: foreach my $field ('symb','courseid','domain','username') {
572: $result .= '<input type="hidden" name="grade_'.$field.
573: '" value="'.$ENV{"form.grade_$field"}.'" />'."\n";
1.159 albertel 574: }
575: }
576: } elsif ($target eq 'tex') {
1.192 sakharuk 577: my $startminipage = '';
1.191 sakharuk 578: if (not $ENV{'form.problem_split'}=~/yes/) {
1.192 sakharuk 579: $startminipage = '\begin{minipage}{\textwidth}';
1.178 sakharuk 580: }
1.159 albertel 581: my $id = $Apache::inputtags::part;
582: my $weight = &Apache::lonnet::EXT("resource.$id.weight");
1.223 sakharuk 583: my $packages=&Apache::lonnet::metadata($ENV{'request.uri'},'packages');
584: my @packages = split /,/,$packages;
585: my $allow_print_points = 0;
586: foreach my $partial_key (@packages) {
1.230 albertel 587: if ($partial_key=~m/^part_0$/) {
1.223 sakharuk 588: $allow_print_points=1;
1.159 albertel 589: }
590: }
1.276 albertel 591: my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
592: if (defined($maxtries) && $maxtries < 0) { $allow_print_points=0; }
1.159 albertel 593: my $duedate = &Apache::lonnet::EXT("resource.$id.duedate");
594: $duedate = POSIX::strftime("%c",localtime($duedate));
595: my $temp_file;
596: my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.due";
597: if (-e $filename) {
598: $temp_file = Apache::File->new($filename);
599: } else {
600: $temp_file = Apache::File->new('>>'.$filename);
601: }
602: my @due_file_content = <$temp_file>;
603: my $due_file_content = $due_file_content[$#due_file_content];
604: chomp $due_file_content;
1.257 sakharuk 605: my $name_of_resourse= &Apache::lonxml::latex_special_symbols(&get_resource_name($parstack,$safeeval),'header');
1.159 albertel 606: if ($due_file_content ne $duedate) {
607: $temp_file = Apache::File->new('>'.$filename);
608: print $temp_file "$duedate\n";
609: if (not $ENV{'request.symb'} =~ m/\.page_/) {
610: if(not $duedate=~m/1969/ and $Apache::lonhomework::type ne 'exam') {
1.206 sakharuk 611: $result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$ENV{'request.uri'}.'</b></small><br /> STAMPOFPASSEDRESOURCEEND} \noindent\textit{Due date: '.$duedate.'} \vskip 1 mm\noindent '.$startminipage.'\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';
1.159 albertel 612: } else {
1.206 sakharuk 613: $result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$ENV{'request.uri'}.'</b></small><br /> STAMPOFPASSEDRESOURCEEND} \noindent \vskip 1 mm \noindent'.$startminipage.'\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';
1.159 albertel 614: if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { $result .= '\fbox{\textit{'.$weight.' pt}}';}
615: }
1.104 sakharuk 616: } else {
1.159 albertel 617: $result .= '\vskip 1mm\textit{Due date: '.$duedate.'} \\\\\\\\';
1.104 sakharuk 618: }
1.101 sakharuk 619: } else {
1.159 albertel 620: if (not $ENV{'request.symb'} =~ m/\.page_/) {
1.206 sakharuk 621: $result .= '\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$ENV{'request.uri'}.'</b></small><br /> STAMPOFPASSEDRESOURCEEND} \noindent \vskip 1 mm\noindent'.$startminipage.'\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';
1.159 albertel 622: if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { $result .= '\fbox{\textit{'.$weight.' pt}}';}
623: } else {
624: $result .= '\vskip 1mm \\\\\\\\';
625: }
626: }
1.99 sakharuk 627: }
1.159 albertel 628: } elsif ($target eq 'edit') {
629: $result.=$head_tag_start."</head>".$body_tag_start.$form_tag_start.
630: &problem_edit_header();
1.226 albertel 631: $Apache::lonxml::warnings_error_header=
632: &mt("Editor Errors - these errors might not effect the running of the problem, but they will likely cause problems with further use of the Edit mode. Please use the EditXML mode to fix these errors.")."<br />";
1.159 albertel 633: my $temp=&Apache::edit::insertlist($target,$token);
634: $result.=$temp;
635: } elsif ($target eq 'modified') {
636: $result=$token->[4];
637: $result.=&Apache::edit::handle_insert();
638: } else {
639: # page_start returned a starting result, delete it if we don't need it
640: $result = '';
1.99 sakharuk 641: }
1.159 albertel 642: return $result;
1.9 albertel 643: }
644:
645: sub end_problem {
1.159 albertel 646: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
647: my $result='';
648: my $status=$Apache::inputtags::status['-1'];
649: if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
650: $target eq 'tex') {
1.249 albertel 651: if ( $target eq 'grade' && $Apache::inputtags::part eq '0') {
1.159 albertel 652: # if part is zero, no <part>s existed, so we need to the grading
1.249 albertel 653: if ($status eq 'CAN_ANSWER' ||$Apache::lonhomework::scantronmode) {
654: &Apache::inputtags::grade;
655: } else {
656: # move any submission data to .hidden
657: &Apache::inputtags::hidealldata($Apache::inputtags::part);
658: }
1.159 albertel 659: } elsif ( ($target eq 'web' || $target eq 'tex') &&
660: $Apache::inputtags::part eq '0' &&
1.252 albertel 661: $status ne 'UNCHECKEDOUT' && $status ne 'NOT_YET_VIEWED') {
1.159 albertel 662: # if part is zero, no <part>s existed, so we need show the current
663: # grading status
664: my $gradestatus = &Apache::inputtags::gradestatus($Apache::inputtags::part,$target);
665: $result.= $gradestatus;
666: }
667: if (
668: (($target eq 'web') && ($ENV{'request.state'} ne 'construct')) ||
669: ($target eq 'answer') || ($target eq 'tex')
670: ) {
1.227 albertel 671: if ($target ne 'tex' &&
672: $ENV{'form.answer_output_mode'} ne 'tex') {
1.254 www 673: $result.="</form>";
674: $result.=&Apache::lonhtmlcommon::htmlareaselectactive(@Apache::lonxml::htmlareafields);
1.159 albertel 675: }
676: if ($target eq 'web') {
1.281 ! albertel 677: $result.=&Apache::lonxml::xmlend().'</html>';
1.159 albertel 678: } elsif ($target eq 'tex') {
1.178 sakharuk 679: my $endminipage = '';
1.191 sakharuk 680: if (not $ENV{'form.problem_split'}=~/yes/) {
1.178 sakharuk 681: $endminipage = '\end{minipage}';
682: }
1.257 sakharuk 683: if ($ENV{'form.print_discussions'} eq 'yes') {
1.263 sakharuk 684: $result.=&Apache::lonxml::xmlend($target,$parser);
1.257 sakharuk 685: $result=~s/<\/html>//;
1.159 albertel 686: } else {
1.262 sakharuk 687: $result .= '\keephidden{ENDOFPROBLEM}\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}';
688: if (not $ENV{'request.symb'} =~ m/\.page_/) {
689: $result .= $endminipage.'\end{document} ';
690: } else {
691: $result .= '';
692: }
1.159 albertel 693: }
694: }
695: }
696: if ($target eq 'grade') {
697: &Apache::lonhomework::showhash(%Apache::lonhomework::results);
698: &finalize_storage();
699: }
1.172 albertel 700: if ($target eq 'answer' && ($ENV{'request.state'} eq 'construct')
1.173 albertel 701: && $ENV{'form.answer_output_mode'} ne 'tex') {
1.172 albertel 702: $result.='</html>'; # normally we get it from xmlend, but in CSTR
703: # we always show answer mode too.
1.159 albertel 704: }
705: } elsif ($target eq 'meta') {
706: if ($Apache::inputtags::part eq '0') {
1.179 albertel 707: @Apache::inputtags::response=();
1.159 albertel 708: $result=&Apache::response::mandatory_part_meta;
709: }
1.215 albertel 710: $result.=&Apache::response::meta_part_order();
1.258 albertel 711: $result.=&Apache::response::meta_response_order();
1.159 albertel 712: } elsif ($target eq 'edit') {
713: &Apache::lonxml::debug("in end_problem with $target, edit");
714: $result = &problem_edit_footer();
715: }
1.155 albertel 716:
1.177 albertel 717: if ($ENV{'request.state'} eq 'construct' && $target eq 'web') {
718: &Apache::inputtags::check_for_duplicate_ids();
719: }
1.204 albertel 720:
721: &reset_problem_globals('problem');
1.159 albertel 722:
723: return $result;
1.48 albertel 724: }
725:
1.108 albertel 726:
1.48 albertel 727: sub start_library {
1.159 albertel 728: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
729: my ($result,$head_tag_start,$body_tag_start,$form_tag_start);
1.244 albertel 730: if ($$tagstack[0] eq 'library') {
731: &init_problem_globals('library');
732: $Apache::lonhomework::type='problem';
733: }
1.159 albertel 734: if ($target eq 'edit') {
735: ($result,$head_tag_start,$body_tag_start,$form_tag_start)=
736: &page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
737: $result.=$head_tag_start."</head>".$body_tag_start.$form_tag_start.
738: &problem_edit_header();
739: my $temp=&Apache::edit::insertlist($target,$token);
740: $result.=$temp;
741: } elsif ($target eq 'modified') {
742: $result=$token->[4];
743: $result.=&Apache::edit::handle_insert();
744: } elsif ($target eq 'web' && $$tagstack[0] ne 'problem' &&
745: $ENV{'request.state'} eq "construct" ) {
746: ($result,$head_tag_start,$body_tag_start,$form_tag_start)=
747: &page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
748: my $name=&get_resource_name($parstack,$safeeval);
749: my $rndseed=&setup_rndseed($safeeval);
750: $result.="$head_tag_start<title>$name</title></head>
1.105 albertel 751: $body_tag_start \n $form_tag_start".
1.159 albertel 752: '<input type="hidden" name="submitted" value="yes" />';
753: $result.=&problem_web_to_edit_header($rndseed);
754: }
755: return $result;
1.48 albertel 756: }
757:
758: sub end_library {
1.159 albertel 759: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
760: my $result='';
761: if ($target eq 'edit') {
762: $result=&problem_edit_footer();
763: } elsif ($target eq 'web' && $$tagstack[0] ne 'problem' &&
764: $ENV{'request.state'} eq "construct") {
1.280 albertel 765: $result.='</form>'.&Apache::loncommon::endbodytag().
766: &Apache::lonxml::xmlend();
1.159 albertel 767: }
1.204 albertel 768: if ($$tagstack[0] eq 'library') { &reset_problem_globals('library') };
1.159 albertel 769: return $result;
1.197 www 770: }
771:
772: sub start_definetag {
773: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
774:
775: my $result;
776:
777: my $name = $token->[2]->{'name'};
778: my $skip=&Apache::lonxml::get_all_text("/definetag",$parser);
779: if ($name=~/^\//) {
780: $result=
781: '<br /><table bgcolor="#FFBBBB"><tr><th>END <tt>'.$name.'</tt></th></tr>';
782: } else {
783: $result=
784: '<br /><table bgcolor="#BBFFBB"><tr><th>BEGIN <tt>'.$name.'</tt></th></tr>';
785: }
786: $skip=~s/\</\<\;/gs;
787: $skip=~s/\>/\>\;/gs;
788: $result.='<tr><td><pre>'.$skip.'</pre></td></tr></table>';
789: return $result;
790: }
791:
792: sub end_definetag {
793: return '';
1.1 albertel 794: }
795:
796: sub start_block {
1.201 albertel 797: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.131 albertel 798:
799: my $result;
1.1 albertel 800:
1.160 albertel 801: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
1.131 albertel 802: $target eq 'tex' || $target eq 'analyze') {
1.159 albertel 803: my $code = $token->[2]->{'condition'};
1.201 albertel 804: if (defined($code)) {
1.137 albertel 805: if (!$Apache::lonxml::default_homework_loaded) {
806: &Apache::lonxml::default_homework_load($safeeval);
807: }
1.131 albertel 808: $result = &Apache::run::run($code,$safeeval);
809: &Apache::lonxml::debug("block :$code: returned :$result:");
810: } else {
811: $result='1';
812: }
813: if ( ! $result ) {
1.201 albertel 814: my $skip=&Apache::lonxml::get_all_text("/block",$parser,$style);
1.131 albertel 815: &Apache::lonxml::debug("skipping ahead :$skip: $$parser[-1]");
816: }
817: $result='';
818: } elsif ($target eq 'edit') {
819: $result .=&Apache::edit::tag_start($target,$token);
820: $result .=&Apache::edit::text_arg('Test Condition:','condition',
821: $token,40);
822: $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
823: } elsif ($target eq 'modified') {
824: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
825: $safeeval,'condition');
826: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
1.38 albertel 827: }
1.131 albertel 828: return $result;
1.1 albertel 829: }
830:
831: sub end_block {
1.167 www 832: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
833: my $result;
834: if ($target eq "edit") {
835: $result.= &Apache::edit::tag_end($target,$token,'');
836: }
837: return $result;
838: }
839:
840: sub start_languageblock {
1.201 albertel 841: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.167 www 842:
843: my $result;
844:
845: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
846: $target eq 'tex' || $target eq 'analyze') {
1.201 albertel 847: my $include = $token->[2]->{'include'};
848: my $exclude = $token->[2]->{'exclude'};
849: my %languages=&Apache::loncommon::display_languages();
850: $result='1';
851: if ($include) {
852: $result='';
853: foreach (split(/\,/,$include)) {
854: if ($languages{$_}) { $result='1'; }
855: }
856: }
857: if ($exclude) {
858: foreach (split(/\,/,$exclude)) {
859: if ($languages{$_}) { $result='0'; }
860: }
861: }
862: if ( ! $result ) {
863: my $skip=&Apache::lonxml::get_all_text("/languageblock",$parser,
864: $style);
865: &Apache::lonxml::debug("skipping ahead :$skip: $$parser[-1]");
866: }
867: $result='';
1.167 www 868: } elsif ($target eq 'edit') {
869: $result .=&Apache::edit::tag_start($target,$token);
1.211 albertel 870: $result .=&Apache::edit::text_arg(&mt('Include Language:'),'include',
1.167 www 871: $token,40);
1.211 albertel 872: $result .=&Apache::edit::text_arg(&mt('Exclude Language:'),'exclude',
1.167 www 873: $token,40);
874: $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
875: } elsif ($target eq 'modified') {
876: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
1.168 albertel 877: $safeeval,'include',
878: 'exclude');
1.167 www 879: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
880: }
881: return $result;
882: }
883:
884: sub end_languageblock {
1.170 www 885: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
886: my $result;
1.201 albertel 887: if ($target eq "edit") {
1.170 www 888: $result.= &Apache::edit::tag_end($target,$token,'');
889: }
890: return $result;
891: }
892:
893: sub start_instructorcomment {
1.201 albertel 894: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.170 www 895:
896: my $result;
897:
898: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
899: $target eq 'tex' || $target eq 'analyze') {
900: $result=($ENV{'request.role'}=~/^(in|cc|au|ca|li)/);
1.269 sakharuk 901: if ( (! $result) or ($ENV{'form.instructor_comments'} eq 'hide')) {
1.201 albertel 902: my $skip=&Apache::lonxml::get_all_text("/instructorcomment",
903: $parser,$style);
1.170 www 904: &Apache::lonxml::debug("skipping ahead :$skip: $$parser[-1]");
905: }
906: $result='';
907: } elsif ($target eq 'edit') {
908: $result .=&Apache::edit::tag_start($target,$token);
909: $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
910: }
911: return $result;
912: }
913:
914: sub end_instructorcomment {
1.159 albertel 915: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.160 albertel 916: my $result;
917: if ($target eq "edit") {
918: $result.= &Apache::edit::tag_end($target,$token,'');
919: }
920: return $result;
1.4 tsai 921: }
922:
923: sub start_while {
1.159 albertel 924: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
925:
1.160 albertel 926: my $result;
1.161 albertel 927: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
1.160 albertel 928: $target eq 'tex' || $target eq 'analyze') {
929: my $code = $token->[2]->{'condition'};
1.4 tsai 930:
1.160 albertel 931: push( @Apache::structuretags::whileconds, $code);
932: if (!$Apache::lonxml::default_homework_loaded) {
933: &Apache::lonxml::default_homework_load($safeeval);
934: }
935: my $result = &Apache::run::run($code,$safeeval);
1.161 albertel 936: my $bodytext=&Apache::lonxml::get_all_text("/while",$parser);
1.160 albertel 937: push( @Apache::structuretags::whilebody, $bodytext);
1.161 albertel 938: push( @Apache::structuretags::whileline, $token->[5]);
939: &Apache::lonxml::debug("s code $code got -$result-");
1.160 albertel 940: if ( $result ) {
941: &Apache::lonxml::newparser($parser,\$bodytext);
942: }
943: } elsif ($target eq 'edit') {
944: $result .=&Apache::edit::tag_start($target,$token);
1.211 albertel 945: $result .=&Apache::edit::text_arg(&mt('Test Condition:'),'condition',
1.160 albertel 946: $token,40);
947: $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
948: } elsif ($target eq 'modified') {
949: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
950: $safeeval,'condition');
951: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
1.159 albertel 952: }
1.160 albertel 953: return $result;
1.4 tsai 954: }
955:
956: sub end_while {
1.159 albertel 957: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.160 albertel 958: my $result;
959:
960: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
961: $target eq 'tex' || $target eq 'analyze') {
962: my $code = pop(@Apache::structuretags::whileconds);
963: my $bodytext = pop(@Apache::structuretags::whilebody);
1.161 albertel 964: my $line = pop(@Apache::structuretags::whileline);
965: my $return = &Apache::run::run($code,$safeeval);
966: my $starttime=time;
967: my $error=0;
968: while ($return) {
969: if (time-$starttime >
970: $Apache::lonnet::perlvar{'lonScriptTimeout'}) {
1.270 albertel 971: #$return = 0; $error=1; next;
1.161 albertel 972: }
973: $result.=&Apache::scripttag::xmlparse($bodytext);
974: $return = &Apache::run::run($code,$safeeval);
975: }
976: if ($error) {
1.270 albertel 977: &Apache::lonxml::error('<pre>'.&mt('Code ran too long. It ran for more than').' '.$Apache::lonnet::perlvar{'lonScriptTimeout'}.' '.&mt('seconds occured while running <while> on line').' '.$line.'</pre>');
1.160 albertel 978: }
979: } elsif ($target eq "edit") {
980: $result.= &Apache::edit::tag_end($target,$token,'');
1.159 albertel 981: }
1.160 albertel 982: return $result;
1.1 albertel 983: }
1.6 tsai 984:
1.160 albertel 985: # <randomlist show="1">
1.6 tsai 986: # <tag1>..</tag1>
987: # <tag2>..</tag2>
988: # <tag3>..</tag3>
1.160 albertel 989: # ...
1.6 tsai 990: # </randomlist>
991: sub start_randomlist {
1.159 albertel 992: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
993: my $result;
994: if ($target eq 'answer' || $target eq 'grade' || $target eq 'web' ||
995: $target eq 'tex' || $target eq 'analyze') {
996: my $body= &Apache::lonxml::get_all_text("/randomlist",$parser);
997: my $b_parser= HTML::TokeParser->new(\$body);
998: my $b_tok;
999: my @randomlist;
1000: my $list_item;
1001: while($b_tok = $b_parser->get_token() ) {
1002: if($b_tok->[0] eq 'S') { # start tag
1003: # get content of the tag until matching end tag
1004: # get all text upto the matching tag
1005: # and push the content into @randomlist
1006: $list_item = &Apache::lonxml::get_all_text('/'.$b_tok->[1],
1007: $b_parser);
1008: $list_item = "$b_tok->[4]"."$list_item"."</$b_tok->[1]>";
1009: push(@randomlist,$list_item);
1010: # print "<br /><b>START-TAG $b_tok->[1], $b_tok->[4],
1011: # $list_item</b>";
1012: }
1013: if($b_tok->[0] eq 'T') { # text
1014: # what to do with text in between tags?
1015: # print "<b>TEXT $b_tok->[1]</b><br />";
1016: }
1017: # if($b_tok->[0] eq 'E') { # end tag, should not happen
1018: # print "<b>END-TAG $b_tok->[1]</b><br />";
1019: # }
1020: }
1021: my @idx_arr = (0 .. $#randomlist);
1022: &Apache::structuretags::shuffle(\@idx_arr);
1023: my $bodytext = '';
1024: my $show=$#randomlist;
1025: my $showarg=&Apache::lonxml::get_param('show',$parstack,$safeeval);
1026: $showarg--;
1027: if ( ($showarg >= 0) && ($showarg < $show) ) { $show = $showarg; }
1028: for(0 .. $show) {
1029: $bodytext .= "$randomlist[ $idx_arr[$_] ]";
1030: }
1031: &Apache::lonxml::newparser($parser,\$bodytext);
1032: } elsif ($target eq 'edit' ) {
1033: $result .=&Apache::edit::tag_start($target,$token);
1034: $result .=&Apache::edit::text_arg('Maximum Tags to Show:','show',
1035: $token,5);
1036: $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
1037: } elsif ($target eq 'modified' ) {
1038: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
1039: $safeeval,'show');
1040: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
1041: }
1042: return $result;
1.7 tsai 1043: }
1044:
1045: sub shuffle {
1046: my $a=shift;
1047: my $i;
1.70 albertel 1048: if (defined(@$a)) {
1.251 albertel 1049: &Apache::response::pushrandomnumber();
1.159 albertel 1050: for($i=@$a;--$i;) {
1051: my $j=int(&Math::Random::random_uniform() * ($i+1));
1052: next if $i == $j;
1053: @$a[$i,$j] = @$a[$j,$i];
1054: }
1.251 albertel 1055: &Apache::response::poprandomnumber();
1.7 tsai 1056: }
1.6 tsai 1057: }
1058:
1059: sub end_randomlist {
1.159 albertel 1060: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1061: my $result;
1062: if ($target eq 'edit' ) {
1063: $result=&Apache::edit::tag_end($target,$token,
1064: 'End Randomly Parsed Block');
1065: }
1066: return $result;
1.6 tsai 1067: }
1068:
1.11 albertel 1069: sub start_part {
1.159 albertel 1070: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1071: my $result='';
1072: my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
1073: if ($id eq '') { $id = $Apache::lonxml::curdepth; }
1074: $Apache::inputtags::part=$id;
1.177 albertel 1075: push(@Apache::inputtags::partlist,$id);
1076: @Apache::inputtags::response=();
1.159 albertel 1077: @Apache::inputtags::previous=();
1078: @Apache::inputtags::previous_version=();
1.241 albertel 1079: $Apache::lonhomework::problemstatus=&get_problem_status($id);
1.159 albertel 1080: my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part);
1.259 albertel 1081: my $newtype=&Apache::lonnet::EXT("resource.$id.type");
1082: if ($newtype) { $Apache::lonhomework::type=$newtype; }
1083:
1.214 albertel 1084: my $expression='$external::part=\''.$Apache::inputtags::part.'\';';
1.259 albertel 1085: $expression.='$external::type=\''.$Apache::lonhomework::type.'\';';
1.209 albertel 1086: &Apache::run::run($expression,$safeeval);
1.159 albertel 1087:
1088: if ($target eq 'meta') {
1.224 www 1089: my $display=&Apache::lonxml::get_param('display',$parstack,$safeeval);
1090: return &Apache::response::mandatory_part_meta.
1091: &Apache::response::meta_parameter_write('display','string',$display,'Part Description');
1.159 albertel 1092: } elsif ($target eq 'web' || $target eq 'grade' ||
1093: $target eq 'answer' || $target eq 'tex') {
1094: if ($hidden) {
1095: my $bodytext=&Apache::lonxml::get_all_text("/part",$parser);
1096: } else {
1097: my ($status,$accessmsg) = &Apache::lonhomework::check_access($id);
1098: push (@Apache::inputtags::status,$status);
1099: my $expression='$external::datestatus="'.$status.'";';
1100: $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.$id.solved"}.'";';
1101: &Apache::run::run($expression,$safeeval);
1.240 albertel 1102: if ($ENV{'request.state'} eq 'construct') {
1.241 albertel 1103: &set_problem_state($Apache::inputtags::part);
1.240 albertel 1104: }
1.216 albertel 1105: if (( $status eq 'CLOSED' ) ||
1106: ( $status eq 'UNCHECKEDOUT') ||
1.252 albertel 1107: ( $status eq 'NOT_YET_VIEWED') ||
1.216 albertel 1108: ( $status eq 'BANNED') ||
1109: ( $status eq 'UNAVAILABLE') ||
1110: ( $status eq 'INVALID_ACCESS')) {
1.159 albertel 1111: my $bodytext=&Apache::lonxml::get_all_text("/part",$parser);
1112: if ( $target eq "web" ) {
1.211 albertel 1113: $result="<br />".&mt('Part is not open to be viewed. It')." $accessmsg<br />";
1.159 albertel 1114: } elsif ( $target eq 'tex' ) {
1.195 sakharuk 1115: if (not $ENV{'form.problem_split'}=~/yes/) {
1.211 albertel 1116: $result="\\end{minipage}\\vskip 0 mm ".&mt('Part is not open to be viewed. It')." $accessmsg \\\\\\begin{minipage}{\\textwidth}";
1.195 sakharuk 1117: } else {
1.211 albertel 1118: $result="\\vskip 0 mm ".&mt('Part is not open to be viewed. It')." $accessmsg \\\\";
1.195 sakharuk 1119: }
1.159 albertel 1120: }
1121: } else {
1122: if ($target eq 'tex') {
1.195 sakharuk 1123: if (not $ENV{'form.problem_split'}=~/yes/) {
1.264 sakharuk 1124: if ($$tagstack[-2] eq 'td') {
1125: $result.='\vskip 0 mm \noindent \begin{minipage}{\textwidth}\noindent';
1126: } else {
1127: $result.='\noindent \end{minipage}\vskip 0 mm \noindent \begin{minipage}{\textwidth}\noindent';
1128: }
1.195 sakharuk 1129: }
1.159 albertel 1130: my $weight = &Apache::lonnet::EXT("resource.$id.weight");
1.230 albertel 1131: my $allkeys=&Apache::lonnet::metadata($ENV{'request.uri'},'packages');
1.222 sakharuk 1132: my @allkeys = split /,/,$allkeys;
1133: my $allow_print_points = 0;
1134: foreach my $partial_key (@allkeys) {
1.230 albertel 1135: if ($partial_key=~m/^part_(.*)$/) {
1.222 sakharuk 1136: if ($1 ne '0') {$allow_print_points=1;}
1137: }
1138: }
1.275 albertel 1139: my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
1140: if (defined($maxtries) && $maxtries < 0) {
1141: $allow_print_points=0;
1142: }
1.222 sakharuk 1143: if (($Apache::lonhomework::type eq 'exam') && ($allow_print_points)) { $result .= '\fbox{\textit{'.$weight.' pt}}';}
1.233 www 1144: } elsif ($target eq 'web') {
1145: $result.='<a name="'.&Apache::lonnet::escape($Apache::inputtags::part).'" />';
1.159 albertel 1146: }
1147: }
1148: }
1149: } elsif ($target eq 'edit') {
1150: $result.=&Apache::edit::tag_start($target,$token);
1151: $result.=&Apache::edit::text_arg('Part ID:','id',$token).
1152: &Apache::loncommon::help_open_topic("Part_Tag_Edit_Help").
1.224 www 1153: ' '.
1154: &Apache::edit::text_arg('Displayed Part Description:','display',$token).
1.159 albertel 1155: &Apache::edit::end_row().&Apache::edit::start_spanning_row();
1156: } elsif ($target eq 'modified') {
1157: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
1.225 albertel 1158: $safeeval,'id','display');
1.159 albertel 1159: if ($constructtag) {
1.225 albertel 1160: #limiting ids to only letters numbers, and space
1.224 www 1161: $token->[2]->{'id'}=~s/[^A-Za-z0-9 ]//gs;
1.159 albertel 1162: $result = &Apache::edit::rebuild_tag($token);
1163: $result.=&Apache::edit::handle_insert();
1164: }
1165: }
1166: return $result;
1.11 albertel 1167: }
1168:
1169: sub end_part {
1.159 albertel 1170: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1171: &Apache::lonxml::debug("in end_part $target ");
1172: my $status=$Apache::inputtags::status['-1'];
1173: my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part);
1174: my $result='';
1175: if ( $target eq 'meta' ) {
1176: $result='';
1.249 albertel 1177: } elsif ($target eq 'grade') {
1178: if (($status eq 'CAN_ANSWER' || $Apache::lonhomework::scantronmode) &&
1179: !$hidden) {
1180: $result=&Apache::inputtags::grade;
1181: } else {
1182: # move any submission data to .hidden
1183: &Apache::inputtags::hidealldata($Apache::inputtags::part);
1184: }
1.159 albertel 1185: } elsif (($target eq 'web' || $target eq 'tex') && !$hidden ) {
1186: my $gradestatus=&Apache::inputtags::gradestatus($Apache::inputtags::part,
1187: $target);
1.212 albertel 1188: if ($Apache::lonhomework::type eq 'exam' && $target eq 'tex') {
1189: $gradestatus='';
1190: }
1.159 albertel 1191: $result=$gradestatus;
1.265 sakharuk 1192: if ($$tagstack[-2] eq 'td' and $target eq 'tex') {$result.='\end{minipage}';}
1.181 albertel 1193: } elsif ($target eq 'edit') {
1194: $result=&Apache::edit::end_table();
1.159 albertel 1195: }
1196: pop @Apache::inputtags::status;
1197: $Apache::inputtags::part='';
1198: return $result;
1.11 albertel 1199: }
1.1 albertel 1200:
1.25 albertel 1201: sub start_preduedate {
1.159 albertel 1202: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1203: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') {
1.236 albertel 1204: &Apache::lonxml::debug("State in preduedate is ". $Apache::inputtags::status['-1']);
1.159 albertel 1205: if ($Apache::inputtags::status['-1'] ne 'CAN_ANSWER' &&
1.236 albertel 1206: $Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER') {
1207: &Apache::lonxml::debug("Wha? ". ($Apache::inputtags::status['-1'] ne 'SHOW_ANSWER'));
1.159 albertel 1208: &Apache::lonxml::get_all_text("/preduedate",$parser);
1209: }
1.24 albertel 1210: }
1.159 albertel 1211: return '';
1.24 albertel 1212: }
1213:
1.25 albertel 1214: sub end_preduedate {
1.159 albertel 1215: return '';
1.24 albertel 1216: }
1217:
1.25 albertel 1218: sub start_postanswerdate {
1.159 albertel 1219: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.234 albertel 1220: if ($target eq 'web' || $target eq 'grade') {
1.159 albertel 1221: if ($Apache::inputtags::status['-1'] ne 'SHOW_ANSWER') {
1222: &Apache::lonxml::get_all_text("/postanswerdate",$parser);
1223: }
1224: } elsif ($target eq 'tex') {
1.234 albertel 1225: &Apache::lonxml::get_all_text("/postanswerdate",$parser);
1.159 albertel 1226: }
1227: return '';
1.24 albertel 1228: }
1229:
1.25 albertel 1230: sub end_postanswerdate {
1.159 albertel 1231: return '';
1.24 albertel 1232: }
1233:
1.25 albertel 1234: sub start_notsolved {
1.159 albertel 1235: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1236: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
1237: $target eq 'tex') {
1238: my $gradestatus=$Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"};
1239: &Apache::lonxml::debug("not solved has :$gradestatus:");
1.239 albertel 1240: if ($gradestatus =~ /^correct/ &&
1241: &Apache::response::show_answer()) {
1.159 albertel 1242: &Apache::lonxml::debug("skipping");
1243: &Apache::lonxml::get_all_text("/notsolved",$parser);
1244: }
1.24 albertel 1245: }
1.159 albertel 1246: return '';
1.24 albertel 1247: }
1248:
1.25 albertel 1249: sub end_notsolved {
1.159 albertel 1250: return '';
1.24 albertel 1251: }
1252:
1253: sub start_solved {
1.159 albertel 1254: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1255: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
1256: $target eq 'tex') {
1257: my $gradestatus=$Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"};
1.239 albertel 1258: if ($gradestatus !~ /^correct/ ||
1259: !&Apache::response::show_answer()) {
1.159 albertel 1260: &Apache::lonxml::get_all_text("/solved",$parser);
1261: }
1.24 albertel 1262: }
1.159 albertel 1263: return '';
1.24 albertel 1264: }
1265:
1266: sub end_solved {
1.248 albertel 1267: return '';
1268: }
1269:
1270: sub start_problemtype {
1271: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1272: my $result;
1273: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
1274: $target eq 'tex' || $target eq 'analyze') {
1275: my $mode=lc(&Apache::lonxml::get_param('mode',$parstack,$safeeval));
1276: if (!defined($mode)) { $mode='show'; }
1277: my $for=&Apache::lonxml::get_param('for',$parstack,$safeeval);
1278: my $found=0;
1279: foreach my $type (split(',',$for)) {
1280: if ($Apache::lonhomework::type eq lc($type)) { $found=1; }
1281: }
1282: if ($mode eq 'show' && !$found) {
1283: &Apache::lonxml::get_all_text("/problemtype",$parser);
1284: }
1285: if ($mode eq 'hide' && $found) {
1286: &Apache::lonxml::get_all_text("/problemtype",$parser);
1287: }
1288: } elsif ($target eq 'edit') {
1289: $result .=&Apache::edit::tag_start($target,$token);
1290: $result.=&Apache::edit::select_arg('Mode:','mode',
1291: [['show','Show'],
1292: ['hide','Hide']]
1293: ,$token);
1294: $result .=&Apache::edit::checked_arg('When used as type(s):','for',
1295: [ ['exam','Exam/Quiz Problem'],
1296: ['survey','Survey'],
1297: ['problem','Homework Problem'] ]
1298: ,$token);
1299: $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
1300: } elsif ($target eq 'modified') {
1301: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
1302: $safeeval,'mode','for');
1303: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
1304: }
1305: return $result;
1306: }
1307:
1308: sub end_problemtype {
1.159 albertel 1309: return '';
1.24 albertel 1310: }
1.34 albertel 1311:
1312: sub start_startouttext {
1.159 albertel 1313: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1314: my @result=(''.'');
1315: if ($target eq 'edit' || $target eq 'modified' ) { @result=('','no'); }
1316: return (@result);
1.34 albertel 1317: }
1.159 albertel 1318:
1.34 albertel 1319: sub end_startouttext {
1.159 albertel 1320: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1321: my $result='';
1322: my $text='';
1323:
1324: if ($target eq 'edit') {
1325: $text=&Apache::lonxml::get_all_text("endouttext",$parser);
1.211 albertel 1326: $result.=&Apache::edit::start_table($token)."<tr><td>".&mt('Text Block')."</td>
1327: <td>".&mt('Delete:').
1.159 albertel 1328: &Apache::edit::deletelist($target,$token)
1329: ."</td>
1.42 albertel 1330: <td>".
1.159 albertel 1331: &Apache::edit::insertlist($target,$token).
1332: &Apache::edit::end_row().
1333: &Apache::edit::start_spanning_row()."\n"
1.188 bowersj2 1334: . &Apache::loncommon::helpLatexCheatsheet () .
1.255 www 1335: &Apache::edit::editfield($token->[1],$text,"",80,8,1);
1.159 albertel 1336: }
1337: if ($target eq 'modified') {
1.219 albertel 1338: $result='<startouttext />'.&Apache::edit::modifiedfield("endouttext",$parser);
1.159 albertel 1339: }
1340: if ($target eq 'tex') {
1341: $result .= '\noindent ';
1342: }
1343: return $result;
1.34 albertel 1344: }
1.159 albertel 1345:
1.34 albertel 1346: sub start_endouttext {
1.159 albertel 1347: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1348: my $result='';
1349: if ($target eq "edit" ) { $result="</td></tr>".&Apache::edit::end_table()."\n"; }
1350: if ($target eq "modified") {
1351: $result='<endouttext />'.
1352: &Apache::edit::handle_insertafter('startouttext'); }
1353: return $result;
1.34 albertel 1354: }
1.159 albertel 1355:
1.34 albertel 1356: sub end_endouttext {
1.159 albertel 1357: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1358: my @result=('','');
1359: if ($target eq "edit" || $target eq 'modified') { @result=('','no'); }
1360: return (@result);
1.34 albertel 1361: }
1.159 albertel 1362:
1.45 albertel 1363: sub delete_startouttext {
1.159 albertel 1364: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1365: # my $text=&Apache::lonxml::get_all_text("endouttext",$parser);
1366: my $text=$$parser['-1']->get_text("/endouttext");
1367: my $ntoken=$$parser['-1']->get_token();
1368: &Apache::lonxml::debug("Deleting :$text: and :$ntoken->[0]:$ntoken->[1]:$ntoken->[2]: for startouttext");
1369: &Apache::lonxml::end_tag($tagstack,$parstack,$ntoken);
1370: # Deleting 2 parallel tag pairs, but we need the numbers later to look like
1371: # they did the last time round
1372: &Apache::lonxml::increasedepth($ntoken);
1373: &Apache::lonxml::decreasedepth($ntoken);
1374: return 1;
1.193 www 1375: }
1376:
1377: sub start_simpleeditbutton {
1378: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1379: my $result='';
1.273 albertel 1380: if (($ENV{'form.simple_edit_button'} ne 'off') &&
1381: ($target eq 'web') &&
1.193 www 1382: (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
1.220 www 1383: my $url=$ENV{'request.noversionuri'};
1.193 www 1384: $url=~s/\?.*$//;
1.278 albertel 1385: my ($symb) = &Apache::lonxml::whichuser();
1.194 www 1386: $result='<table width="100%" bgcolor="#FFFFAA" border="2"><tr><td>'.
1.278 albertel 1387: '<a href="'.$url.'/smpedit?symb='.&Apache::lonnet::escape($symb).'">'.&mt('Edit').'</a> - '.&mt('Note: it can take up to 10 minutes for changes to take effect for all users.').
1.196 www 1388: &Apache::loncommon::help_open_topic('Caching').'</td></tr></table><br />';
1.193 www 1389: }
1390: return $result;
1391: }
1392:
1393: sub end_simpleeditbutton {
1394: return '';
1.45 albertel 1395: }
1.34 albertel 1396:
1.1 albertel 1397: 1;
1398: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>