[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 2193 Revision 2199
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' or $displayMode eq 'HTML_jsMath') { 746 $displayMode eq 'HTML_dpng' or $displayMode eq 'HTML_img' or $displayMode eq 'HTML_jsMath' or $displayMode eq 'HTML_asciimath') {
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!;
1129 return $options{HTML_img} if defined $options{HTML_img}; 1129 return $options{HTML_img} if defined $options{HTML_img};
1130 return $options{HTML_dpng} if defined $options{HTML_dpng}; 1130 return $options{HTML_dpng} if defined $options{HTML_dpng};
1131 return $options{HTML_tth} if defined $options{HTML_tth}; 1131 return $options{HTML_tth} if defined $options{HTML_tth};
1132 return $options{HTML} if defined $options{HTML}; 1132 return $options{HTML} if defined $options{HTML};
1133 die " ERROR in using MODES: 'HTML' option not defined for HTML_jsMath"; 1133 die " ERROR in using MODES: 'HTML' option not defined for HTML_jsMath";
1134 }
1135
1136 if ($displayMode eq "HTML_asciimath") {
1137# return $options{HTML_img} if defined $options{HTML_img};
1138# return $options{HTML_dpng} if defined $options{HTML_dpng};
1139 return $options{HTML_tth} if defined $options{HTML_tth};
1140 return $options{HTML} if defined $options{HTML};
1141 die " ERROR in using MODES: 'HTML' option not defined for HTML_asciimath";
1134 } 1142 }
1135 1143
1136 # trap undefined errors 1144 # trap undefined errors
1137 die "ERROR in defining MODES: Can't find |$displayMode| among 1145 die "ERROR in defining MODES: Can't find |$displayMode| among
1138 available options:" . join(" ", keys(%options) ) 1146 available options:" . join(" ", keys(%options) )
1519 } elsif ($displayMode eq "HTML_img") { 1527 } elsif ($displayMode eq "HTML_img") {
1520 $out = math2img($in, $mode); 1528 $out = math2img($in, $mode);
1521 } elsif ($displayMode eq "HTML_jsMath") { 1529 } elsif ($displayMode eq "HTML_jsMath") {
1522 $out = '<SPAN CLASS="math">'.$in.'</SPAN>' if $mode eq "inline"; 1530 $out = '<SPAN CLASS="math">'.$in.'</SPAN>' if $mode eq "inline";
1523 $out = '<DIV CLASS="math">'.$in.'</DIV>' if $mode eq "display"; 1531 $out = '<DIV CLASS="math">'.$in.'</DIV>' if $mode eq "display";
1532 } elsif ($displayMode eq "HTML_asciimath") {
1533 $out = "`$in`" if $mode eq "inline";
1534 $out = '<DIV ALIGN="CENTER">`'.$in.'`</DIV>' if $mode eq "display";
1524 } else { 1535 } else {
1525 $out = "\\($in\\)" if $mode eq "inline"; 1536 $out = "\\($in\\)" if $mode eq "inline";
1526 $out = "\\[$in\\]" if $mode eq "display"; 1537 $out = "\\[$in\\]" if $mode eq "display";
1527 } 1538 }
1528 return $out; 1539 return $out;
1837 $out .= "\n\\par\\smallskip\\begin{center}\\begin{tabular}{" . "|c" x $number . "|} \\hline\n"; 1848 $out .= "\n\\par\\smallskip\\begin{center}\\begin{tabular}{" . "|c" x $number . "|} \\hline\n";
1838 } 1849 }
1839 elsif ($displayMode eq 'Latex2HTML') { 1850 elsif ($displayMode eq 'Latex2HTML') {
1840 $out .= "\n\\begin{rawhtml} <TABLE , BORDER=1>\n\\end{rawhtml}"; 1851 $out .= "\n\\begin{rawhtml} <TABLE , BORDER=1>\n\\end{rawhtml}";
1841 } 1852 }
1842 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' || $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath') { 1853 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' || $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath' || $displayMode eq 'HTML_asciimath') {
1843 $out .= "<TABLE BORDER=1>\n" 1854 $out .= "<TABLE BORDER=1>\n"
1844 } 1855 }
1845 else { 1856 else {
1846 $out = "Error: PGbasicmacros: begintable: Unknown displayMode: $displayMode.\n"; 1857 $out = "Error: PGbasicmacros: begintable: Unknown displayMode: $displayMode.\n";
1847 } 1858 }
1854 $out .= "\n\\end {tabular}\\end{center}\\par\\smallskip\n"; 1865 $out .= "\n\\end {tabular}\\end{center}\\par\\smallskip\n";
1855 } 1866 }
1856 elsif ($displayMode eq 'Latex2HTML') { 1867 elsif ($displayMode eq 'Latex2HTML') {
1857 $out .= "\n\\begin{rawhtml} </TABLE >\n\\end{rawhtml}"; 1868 $out .= "\n\\begin{rawhtml} </TABLE >\n\\end{rawhtml}";
1858 } 1869 }
1859 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' ||$displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath') { 1870 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' ||$displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath' || $displayMode eq 'HTML_asciimath') {
1860 $out .= "</TABLE>\n"; 1871 $out .= "</TABLE>\n";
1861 } 1872 }
1862 else { 1873 else {
1863 $out = "Error: PGbasicmacros: endtable: Unknown displayMode: $displayMode.\n"; 1874 $out = "Error: PGbasicmacros: endtable: Unknown displayMode: $displayMode.\n";
1864 } 1875 }
1882 while (@elements) { 1893 while (@elements) {
1883 $out .= " \n\\begin{rawhtml}\n<TD> \n\\end{rawhtml}\n" . shift(@elements) . " \n\\begin{rawhtml}\n</TD> \n\\end{rawhtml}\n"; 1894 $out .= " \n\\begin{rawhtml}\n<TD> \n\\end{rawhtml}\n" . shift(@elements) . " \n\\begin{rawhtml}\n</TD> \n\\end{rawhtml}\n";
1884 } 1895 }
1885 $out .= " \n\\begin{rawhtml}\n</TR> \n\\end{rawhtml}\n"; 1896 $out .= " \n\\begin{rawhtml}\n</TR> \n\\end{rawhtml}\n";
1886 } 1897 }
1887 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng'||$displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath') { 1898 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng'||$displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath' || $displayMode eq 'HTML_asciimath') {
1888 $out .= "<TR>\n"; 1899 $out .= "<TR>\n";
1889 while (@elements) { 1900 while (@elements) {
1890 $out .= "<TD>" . shift(@elements) . "</TD>"; 1901 $out .= "<TD>" . shift(@elements) . "</TD>";
1891 } 1902 }
1892 $out .= "\n</TR>\n"; 1903 $out .= "\n</TR>\n";
1971 $out = "\\includegraphics[width=$width_ratio\\linewidth]{$imagePath}\n"; 1982 $out = "\\includegraphics[width=$width_ratio\\linewidth]{$imagePath}\n";
1972 } 1983 }
1973 } elsif ($displayMode eq 'Latex2HTML') { 1984 } elsif ($displayMode eq 'Latex2HTML') {
1974 $out = qq!\\begin{rawhtml}\n<A HREF= "$imageURL" TARGET="ZOOM"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height"></A>\n 1985 $out = qq!\\begin{rawhtml}\n<A HREF= "$imageURL" TARGET="ZOOM"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height"></A>\n
1975 \\end{rawhtml}\n ! 1986 \\end{rawhtml}\n !
1976 } elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' || $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath') { 1987 } elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' || $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath' || $displayMode eq 'HTML_asciimath') {
1977 $out = qq!<A HREF= "$imageURL" TARGET="ZOOM"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height"></A> 1988 $out = qq!<A HREF= "$imageURL" TARGET="ZOOM"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height"></A>
1978 ! 1989 !
1979 } else { 1990 } else {
1980 $out = "Error: PGbasicmacros: image: Unknown displayMode: $displayMode.\n"; 1991 $out = "Error: PGbasicmacros: image: Unknown displayMode: $displayMode.\n";
1981 } 1992 }
2001 $out = " $out " if $displayMode eq 'HTML'; 2012 $out = " $out " if $displayMode eq 'HTML';
2002 $out = " $out " if $displayMode eq 'HTML_tth'; 2013 $out = " $out " if $displayMode eq 'HTML_tth';
2003 $out = " $out " if $displayMode eq 'HTML_dpng'; 2014 $out = " $out " if $displayMode eq 'HTML_dpng';
2004 $out = " $out " if $displayMode eq 'HTML_img'; 2015 $out = " $out " if $displayMode eq 'HTML_img';
2005 $out = " $out " if $displayMode eq 'HTML_jsMath'; 2016 $out = " $out " if $displayMode eq 'HTML_jsMath';
2017 $out = " $out " if $displayMode eq 'HTML_asciimath';
2006 $out = " $out " if $displayMode eq 'Latex2HTML'; 2018 $out = " $out " if $displayMode eq 'Latex2HTML';
2007 $out; 2019 $out;
2008} 2020}
2009 2021
2010sub captions { 2022sub captions {
2056 $out .= "\n\\begin{rawhtml} <TH>\n\\end{rawhtml}\n".&caption( shift(@captions) ) 2068 $out .= "\n\\begin{rawhtml} <TH>\n\\end{rawhtml}\n".&caption( shift(@captions) )
2057 . "\n\\begin{rawhtml} </TH>\n\\end{rawhtml}\n" ; 2069 . "\n\\begin{rawhtml} </TH>\n\\end{rawhtml}\n" ;
2058 } 2070 }
2059 2071
2060 $out .= "\n\\begin{rawhtml} </TR> </TABLE >\n\\end{rawhtml}"; 2072 $out .= "\n\\begin{rawhtml} </TR> </TABLE >\n\\end{rawhtml}";
2061 } elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng'|| $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath'){ 2073 } elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng'|| $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath' || $displayMode eq 'HTML_asciimath'){
2062 $out .= "<P>\n <TABLE BORDER=2 CELLPADDING=3 CELLSPACING=2 ><TR ALIGN=CENTER VALIGN=MIDDLE>\n"; 2074 $out .= "<P>\n <TABLE BORDER=2 CELLPADDING=3 CELLSPACING=2 ><TR ALIGN=CENTER VALIGN=MIDDLE>\n";
2063 while (@images) { 2075 while (@images) {
2064 $out .= " \n<TD>". &image( shift(@images),%options ) ."</TD>"; 2076 $out .= " \n<TD>". &image( shift(@images),%options ) ."</TD>";
2065 } 2077 }
2066 $out .= "</TR>\n<TR>"; 2078 $out .= "</TR>\n<TR>";

Legend:
Removed from v.2193  
changed lines
  Added in v.2199

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9