--- loncom/homework/structuretags.pm 2012/02/01 18:51:52 1.465.2.14.2.1 +++ loncom/homework/structuretags.pm 2011/01/07 05:09:32 1.484 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.465.2.14.2.1 2012/02/01 18:51:52 raeburn Exp $ +# $Id: structuretags.pm,v 1.484 2011/01/07 05:09:32 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -129,16 +129,8 @@ sub homework_js { <<'JS'; @@ -162,12 +154,10 @@ JS sub setmode_javascript { return <<"ENDSCRIPT"; ENDSCRIPT } @@ -185,7 +175,7 @@ function file_deletion_check(formname) { } var str = new RegExp("^HWFILE.+_delete\$"); var delboxes = new Array(); - for (i=0; i'; } -sub problem_edit_action_button { - my ($name,$action,$accesskey,$text,$flag)=@_; - my $actionscript="setmode(this.form,'$action')"; - return "\n"; -} - sub problem_edit_buttons { - my ($mode)=@_; -# Buttons that do not save - my $result='
'. - &problem_edit_action_button('subdiscview','discard','d','Discard Edits and View',1); - if ($mode eq 'editxml') { - $result.=&problem_edit_action_button('subedit','edit','e','Edit',1); - $result.=&problem_edit_action_button('subundo','undoxml','u','Undo',1); - $result.=&Apache::lonhtmlcommon::dragmath_button("LC_editxmltext",1); - } else { - $result.=&problem_edit_action_button('subeditxml','editxml','x','EditXML',1); - $result.=&problem_edit_action_button('subundo','undo','u','Undo',1); - } - $result.="\n
"; -# Buttons that save - $result.='
'; - if ($mode eq 'editxml') { - $result.=&problem_edit_action_button('subsaveedit','saveeditxml','s','Save and EditXML'); - $result.=&problem_edit_action_button('subsaveview','saveviewxml','v','Save and View'); - } else { - $result.=&problem_edit_action_button('subsaveedit','saveedit','s','Save and Edit'); - $result.=&problem_edit_action_button('subsaveview','saveview','v','Save and View'); - } - $result.="\n
\n"; - return $result; + return ' +
+ + + +
+
+ + +
'; } sub problem_edit_header { - return ''. - &remember_problem_state('edit').' + return ''. + &Apache::structuretags::remember_problem_state().'
'.&mt('Problem Editing').&Apache::loncommon::help_open_menu('Problem Editing','Problem_Editor_XML_Index',5,'Authoring').'
'. -''. &problem_edit_buttons().'
'.&Apache::lonxml::message_location().' @@ -793,15 +758,15 @@ sub store_aggregates { foreach my $part (@parts) { if ($env{'request.role'} =~/^st/) { if ($Apache::lonhomework::results{'resource.'.$part.'.award'} - eq 'APPROX_ANS' || - $Apache::lonhomework::results{'resource.'.$part.'.award'} - eq 'EXACT_ANS') { + eq 'APPROX_ANS' || + $Apache::lonhomework::results{'resource.'.$part.'.award'} + eq 'EXACT_ANS') { $aggregate{$symb."\0".$part."\0correct"} = 1; } if ($Apache::lonhomework::results{'resource.'.$part.'.tries'} == 1) { $aggregate{$symb."\0".$part."\0users"} = 1; } else { - my (undef,$last_reset) = &Apache::grades::get_last_resets($symb,$env{'request.course.id'},[$part]); + my (undef,$last_reset) = &Apache::grades::get_last_resets($symb,$env{'request.course.id'},[$part]); if ($last_reset) { if (&Apache::grades::get_num_tries(\%Apache::lonhomework::history,$last_reset,$part) == 0) { $aggregate{$symb."\0".$part."\0users"} = 1; @@ -810,7 +775,7 @@ sub store_aggregates { } $aggregate{$symb."\0".$part."\0attempts"} = 1; } - if (($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurvey') || + if (($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurvey') || ($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurveycred') || ($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'randomizetry')) { if ($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'randomizetry') { @@ -819,7 +784,7 @@ sub store_aggregates { $anoncounter{$symb."\0".$part} = 1; } my $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$Apache::lonhomework::results{'resource.'.$part.'.type'}}; - if ($needsrelease) { + if ($needsrelease) { my $curr_required = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'}; if ($curr_required eq '') { &Apache::lonnet::update_released_required($needsrelease); @@ -945,9 +910,6 @@ sub reset_problem_globals { undef(%Apache::lonhomework::history); undef(%Apache::lonhomework::results); undef($Apache::inputtags::part); - if ($type eq 'Task') { - undef($Apache::inputtags::slot_name); - } #don't undef this, lonhomework.pm takes care of this, we use this to #detect if we try to do 2 problems in one file # undef($Apache::lonhomework::parsing_a_problem); @@ -1060,17 +1022,6 @@ sub start_problem { if ($target eq 'analyze') { my $rndseed=&setup_rndseed($safeeval,$target); } if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') { - #handle exam checkout - if ($Apache::lonhomework::type eq 'exam') { - my $token= - $Apache::lonhomework::history{"resource.0.outtoken"}; - if (($env{'form.doescheckout'}) && (!$token)) { - $token=&Apache::lonxml::maketoken(); - $Apache::lonhomework::history{"resource.0.outtoken"}= - $token; - } - $result.=&Apache::lonxml::printtokenheader($target,$token); - } if ($env{'form.markaccess'}) { my @interval=&Apache::lonnet::EXT("resource.0.interval"); &Apache::lonnet::set_first_access($interval[1]); @@ -1196,13 +1147,12 @@ sub start_problem { $result .= ''."\n"; } - foreach my $field ('questiontype','rndseed') { + foreach my $field ('trial','questiontype') { if ($env{"form.grade_$field"} ne '') { $result .= ''."\n"; } } - } } elsif ($target eq 'tex') { $result .= 'INSERTTEXFRONTMATTERHERE'; @@ -1308,7 +1258,7 @@ sub end_problem { } else { $frontmatter.= $begin_doc.$toc_line; if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { - $frontmatter .= '\fbox{\textit{'.&mt('[quant,_1,pt,pt]',$weight ).'}}'; + $frontmatter .= '\fbox{\textit{'.$weight.' pt}}'; } } } else { @@ -1318,7 +1268,7 @@ sub end_problem { if (not $env{'request.symb'} =~ m/\.page_/) { $frontmatter .= $begin_doc.$toc_line; if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { - $frontmatter .= '\fbox{\textit{'.&mt('[quant,_1,pt,pt]',$weight ).'}}'; + $frontmatter .= '\fbox{\textit{'.$weight.' pt}}'; } } else { $frontmatter .= '\vskip 1mm \\\\\\\\'.$startminipage; @@ -1342,7 +1292,7 @@ sub end_problem { } } elsif ( ($target eq 'web' || $target eq 'tex') && $Apache::inputtags::part eq '0' && - $status ne 'UNCHECKEDOUT' && $status ne 'NOT_YET_VIEWED') { + $status ne 'UNCHECKEDOUT' && $status ne 'NOT_YET_VIEWED') { # if part is zero, no s existed, so we need show the current # grading status my $gradestatus = &Apache::inputtags::gradestatus($Apache::inputtags::part,$target); @@ -1352,8 +1302,8 @@ sub end_problem { (($target eq 'web') && ($env{'request.state'} ne 'construct')) || ($target eq 'answer') || ($target eq 'tex') ) { - if (($target ne 'tex') && - ($env{'form.answer_output_mode'} ne 'tex')) { + if ($target ne 'tex' && + $env{'form.answer_output_mode'} ne 'tex') { $result.=""; } if ($target eq 'web') { @@ -1879,6 +1829,7 @@ sub ordered_show_check { return $in_order_show; } + sub start_startpartmarker { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; my $result=''; @@ -1887,7 +1838,7 @@ sub start_startpartmarker { $result.=&mt('Marker for the start of a part. Place end marker below to wrap in-between tags into a new part.').''; $result.=&Apache::edit::end_table(); - } + } return $result; } @@ -1917,6 +1868,10 @@ sub end_endpartmarker { return @result; } + + + + sub start_part { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; if (!$Apache::lonxml::metamode) { @@ -2002,12 +1957,12 @@ sub start_part { $allow_print_points=0; } if (($Apache::lonhomework::type eq 'exam') && ($allow_print_points)) { - $result .= '\vskip 10mm\fbox{\textit{'.&mt('[quant,_1,pt,pt]',$weight ).'}}'; + $result .= '\vskip 10mm\fbox{\textit{'.$weight.' pt}}'; } } elsif ($target eq 'web') { if ($status eq 'CAN_ANSWER') { - my $problemstatus = &get_problem_status($Apache::inputtags::part); + my $problemstatus = &get_problem_status($Apache::inputtags::part); my $probrandomize = &Apache::lonnet::EXT("resource.$Apache::inputtags::partlist[0].type"); my $probrandtries = &Apache::lonnet::EXT("resource.$Apache::inputtags::partlist[0].randomizeontries"); my $num = scalar(@Apache::inputtags::partlist)-1; @@ -2025,7 +1980,7 @@ sub start_part { $result .= &randomizetry_part_header($problemstatus,$reqtries,$num); } } - $result.=''; + $result.=''; } } } @@ -2239,7 +2194,7 @@ sub end_startouttext { .'' .'' .&Apache::lonhtmlcommon::dragmath_button($areaid,1) - .'' + .'' .'' .&Apache::edit::insertlist($target,$token) .'' @@ -2312,12 +2267,11 @@ sub start_simpleeditbutton { # .&mt('Note: it can take up to 10 minutes for changes to take effect for all users.') # .&Apache::loncommon::help_open_topic('Caching') # .'

'; - $result.=&Apache::loncommon::head_subbox( - &Apache::lonhtmlcommon::start_funclist() + $result.=&Apache::lonhtmlcommon::start_funclist() .&Apache::lonhtmlcommon::add_item_funclist( '' .&mt('Edit').'') - .&Apache::lonhtmlcommon::end_funclist()); + .&Apache::lonhtmlcommon::end_funclist(); } return $result;