--- loncom/homework/structuretags.pm 2007/10/31 01:37:52 1.408 +++ loncom/homework/structuretags.pm 2008/08/21 20:46:23 1.428 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.408 2007/10/31 01:37:52 albertel Exp $ +# $Id: structuretags.pm,v 1.428 2008/08/21 20:46:23 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -94,6 +94,7 @@ sub end_tex { sub homework_js { return &Apache::loncommon::resize_textarea_js(). + &setmode_javascript(). <<'JS'; JS } +sub setmode_javascript { + return <<"ENDSCRIPT"; + +ENDSCRIPT +} + sub page_start { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$name, $extra_head)=@_; @@ -135,6 +148,10 @@ sub page_start { $extra_head .= &homework_js(); + unless ($env{'environment.wysiwygeditor'} eq 'on') { + $extra_head .= &Apache::lonhtmlcommon::dragmath_js(); + } + my %body_args; if (defined($found{'html'})) { $body_args{'skip_phases'}{'head'}=1; @@ -199,7 +216,7 @@ sub page_start { } } - if (!defined($found{'body'})) { + if (!defined($found{'body'}) && $env{'request.state'} ne 'construct') { $page_start .= &Apache::lonxml::message_location(); } @@ -299,32 +316,44 @@ sub remember_problem_state { '; } +sub problem_edit_buttons { + return ' +
+ + + +
+
+ + +
'; +} + sub problem_edit_header { - return ''. + 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().' '. '
'; } sub problem_edit_footer { - return '

- '. + return '
+ +'. + &Apache::lonhtmlcommon::htmlareaselectactive(&Apache::lonhtmlcommon::get_htmlareafields()). "\n\n".&Apache::loncommon::end_page(); } @@ -387,8 +416,9 @@ sub problem_web_to_edit_header { $show_all @@ -421,7 +451,6 @@ $show_all $show_all "; } - $result.=' '.&mt('Apply style file: ').' @@ -429,6 +458,9 @@ $show_all '.&mt('Select').' +
'. + &Apache::lonxml::renderingoptions().' +
@@ -446,8 +478,9 @@ $show_all if (!$numtoanalyze) { $numtoanalyze=20; } $result .= ''. &mt('[_1] for [_2] versions.', - '', - '' + ,''). &Apache::loncommon::help_open_topic("Analyze_Problem",'',undef,undef,300). ''; @@ -457,12 +490,14 @@ $show_all $result.='
'; - $result.=''; - $result .= ''; - $result .= ''; - + $result.=''; + $result .= ''; + $result .= ''; $result.='
+ '.&Apache::lonxml::message_location().' '; return $result; } @@ -605,17 +640,37 @@ ENDCHECKOUT sub firstaccess_msg { my ($time,$symb)=@_; - my ($map)=&Apache::lonnet::decode_symb($symb); - my $foldertitle=&Apache::lonnet::gettitle($map); - &Apache::lonxml::debug("map is $map title is $foldertitle"); + my $result; + my @interval=&Apache::lonnet::EXT("resource.0.interval"); + if ($interval[1] eq 'map') { + my ($map)=&Apache::lonnet::decode_symb($symb); + my $foldertitle=&Apache::lonnet::gettitle($map); + + &Apache::lonxml::debug("map is $map title is $foldertitle"); + $result .= "

".&mt('The resources in "[_1]" are open for a limited time.' + .' Once you click the "Show Resource" button below you have [_2] to complete all resources "[_1]".' + ,$foldertitle,$time)."

"; + } elsif ($interval[1] eq 'course') { + my $course = $env{'course.'.$env{'request.course.id'}.'.description'}; + $result .= "

".&mt('The resources in "[_1]" are open for a limited time.' + .' Once you click the "Show Resource" button below you have [_2] to complete all resources "[_1]".' + ,$course,$time)."

"; + } else { + my $title=&Apache::lonnet::gettitle($symb); + $result .= "

".&mt('This resource "[_1]" is open for a limited time.' + .' Once you click the "Show Resource" button below you have [_2] to complete this resource "[_1]".' + ,$title,$time)."

