--- loncom/homework/structuretags.pm 2013/09/05 12:07:29 1.515 +++ loncom/homework/structuretags.pm 2014/09/15 17:45:35 1.521 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.515 2013/09/05 12:07:29 goltermann Exp $ +# $Id: structuretags.pm,v 1.521 2014/09/15 17:45:35 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -254,6 +254,52 @@ function image_response_click (which, e) input_element.value = click; img_element.src = '/adm/randomlabel.png?token='+token+'&clickdata='+click; } + +var submithandled = 0; +var keypresshandled = 0; + +$(document).ready(function(){ + + $(document).keypress(function(event){ + var keycode = (event.keyCode ? event.keyCode : event.which); + if ((keycode == '13') && (keypresshandled == 0)) { + if ( $( document.activeElement ).hasClass("LC_textline") ) { + keypresshandled = 1; + var idsArray = $( document.activeElement ).attr("id").split(/HWVAL_/); + if (idsArray.length) { + event.preventDefault(); + var itemsArray = idsArray[1].split(/_/); + var buttonId = idsArray[0]+'submit_'+itemsArray[0]; + $("#"+buttonId).trigger("click"); + } + } + } + }); + + $(document).delegate('form :submit', 'click', function( event ) { + if ( $( this ).hasClass( "LC_hwk_submit" ) ) { + var buttonId = this.id; + if (submithandled == 0) { + submithandled = 1; + $( "#msg_"+buttonId ).css({"display": "inline","background-color": "#87cefa", + "color": "black","padding": "2px"}) ; + $( ".LC_status_"+buttonId ).hide(); + if (( $(this.form).id == "LC_page" ) && ($('input[name="all_submit"]').length )) { + if (( "#"+buttonId+"_pressed" ).length) { + $( "#"+buttonId+"_pressed" ).val( "1" ); + } + } + $(this.form).submit(); + $( ".LC_hwk_submit" ).prop( "disabled", true); + $( ".LC_textline" ).prop( "readonly", "readonly"); + event.preventDefault(); + return true; + } + } + }); +}); + + // ]]> JS @@ -414,6 +460,8 @@ sub page_start { $body_args{'add_entries'} = \%add_entries; if ( $env{'request.state'} eq 'construct') { $body_args{'only_body'} = 1; + } elsif ($target eq 'web') { + $body_args{'print_suppress'} = 1; } } $body_args{'no_auto_mt_title'} = 1; @@ -728,7 +776,7 @@ $show_all @@ -1168,7 +1216,7 @@ sub start_problem { $target eq 'tex') { if ($env{'form.markaccess'}) { my @interval=&Apache::lonnet::EXT("resource.0.interval"); - &Apache::lonnet::set_first_access($interval[1]); + &Apache::lonnet::set_first_access($interval[1],$interval[0]); } ($status,$accessmsg,$slot_name,$slot) = @@ -2057,9 +2105,15 @@ sub end_while { } $return = &Apache::run::run($code,$safeeval); } - if ($error) { - &Apache::lonxml::error('
'.&mt('Code ran too long. It ran for more than').' '.$Apache::lonnet::perlvar{'lonScriptTimeout'}.' '.&mt('seconds occurred while running <while> on line').' '.$line.'
'); - } + if ($error) { + &Apache::lonxml::error( + '
'
+               .&mt('Code ran too long. It ran for more than [_1] seconds.',
+                        $Apache::lonnet::perlvar{'lonScriptTimeout'})
+               .&mt('This occurred while running <while> on line [_1].',
+                        $line)
+               .'
'); + } } elsif ($target eq "edit") { $result.= &Apache::edit::tag_end($target,$token,''); }