[LON-CAPA-cvs] cvs: loncom /interface lonsyllabus.pm
raeburn
raeburn at source.lon-capa.org
Mon Aug 26 23:00:39 EDT 2013
raeburn Tue Aug 27 03:00:39 2013 EDT
Modified files:
/loncom/interface lonsyllabus.pm
Log:
- Eliminate printing errors when syllabus is an uploaded HTML file, tex file
or an external URL.
Index: loncom/interface/lonsyllabus.pm
diff -u loncom/interface/lonsyllabus.pm:1.129 loncom/interface/lonsyllabus.pm:1.130
--- loncom/interface/lonsyllabus.pm:1.129 Mon Aug 26 23:38:07 2013
+++ loncom/interface/lonsyllabus.pm Tue Aug 27 03:00:38 2013
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Syllabus
#
-# $Id: lonsyllabus.pm,v 1.129 2013/08/26 23:38:07 raeburn Exp $
+# $Id: lonsyllabus.pm,v 1.130 2013/08/27 03:00:38 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -73,12 +73,6 @@
my %courseenv=&Apache::lonnet::dump('environment',$cdom,$cnum);
my $crstype = &Apache::loncommon::course_type();
-# ------------------------------------------------------------ Print the screen
-
- if ($target eq 'tex') {
- $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}));
- }
-
# --------------------------------------------------------------- Force Student
my ($forceedit,$forcestudent);
if ($env{'form.forceedit'}) { $forceedit=1; }
@@ -124,19 +118,26 @@
if ($filecontents eq -1) {
$r->print(&mt('Syllabus file unavailable'));
} elsif ($filetype eq 'tex') {
- my $result = &Apache::lontexconvert::converted(\$filecontents,
- $env{'form.texengine'});
- my %args;
- &get_breadcrumbs($cdom,$cnum,$crstype,\%args);
- $r->print(&Apache::loncommon::start_page("Syllabus",undef,\%args).
- $result.
- &Apache::loncommon::end_page());
+ if ($target eq 'tex') {
+ $r->print($filecontents);
+ } else {
+ my $result = &Apache::lontexconvert::converted(\$filecontents,
+ $env{'form.texengine'});
+ my %args;
+ &get_breadcrumbs($cdom,$cnum,$crstype,\%args);
+ $r->print(&Apache::loncommon::start_page("Syllabus",undef,\%args).
+ $result.
+ &Apache::loncommon::end_page());
+ }
} else {
my %mystyle;
+ unless ($target eq 'tex') {
+ $target = 'web';
+ }
&Apache::structuretags::reset_problem_globals();
my $oldfile = $env{'request.filename'};
$env{'request.filename'} = $item;
- my $result = &Apache::lonxml::xmlparse($r,'web',$filecontents,
+ my $result = &Apache::lonxml::xmlparse($r,$target,$filecontents,
'',%mystyle);
&Apache::structuretags::reset_problem_globals();
&Apache::lonhomework::finished_parsing();
@@ -145,17 +146,37 @@
$r->print($result);
}
} else {
- $r->print(&Apache::lonwrapper::wrapper($item));
+ if ($target eq 'tex') {
+ $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}).
+ ' \strut \\\\ \textbf{'.&mt('Syllabus').'} \strut \\\\ '.
+ &mt('Unsupported file type.').' \strut \\\\ '.
+ &mt('Print the syllabus directly from your web browser').
+ '\end{document}');
+ } else {
+ $r->print(&Apache::lonwrapper::wrapper($item));
+ }
}
return OK;
}
} elsif ($external=~/\w/) {
unless ($allowed && $forceedit) {
- $r->print(&Apache::lonwrapper::wrapper($external));
+ if ($target eq 'tex') {
+ $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}).
+ ' \strut \\\\ \textbf{'.&mt('Syllabus').'} \strut \\\\ '.$external.' '.
+ ' \strut \\\\ '.&mt('Print the syllabus directly from your web browser').
+ '\end{document}');
+ } else {
+ $r->print(&Apache::lonwrapper::wrapper($external));
+ }
return OK;
}
}
+# ------------------------------------------------------------ Print the screen
+
+ if ($target eq 'tex') {
+ $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}));
+ }
# ------------------------------ The buck stops here: internal syllabus display
# --------------------------------------------------------- The syllabus fields
@@ -1363,7 +1384,6 @@
$storehash{'updatedsyllabus'} = $now;
&Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.updatedsyllabus' => $now
});
-
} elsif ($saved eq 'url') {
my $prefix = &home_http_host($cdom,$cnum);
if ($external =~ m{^\Q$prefix/uploaded/$cdom/$cnum/portfolio/syllabus/\E(.+)$}) {
@@ -1395,7 +1415,7 @@
if (@envkeys > 0) {
foreach my $item (@envkeys) {
my $key = $item.'syllabus';
- if ($courseenv->{$key}) {
+ if ($courseenv->{$key} ne '') {
&Apache::lonnet::delenv('course.'.$env{'request.course.id'}.'.'.$key);
$storehash{$key} = '';
}
More information about the LON-CAPA-cvs
mailing list