--- loncom/homework/structuretags.pm 2011/12/14 11:56:08 1.497.2.4
+++ loncom/homework/structuretags.pm 2013/12/14 01:44:31 1.512.2.5
@@ -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.512.2.5 2013/12/14 01:44:31 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;
}
@@ -359,10 +379,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
@@ -433,7 +453,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 +637,7 @@ sub problem_edit_header {
'.&Apache::lonxml::message_location().'
'.
- '
';
+ '
';
}
sub problem_edit_footer {
@@ -956,7 +975,7 @@ sub checkout_msg {
$lt{'warning'}
ENDCHECKOUT
}
@@ -970,19 +989,19 @@ sub firstaccess_msg {
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)."
";
+ $result .= "
".&mt('The resources in "[_1]" are open for a limited time.',$foldertitle)."
"
+ .'
'.&mt('Once you click the "Show Resource" button below you have [_2] to complete all resources "[_1]".'
+ ,$foldertitle,$time)."
".&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)."
";
+ $result .= "
".&mt('The resources in "[_1]" are open for a limited time.',$course)."
"
+ .'
'.&mt('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)."
";
+ $result .= "
".&mt('This resource "[_1]" is open for a limited time.',$title)."
"
+ .'
'.&mt('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'});
my $buttontext = &mt('Show Resource');
@@ -990,7 +1009,7 @@ sub firstaccess_msg {
$result .= (<
-
+
ENDCHECKOUT
return $result;
@@ -1040,6 +1059,9 @@ 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);
@@ -1137,9 +1159,23 @@ sub start_problem {
&Apache::run::run($expression,$safeeval);
my $status;
my $accessmsg;
+ my $resource_due;
my $name= &get_resource_name($parstack,$safeeval);
- my ($result,$form_tag_start);
+ my ($result,$form_tag_start,$slot_name,$slot);
+
+ if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
+ $target eq 'tex') {
+ if ($env{'form.markaccess'}) {
+ my @interval=&Apache::lonnet::EXT("resource.0.interval");
+ &Apache::lonnet::set_first_access($interval[1]);
+ }
+
+ ($status,$accessmsg,$slot_name,$slot) =
+ &Apache::lonhomework::check_slot_access('0','problem');
+ push (@Apache::inputtags::status,$status);
+ }
+
if ($target eq 'web' || $target eq 'webgrade' || $target eq 'tex'
|| $target eq 'edit') {
($result,$form_tag_start) =
@@ -1152,14 +1188,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') {
- if ($env{'form.markaccess'}) {
- my @interval=&Apache::lonnet::EXT("resource.0.interval");
- &Apache::lonnet::set_first_access($interval[1]);
- }
-
- ($status,$accessmsg,my $slot_name,my $slot) =
- &Apache::lonhomework::check_slot_access('0','problem');
- push (@Apache::inputtags::status,$status);
#handle rand seed in construction space
my $rndseed=&setup_rndseed($safeeval,$target);
@@ -1209,18 +1237,24 @@ sub start_problem {
( $status eq 'BANNED') ||
( $status eq 'UNAVAILABLE') ||
( $status eq 'NOT_IN_A_SLOT') ||
+ ( $status eq 'NOTRESERVABLE') ||
+ ( $status eq 'RESERVABLE') ||
+ ( $status eq 'RESERVABLE_LATER') ||
( $status eq 'INVALID_ACCESS')) {
my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser,
$style);
if ( $target eq "web" ) {
my $msg;
if ($status eq 'UNAVAILABLE') {
- $msg.='
'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'
';
+ $msg.='
'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'