--- loncom/homework/structuretags.pm 2011/01/07 05:14:57 1.465.2.12 +++ loncom/homework/structuretags.pm 2011/06/06 21:01:06 1.489 @@ -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.12 2011/01/07 05:14:57 raeburn Exp $ +# $Id: structuretags.pm,v 1.489 2011/06/06 21:01:06 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -144,7 +144,7 @@ function image_response_click (which, e) var y= e.clientY-getY(img_element)+Geometry.getVerticalScroll(); var click = x+':'+y; input_element.value = click; - img_element.src = '/adm/randomlabel.png?token='+token+'&clickdata='+click; + img_element.src = '/adm/randomlabel.png?token='+token+'&clickdata='+click; } // ]]> @@ -154,10 +154,12 @@ JS sub setmode_javascript { return <<"ENDSCRIPT"; ENDSCRIPT } @@ -175,7 +177,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 { - return ' -
- - - -
-
- - -
'; + 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; } sub problem_edit_header { - return ''. - &Apache::structuretags::remember_problem_state().' + return ''. + &remember_problem_state('edit').'
'.&mt('Problem Editing').&Apache::loncommon::help_open_menu('Problem Editing','Problem_Editor_XML_Index',5,'Authoring').'
'. +''. &problem_edit_buttons().'
'.&Apache::lonxml::message_location().' @@ -623,7 +648,7 @@ $show_all
- '; @@ -762,15 +787,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; @@ -779,7 +804,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') { @@ -788,7 +813,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); @@ -1026,17 +1051,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]); @@ -1162,13 +1176,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'; @@ -1845,6 +1858,7 @@ sub ordered_show_check { return $in_order_show; } + sub start_startpartmarker { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; my $result=''; @@ -1853,7 +1867,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; } @@ -1883,6 +1897,10 @@ sub end_endpartmarker { return @result; } + + + + sub start_part { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; if (!$Apache::lonxml::metamode) { @@ -1973,7 +1991,7 @@ sub start_part { } } 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; @@ -1991,7 +2009,7 @@ sub start_part { $result .= &randomizetry_part_header($problemstatus,$reqtries,$num); } } - $result.=''; + $result.=''; } } } @@ -2205,7 +2223,7 @@ sub end_startouttext { .'' .'' .&Apache::lonhtmlcommon::dragmath_button($areaid,1) - .'' + .'' .'' .&Apache::edit::insertlist($target,$token) .'' @@ -2278,11 +2296,12 @@ 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::lonhtmlcommon::start_funclist() + $result.=&Apache::loncommon::head_subbox( + &Apache::lonhtmlcommon::start_funclist() .&Apache::lonhtmlcommon::add_item_funclist( '' .&mt('Edit').'') - .&Apache::lonhtmlcommon::end_funclist(); + .&Apache::lonhtmlcommon::end_funclist()); } return $result;