[system] / trunk / pg / macros / PGbasicmacros.pl Repository:
ViewVC logotype

Diff of /trunk/pg/macros/PGbasicmacros.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 2165 Revision 2166
741 $name = RECORD_ANS_NAME($name); # record answer name 741 $name = RECORD_ANS_NAME($name); # record answer name
742 my $answer_value = ''; 742 my $answer_value = '';
743 $answer_value = ${$inputs_ref}{$name} if defined(${$inputs_ref}{$name}); 743 $answer_value = ${$inputs_ref}{$name} if defined(${$inputs_ref}{$name});
744 my $out = ""; 744 my $out = "";
745 if ($displayMode eq 'HTML' or $displayMode eq 'HTML_tth' or 745 if ($displayMode eq 'HTML' or $displayMode eq 'HTML_tth' or
746 $displayMode eq 'HTML_dpng' or $displayMode eq 'HTML_img') { 746 $displayMode eq 'HTML_dpng' or $displayMode eq 'HTML_img' or $displayMode eq 'HTML_jsMath') {
747 $out = qq!<SELECT NAME = "$name" SIZE=1> \n!; 747 $out = qq!<SELECT NAME = "$name" SIZE=1> \n!;
748 my $i; 748 my $i;
749 foreach ($i=0; $i< @list; $i=$i+2) { 749 foreach ($i=0; $i< @list; $i=$i+2) {
750 my $select_flag = ($list[$i] eq $answer_value) ? "SELECTED" : ""; 750 my $select_flag = ($list[$i] eq $answer_value) ? "SELECTED" : "";
751 $out .= qq!<OPTION $select_flag VALUE ="$list[$i]" > $list[$i+1] </OPTION>\n!; 751 $out .= qq!<OPTION $select_flag VALUE ="$list[$i]" > $list[$i+1] </OPTION>\n!;
1104 if defined( $options{HTML_tth} ); 1104 if defined( $options{HTML_tth} );
1105 return $options{HTML} 1105 return $options{HTML}
1106 if defined( $options{HTML} ); 1106 if defined( $options{HTML} );
1107 die " ERROR in using MODES: 'HTML' option not defined for HTML_dpng"; 1107 die " ERROR in using MODES: 'HTML' option not defined for HTML_dpng";
1108 1108
1109 }
1110
1111 if ($displayMode eq "HTML_jsMath") {
1112 return $options{HTML_img} if defined $options{HTML_img};
1113 return $options{HTML_dpng} if defined $options{HTML_dpng};
1114 return $options{HTML_tth} if defined $options{HTML_tth};
1115 return $options{HTML} if defined $options{HTML};
1116 die " ERROR in using MODES: 'HTML' option not defined for HTML_jsMath";
1109 } 1117 }
1110 1118
1111 # trap undefined errors 1119 # trap undefined errors
1112 die "ERROR in defining MODES: Can't find |$displayMode| among 1120 die "ERROR in defining MODES: Can't find |$displayMode| among
1113 available options:" . join(" ", keys(%options) ) 1121 available options:" . join(" ", keys(%options) )
1489 $out = $envir->{'imagegen'}->add($in_delim); 1497 $out = $envir->{'imagegen'}->add($in_delim);
1490 # for my version of ImageGenerator 1498 # for my version of ImageGenerator
1491 #$out = $envir->{'imagegen'}->add($in, $mode); 1499 #$out = $envir->{'imagegen'}->add($in, $mode);
1492 } elsif ($displayMode eq "HTML_img") { 1500 } elsif ($displayMode eq "HTML_img") {
1493 $out = math2img($in, $mode); 1501 $out = math2img($in, $mode);
1502 } elsif ($displayMode eq "HTML_jsMath") {
1503 $out = '<SPAN CLASS="math">'.$in.'</SPAN>' if $mode eq "inline";
1504 $out = '<DIV CLASS="math">'.$in.'</DIV>' if $mode eq "display";
1494 } else { 1505 } else {
1495 $out = "\\($in\\)" if $mode eq "inline"; 1506 $out = "\\($in\\)" if $mode eq "inline";
1496 $out = "\\[$in\\]" if $mode eq "display"; 1507 $out = "\\[$in\\]" if $mode eq "display";
1497 } 1508 }
1498 return $out; 1509 return $out;
1792 $out .= "\n\\par\\smallskip\\begin{center}\\begin{tabular}{" . "|c" x $number . "|} \\hline\n"; 1803 $out .= "\n\\par\\smallskip\\begin{center}\\begin{tabular}{" . "|c" x $number . "|} \\hline\n";
1793 } 1804 }
1794 elsif ($displayMode eq 'Latex2HTML') { 1805 elsif ($displayMode eq 'Latex2HTML') {
1795 $out .= "\n\\begin{rawhtml} <TABLE , BORDER=1>\n\\end{rawhtml}"; 1806 $out .= "\n\\begin{rawhtml} <TABLE , BORDER=1>\n\\end{rawhtml}";
1796 } 1807 }
1797 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' || $displayMode eq 'HTML_img') { 1808 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' || $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath') {
1798 $out .= "<TABLE BORDER=1>\n" 1809 $out .= "<TABLE BORDER=1>\n"
1799 } 1810 }
1800 else { 1811 else {
1801 $out = "Error: PGbasicmacros: begintable: Unknown displayMode: $displayMode.\n"; 1812 $out = "Error: PGbasicmacros: begintable: Unknown displayMode: $displayMode.\n";
1802 } 1813 }
1809 $out .= "\n\\end {tabular}\\end{center}\\par\\smallskip\n"; 1820 $out .= "\n\\end {tabular}\\end{center}\\par\\smallskip\n";
1810 } 1821 }
1811 elsif ($displayMode eq 'Latex2HTML') { 1822 elsif ($displayMode eq 'Latex2HTML') {
1812 $out .= "\n\\begin{rawhtml} </TABLE >\n\\end{rawhtml}"; 1823 $out .= "\n\\begin{rawhtml} </TABLE >\n\\end{rawhtml}";
1813 } 1824 }
1814 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' ||$displayMode eq 'HTML_img') { 1825 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' ||$displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath') {
1815 $out .= "</TABLE>\n"; 1826 $out .= "</TABLE>\n";
1816 } 1827 }
1817 else { 1828 else {
1818 $out = "Error: PGbasicmacros: endtable: Unknown displayMode: $displayMode.\n"; 1829 $out = "Error: PGbasicmacros: endtable: Unknown displayMode: $displayMode.\n";
1819 } 1830 }
1837 while (@elements) { 1848 while (@elements) {
1838 $out .= " \n\\begin{rawhtml}\n<TD> \n\\end{rawhtml}\n" . shift(@elements) . " \n\\begin{rawhtml}\n</TD> \n\\end{rawhtml}\n"; 1849 $out .= " \n\\begin{rawhtml}\n<TD> \n\\end{rawhtml}\n" . shift(@elements) . " \n\\begin{rawhtml}\n</TD> \n\\end{rawhtml}\n";
1839 } 1850 }
1840 $out .= " \n\\begin{rawhtml}\n</TR> \n\\end{rawhtml}\n"; 1851 $out .= " \n\\begin{rawhtml}\n</TR> \n\\end{rawhtml}\n";
1841 } 1852 }
1842 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng'||$displayMode eq 'HTML_img') { 1853 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng'||$displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath') {
1843 $out .= "<TR>\n"; 1854 $out .= "<TR>\n";
1844 while (@elements) { 1855 while (@elements) {
1845 $out .= "<TD>" . shift(@elements) . "</TD>"; 1856 $out .= "<TD>" . shift(@elements) . "</TD>";
1846 } 1857 }
1847 $out .= "\n</TR>\n"; 1858 $out .= "\n</TR>\n";
1926 $out = "\\includegraphics[width=$width_ratio\\linewidth]{$imagePath}\n"; 1937 $out = "\\includegraphics[width=$width_ratio\\linewidth]{$imagePath}\n";
1927 } 1938 }
1928 } elsif ($displayMode eq 'Latex2HTML') { 1939 } elsif ($displayMode eq 'Latex2HTML') {
1929 $out = qq!\\begin{rawhtml}\n<A HREF= "$imageURL" TARGET="ZOOM"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height"></A>\n 1940 $out = qq!\\begin{rawhtml}\n<A HREF= "$imageURL" TARGET="ZOOM"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height"></A>\n
1930 \\end{rawhtml}\n ! 1941 \\end{rawhtml}\n !
1931 } elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' || $displayMode eq 'HTML_img') { 1942 } elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' || $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath') {
1932 $out = qq!<A HREF= "$imageURL" TARGET="ZOOM"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height"></A> 1943 $out = qq!<A HREF= "$imageURL" TARGET="ZOOM"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height"></A>
1933 ! 1944 !
1934 } else { 1945 } else {
1935 $out = "Error: PGbasicmacros: image: Unknown displayMode: $displayMode.\n"; 1946 $out = "Error: PGbasicmacros: image: Unknown displayMode: $displayMode.\n";
1936 } 1947 }
1955 $out = " $out \n" if $displayMode eq 'TeX'; 1966 $out = " $out \n" if $displayMode eq 'TeX';
1956 $out = " $out " if $displayMode eq 'HTML'; 1967 $out = " $out " if $displayMode eq 'HTML';
1957 $out = " $out " if $displayMode eq 'HTML_tth'; 1968 $out = " $out " if $displayMode eq 'HTML_tth';
1958 $out = " $out " if $displayMode eq 'HTML_dpng'; 1969 $out = " $out " if $displayMode eq 'HTML_dpng';
1959 $out = " $out " if $displayMode eq 'HTML_img'; 1970 $out = " $out " if $displayMode eq 'HTML_img';
1971 $out = " $out " if $displayMode eq 'HTML_jsMath';
1960 $out = " $out " if $displayMode eq 'Latex2HTML'; 1972 $out = " $out " if $displayMode eq 'Latex2HTML';
1961 $out; 1973 $out;
1962} 1974}
1963 1975
1964sub captions { 1976sub captions {
2010 $out .= "\n\\begin{rawhtml} <TH>\n\\end{rawhtml}\n".&caption( shift(@captions) ) 2022 $out .= "\n\\begin{rawhtml} <TH>\n\\end{rawhtml}\n".&caption( shift(@captions) )
2011 . "\n\\begin{rawhtml} </TH>\n\\end{rawhtml}\n" ; 2023 . "\n\\begin{rawhtml} </TH>\n\\end{rawhtml}\n" ;
2012 } 2024 }
2013 2025
2014 $out .= "\n\\begin{rawhtml} </TR> </TABLE >\n\\end{rawhtml}"; 2026 $out .= "\n\\begin{rawhtml} </TR> </TABLE >\n\\end{rawhtml}";
2015 } elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng'|| $displayMode eq 'HTML_img'){ 2027 } elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng'|| $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath'){
2016 $out .= "<P>\n <TABLE BORDER=2 CELLPADDING=3 CELLSPACING=2 ><TR ALIGN=CENTER VALIGN=MIDDLE>\n"; 2028 $out .= "<P>\n <TABLE BORDER=2 CELLPADDING=3 CELLSPACING=2 ><TR ALIGN=CENTER VALIGN=MIDDLE>\n";
2017 while (@images) { 2029 while (@images) {
2018 $out .= " \n<TD>". &image( shift(@images),%options ) ."</TD>"; 2030 $out .= " \n<TD>". &image( shift(@images),%options ) ."</TD>";
2019 } 2031 }
2020 $out .= "</TR>\n<TR>"; 2032 $out .= "</TR>\n<TR>";

Legend:
Removed from v.2165  
changed lines
  Added in v.2166

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9