Update of /cvsroot/aimmath/AIM/WEB-INF/maple/aim
In directory sc8-pr-cvs1:/tmp/cvs-serv7612
Modified Files:
Tag: develop_2_1
Compile.mpl Diff.mpl Functions.mpl Int.mpl Matrix.mpl
MatrixQuestion.mpl MCQuestion.mpl Question.mpl Quiz.mpl
Subject.mpl TextQuestion.mpl Trig.mpl Util.mpl Util1.mpl
Added Files:
Tag: develop_2_1
LaTeX.mpl
Log Message:
Many changes. See posting to developers' list.
--- NEW FILE: LaTeX.mpl ---
# @(#)$Id: LaTeX.mpl,v 1.1.2.1 2003/08/25 18:35:11 monks Exp $
read("Package.mpl"):
Package("aim/LaTeX","
This package defines various utilities for generating LaTeX,
extending and modifying the standard Maple @latex()@ function.
<br/><br/>
One issue is that @latex(e)@ prints a LaTeX representation of
e and returns @NULL@. We instead define a function
@`aim/LaTeX`(e)@ that prints nothing and returns a LaTeX
representation of e as a string.
<br/><br/>
The LaTeX code produced by this package is intended to be
passed to
<a href='http://hutchinson.belmont.ma.us/tth/'>TtH</a> for
translation to HTML. Because of this we modify a number of
routines to produce output more congenial to TtH.
<br/><br/>
Eventually, the whole Maple latex library should be replaced
by an AIM-adapted version.
"
):
`Package/Dependencies` = ["Util"]:
`Package/Assign`(
`latex/latex/function`,
"",
proc(e)
local `(`, `)`, `,`, texlist, lf, `{`, `}`,`\\,`;
if 1 < nops(op(0, e)) or
type(op(0, e), 'function') and op([0, 0], e) = '`@`' or
type(op(0, e), {'`+`', '`*`'})
then
texlist := `latex/prinpar`(op(0, e))
elif type(op(0, e), {'string', 'symbol'}) then
lf := cat(`latex/`,op(0, e));
if (eval(lf) <> eval(lf,1)) then
RETURN(eval(cat(`latex/`,op(0, e))(op(e))));
else
texlist := `\\,`,`latex/print`(op(0, e));
fi;
else
texlist := `\\,`,`latex/print`(op(0, e));
fi;
texlist, `latex/latex/commalist`([op(e)], `,`, `(`, `)`)
end
):
`Package/Assign`(
`latex/diff`,
"",
proc(a, b)
local `\\partial `,`\\frac `, `{`, `}`,
d, n, A, num,denom,ans, blist, x, y, i, c,short;
if nargs < 2 then ERROR(`invalid arguments`) fi;
A := a; # the expression to differentiate
c := args[2 .. nargs]; # the list of variables wrt which to differentiate
# It could happen that A is already a differential expression
# like Diff(B,x). If so, we want to remove the differential
# operator from A and absorb it into c.
blist := NULL;
while type(A, function) and member(op(0, A), {'diff', 'Diff'}) do
blist := op(2 .. nops(A), A), blist; A := op(1, A)
od;
blist := [`latex/latex/reverse`(c, blist)];
# blist is now the (possibly expanded) list of variables
# wrt which to differentiate.
# denom is the denominator of the differential operator
# eg for Diff(f(x,y),x,x,y), denom would be a list of names
# that would concatenate to give {dx^2 dy}.
denom := `{`;
x := blist[1];
n := 0;
for y in blist do
if y = x then n := n + 1; next fi;
denom := denom, d, `latex/print`(x^n);
x := y;
n := 1
od;
denom := denom, d, `latex/print`(y^n), `}`;
# If A is now a single character name (eg 'y') then
# we put short = true and format the derivative like
# \frac{dy}{dx}. If A is anything more complicated (eg 'f(x)')
# we put short = false and format the derivative like
# \frac{d}{dx} f(x).
short :=
evalb(type([A],[symbol]) and length(convert(A,string)) = 1);
num := `\\frac `, `{`, d;
if 1 < nops(blist) then
num := num, `^`, `{`, `latex/print`(nops(blist)), `}`;
fi;
if short then num := num, `latex/print`(A); fi;
num := num, `}`;
ans := num,denom;
if not(short) then
ans := `{`,ans,`}`;
if type(A, {'function', 'name'}) then
ans := ans, `latex/print`(A)
else
ans := ans, `latex/latex/prinpar`(A)
fi;
fi;
if 1 < nops(indets(A, name)) then
RETURN(op(subs(d = `\\partial `, [ans])))
else RETURN(ans)
fi
end
):
`Package/Assign`(
`latex/latex/**`,
"This function overrides the default Maple routine for
LaTeX'ing powers, to prevent conversion of x^(1/n) to
\\sqrt[n]{x}. This is necessary because TtH cannot
render \\sqrt[n]{x} very well.",
proc (e::anything)
local texlist,`[`,`\\frac `,`\\sqrt `,`]`,`{`,`}`;
texlist := NULL;
if type(op(2,e),'fraction') and abs(op([2, 1],e)) = 1
and abs(op([2, 2],e)) < 10 and op(2,e) < 0 then
texlist:=texlist,`{`,`\\frac`,`{`,1,`}`,`{`,`latex/print`(1/e),`}`,`}`
elif type(op(1,e),{name,numeric}) and op(2,e) = 1/2 then
texlist := `\\sqrt `,`{`,`latex/print`(op(1,e)),`}`;
else
if
type(op(1,e),{'`+`','`*`','`^`','function','series','fraction','negative'})
then
texlist:=texlist,`latex/latex/prinpar`(op(1,e))
else
texlist:=texlist,`{`,`latex/print`(op(1,e)),`}`
fi;
texlist:=texlist,`^`,`{`,`latex/print`(op(2,e)),`}`
fi;
texlist
end
):
`Package/Assign`(
`latex/latex/matrix`,
"This function overrides the default Maple routine for
LaTeX'ing matrices. The sole change is that one line has been
modifed to prevent the insertion of extra whitespace
that confuses TtH.
",
proc(e)
local i, j, m, n, texlist, `&`, `\\\\`, `\\mbox `, `?`, `\\end `,
`\\right `, `]`, `[`, `\\begin `, `\\left `, c;
option
`Copyright (c) 1992 by the University of Waterloo. All rights reserved.`;
m := linalg['rowdim'](e);
n := linalg['coldim'](e);
texlist := `\\left `, `[`,
`latex/latex/copy`(cat(`\\begin `, `{`, 'array', `}`)),
`{`,(`latex/latex/copy`(cat(c $ n))),`} `;
for i to m do
if not has(e[i, 1], e) then
texlist := texlist, `latex/print`(e[i, 1])
else texlist := texlist, `latex/latex/undefined_entry`(e, i, j)
fi;
for j from 2 to n do
if not has(e[i, j], e) then
texlist := texlist, `&`, `latex/print`(e[i, j])
else texlist :=
texlist, `&`, `latex/latex/undefined_entry`(e, i, j)
fi
od;
if i <> m then texlist := texlist, `\\\\` fi
od;
texlist := texlist,
`latex/latex/copy`(cat(`\\end `, `{`, 'array', `}`)), `\\right `,
`]`
end
):
`Package/Assign`(
`latex/`,
"The purpose of this function is to give control over bracketing
when expressions are LaTeX'ed. If we evaluate something like
@`aim/LaTeX`(a + ``(b + c))@, then, via a call to this function, we get
@\"a + (b + c)\"@, whereas @`aim/LaTeX`(a + (b + c))@ just gives
@\"a + b + c\"@.
",
proc()
local `(`,`)`;
`latex/latex/commalist`([args], `,`, `(`, `)`);
end
):
`Package/Assign`(
`latex/latex/symbol`,
"",
proc(QQ)
local texlist, s,n,`{`, `}`, `\\_`;
option system, remember;
if assigned(`latex/special_names`[cat(``,QQ)]) then
texlist := `latex/special_names`[cat(``,QQ)]
elif member(QQ, eval(`latex/greek`, 1)) then
texlist := `latex/latex/copy`(cat(`\\`,QQ))
else
texlist := `latex/latex/copy`(QQ);
s := convert(texlist,string);
if s <> "" and substring(s,1..1) = "&" then
s := substring(s,2..-1);
n := convert(s,name);
texlist := `latex/latex/copy`(n);
fi;
fi;
RETURN(texlist);
end
):
`Package/Assign`(
`latex/latex/*`,
"",
proc(e)
local subexp, den, ee, subee, i, num, texlist, lnum,lden, `\\,`, `\\frac `, `\\sqrt `,
`{`, `}`;
global _LatexSmallFractionConstant;
option
`Copyright (c) 1992 by the University of Waterloo. All rights reserved.`;
if type(op(1, e), 'numeric') and op(1, e) < 0 then
RETURN(`latex/latex/copy`('`-`'), `latex/print`(-e))
fi;
if type(op(1, e), 'numeric') then
i := _LatexSmallFractionConstant;
_LatexSmallFractionConstant := 50;
texlist :=
`latex/print`(op(1, e)), `\\,`, `latex/print`(subsop(1 = 1, e))
;
_LatexSmallFractionConstant := i;
RETURN(texlist)
fi;
texlist := NULL;
num := 1;
den := 1;
ee := e;
for subee in [op(ee)] do
if type(subee, 'fraction') then
num := num*op(1, subee); den := den*op(2, subee)
elif type(subee, '`^`') and type(op(2, subee), 'rational') and
op(2, subee) < 0 then
if type(subee,table) then
den := den/op(subee)
else
den := den/subee
fi
else
if type(subee,table) then
num := num*op(subee)
else
num := num*subee
fi
fi
od;
if den <> 1 then
if type(num, '`latex/istall`') or type(den, '`latex/istall`') then
if num <> 1 then
texlist := `latex/print`(num);
if type(num, `+`) then
texlist := `\\left(`, texlist, `\\right)`
fi
else texlist := NULL
fi;
if type(den, '`*`') then den := [op(den)] else den := [den] fi;
for subexp in den do
texlist := texlist, `latex/print`(1/subexp)
od;
texlist
else
lnum := `if`(type(num,table),
`latex/print`(op(num)),
`latex/print`(num));
lden := `if`(type(den,table),
`latex/print`(op(den)),
`latex/print`(den));
texlist := texlist, `{`, '`\\frac `', '`{`',
lnum, '`}`', '`{`', lden, '`}`', `}`;
fi
else
i := 1;
for subee in ee do
if type(subee, {'series', '`+`'}) then
texlist := texlist, `latex/latex/prinpar`(subee)
elif i < nops(ee) and type(subee, 'function') and
member(op(0, subee), {diff, Diff}) then
texlist := texlist, `latex/latex/prinpar`(subee)
elif type(subee,table) then
texlist := texlist,`latex/print`(op(subee));
else texlist := texlist, `latex/print`(subee)
fi;
if i < nops(ee) and (
i = 1 and type(op(1, ee), 'integer') or type(subee, '`!`') or
type(subee, {'string', 'symbol'}) and 1 < length(subee) or
has([`latex/print`(subee)], '`\\sqrt `')) then
texlist := texlist, `\\,`
fi;
i := i + 1
od
fi;
RETURN(texlist)
end
):
`Package/Assign`(
`aim/LaTeX/trim`::string,
"Maple's latex routines insert whitespace in things like \"\\begin {\",
\"\\end {\", \"\\left [\" and \"\\right [\". TtH objects to such
whitespace, so this function removes it.
",
proc(s)
local t;
t := convert(s,string);
if t = "\\left " then
t := "\\left";
elif t = "\\right " then
t := "\\right";
elif substring(t,1..8) = "\\begin {" then
t := cat("\\begin{",substring(t,9..-1));
elif substring(t,1..6) = "\\end {" then
t := cat("\\end{",substring(t,7..-1));
fi;
t;
end
):
######################################################################
`Package/Assign`(
`aim/LaTeX`::string,
"Return a string of LaTeX representing @e@",
proc(e::anything)
local texlist,err;
if nargs = 0 then
RETURN("NULL");
elif nargs > 1 then
RETURN(`Util/CommaJoin`(op(map(`aim/LaTeX`,[args]))));
else
texlist := traperror([`latex/print`(eval(e))]);
if texlist = lasterror then
err := sprintf("%A",e);
if (length(err) > 20) then
err := cat(substring(err,1..20),"...");
fi;
err := cat(__("Maple to LaTeX error: "),err);
RETURN(err);
fi;
texlist := map(`aim/LaTeX/trim`,texlist);
cat(op(texlist));
fi;
end
):
######################################################################
`Package/Assign`(`aim/LaTeX/Subs`::string,
"This procedure converts all its arguments to strings and
concatenates them to form a string @s@. It then searches @s@
for Maple expressions enclosed in @@...@@ or @@<...>@@.
Expressions enclosed in @@...@@ are replaced by their LaTeX
representations. Those enclosed in @@<...>@@ are converted to
strings using @sprintf(\"%A\",..)@. The result is returned.
",
proc()
local s,len,out,start,maplestart,mapleend,expr,evexp,err;
s := cat(op(map((x) -> sprintf("%A",x),[args])));
len := length(s);
start := 1;
out := NULL;
maplestart := 0;
mapleend := 0;
while true do
if start <= len then
maplestart := SearchText("@",s,start..-1);
else
maplestart := 0;
fi;
if maplestart = 0 then
out := out,substring(s,start..-1);
RETURN(cat(out));
fi;
maplestart := maplestart + start - 1;
if maplestart < len then
mapleend := SearchText("@",s,maplestart+1..-1);
else
mapleend := 0;
fi;
if mapleend = 0 then
ERROR(cat("Unmatched @ in LaTeX/Subs(",s,")\n"));
fi;
mapleend := mapleend + maplestart;
out := out,substring(s,start..(maplestart-1));
expr := substring(s,(maplestart+1)..(mapleend-1));
if length(expr) > 1 and
substring(expr,1..1) = "<" and
substring(expr,-1..-1) = ">" then
evexp :=
traperror(eval(`Util/Parse`(substring(expr,2..-2),err,0)));
if (evexp = lasterror) then
out :=
out,"</latex>\n<br/>\n<font color='red'>",
__("Substitution error in Util/Parse"),
"</font><br/>\n<latex>",
sprintf("\n<br/>\n%s\n<br/><br/>\n%s\n<br/><br/>\n",err[1],err[3]);
else
out := out,evexp;
fi;
else
evexp := traperror(eval(`Util/Parse`(expr,err,0)));
if (evexp = lasterror) then
out :=
out,"\n<br/>\n<font color='red'>",
__("Substitution error in Util/Parse"),
"</font><br/>\n",
sprintf("\n<br/>\n%s\n<br/><br/>\n%s\n<br/><br/>\n",err[1],err[3]);
else
out := out,`aim/LaTeX`(evexp);
fi;
fi;
start := mapleend+1;
od;
end
):
######################################################################
`Package/Assign`(
`aim/LaTeX/Wrap`::string,
"Return @s@ wrapped in <latex>..</latex>, unless it is already
so wrapped, in which case just return @s@.",
proc(s::string)
if length(s) >= 7 and substring(s,1..7) = "<latex>" then
s;
else
cat("<latex>",s,"</latex>");
fi;
end
):
######################################################################
`Package/Assign`(
`aim/LaTeX/Display`::string,
"Convert all arguments to latex strings, join them with commas,
add \\[...\\] to give a displayed equation, and wrap it in
<latex>..</latex>",
proc()
cat("<latex>\\[",
`Util/CommaJoin`(op(map(`aim/LaTeX`,[args]))),
"\\]</latex>\n");
end
):
######################################################################
`Package/Assign`(
`aim/LaTeX/DisplayParse`::string,
"Parse @s@ to give a Maple expression @e@, convert to LaTeX,
add \\[...\\] to give a displayed equation, and wrap it in
<latex>..</latex>",
proc(s::string)
cat("<latex>\\[",`aim/LaTeX`(`Util/Parse`(s)),"\\]</latex>\n");
end
):
######################################################################
`Package/Assign`(
`aim/LaTeX/WrapSubs`::string,
"",
proc()
`aim/LaTeX/Wrap`(`aim/LaTeX/Subs`(args));
end
):
######################################################################
`Package/Assign`(
`aim/LaTeX/Squash`::string,
"Merge together any adjacent <latex>..</latex> tags in @s@.
This makes for more efficient translation by TtH.",
proc(s::evaln(string))
s := `Util/ReplaceSubstring`("</latex><latex>" = "",eval(s));
end
):
######################################################################
# KM
# KM GG's suggestion for fixing the conflict with LaTeX in Maple 9
if Config['MapleVersion'] <= 8 then
`Package/Assign`(`LaTeX/trim` ,"", `aim/LaTeX/trim`):
`Package/Assign`(LaTeX ,"", `aim/LaTeX`):
`Package/Assign`(`LaTeX/Subs` ,"", `aim/LaTeX/Subs`):
`Package/Assign`(`LaTeX/Wrap` ,"", `aim/LaTeX/Wrap`):
`Package/Assign`(`LaTeX/Display` ,"", `aim/LaTeX/Display`):
`Package/Assign`(`LaTeX/DisplayParse`,"", `aim/LaTeX/DisplayParse`):
fi;
# END KM
######################################################################
EndPackage():
Index: Compile.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/Compile.mpl,v
retrieving revision 1.2.2.5
retrieving revision 1.2.2.6
diff -C2 -d -r1.2.2.5 -r1.2.2.6
*** Compile.mpl 23 Aug 2003 16:27:43 -0000 1.2.2.5
--- Compile.mpl 25 Aug 2003 18:35:11 -0000 1.2.2.6
***************
*** 179,183 ****
partlabel_::string
)
! global MPROC_,IPROC,IPROCSTRING;
local question,line,flag,text,solstarted,solended,
qtype,value,keywords,aimlocals,ansvar,
--- 179,186 ----
partlabel_::string
)
! # KM
! # DIST global MPROC_,IPROC,IPROCSTRING;
! global MPROC_,IPROC,IPROCSTRING,Config;
! # END
local question,line,flag,text,solstarted,solended,
qtype,value,keywords,aimlocals,ansvar,
***************
*** 209,213 ****
answertest := "";
typespec := NULL;
! tlimit := 2.0;
setans := "";
--- 212,220 ----
answertest := "";
typespec := NULL;
!
! # KM
! # DIST tlimit := 2.0;
! tlimit := Config['TimeLimit'];
! # END
setans := "";
***************
*** 424,432 ****
elif flag = "prompt>" then
setprompt :=
! sprintf("questionversion['Prompt'] := `LaTeX/WrapSubs`(%a);\n",text);
##########
elif flag = "postprompt>" then
setpost :=
! sprintf("questionversion['PostPrompt'] := `LaTeX/WrapSubs`(%a);\n",text);
##########
elif flag = "mapletype>" then
--- 431,439 ----
elif flag = "prompt>" then
setprompt :=
! sprintf("questionversion['Prompt'] := `aim/LaTeX/WrapSubs`(%a);\n",text);
##########
elif flag = "postprompt>" then
setpost :=
! sprintf("questionversion['PostPrompt'] := `aim/LaTeX/WrapSubs`(%a);\n",text);
##########
elif flag = "mapletype>" then
***************
*** 843,847 ****
partlabel_::string
)
! global IPROC,IPROCSTRING;
local question,line,flag,text,solstarted,solended,
keywords,aimlocals,params,setnote,printvar,
--- 850,857 ----
partlabel_::string
)
! # KM
! # DIST global IPROC,IPROCSTRING;
! global IPROC,IPROCSTRING,Config;
! # END KM
local question,line,flag,text,solstarted,solended,
keywords,aimlocals,params,setnote,printvar,
***************
*** 862,866 ****
keywords := NULL;
shft := NULL;
! tlimit := 2.0;
aimlocals := NULL;
params := table();
--- 872,879 ----
keywords := NULL;
shft := NULL;
! # KM
! # DIST tlimit := 2.0;
! tlimit := Config['TimeLimit'];
! # END KM
aimlocals := NULL;
params := table();
Index: Diff.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/Diff.mpl,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -C2 -d -r1.2.2.2 -r1.2.2.3
*** Diff.mpl 18 Jul 2003 07:24:46 -0000 1.2.2.2
--- Diff.mpl 25 Aug 2003 18:35:11 -0000 1.2.2.3
***************
*** 196,200 ****
sprintf(
__("Put \\[ %A = %s, \\] so you were asked to evaluate \n\\[ %s . \\]\n"),
! fn,LaTeX(f),LaTeX(Diff(fn,var)));
else
fn := q['FunctionName'];
--- 196,200 ----
sprintf(
__("Put \\[ %A = %s, \\] so you were asked to evaluate \n\\[ %s . \\]\n"),
! fn,`aim/LaTeX`(f),`aim/LaTeX`(Diff(fn,var)));
else
fn := q['FunctionName'];
***************
*** 235,239 ****
so
\\[ %A = %s = %s. \\]"),
! newvar,LaTeX(h),fn,LaTeX(f),LaTeX(g)),
"\n",
sprintf(
--- 235,239 ----
so
\\[ %A = %s = %s. \\]"),
! newvar,`aim/LaTeX`(h),fn,`aim/LaTeX`(f),`aim/LaTeX`(g)),
"\n",
sprintf(
***************
*** 241,251 ****
\\[ %s = %s = %s, \\]
which is your answer.\n"),
! LaTeX(Diff(fn,newvar)),
! LaTeX(diff(g,newvar)),
! LaTeX(wrongans)),
"\n",
sprintf(
__("But this is $%s$, not $%s$."),
! TextStyle(LaTeX(Diff(fn,newvar))),TextStyle(LaTeX(Diff(fn,var)))));
feedback := feedback,"<latex>\n",msg,"</latex>\n";
fi;
--- 241,251 ----
\\[ %s = %s = %s, \\]
which is your answer.\n"),
! `aim/LaTeX`(Diff(fn,newvar)),
! `aim/LaTeX`(diff(g,newvar)),
! `aim/LaTeX`(wrongans)),
"\n",
sprintf(
__("But this is $%s$, not $%s$."),
! TextStyle(`aim/LaTeX`(Diff(fn,newvar))),TextStyle(`aim/LaTeX`(Diff(fn,var)))));
feedback := feedback,"<latex>\n",msg,"</latex>\n";
fi;
***************
*** 274,282 ****
\\[ %s = %s = %s. \\]
"),
! expvar,LaTeX(expt),
! fn,LaTeX(f),LaTeX(var^expvar),
! LaTeX(Diff(fn,var)),
! LaTeX(expvar * var^(expvar -1)),
! LaTeX(wrongans)),
"\n",
sprintf(
--- 274,282 ----
\\[ %s = %s = %s. \\]
"),
! expvar,`aim/LaTeX`(expt),
! fn,`aim/LaTeX`(f),`aim/LaTeX`(var^expvar),
! `aim/LaTeX`(Diff(fn,var)),
! `aim/LaTeX`(expvar * var^(expvar -1)),
! `aim/LaTeX`(wrongans)),
"\n",
sprintf(
***************
*** 287,292 ****
"),
expvar,var,
! LaTeX(Diff(var^expvar,var)),
! LaTeX(expvar * var^(expvar-1))));
else
newvar :=
--- 287,292 ----
"),
expvar,var,
! `aim/LaTeX`(Diff(var^expvar,var)),
! `aim/LaTeX`(expvar * var^(expvar-1))));
else
newvar :=
***************
*** 307,316 ****
\\[ %s = %s = %s. \\]
"),
! newvar,LaTeX(base),
! expvar,LaTeX(expt),
! fn,LaTeX(f),LaTeX(newvar^expvar),
! LaTeX(Diff(fn,var)),
! LaTeX(expvar * newvar^(expvar -1) * Diff(newvar,var)),
! LaTeX(wrongans)),
"\n",
sprintf(
--- 307,316 ----
\\[ %s = %s = %s. \\]
"),
! newvar,`aim/LaTeX`(base),
! expvar,`aim/LaTeX`(expt),
! fn,`aim/LaTeX`(f),`aim/LaTeX`(newvar^expvar),
! `aim/LaTeX`(Diff(fn,var)),
! `aim/LaTeX`(expvar * newvar^(expvar -1) * Diff(newvar,var)),
! `aim/LaTeX`(wrongans)),
"\n",
sprintf(
***************
*** 341,354 ****
\\[ %A = %s = %s. \\]
"),
! newvar,LaTeX(base),fn,LaTeX(f),LaTeX(newvar^expt)),
sprintf(
__("Then \\[ %s = %s = %s, \\] which is your answer.\n"),
! LaTeX(Diff(fn,newvar)),
! LaTeX(expt * newvar^(expt - 1)),
! LaTeX(wrongans)),
"\n",
sprintf(
__("But this is $%s$, not $%s$."),
! LaTeX(Diff(fn,newvar)),LaTeX(Diff(fn,var))));
feedback := feedback,"<latex>\n",msg,"</latex>\n";
fi;
--- 341,354 ----
\\[ %A = %s = %s. \\]
"),
! newvar,`aim/LaTeX`(base),fn,`aim/LaTeX`(f),`aim/LaTeX`(newvar^expt)),
sprintf(
__("Then \\[ %s = %s = %s, \\] which is your answer.\n"),
! `aim/LaTeX`(Diff(fn,newvar)),
! `aim/LaTeX`(expt * newvar^(expt - 1)),
! `aim/LaTeX`(wrongans)),
"\n",
sprintf(
__("But this is $%s$, not $%s$."),
! `aim/LaTeX`(Diff(fn,newvar)),`aim/LaTeX`(Diff(fn,var))));
feedback := feedback,"<latex>\n",msg,"</latex>\n";
fi;
Index: Functions.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/Functions.mpl,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -C2 -d -r1.2.2.1 -r1.2.2.2
*** Functions.mpl 10 Jul 2003 20:10:03 -0000 1.2.2.1
--- Functions.mpl 25 Aug 2003 18:35:11 -0000 1.2.2.2
***************
*** 125,129 ****
"The function $%s$ is equal to $%s$ when $x = %s$, but the
function $%s$ is not.",
! A,LaTeX(b),LaTeX(a),B);
end,
a,b)
--- 125,129 ----
"The function $%s$ is equal to $%s$ when $x = %s$, but the
function $%s$ is not.",
! A,`aim/LaTeX`(b),`aim/LaTeX`(a),B);
end,
a,b)
***************
*** 143,147 ****
"The function $%s$ is flat (ie the derivative is zero) when
$x = %s$, but the function $%s$ is not.",
! A,LaTeX(a),B);
end,
a)
--- 143,147 ----
"The function $%s$ is flat (ie the derivative is zero) when
$x = %s$, but the function $%s$ is not.",
! A,`aim/LaTeX`(a),B);
end,
a)
***************
*** 165,169 ****
"The function $%s$ is finite and continuous at
$x = %s$, but the function $%s$ is not.",
! A,LaTeX(a),B);
end,
a)
--- 165,169 ----
"The function $%s$ is finite and continuous at
$x = %s$, but the function $%s$ is not.",
! A,`aim/LaTeX`(a),B);
end,
a)
***************
*** 187,191 ****
"The function $%s$ is strictly positive
$x = %s$, but the function $%s$ is not.",
! A,LaTeX(a),B);
end,
a)
--- 187,191 ----
"The function $%s$ is strictly positive
$x = %s$, but the function $%s$ is not.",
! A,`aim/LaTeX`(a),B);
end,
a)
***************
*** 209,213 ****
"The function $%s$ is strictly negative
$x = %s$, but the function $%s$ is not.",
! A,LaTeX(a),B);
end,
a)
--- 209,213 ----
"The function $%s$ is strictly negative
$x = %s$, but the function $%s$ is not.",
! A,`aim/LaTeX`(a),B);
end,
a)
***************
*** 230,234 ****
"The function $%s$ repeats with period
$%s$, but the function $%s$ does not.",
! A,LaTeX(a),B);
end,
a)
--- 230,234 ----
"The function $%s$ repeats with period
$%s$, but the function $%s$ does not.",
! A,`aim/LaTeX`(a),B);
end,
a)
***************
*** 264,268 ****
"The function $%s$ is always less than or equal to $%s$,
but this is not true for $%s$",
! A,LaTeX(a),B);
fi;
end,
--- 264,268 ----
"The function $%s$ is always less than or equal to $%s$,
but this is not true for $%s$",
! A,`aim/LaTeX`(a),B);
fi;
end,
***************
*** 300,304 ****
"The function $%s$ is always greater than or equal to $%s$,
but this is not true for $%s$",
! A,LaTeX(a),B);
fi;
end,
--- 300,304 ----
"The function $%s$ is always greater than or equal to $%s$,
but this is not true for $%s$",
! A,`aim/LaTeX`(a),B);
fi;
end,
***************
*** 388,394 ****
if (u and not(v)) then
! m := msg("f(x)",LaTeX(g),args[5..-1]);
else
! m := msg(LaTeX(g),"f(x)",args[5..-1]);
fi;
--- 388,394 ----
if (u and not(v)) then
! m := msg("f(x)",`aim/LaTeX`(g),args[5..-1]);
else
! m := msg(`aim/LaTeX`(g),"f(x)",args[5..-1]);
fi;
Index: Int.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/Int.mpl,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -C2 -d -r1.2.2.2 -r1.2.2.3
*** Int.mpl 19 Jul 2003 17:37:34 -0000 1.2.2.2
--- Int.mpl 25 Aug 2003 18:35:11 -0000 1.2.2.3
***************
*** 193,201 ****
feedback,
__("The derivative of your answer should be equal to the function that you were asked to integrate, which was:"),
! "\n",`LaTeX/Display`(integrand),"\n",
__("In fact, the derivative of your answer is:"),
"\n",
sprintf("<latex>\\[\\frac{d}{d%a}\\bigl(%s\\bigr) = %s\\]</latex>",
! var,LaTeX(ans),LaTeX(simplifyabs(diff(ans,var)))),
"\n",
__("so you must have done something wrong."),
--- 193,201 ----
feedback,
__("The derivative of your answer should be equal to the function that you were asked to integrate, which was:"),
! "\n",`aim/LaTeX/Display`(integrand),"\n",
__("In fact, the derivative of your answer is:"),
"\n",
sprintf("<latex>\\[\\frac{d}{d%a}\\bigl(%s\\bigr) = %s\\]</latex>",
! var,`aim/LaTeX`(ans),`aim/LaTeX`(simplifyabs(diff(ans,var)))),
"\n",
__("so you must have done something wrong."),
***************
*** 341,354 ****
if member(convert(x,string),V['Extra']) then
feedback :=
! `LaTeX/Wrap`(
sprintf(
__("#Explain definite ($%s$,$%s$,$%s$,%a,$%s$,%a,$%s$,%a)"),
! LaTeX(q['Integrand']),
! LaTeX(x = u),
! LaTeX(x = v),
x,
! LaTeX(Int(x^4,x)=x^4/4),
x,
! LaTeX(Int(x^4,x=0..2)=4),
x
));
--- 341,354 ----
if member(convert(x,string),V['Extra']) then
feedback :=
! `aim/LaTeX/Wrap`(
sprintf(
__("#Explain definite ($%s$,$%s$,$%s$,%a,$%s$,%a,$%s$,%a)"),
! `aim/LaTeX`(q['Integrand']),
! `aim/LaTeX`(x = u),
! `aim/LaTeX`(x = v),
x,
! `aim/LaTeX`(Int(x^4,x)=x^4/4),
x,
! `aim/LaTeX`(Int(x^4,x=0..2)=4),
x
));
***************
*** 387,391 ****
cat( "\\int_{", NiceFrac(a, 1, "textstyle"), "}",
"^{", NiceFrac(b, 1, "textstyle"), "} ",
! LaTeX( op(1, q['Integral']) ), " d", LaTeX( q['Variable'] ) );
end
):
--- 387,391 ----
cat( "\\int_{", NiceFrac(a, 1, "textstyle"), "}",
"^{", NiceFrac(b, 1, "textstyle"), "} ",
! `aim/LaTeX`( op(1, q['Integral']) ), " d", `aim/LaTeX`( q['Variable'] ) );
end
):
***************
*** 424,438 ****
L0 := cat( "\\int", limits, " ",
! LaTeX( op(1, q['Integral']) ), " d", LaTeX(x) );
! LaTeXF := LaTeX(F);
L1 := `if`( evalb( SearchText("frac", LaTeXF) > 0 ),
cat("\\left[ ", LaTeXF, " \\right]", limits),
cat("\\bigl[ ", LaTeXF, " \\bigr]", limits) );
! L2 := cat( "\\left(", LaTeX(Fb), "\\right) - ",
! "\\left(", LaTeX(Fa), "\\right)");
! L3 := LaTeX(Fb - Fa);
--- 424,438 ----
L0 := cat( "\\int", limits, " ",
! `aim/LaTeX`( op(1, q['Integral']) ), " d", `aim/LaTeX`(x) );
! LaTeXF := `aim/LaTeX`(F);
L1 := `if`( evalb( SearchText("frac", LaTeXF) > 0 ),
cat("\\left[ ", LaTeXF, " \\right]", limits),
cat("\\bigl[ ", LaTeXF, " \\bigr]", limits) );
! L2 := cat( "\\left(", `aim/LaTeX`(Fb), "\\right) - ",
! "\\left(", `aim/LaTeX`(Fa), "\\right)");
! L3 := `aim/LaTeX`(Fb - Fa);
***************
*** 443,447 ****
# simplification, provided that the question is correct.
if (Fb - Fa <> q['RightAnswer']) then
! s := cat(s,"\\\\ &= ", LaTeX(q['RightAnswer']));
fi;
--- 443,447 ----
# simplification, provided that the question is correct.
if (Fb - Fa <> q['RightAnswer']) then
! s := cat(s,"\\\\ &= ", `aim/LaTeX`(q['RightAnswer']));
fi;
***************
*** 482,494 ****
err2 := err1 * dxdu;
! Lx := LaTeX(x);
! Lu := LaTeX(u);
! Lf := LaTeX(f);
! Lg := LaTeX(g);
! LU := LaTeX(U);
! LF := LaTeX(F);
! Ldxdu := LaTeX(dxdu);
! Lerr1 := LaTeX(err1);
! Lerr2 := LaTeX(err2);
if `aim/TestSymbolic`(ans,err1) then
--- 482,494 ----
err2 := err1 * dxdu;
! Lx := `aim/LaTeX`(x);
! Lu := `aim/LaTeX`(u);
! Lf := `aim/LaTeX`(f);
! Lg := `aim/LaTeX`(g);
! LU := `aim/LaTeX`(U);
! LF := `aim/LaTeX`(F);
! Ldxdu := `aim/LaTeX`(dxdu);
! Lerr1 := `aim/LaTeX`(err1);
! Lerr2 := `aim/LaTeX`(err2);
if `aim/TestSymbolic`(ans,err1) then
***************
*** 503,509 ****
"\n",
"\\[ ",
! LaTeX(q['Integral']),
" = ",
! LaTeX(Int(f,u)),
" = ",
LF,
--- 503,509 ----
"\n",
"\\[ ",
! `aim/LaTeX`(q['Integral']),
" = ",
! `aim/LaTeX`(Int(f,u)),
" = ",
LF,
***************
*** 525,529 ****
__("The integral becomes"),"\n",
"\\[ ",
! LaTeX(q['Integral']),
" = ",
sprintf("\\int %s \\frac{d%s}{d%s} d%s",Lf,Lx,Lu,Lu),
--- 525,529 ----
__("The integral becomes"),"\n",
"\\[ ",
! `aim/LaTeX`(q['Integral']),
" = ",
sprintf("\\int %s \\frac{d%s}{d%s} d%s",Lf,Lx,Lu,Lu),
Index: Matrix.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/Matrix.mpl,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -C2 -d -r1.2.2.1 -r1.2.2.2
*** Matrix.mpl 10 Jul 2003 20:10:03 -0000 1.2.2.1
--- Matrix.mpl 25 Aug 2003 18:35:11 -0000 1.2.2.2
***************
*** 29,33 ****
s := "<latex>\\begin{eqnarray*}\n";
for i from 1 to nops(u) do
! s := s,LaTeX(u[i])," &= ",LaTeX(v[i])," \\\\\n";
od;
s := cat(s,"\\end{eqnarray*}</latex>\n");
--- 29,33 ----
s := "<latex>\\begin{eqnarray*}\n";
for i from 1 to nops(u) do
! s := s,`aim/LaTeX`(u[i])," &= ",`aim/LaTeX`(v[i])," \\\\\n";
od;
s := cat(s,"\\end{eqnarray*}</latex>\n");
***************
*** 344,348 ****
feedback := feedback,"<td>";
fi;
! feedback := feedback,"<latex>$$",LaTeX(A0[i,j]),"$$</latex>\n </td>";
od;
feedback := feedback," </tr>\n";
--- 344,348 ----
feedback := feedback,"<td>";
fi;
! feedback := feedback,"<latex>$$",`aim/LaTeX`(A0[i,j]),"$$</latex>\n </td>";
od;
feedback := feedback," </tr>\n";
***************
*** 360,364 ****
feedback := feedback,"<td>";
fi;
! feedback := feedback,"<latex>$$",LaTeX(A0[i]),"$$</latex></td></tr>\n";
od;
feedback := feedback,"</table></center>\n<br/>\n";
--- 360,364 ----
feedback := feedback,"<td>";
fi;
! feedback := feedback,"<latex>$$",`aim/LaTeX`(A0[i]),"$$</latex></td></tr>\n";
od;
feedback := feedback,"</table></center>\n<br/>\n";
***************
*** 371,373 ****
######################################################################
! EndPackage():
\ No newline at end of file
--- 371,373 ----
######################################################################
! EndPackage():
Index: MatrixQuestion.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/MatrixQuestion.mpl,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -C2 -d -r1.2.2.2 -r1.2.2.3
*** MatrixQuestion.mpl 23 Aug 2003 16:13:38 -0000 1.2.2.2
--- MatrixQuestion.mpl 25 Aug 2003 18:35:11 -0000 1.2.2.3
***************
*** 139,146 ****
local attempt,err,rawans,rawlines,rawcells,
isempty,warmans,cookedans,e,f,tlimit;
!
tlimit := this['TimeLimit'];
if not(type([tlimit],[numeric])) then
! tlimit := 2.0;
fi;
--- 139,152 ----
local attempt,err,rawans,rawlines,rawcells,
isempty,warmans,cookedans,e,f,tlimit;
! # KM
! global Config;
! # END KM
!
tlimit := this['TimeLimit'];
if not(type([tlimit],[numeric])) then
! # KM
! # DIST tlimit := 2.0;
! tlimit := Config['TimeLimit'];
! # END KM
fi;
***************
*** 224,227 ****
--- 230,236 ----
local savedframe,attempt,mapletype,err,msg,ans,rightans,
ok,rawmark,tlimit;
+ # KM
+ global Config;
+ # END KM
attempt := eval(`aim/Question/MakeAttempt`(x));
***************
*** 256,260 ****
tlimit := this['TimeLimit'];
if not(type([tlimit],[numeric])) then
! tlimit := 2.0;
fi;
--- 265,272 ----
tlimit := this['TimeLimit'];
if not(type([tlimit],[numeric])) then
! # KM
! # DIST tlimit := 2.0;
! tlimit := Config['TimeLimit'];
! # END KM
fi;
***************
*** 270,275 ****
attempt['SetMarkingError',
sprintf(__("Error in %s: %s"),
! lastexception[1],
! StringTools[FormatMessage]( lastexception[ 2 .. -1 ] ))];
RETURN(eval(attempt));
end try;
--- 282,287 ----
attempt['SetMarkingError',
sprintf(__("Error in %s: %s"),
! lastexception[1],
! StringTools[FormatMessage]( lastexception[ 2 .. -1 ] ))];
RETURN(eval(attempt));
end try;
***************
*** 303,307 ****
if cell = lasterror then cell := ""; fi;
rawans := rawans,cell;
! if j < numcols then rawans := rawans,"|"; fi;
od;
if i < numrows then rawans := rawans,"\n"; fi;
--- 315,319 ----
if cell = lasterror then cell := ""; fi;
rawans := rawans,cell;
! if j < numcols then rawans := rawans,"|"; fi;
od;
if i < numrows then rawans := rawans,"\n"; fi;
***************
*** 431,435 ****
__("Your last answer was: \n"),
"<latex>\\[",
! LaTeX(attempt['Answer']),
"\\]</latex>\n<br/>\n"
);
--- 443,447 ----
__("Your last answer was: \n"),
"<latex>\\[",
! `aim/LaTeX`(attempt['Answer']),
"\\]</latex>\n<br/>\n"
);
***************
*** 456,460 ****
__("The teacher's answer was: "),
"\n<latex>\\[",
! LaTeX(rightans),
"\\]</latex>\n<br/>\n");
--- 468,472 ----
__("The teacher's answer was: "),
"\n<latex>\\[",
! `aim/LaTeX`(rightans),
"\\]</latex>\n<br/>\n");
Index: MCQuestion.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/MCQuestion.mpl,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -C2 -d -r1.2.2.1 -r1.2.2.2
*** MCQuestion.mpl 10 Jul 2003 20:10:03 -0000 1.2.2.1
--- MCQuestion.mpl 25 Aug 2003 18:35:11 -0000 1.2.2.2
***************
*** 372,376 ****
cat("<latex>",x,"</latex>");
else
! `LaTeX/Display`(x);
fi;
end
--- 372,376 ----
cat("<latex>",x,"</latex>");
else
! `aim/LaTeX/Display`(x);
fi;
end
Index: Question.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/Question.mpl,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -C2 -d -r1.2.2.1 -r1.2.2.2
*** Question.mpl 10 Jul 2003 20:10:03 -0000 1.2.2.1
--- Question.mpl 25 Aug 2003 18:35:11 -0000 1.2.2.2
***************
*** 15,18 ****
--- 15,19 ----
`Class/Declare`(`aim/Question`,
+
['Field','Name'::string,
"The name of the question. This is used as a file name, so it
***************
*** 98,102 ****
],
! ['Field','TimeLimit'::numeric = 2.0,
"The maximum time allowed for the @IProc@, @SProc@, @MProc@ or
@AProc@ procedures to run.
--- 99,106 ----
],
! # KM
! # DIST ['Field','TimeLimit'::numeric = 2.0,
! ['Field','TimeLimit'::numeric = Config['TimeLimit'],
! # END KM
"The maximum time allowed for the @IProc@, @SProc@, @MProc@ or
@AProc@ procedures to run.
***************
*** 439,443 ****
IProc procedure of the associated Question.",
proc(this)
! global AimImageCache;
local question,locals,savedframe,iproc,err,tlimit;
--- 443,450 ----
IProc procedure of the associated Question.",
proc(this)
! # KM
! # DIST global AimImageCache;
! global AimImageCache,Config;
! # END KM
local question,locals,savedframe,iproc,err,tlimit;
***************
*** 448,452 ****
tlimit := this['TimeLimit'];
if not(type([tlimit],[numeric])) then
! tlimit := 2.0;
fi;
iproc := eval(this['IProc']);
--- 455,463 ----
tlimit := this['TimeLimit'];
if not(type([tlimit],[numeric])) then
! # KM
! # DIST tlimit := 2.0;
! tlimit := Config['TimeLimit'];
! # END KM
!
fi;
iproc := eval(this['IProc']);
***************
*** 461,466 ****
this['Preamble'] :=
cat("<font color='red'>",
! __("There was an internal error while initializing this question:"),
! "\n<br/>\n",err,"\n</font>\n<br/>\n");
this['Note'] := __("Internal error");
this['InitializationFailed'] := true;
--- 472,477 ----
this['Preamble'] :=
cat("<font color='red'>",
! __("There was an internal error while initializing this question:"),
! "\n<br/>\n",err,"\n</font>\n<br/>\n");
this['Note'] := __("Internal error");
this['InitializationFailed'] := true;
***************
*** 548,552 ****
proc(this,attempt::`aim/Question/Attempt`)
local savedframe, tlimit, mproc, err, msg, rawmark;
!
savedframe := `Local/Save`(this['Locals']);
`Local/Restore`(this['LocalValues']);
--- 559,565 ----
proc(this,attempt::`aim/Question/Attempt`)
local savedframe, tlimit, mproc, err, msg, rawmark;
! # KM
! global Config;
! # END
savedframe := `Local/Save`(this['Locals']);
`Local/Restore`(this['LocalValues']);
***************
*** 554,558 ****
tlimit := this['TimeLimit'];
if not(type([tlimit],[numeric])) then
! tlimit := 2.0;
fi;
--- 567,574 ----
tlimit := this['TimeLimit'];
if not(type([tlimit],[numeric])) then
! # KM
! # DIST tlimit := 2.0;
! tlimit := Config['TimeLimit'];
! # END KM
fi;
***************
*** 614,618 ****
proc(this,attempt::`aim/Question/Attempt`)
local savedframe, tlimit, vproc, err, msg, rawmark;
!
savedframe := `Local/Save`(this['Locals']);
`Local/Restore`(this['LocalValues']);
--- 630,636 ----
proc(this,attempt::`aim/Question/Attempt`)
local savedframe, tlimit, vproc, err, msg, rawmark;
! # KM
! global Config;
! # END KM
savedframe := `Local/Save`(this['Locals']);
`Local/Restore`(this['LocalValues']);
***************
*** 620,624 ****
tlimit := this['TimeLimit'];
if not(type([tlimit],[numeric])) then
! tlimit := 2.0;
fi;
--- 638,645 ----
tlimit := this['TimeLimit'];
if not(type([tlimit],[numeric])) then
! # KM
! # DIST tlimit := 2.0;
! tlimit := Config['TimeLimit'];
! # END KM
fi;
***************
*** 658,662 ****
proc(this,history::`aim/Question/History`)
local savedframe,err,aproc,tlimit;
!
if this['AProc'] <> NULL then
history['Mark'] := 0.;
--- 679,685 ----
proc(this,history::`aim/Question/History`)
local savedframe,err,aproc,tlimit;
! # KM
! global Config;
! # END KM
if this['AProc'] <> NULL then
history['Mark'] := 0.;
***************
*** 668,672 ****
tlimit := this['TimeLimit'];
if not(type([tlimit],[numeric])) then
! tlimit := 2.0;
fi;
--- 691,698 ----
tlimit := this['TimeLimit'];
if not(type([tlimit],[numeric])) then
! # KM
! # DIST tlimit := 2.0;
! tlimit := Config['TimeLimit'];
! # END KM
fi;
***************
*** 676,681 ****
err :=
sprintf(__("Error in %s: %s"),
! lastexception[1],
! StringTools[FormatMessage]( lastexception[ 2 .. -1 ] ));
history['MarkMessage'] :=
--- 702,707 ----
err :=
sprintf(__("Error in %s: %s"),
! lastexception[1],
! StringTools[FormatMessage]( lastexception[ 2 .. -1 ] ));
history['MarkMessage'] :=
***************
*** 1606,1618 ****
if b = 1 then
msg := cat(msg,"\n<br/>\n",
! sprintf(__("You previously made one incorrect attempt, and were penalised %.2f, giving an overall mark of %.2f."),
p,mark));
elif b > 1 then
msg :=
cat(
! msg,
! "\n<br/>\n",
! sprintf(__("You previously made %d incorrect attempts, and were penalised %.2f for each of them, giving an overall mark of %.2f."),
! b,p,mark))
fi;
else # not isright
--- 1632,1644 ----
if b = 1 then
msg := cat(msg,"\n<br/>\n",
! sprintf(__("You previously made one incorrect attempt, and were penalised %.2f, giving an overall mark of %.2f."),
p,mark));
elif b > 1 then
msg :=
cat(
! msg,
! "\n<br/>\n",
! sprintf(__("You previously made %d incorrect attempts, and were penalised %.2f for each of them, giving an overall mark of %.2f."),
! b,p,mark))
fi;
else # not isright
***************
*** 1635,1651 ****
if b = 0 or r = 0. then
msg := sprintf(__("Your mark is %.2f"),mark);
elif b = 1 then
msg :=
cat(
! sprintf(__("The mark for your last attempt was %.2f"),r),
! "\n<br/>\n",
! sprintf(__("You previously made one incorrect attempt, and were penalised %.2f, giving an overall mark of %A."),
! p,mark));
else
msg :=
cat(
! sprintf(__("The mark for your last attempt was %A"),r),
! "\n<br/>\n",
! sprintf(__("You previously made %d incorrect attempts, and were penalised %.2f for each of them, giving an overall mark of %.2f."),
b,p,mark))
fi;
--- 1661,1684 ----
if b = 0 or r = 0. then
msg := sprintf(__("Your mark is %.2f"),mark);
+ # KM
+ if b>0 then
+ msg := cat(msg,sprintf(__(".    You have made %d incorrect attempts."),b+1));
+ else
+ msg := cat(msg,".    You have made one incorrect attempt.");
+ fi:
+ # END KM
elif b = 1 then
msg :=
cat(
! sprintf(__("The mark for your last attempt was %.2f"),r),
! "\n<br/>\n",
! sprintf(__("You previously made one incorrect attempt, and were penalised %.2f, giving an overall mark of %A."),
! p,mark));
else
msg :=
cat(
! sprintf(__("The mark for your last attempt was %A"),r),
! "\n<br/>\n",
! sprintf(__("You previously made %d incorrect attempts, and were penalised %.2f for each of them, giving an overall mark of %.2f."),
b,p,mark))
fi;
***************
*** 1738,1742 ****
label,cgilabel,errlabel,keys,rawans,
insertrightans,savedframe,err,sproc,tlimit;
!
insertrightans :=
evalb(nargs > 4 and insertrightans_);
--- 1771,1777 ----
label,cgilabel,errlabel,keys,rawans,
insertrightans,savedframe,err,sproc,tlimit;
! # KM
! global Config;
! # END KM
insertrightans :=
evalb(nargs > 4 and insertrightans_);
***************
*** 1762,1766 ****
tlimit := vrsion['TimeLimit'];
if not(type([tlimit],[numeric])) then
! tlimit := 2.0;
fi;
--- 1797,1804 ----
tlimit := vrsion['TimeLimit'];
if not(type([tlimit],[numeric])) then
! # KM
! # DIST tlimit := 2.0;
! tlimit := Config['TimeLimit'];
! # END KM
fi;
***************
*** 1770,1779 ****
err :=
sprintf(__("Error in %s: %s"),
! lastexception[1],
! StringTools[FormatMessage]( lastexception[ 2 .. -1 ] ));
instance['Solution'] :=
cat("<div class='solutionerror'><font color='red'>",
! __("There was an internal error while generating a solution for this question:"),
! "\n<br/>\n",err,"\n</font>\n</div>\n");
vrsion['Note'] := __("Solution error");
###TODO: a better way to log this
--- 1808,1817 ----
err :=
sprintf(__("Error in %s: %s"),
! lastexception[1],
! StringTools[FormatMessage]( lastexception[ 2 .. -1 ] ));
instance['Solution'] :=
cat("<div class='solutionerror'><font color='red'>",
! __("There was an internal error while generating a solution for this question:"),
! "\n<br/>\n",err,"\n</font>\n</div>\n");
vrsion['Note'] := __("Solution error");
###TODO: a better way to log this
***************
*** 1835,1839 ****
local attempt,history,quizcontext,
ansvar,locals,savedframe,err,sproc,tlimit;
!
if type([vrsion],[`aim/MultiQuestion/Version`]) then
ERROR(__("The `aim/Question/Instance` constructor cannot be used for multipart questions"));
--- 1873,1879 ----
local attempt,history,quizcontext,
ansvar,locals,savedframe,err,sproc,tlimit;
! # KM
! global Config;
! # END KM
if type([vrsion],[`aim/MultiQuestion/Version`]) then
ERROR(__("The `aim/Question/Instance` constructor cannot be used for multipart questions"));
***************
*** 1892,1896 ****
tlimit := vrsion['TimeLimit'];
if not(type([tlimit],[numeric])) then
! tlimit := 2.0;
fi;
--- 1932,1939 ----
tlimit := vrsion['TimeLimit'];
if not(type([tlimit],[numeric])) then
! # KM
! # DIST tlimit := 2.0;
! tlimit := Config['TimeLimit'];
! # END KM
fi;
***************
*** 1900,1909 ****
err :=
sprintf(__("Error in %s: %s"),
! lastexception[1],
! StringTools[FormatMessage]( lastexception[ 2 .. -1 ] ));
this['Solution'] :=
cat("<div class='solutionerror'><font color='red'>",
! __("There was an internal error while generating a solution for this question:"),
! "\n<br/>\n",err,"\n</font>\n</div>\n");
vrsion['Note'] := __("Solution error");
###TODO: a better way to log this
--- 1943,1952 ----
err :=
sprintf(__("Error in %s: %s"),
! lastexception[1],
! StringTools[FormatMessage]( lastexception[ 2 .. -1 ] ));
this['Solution'] :=
cat("<div class='solutionerror'><font color='red'>",
! __("There was an internal error while generating a solution for this question:"),
! "\n<br/>\n",err,"\n</font>\n</div>\n");
vrsion['Note'] := __("Solution error");
###TODO: a better way to log this
***************
*** 2016,2020 ****
"",
proc(this,quizcontext::`aim/Quiz/Context`,labels::list(string))
! local reviewmode, trymode, qtrymode,
focused, focuslabel, focusindex,
nav, href, header, control, editlink, label;
--- 2059,2066 ----
"",
proc(this,quizcontext::`aim/Quiz/Context`,labels::list(string))
! # KM
! # DIST local reviewmode, trymode, qtrymode,
! local reviewmode, trymode, qtrymode, jscript,
! # END KM
focused, focuslabel, focusindex,
nav, href, header, control, editlink, label;
***************
*** 2029,2033 ****
focusindex := 1;
while focusindex <= nops(labels) and
! labels[focusindex] <> focuslabel do
focusindex := focusindex + 1;
od;
--- 2075,2079 ----
focusindex := 1;
while focusindex <= nops(labels) and
! labels[focusindex] <> focuslabel do
focusindex := focusindex + 1;
od;
***************
*** 2043,2090 ****
if this['Level'] = 0 then
nav := `new/HTML/Tag`("tr");
! if not(qtrymode) then
if focused then
if focusindex > 1 then
! href := sprintf("javascript:MoveFocus('%s');",
! labels[focusindex - 1]);
nav['AddContents',
! ["td",[["a","href" = href],__("Previous")]]];
fi;
for label in labels do
! href := sprintf("javascript:MoveFocus('%s');",
! label);
nav['AddContents',
! ["td",[["a","href" = href],label]]];
od;
if focusindex < nops(labels) then
! href := sprintf("javascript:MoveFocus('%s');",
! labels[focusindex + 1]);
nav['AddContents',
! ["td",[["a","href" = href],__("Next")]]];
fi;
if quizcontext['InviteValidation'] then
nav['AddContents',
! ["td",
! [["a","href" = "javascript:Validate();"],__("Validate")]]];
fi;
if quizcontext['InviteMarking'] then
nav['AddContents',
! ["td",
! [["a","href" = "javascript:Mark();"],__("Mark")]]];
fi;
!
nav['AddContents',
! ["td",
! [["a","href" = "javascript:Unfocus();"],__("Unfocus")]],
! ["td",`aim/HelpLink`(__("Help"))]];
else # not focused
nav['AddContents',["td",[["a","href" = "#top"],__("Top")]]];
for label in labels do
nav['AddContents',
! ["td",[["a","href" = cat("#",label)],label]]];
od;
nav['AddContents',["td",[["a","href" = "#bottom"],__("Bottom")]]];
--- 2089,2153 ----
if this['Level'] = 0 then
nav := `new/HTML/Tag`("tr");
! if not qtrymode then
if focused then
+ # KM
+ jscript :="javascript:MoveFocus('%s');";
+ # END KM
if focusindex > 1 then
! # KM
! # DIST href := sprintf("javascript:MoveFocus('%s');",
! # DIST labels[focusindex - 1]);
! href := sprintf(jscript,labels[focusindex - 1]);
! # END KM
nav['AddContents',
! ["td",[["a","href" = href],__("Previous")]]];
fi;
for label in labels do
! # KM
! # DIST href := sprintf("javascript:MoveFocus('%s');",
! # DIST label);
! href := sprintf(jscript,label);
! # END KM
nav['AddContents',
! ["td",[["a","href" = href],label]]];
od;
if focusindex < nops(labels) then
! # KM
! # DIST href := sprintf("javascript:MoveFocus('%s');",
! # DIST labels[focusindex + 1]);
! href := sprintf(jscript,labels[focusindex + 1]);
! # END KM
nav['AddContents',
! ["td",[["a","href" = href],__("Next")]]];
fi;
if quizcontext['InviteValidation'] then
nav['AddContents',
! ["td",
! [["a","href" = "javascript:Validate();"],__("Validate")]]];
fi;
if quizcontext['InviteMarking'] then
nav['AddContents',
! ["td",
! [["a","href" = "javascript:Mark();"],__("Mark")]]];
fi;
! # KM
! jscript := "javascript:Unfocus();";
! # END KM
nav['AddContents',
! ["td",
! # KM
! # DIST [["a","href" = "javascript:Unfocus();"],__("Unfocus")]],
! [["a","href" = jscript],__("Unfocus")]],
! # END KM
! ["td",`aim/HelpLink`(__("Help"))]];
else # not focused
nav['AddContents',["td",[["a","href" = "#top"],__("Top")]]];
for label in labels do
nav['AddContents',
! ["td",[["a","href" = cat("#",label)],label]]];
od;
nav['AddContents',["td",[["a","href" = "#bottom"],__("Bottom")]]];
***************
*** 2092,2114 ****
if quizcontext['InviteValidation'] then
href := sprintf("javascript:ValidateQuestion('%s');",
! this['Label']);
nav['AddContents',
! ["td",
! [["a","href" = href],__("Validate")]]];
fi;
if quizcontext['InviteMarking'] then
href := sprintf("javascript:MarkQuestion('%s');",
! this['Label']);
nav['AddContents',
! ["td",
! [["a","href" = href],__("Mark")]]];
fi;
! href := sprintf("javascript:Focus('%s');",
! this['Label']);
! nav['AddContents',
! ["td",
! [["a","href" = href],__("Focus")]]];
nav['AddContents',["td",`aim/HelpLink`(__("Help"))]];
--- 2155,2186 ----
if quizcontext['InviteValidation'] then
href := sprintf("javascript:ValidateQuestion('%s');",
! this['Label']);
nav['AddContents',
! ["td",
! [["a","href" = href],__("Validate")]]];
fi;
if quizcontext['InviteMarking'] then
href := sprintf("javascript:MarkQuestion('%s');",
! this['Label']);
nav['AddContents',
! ["td",
! [["a","href" = href],__("Mark")]]];
fi;
! # KM
! if not trymode then
! # END KM
! # DIST href := sprintf(,"javascript:Focus('%s');",
! # DIST this['Label']);
! jscript := "javascript:Focus('%s');";
! href := sprintf(jscript,this['Label']);
! # END KM
! nav['AddContents',
! ["td",
! [["a","href" = href],__("Focus")]]];
! # KM
! fi;
! # END KM
nav['AddContents',["td",`aim/HelpLink`(__("Help"))]];
***************
*** 2188,2196 ****
this['Description'] <> "" then
control['AddContents',
! "tr",
[["td", "align" = "left"],
["b", __("Description"), ":"]],
[["td", "align" = "left", "colspan" = "3"],
! ["latex", this['Description']]]];
fi;
--- 2260,2274 ----
this['Description'] <> "" then
control['AddContents',
! # KM
! # DIST "tr",
! ["tr",
! # END KM
[["td", "align" = "left"],
["b", __("Description"), ":"]],
[["td", "align" = "left", "colspan" = "3"],
! # KM
! # DIST ["latex", this['Description']]]];
! ["latex", this['Description']]]]];
! # END KM
fi;
***************
*** 2253,2264 ****
html1:=`new/HTML/Tag`(
! ["div","class" = "question","id" = cat("question",this['Label'])],
! header, "\n",
! [["table", "width"="100%"],
! ["tr",
[["td", "width" = "5%"]," "],
! [["td", "width" = "95%"],
! [["div", "class" = "questionbody"],
! html]]]]);
RETURN(html1['ToString']);
--- 2331,2342 ----
html1:=`new/HTML/Tag`(
! ["div","class" = "question","id" = cat("question",this['Label'])],
! header, "\n",
! [["table", "width"="100%"],
! ["tr",
[["td", "width" = "5%"]," "],
! [["td", "width" = "95%"],
! [["div", "class" = "questionbody"],
! html]]]]);
RETURN(html1['ToString']);
***************
*** 2430,2434 ****
["hr"],
[["div", "class" = "rightanswer"],
! this['ReportRightAnswer']]];
fi;
fi; # ends if type([this],[`aim/MultiQuestion/Instance`])
--- 2508,2518 ----
["hr"],
[["div", "class" = "rightanswer"],
! # KM
! [["table", "width"="100%", "bgcolor"="PaleGoldenRod"],
! ["tr",
! [["td", "width"="100%"],
! this['ReportRightAnswer']]]]]];
! # DIST this['ReportRightAnswer']]];
! # END KM
fi;
fi; # ends if type([this],[`aim/MultiQuestion/Instance`])
***************
*** 2437,2445 ****
this['Solution'] <> "" then
html['AddContents',
! ["hr"],
[["div", "class" = "solution"],
! ["b",__("Solution:")],
! ["br"],
! this['Solution']]];
fi;
--- 2521,2539 ----
this['Solution'] <> "" then
html['AddContents',
! # DIST ["hr"],
[["div", "class" = "solution"],
! # KM
! [["table", "width"="100%", "bgcolor"="PaleGoldenRod"],
! ["tr",[["td", "width"="100%"],["hr"]]],
! ["tr",
! [["td", "width"="100%"],
! ["b",__("Solution:")],
! ["br"]]],
! ["tr",
! [["td", "width"="100%"],this['Solution']]]]]];
! # DIST ["b",__("Solution:")],
! # DIST ["br"],
! # DIST this['Solution']]];
! # END KM
fi;
***************
*** 2450,2454 ****
["tr",
[["td", "width" = "5%"]," "],
! [["td", "width" = "95%"],
"\n",
html]]]
--- 2544,2548 ----
["tr",
[["td", "width" = "5%"]," "],
! [["td", "width" = "95%"],
"\n",
html]]]
***************
*** 2608,2611 ****
--- 2702,2714 ----
"The name of the question of which this is an analysis."
],
+
+ # KM
+ ['Field','PartLabel'::string,
+ "If this is the 3rd subsubquestion of the 5th subquestion of a
+ multipart question, then this field will be the string
+ @\".5.3\"@
+ "
+ ],
+ # END KM
['Field','NumHistories'::integer,
Index: Quiz.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/Quiz.mpl,v
retrieving revision 1.3.2.2
retrieving revision 1.3.2.3
diff -C2 -d -r1.3.2.2 -r1.3.2.3
*** Quiz.mpl 27 Jul 2003 20:22:13 -0000 1.3.2.2
--- Quiz.mpl 25 Aug 2003 18:35:11 -0000 1.3.2.3
***************
*** 845,849 ****
['Field','NameTable'::table,
"A table of #`aim/Question/History`# objects, indexed by pairs of
! the form @(question name,part label)@. Th entries are the same
objects as in the @LabelTable@ field.
"
--- 845,849 ----
['Field','NameTable'::table,
"A table of #`aim/Question/History`# objects, indexed by pairs of
! the form @(question name,part label)@. The entries are the same
objects as in the @LabelTable@ field.
"
***************
*** 909,912 ****
--- 909,930 ----
],
+ ### GWD
+ ['Method','TotalValue'::numeric,"The total value of the quiz",
+ proc(this)
+ local total,label,histories;
+ total := 0.;
+ # KM
+ # DIST histories := eval(this['QuestionHistory']);
+ histories := eval(this['LabelTable']);
+ # END KM
+ for label in this['Labels'] do
+ total := total + histories[label]['QuestionValue'];
+ od;
+
+ RETURN(total);
+ end
+ ],
+ ### GWD
+
['Method','TotalMarkCode'::`aim/MarkCode`,"",
proc(this)
***************
*** 960,963 ****
--- 978,987 ----
],
+ # KM
+ ['Field','SolutionsRevealed'::boolean = false,
+ "@true@ if the student has previously requested
+ the solutions for the quiz.
+ "],
+ # END KM
['Method','ValidlyAttempted'::boolean,
***************
*** 1003,1010 ****
to the student.
",
! proc(this)
local totalmark,totalvalue,numattempted,attemptedvalue,
histories,history,marksummary,questionvalue,mark,
! percentage,label;
totalmark := 0.;
--- 1027,1044 ----
...
[truncated message content] |