--- loncom/homework/structuretags.pm 2003/10/14 00:21:12 1.217 +++ loncom/homework/structuretags.pm 2004/02/10 22:11:37 1.233 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.217 2003/10/14 00:21:12 albertel Exp $ +# $Id: structuretags.pm,v 1.233 2004/02/10 22:11:37 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -37,6 +37,7 @@ use Apache::lonnet; use Apache::File(); use Apache::lonmenu; use Apache::lonlocal; +use Apache::lonxml; BEGIN { &Apache::lonxml::register('Apache::structuretags',('block','languageblock','instructorcomment','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','startouttext','endouttext', @@ -84,10 +85,7 @@ sub page_start { if (!defined($found{'html'})) { $result=&Apache::londefdef::start_html($target,$token,$tagstack, $parstack,$parser,$safeeval); - $head_tag_start=''; - if ($ENV{'request.state'} eq 'published') { - $head_tag_start.=&Apache::lonmenu::registerurl(undef,$target); - } + $head_tag_start=''.&Apache::lonmenu::registerurl(undef,$target); } my $body_tag_start; if (!defined($found{'body'})) { @@ -174,8 +172,10 @@ sub setup_rndseed { if (defined($rndseed) && $rndseed ne int($rndseed)) { $rndseed=join(',',&Math::Random::random_seed_from_phrase($rndseed)); } - &Apache::lonxml::debug("Setting rndseed to $rndseed"); - &Apache::run::run('$external::randomseed='.$rndseed.';',$safeeval); + if ($safeeval) { + &Apache::lonxml::debug("Setting rndseed to $rndseed"); + &Apache::run::run('$external::randomseed='.$rndseed.';',$safeeval); + } } return $rndseed; } @@ -187,8 +187,12 @@ sub problem_edit_header {
-

 