"; + } my $uri = &Apache::lonenc::check_encrypt($env{'request.uri'}); - return (<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". + my $buttontext = &mt('Show Resource'); + my $timertext = &mt('Start Timer?'); + $result .= (< - + ENDCHECKOUT + return $result; } sub init_problem_globals { @@ -720,9 +775,10 @@ sub start_problem { } if ($target ne 'analyze') { - $Apache::lonhomework::type=&Apache::lonnet::EXT('resource.0.type'); + my $type = &Apache::lonnet::EXT('resource.0.type'); + $Apache::lonhomework::type=$type; if (($env{'request.state'} eq 'construct') && - defined($env{'form.problemtype'})) { + $env{'form.problemtype'} =~ /\S/) { $Apache::lonhomework::type=$env{'form.problemtype'}; } &Apache::lonxml::debug("Found this to be of type :$Apache::lonhomework::type:"); @@ -783,7 +839,8 @@ sub start_problem { $result.=&Apache::lonxml::printtokenheader($target,$token); } if ($env{'form.markaccess'}) { - &Apache::lonnet::set_first_access('map'); + my @interval=&Apache::lonnet::EXT("resource.0.interval"); + &Apache::lonnet::set_first_access($interval[1]); } #handle rand seed in construction space my $rndseed=&setup_rndseed($safeeval); @@ -808,6 +865,9 @@ sub start_problem { $form_tag_start.= ' />'.&mt(' Show All Foils'). ''; } + if ($Apache::lonhomework::type eq 'practice') { + $form_tag_start.=&practice_problem_header(); + } $form_tag_start.='
'; } @@ -880,6 +940,11 @@ sub start_problem { # create a page header and exit if ($env{'request.state'} eq "construct") { $result.= &problem_web_to_edit_header($env{'form.rndseed'}); + if ($Apache::lonhomework::type eq 'practice') { + $result.= ''. + &practice_problem_header().'
'; + } } # if we are viewing someone else preserve that info if (defined $env{'form.grade_symb'}) { @@ -1115,6 +1180,11 @@ sub start_library { $result.=" \n $form_tag_start". ''; $result.=&problem_web_to_edit_header($rndseed); + if ($Apache::lonhomework::type eq 'practice') { + $result.= ''. + &practice_problem_header().'
'; + } } return $result; } @@ -1322,7 +1392,11 @@ sub end_languageblock { my $result = &Apache::lonxml::endredirection(); my $which = &Apache::lonxml::get_param('which',$parstack, $safeeval); - $available_texts{$which} = $result; + foreach my $language (split(/\s*\,\s*/,$which)) { + unless ($language=~/\w/) { next; } + $available_texts{$language} = $result; + } + } return ''; } @@ -1779,7 +1853,8 @@ sub start_problemtype { $result .=&Apache::edit::checked_arg('When used as type(s):','for', [ ['exam','Exam/Quiz Problem'], ['survey','Survey'], - ['problem','Homework Problem'] ] + ['problem','Homework Problem'], + ['practice','Practice Problem'] ] ,$token); $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row(); } elsif ($target eq 'modified') { @@ -1814,14 +1889,18 @@ sub end_startouttext { my $text=''; if ($target eq 'edit') { + my $areaid = 'homework_edit_'.$Apache::lonxml::curdepth; $text=&Apache::lonxml::get_all_text("endouttext",$parser,$style); $result.=&Apache::edit::start_table($token)."".&mt('Text Block')." ".&mt('Delete:'). &Apache::edit::deletelist($target,$token) - ." -". - &Apache::edit::insertlist($target,$token). - '' . + .""; + unless ($env{'environment.wysiwygeditor'} eq 'on') { + $result.='' + .&Apache::lonhtmlcommon::dragmath_button($areaid,1) + .''; + } + $result.='' . &Apache::loncommon::helpLatexCheatsheet(). &Apache::edit::end_row(). &Apache::edit::start_spanning_row()."\n". @@ -1896,5 +1975,11 @@ sub end_simpleeditbutton { return ''; } +sub practice_problem_header { + return '

'.&mt('Practice Problem').'

'. + ''.&mt('Submissions are not permanently recorded'). + ''; +} + 1; __END__