--- loncom/interface/lonsyllabus.pm 2013/08/26 23:38:07 1.129 +++ loncom/interface/lonsyllabus.pm 2013/08/27 03:00:38 1.130 @@ -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 @@ sub handler { 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 @@ sub handler { 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 @@ sub handler { $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 @@ sub update_syllabus_env { $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 @@ sub update_syllabus_env { 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} = ''; }