- '; +
'. + &Apache::loncommon::help_open_topic('Problem_Editor_XML_Index', + 'Problem Editing Help').''. + &Apache::loncommon::help_open_faq(5). + &Apache::loncommon::help_open_bug('Authoring').'
'. + '
'; } sub problem_edit_footer { @@ -209,8 +213,9 @@ sub problem_web_to_edit_header { onChange="javascript:document.lonhomework.changerandseed.click()" /> '; + $result.= ' />'.&mt(' Show All Foils'). + &Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems'). + '
'; my $numtoanalyze=$ENV{'form.numtoanalyze'}; if (!$numtoanalyze) { $numtoanalyze=20; } $result.= '$name $body_tag_start \n $form_tag_start". - ''; - if ($ENV{'request.state'} eq "construct") { - $result.= &problem_web_to_edit_header($ENV{'form.rndseed'}); - } - # if we are viewing someone else preserve that info - if (defined $ENV{'form.grade_symb'}) { - foreach my $field ('symb','courseid','domain','username') { - $result .= ''."\n"; - } + ''; + # create a page header and exit + if ($ENV{'request.state'} eq "construct") { + $result.= &problem_web_to_edit_header($ENV{'form.rndseed'}); + } + # if we are viewing someone else preserve that info + if (defined $ENV{'form.grade_symb'}) { + foreach my $field ('symb','courseid','domain','username') { + $result .= ''."\n"; } - } elsif ($status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER' - || $status eq 'CLOSED' || $status eq 'UNAVALAILABLE' || - $status eq 'INVALID_ACCESS') { - $result.=$head_tag_start. - "$name\n$body_tag_start\n"; } } elsif ($target eq 'tex') { my $startminipage = ''; @@ -458,12 +456,12 @@ sub start_problem { } my $id = $Apache::inputtags::part; my $weight = &Apache::lonnet::EXT("resource.$id.weight"); - my $allkeys=&Apache::lonnet::metadata($ENV{'request.uri'},'keys'); - my @allkeys = split /,/,$allkeys; + my $packages=&Apache::lonnet::metadata($ENV{'request.uri'},'packages'); + my @packages = split /,/,$packages; my $allow_print_points = 0; - foreach my $partial_key (@allkeys) { - if ($partial_key=~m/weight/) { - $allow_print_points++; + foreach my $partial_key (@packages) { + if ($partial_key=~m/^part_0$/) { + $allow_print_points=1; } } my $duedate = &Apache::lonnet::EXT("resource.$id.duedate"); @@ -478,7 +476,7 @@ sub start_problem { my @due_file_content = <$temp_file>; my $due_file_content = $due_file_content[$#due_file_content]; chomp $due_file_content; - my $name_of_resourse= &get_resource_name($parstack,$safeeval); + my $name_of_resourse= &Apache::lonxml::latex_special_symbols(&get_resource_name($parstack,$safeeval)); if ($due_file_content ne $duedate) { $temp_file = Apache::File->new('>'.$filename); print $temp_file "$duedate\n"; @@ -504,6 +502,8 @@ sub start_problem { } elsif ($target eq 'edit') { $result.=$head_tag_start."".$body_tag_start.$form_tag_start. &problem_edit_header(); + $Apache::lonxml::warnings_error_header= + &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.")."
"; my $temp=&Apache::edit::insertlist($target,$token); $result.=$temp; } elsif ($target eq 'modified') { @@ -523,7 +523,7 @@ sub end_problem { if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || $target eq 'tex') { if ( $target eq 'grade' && $Apache::inputtags::part eq '0' && - $status eq 'CAN_ANSWER' ) { + ($status eq 'CAN_ANSWER' || $Apache::lonhomework::scantronmode)) { # if part is zero, no s existed, so we need to the grading &Apache::inputtags::grade; } elsif ( ($target eq 'web' || $target eq 'tex') && @@ -538,17 +538,9 @@ sub end_problem { (($target eq 'web') && ($ENV{'request.state'} ne 'construct')) || ($target eq 'answer') || ($target eq 'tex') ) { - if ($status eq 'CAN_ANSWER') { - if ($target ne 'tex' && - $ENV{'form.answer_output_mode'} ne 'tex') { - $result.="\n"; - } - } elsif ($status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER' || - $status eq 'UNCHECKEDOUT' || $status eq 'INVALID_ACCESS') { - if ($target ne 'tex' && - $ENV{'form.answer_output_mode'} ne 'tex') { - $result.="\n"; - } + if ($target ne 'tex' && + $ENV{'form.answer_output_mode'} ne 'tex') { + $result.="\n"; } if ($target eq 'web') { $result.=&Apache::lonxml::xmlend(); @@ -949,7 +941,9 @@ sub start_part { &Apache::run::run($expression,$safeeval); if ($target eq 'meta') { - return &Apache::response::mandatory_part_meta; + my $display=&Apache::lonxml::get_param('display',$parstack,$safeeval); + return &Apache::response::mandatory_part_meta. + &Apache::response::meta_parameter_write('display','string',$display,'Part Description'); } elsif ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') { if ($hidden) { @@ -981,7 +975,17 @@ sub start_part { $result.='\noindent \end{minipage}\vskip 0 mm \noindent \begin{minipage}{\textwidth}\noindent'; } my $weight = &Apache::lonnet::EXT("resource.$id.weight"); - if ($Apache::lonhomework::type eq 'exam') { $result .= '\fbox{\textit{'.$weight.' pt}}';} + my $allkeys=&Apache::lonnet::metadata($ENV{'request.uri'},'packages'); + my @allkeys = split /,/,$allkeys; + my $allow_print_points = 0; + foreach my $partial_key (@allkeys) { + if ($partial_key=~m/^part_(.*)$/) { + if ($1 ne '0') {$allow_print_points=1;} + } + } + if (($Apache::lonhomework::type eq 'exam') && ($allow_print_points)) { $result .= '\fbox{\textit{'.$weight.' pt}}';} + } elsif ($target eq 'web') { + $result.=''; } } } @@ -989,11 +993,15 @@ sub start_part { $result.=&Apache::edit::tag_start($target,$token); $result.=&Apache::edit::text_arg('Part ID:','id',$token). &Apache::loncommon::help_open_topic("Part_Tag_Edit_Help"). + '  '. +&Apache::edit::text_arg('Displayed Part Description:','display',$token). &Apache::edit::end_row().&Apache::edit::start_spanning_row(); } elsif ($target eq 'modified') { my $constructtag=&Apache::edit::get_new_args($token,$parstack, - $safeeval,'id'); + $safeeval,'id','display'); if ($constructtag) { + #limiting ids to only letters numbers, and space + $token->[2]->{'id'}=~s/[^A-Za-z0-9 ]//gs; $result = &Apache::edit::rebuild_tag($token); $result.=&Apache::edit::handle_insert(); } @@ -1009,7 +1017,9 @@ sub end_part { my $result=''; if ( $target eq 'meta' ) { $result=''; - } elsif ( $target eq 'grade' && $status eq 'CAN_ANSWER' && !$hidden) { + } elsif ($target eq 'grade' && + ($status eq 'CAN_ANSWER' || $Apache::lonhomework::scantronmode) && + !$hidden) { $result=&Apache::inputtags::grade; } elsif (($target eq 'web' || $target eq 'tex') && !$hidden ) { my $gradestatus=&Apache::inputtags::gradestatus($Apache::inputtags::part, @@ -1118,8 +1128,7 @@ sub end_startouttext { &Apache::edit::editfield($token->[1],$text,"",80,4); } if ($target eq 'modified') { - $text=&Apache::lonxml::get_all_text("endouttext",$parser); - $result=''.&Apache::edit::modifiedfield(); + $result=''.&Apache::edit::modifiedfield("endouttext",$parser); } if ($target eq 'tex') { $result .= '\noindent '; @@ -1163,7 +1172,7 @@ sub start_simpleeditbutton { my $result=''; if (($target eq 'web') && (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) { - my $url=$ENV{'REQUEST_URI'}; + my $url=$ENV{'request.noversionuri'}; $url=~s/\?.*$//; $result='
'. ''.&mt('Simple Problem Editor').' - '.&mt('Note: it can take up to 10 minutes for changes to take effect for all users.').