--- loncom/xml/lonxml.pm 2009/11/30 21:29:41 1.502 +++ loncom/xml/lonxml.pm 2010/07/26 09:58:53 1.511 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.502 2009/11/30 21:29:41 raeburn Exp $ +# $Id: lonxml.pm,v 1.511 2010/07/26 09:58:53 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -222,101 +222,6 @@ sub xmlend { return $discussion; } -sub tokeninputfield { - my $defhost=$Apache::lonnet::perlvar{'lonHostID'}; - $defhost=~tr/a-z/A-Z/; - return (< - function updatetoken() { - var comp=new Array; - var barcode=unescape(document.tokeninput.barcode.value); - comp=barcode.split('*'); - if (typeof(comp[0])!="undefined") { - document.tokeninput.codeone.value=comp[0]; - } - if (typeof(comp[1])!="undefined") { - document.tokeninput.codetwo.value=comp[1]; - } - if (typeof(comp[2])!="undefined") { - comp[2]=comp[2].toUpperCase(); - document.tokeninput.codethree.value=comp[2]; - } - document.tokeninput.barcode.value=''; - } - -
- - - - -
DocID Checkin
- - - - - - - -
Scan in Barcode
or Type in DocID - -* - -* - -
-
-
-ENDINPUTFIELD -} - -sub maketoken { - my ($symb,$tuname,$tudom,$tcrsid)=@_; - unless ($symb) { - $symb=&Apache::lonnet::symbread(); - } - unless ($tuname) { - $tuname=$env{'user.name'}; - $tudom=$env{'user.domain'}; - $tcrsid=$env{'request.course.id'}; - } - - return &Apache::lonnet::checkout($symb,$tuname,$tudom,$tcrsid); -} - -sub printtokenheader { - my ($target,$token,$tsymb,$tcrsid,$tudom,$tuname)=@_; - unless ($token) { return ''; } - - my ($symb,$courseid,$domain,$name) = &Apache::lonnet::whichuser(); - unless ($tsymb) { - $tsymb=$symb; - } - unless ($tuname) { - $tuname=$name; - $tudom=$domain; - $tcrsid=$courseid; - } - - my $plainname=&Apache::loncommon::plainname($tuname,$tudom); - - if ($target eq 'web') { - my %idhash=&Apache::lonnet::idrget($tudom,($tuname)); - return - ''. - &mt('Checked out for').' '.$plainname. - '
'.&mt('User').': '.$tuname.' at '.$tudom. - '
'.&mt('ID').': '.$idhash{$tuname}. - '
'.&mt('CourseID').': '.$tcrsid. - '
'.&mt('Course').': '.$env{'course.'.$tcrsid.'.description'}. - '
'.&mt('DocID').': '.$token. - '
'.&mt('Time').': '.&Apache::lonlocal::locallocaltime().'
'; - } else { - return $token; - } -} - sub printalltags { my $temp; foreach $temp (sort keys %Apache::lonxml::alltags) { @@ -571,6 +476,10 @@ sub inner_xmlparse { } if (($ENV{'QUERY_STRING'}) && ($target eq 'web')) { $finaloutput=&afterburn($finaloutput); + } + if ($target eq 'modified') { +# if modfied, handle startpart and endpart + $finaloutput=~s/\]*\>(.*)\]*\>/$1<\/part>/gs; } return $finaloutput; } @@ -733,8 +642,9 @@ sub setup_globals { sub init_safespace { my ($target,$safeeval,$safehole,$safeinit) = @_; - $safeeval->deny_only(':dangerous'); $safeeval->reval('use Math::Complex;'); + $safeeval->reval('use LaTeX::Table;'); + $safeeval->deny_only(':dangerous'); $safeeval->permit_only(":default"); $safeeval->permit("entereval"); $safeeval->permit(":base_math"); @@ -1549,22 +1459,27 @@ sub renderingoptions { } my $output; unless ($env{'form.forceedit'}) { - $output .= ' - '. + $output .= + ''. &mt('Language:').' '. - &Apache::loncommon::select_form($env{'form.languages'},'languages', - %langchoices).' - '; + &Apache::loncommon::select_form( + $env{'form.languages'}, + 'languages', + {&Apache::lonlocal::texthash(%langchoices)}). + ''; } - $output .= ' - '. + $output .= + ' '. &mt('Math Rendering:').' '. - &Apache::loncommon::select_form($env{'form.texengine'},'texengine', - ('' => '', - 'tth' => 'tth (TeX to HTML)', - 'jsMath' => 'jsMath', - 'mimetex' => 'mimetex (Convert to Images)')).' - '; + &Apache::loncommon::select_form( + $env{'form.texengine'}, + 'texengine', + {&Apache::lonlocal::texthash + ('' => '', + 'tth' => 'tth (TeX to HTML)', + 'jsMath' => 'jsMath', + 'mimetex' => 'mimetex (Convert to Images)')}). + ''; return $output; } @@ -1820,14 +1735,22 @@ ENDNOTFOUND &Apache::structuretags::reset_problem_globals(); &Apache::lonhomework::finished_parsing(); } elsif ($filetype eq 'tex') { - $result .= &Apache::lontexconvert::converted(\$filecontents); + $result = &Apache::lontexconvert::converted(\$filecontents, + $env{'form.texengine'}); + if ($env{'form.return_only_error_and_warning_counts'}) { + if (&verify_html(''.$result.'')) { + $errorcount++; + } + $result = "$errorcount:$warningcount"; + } } else { $result = $filecontents; } &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['rawmode']); if ($env{'form.rawmode'}) { $result = $filecontents; } - if ($filetype ne 'html') { + if (($filetype ne 'html') && + (!$env{'form.return_only_error_and_warning_counts'})) { my $nochgview = 1; my $controls = ''; if ($env{'request.state'} eq 'construct') { @@ -1842,26 +1765,22 @@ ENDNOTFOUND '
'.$result.
                               '
'; } - if ($env{'environment.remote'} eq 'off') { - my $brcrum; - if ($env{'request.state'} eq 'construct') { - $brcrum = [{'href' => &Apache::loncommon::authorspace(), - 'text' => 'Construction Space'}, - {'href' => '', - 'text' => $breadcrumbtext}]; - } else { - $brcrum = ''; # FIXME: Where are we? - } - my %options = ('bread_crumbs' => $brcrum, - 'bgcolor' => '#FFFFFF'); - $result = - &Apache::loncommon::start_page(undef,undef,\%options) - .$controls - .$result - .&Apache::loncommon::end_page(); + my $brcrum; + if ($env{'request.state'} eq 'construct') { + $brcrum = [{'href' => &Apache::loncommon::authorspace(), + 'text' => 'Construction Space'}, + {'href' => '', + 'text' => $breadcrumbtext}]; } else { - $result = $controls.$result; + $brcrum = ''; # FIXME: Where are we? } + my %options = ('bread_crumbs' => $brcrum, + 'bgcolor' => '#FFFFFF'); + $result = + &Apache::loncommon::start_page(undef,undef,\%options) + .$controls + .$result + .&Apache::loncommon::end_page(); } } } @@ -1892,10 +1811,6 @@ ENDNOTFOUND $header = &Apache::loncommon::head_subbox( &Apache::loncommon::CSTR_pageheader()); } - if ($env{'environment.remote'} ne 'off') { - $options{'bgcolor'} = '#FFFFFF'; - $options{'only_body'} = 1; - } my $js = &Apache::edit::js_change_detection(). &Apache::loncommon::resize_textarea_js(); @@ -2278,24 +2193,20 @@ sub get_tag { =pod -=item &print_pdf_radiobutton(fieldname, value, text) +=item &print_pdf_radiobutton(fieldname, value) -Returns a latexline to generate a PDF-Form-Radiobutton with Text. +Returns a latexline to generate a PDF-Form-Radiobutton. +Note: Radiobuttons with equal names are automaticly grouped + in a selection-group. -$fieldname: PDF internalname of the radiobutton -$value: Value of radiobutton (read when dumping the PDF data) -$text: Text on the rightside of the radiobutton +$fieldname: PDF internalname of the radiobutton(group) +$value: Value of radiobutton =cut sub print_pdf_radiobutton { - my $result = ''; - my ($fieldName, $value, $text) = @_; - $result .= '\begin{tabularx}{\textwidth}{p{0cm}X}'."\n"; - $result .= '\radioButton[\symbolchoice{circle}]{'. - $fieldName.'}{10bp}{10bp}{'.$value.'}&'.$text."\n"; - $result .= '\end{tabularx}' . "\n"; - $result .= '\hspace{2mm}' . "\n"; - return $result; + my ($fieldname, $value) = @_; + return '\radioButton[\symbolchoice{circle}]{' + .$fieldname.'}{10bp}{10bp}{'.$value.'}'; }