--- loncom/homework/structuretags.pm 2011/12/14 11:56:08 1.497.2.4 +++ loncom/homework/structuretags.pm 2014/12/15 18:44:20 1.526 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.497.2.4 2011/12/14 11:56:08 foxr Exp $ +# $Id: structuretags.pm,v 1.526 2014/12/15 18:44:20 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -61,6 +61,7 @@ use Apache::lonlocal; use Apache::lonxml; use Apache::londefdef; use Apache::lonenc(); +use Apache::loncommon(); use Time::HiRes qw( gettimeofday tv_interval ); use lib '/home/httpd/lib/perl/'; use LONCAPA; @@ -96,13 +97,13 @@ my %languages_required; sub select_hyphenation { my $language = shift; - $language = &Apache::loncommon::latex_language($language); # Translate -> latex language. + $language = &Apache::loncommon::latexlanguage($language); # Translate -> latex language. # If there is no latex language there's not much we can do: if ($language) { &require_language($language); - my $babel_hyphenation = "\\select_language{$language}"; + my $babel_hyphenation = "\\selectlanguage{$language}"; return $babel_hyphenation; } else { @@ -110,6 +111,28 @@ sub select_hyphenation { } } ## +# Selects hyphenation based on the current problem metadata. +# This requires that +# - There is a language metadata item set for the problem. +# - The language has a latex/babel hyphenation. +# +# @note: Uses &Apache::lonxml::request to locate the Uri associated with +# this problem. +# @return string (possibly empty). +# @retval If not empty an appropriate \selectlanguage{} directive. +# +sub select_metadata_hyphenation { + my $uri = $Apache::lonxml::request->uri; + my $language = &Apache::lonnet::metadata($uri, 'language'); + my $latex_language = &Apache::loncommon::latexhyphenation($language); + if ($latex_language) { + return '\selectlanguage{'.$latex_language."}\n"; + } + return ''; # no latex hyphenation or no lang metadata. +} + + +## # Clears the set of languages required by the document being rendered. # sub clear_required_languages { @@ -122,7 +145,6 @@ sub clear_required_languages { # sub require_language { my $language = shift; - $languages_required{$language} = 1; } @@ -133,9 +155,8 @@ sub require_language { # @retval \usepackage[lang1,lang2...]{babel} # @retval '' if there are no languages_required. sub languages_header { - my $header =''; - my @languages = keys(%languages_required); + my @languages = (keys(%languages_required)); # Only generate the header if there are languages: @@ -143,7 +164,6 @@ sub languages_header { my $language_list = join(',', (@languages)); $header = '\usepackage['.$language_list."]{babel}\n"; } - return $header; } @@ -234,6 +254,55 @@ 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"}) ; + if (( $(this.form).id == "LC_page" ) && ($('input[name="all_submit"]').length )) { + if (buttonId != "all_submit") { + $( ".LC_status_"+buttonId ).hide(); + if (( "#"+buttonId+"_pressed" ).length) { + $( "#"+buttonId+"_pressed" ).val( "1" ); + } + } + } else { + $( ".LC_status_"+buttonId ).hide(); + } + $(this.form).submit(); + $( ".LC_hwk_submit" ).prop( "disabled", true); + $( ".LC_textline" ).prop( "readonly", "readonly"); + event.preventDefault(); + return true; + } + } + }); +}); + // ]]> JS @@ -350,6 +419,9 @@ sub page_start { "if (typeof swmenu != 'undefined') {swmenu.currentURL=null;}\n". &Apache::loncommon::browser_and_searcher_javascript(). "\n\n"; + if ($target eq 'edit') { + $extra_head .= &Apache::edit::js_update_linknum(); + } } } @@ -359,10 +431,10 @@ sub page_start { } elsif (!defined($found{'body'}) && $env{'request.state'} eq 'construct') { if ($target eq 'web' || $target eq 'edit') { - # Breadcrumbs for Construction Space + # Breadcrumbs for Authoring Space &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb({ - 'text' => 'Construction Space', + 'text' => 'Authoring Space', 'href' => &Apache::loncommon::authorspace($env{'request.uri'}), }); # breadcrumbs (and tools) will be created @@ -394,6 +466,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; @@ -433,7 +507,6 @@ sub page_start { } $form_tag_start.='>'."\n"; - my $symb=&Apache::lonnet::symbread(); if ($symb =~ /\S/) { $symb= &HTML::Entities::encode(&Apache::lonenc::check_encrypt($symb)); @@ -618,7 +691,7 @@ sub problem_edit_header { '.&Apache::lonxml::message_location().' '. - '
$lt{'warning'}
'.&mt('Once you click the "Show Resource" button below you have [_2] to complete all resources "[_1]".' + ,$foldertitle,$time)."
'.&mt('Once you click the "Show Resource" button below you have [_2] to complete all resources "[_1]".' + ,$course,$time)."
'.&mt('Once you click the "Show Resource" button below you have [_2] to complete this resource "[_1]".' + ,$title,$time)."
'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'
'.&mt('You are not currently signed up to work at this time and/or place.').'
'.&mt('Access requires reservation to work at specific time/place.').'
'.&mt('Not open to be viewed').'