Update of /cvsroot/aimmath/AIM/WEB-INF/maple/aim
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27120/WEB-INF/maple/aim
Modified Files:
Tag: aim-xml
MRQuestion.mpl MatrixQuestion.mpl Question.mpl Quiz.mpl
SOAP.mpl TextQuestion.mpl
Log Message:
Index: MRQuestion.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/MRQuestion.mpl,v
retrieving revision 1.3.6.1
retrieving revision 1.3.6.2
diff -C2 -d -r1.3.6.1 -r1.3.6.2
*** MRQuestion.mpl 10 Mar 2005 21:13:54 -0000 1.3.6.1
--- MRQuestion.mpl 22 Apr 2005 07:15:43 -0000 1.3.6.2
***************
*** 10,75 ****
`Package/Assign`(
! `aim/MRQuestion/Script`::string,
! "This is a script to be included in an HTML page header, defining
! JavaScript functions that are used to make checkboxes work
! properly. For example, clicking the 'None of the above' box
! should clear all the other boxes.
! <br/><br/>
! The functions assume that we have a group of checkboxes, all with
! the same name. One of them may have the value @'NoneOfTheAbove'@,
! one may have the value @''@, and all others are considered
! 'ordinary'. Ordinary checkboxes should have the @onclick@ attribute
! set to @'checkopt(form,name)'@; this means that when they are
! checked, the two special boxes will be cleared. The box with
! value @'NoneOfTheAbove'@ should use the handler
! @'checknone(form,name)'@, which clears all the other boxes. The box
! with value @''@ should use the handler @'checknull(form,name)'@,
! which behaves similarly.
! ",
! " function checkopt(f,n) {
! var optarray = f.elements[n];
! var numopts = optarray.length;
! var raw,i;
! optarray[numopts-2].checked = false;
! optarray[numopts-1].checked = false;
! raw = '{';
! for (i = 0; i < numopts-2; i++) {
! if (optarray[i].checked) {
! raw += '\\\"' + optarray[i].value + '\\\",';
! }
! }
! if (raw.length > 1) {
! raw = raw.substring(0,raw.length-1) + '}';
! } else {
! raw = '{}';
! optarray[numopts-2].checked = true;
! }
! var base = n.substring(0,n.length-8);
! f.elements[base].value = raw;
! };
! function checknone(f,n) {
! var optarray = f.elements[n];
! var numopts = optarray.length;
! var i;
! for (i = 0; i < numopts-2; i++) {
! optarray[i].checked = false;
! }
! optarray[numopts-1].checked = false;
! var base = n.substring(0,n.length-8);
! f.elements[base].value = '{}';
! };
! function checknull(f,n) {
! var optarray = f.elements[n];
! var numopts = optarray.length;
! var i;
! for (i = 0; i < numopts-1; i++) {
! optarray[i].checked = false;
! }
! var base = n.substring(0,n.length-8);
! f.elements[base].value = '';
! };
! "
):
--- 10,64 ----
`Package/Assign`(
! `aim/MRQuestion/OnClickScript`,
! "",
! proc(base::string,optlabels::list(string))
! local n,g,s,j;
! g := (t) -> sprintf("document.getElementById('%s%s')",base,t);
! n := nops(optlabels);
! s := sprintf("%s.checked=false;%s.checked=false;",
! g("_None"),g("_Null"));
! s := cat(s,g(""),".value='{'+");
! for j from 1 to n do
! s := sprintf("%s+(document.getElementById('%s_%d').checked ? '"%s",' : '')",
! s,base,j,optlabels[j])
! od;
! s := sprintf("%s+'NULL}';",s);
! return(s);
! end
! ):
! `Package/Assign`(
! `aim/MRQuestion/OnClickScript/None`,
! "",
! proc(base::string,optlabels::list(string))
! local n,g,s,j;
! g := (t) -> sprintf("document.getElementById('%s%s')",base,t);
! n := nops(optlabels);
! s := sprintf("%s.checked=false;",g("_Null"));
! for j from 1 to n do
! s := sprintf("%s document.getElementById('%s_%d').checked=false;",
! s,base,j)
! od;
! s := sprintf("%s document.getElementById('%s').value='{}';",s);
! return(s);
! end
! ):
!
! `Package/Assign`(
! `aim/MRQuestion/OnClickScript/Null`,
! "",
! proc(base::string,optlabels::list(string))
! local n,g,s,j;
! g := (t) -> sprintf("document.getElementById('%s%s')",base,t);
! n := nops(optlabels);
! s := sprintf("%s.checked=false;",g("_None"));
! for j from 1 to n do
! s := sprintf("%s document.getElementById('%s_%d').checked=false;",
! s,base,j)
! od;
! s := sprintf("%s document.getElementById('%s').value='';",s);
! return(s);
! end
):
***************
*** 355,359 ****
proc(this,allowinput_::boolean)
local cgilabel,lastrawans,lastans,choices,labels,i,n,c,choicetable,
! allowinput,inputelement,rawelt,html;
if nargs > 1 then
--- 344,348 ----
proc(this,allowinput_::boolean)
local cgilabel,lastrawans,lastans,choices,labels,i,n,c,choicetable,
! allowinput,inputelement,rawelt,html,onclick;
if nargs > 1 then
***************
*** 363,367 ****
fi;
! cgilabel := cat(this['CGILabel'],"Multiple");
lastrawans := this['History']['LastRawAnswer'];
lastans := this['History']['LastAnswer'];
--- 352,356 ----
fi;
! cgilabel := this['CGILabel'];
lastrawans := this['History']['LastRawAnswer'];
lastans := this['History']['LastAnswer'];
***************
*** 388,397 ****
fi;
if allowinput then
inputelement :=
[["inputcheckbox",
"name" = cgilabel,
"value" = labels[i],
! "onclick" = "checkopt(form,name)",
c]];
else
--- 377,388 ----
fi;
+ onclick := `aim/MRQuestion/OnClick`(cgilabel,labels);
if allowinput then
inputelement :=
[["inputcheckbox",
"name" = cgilabel,
+ "id" = sprintf("%s_%d",cgilabel,i),
"value" = labels[i],
! "onclick" = onclick,
c]];
else
***************
*** 411,416 ****
[["inputcheckbox",
"name" = cgilabel,
"value" = "NoneOfTheAbove",
! "onclick" = "checknone(form,name)",
c]];
else
--- 402,408 ----
[["inputcheckbox",
"name" = cgilabel,
+ "id" = sprintf("%s_None",cgilabel),
"value" = "NoneOfTheAbove",
! "onclick" = `aim/MRQuestion/OnClick/None`(cgilabel,labels),
c]];
else
***************
*** 428,433 ****
[["inputcheckbox",
"name" = cgilabel,
"value" = "",
! "onclick" = "checknull(form,name)",
c]];
--- 420,426 ----
[["inputcheckbox",
"name" = cgilabel,
+ "id" = sprintf("%s_Null",cgilabel),
"value" = "",
! "onclick" = `aim/MRQuestion/OnClick/Null`(cgilabel,labels),
c]];
***************
*** 449,492 ****
],
- ['Method','AnswerBoxXML'::`XML/Element`,
- "",
- proc(this,disabled_::boolean)
- local cgilabel,lastans,choices,labels,i,n,c,choicetable,
- allowinput,inputelement,disabled,b;
-
- if nargs > 1 then
- disabled := args[2];
- else
- disabled := false;
- fi;
-
- lastans := this['History']['LastAnswer'];
- choices := eval(this['Choices']);
- choices := map(`aim/MCQuestion/ChoiceToString`,choices);
-
- n := nops(choices);
- labels := eval(this['ChoiceLabels']);
-
- b :=
- `new/XML/Element`(
- ["aim:AnswerBox",
- "widget" = "multipleresponse",
- `if`(disabled,"disabled" = "true", NULL)
- ]);
-
- for i from 1 to n do
- if member(labels[i],lastans) then
- b['AddContents',
- [["choice","label"=labels[i],"chosen"="true"],choices[i]]];
- else
- b['AddContents',
- [["choice","label"=labels[i]],choices[i]]];
- fi;
- od;
-
- RETURN(eval(b));
- end
- ],
-
['Method','AnswerBoxSubstitute'::`HTML/String`,"",
proc(this)
--- 442,445 ----
***************
*** 515,544 ****
],
- ['Method','LastAnswerXML'::`XML/Element`,
- "",
- proc(this)
- local attempt,xml;
-
- attempt := eval(this['Attempt']);
-
- if attempt['RawAnswer'] = "" then
- return(`new/XML/Element`("aim:LastAnswer"));
- else
- if attempt['Answer'] <> NULL then
- ### Check the escapology
- if type([attempt['Answer']],[list(string)]) then
- return(`new/XML/Element`(
- [["aim:LastAnswer", "raw"="true"],
- map(x -> ["choice",x],attempt['Answer'])]));
- else
- error(__("Non-string answer to multiple response question"));
- fi;
- else
- return(`new/XML/Element`("aim:LastAnswer"));
- fi;
- fi;
- end
- ],
-
['Method','ReportRightAnswer'::`HTML/String`,"",
proc(this)
--- 468,471 ----
Index: Question.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/Question.mpl,v
retrieving revision 1.13.2.3
retrieving revision 1.13.2.4
diff -C2 -d -r1.13.2.3 -r1.13.2.4
*** Question.mpl 1 Apr 2005 01:42:55 -0000 1.13.2.3
--- Question.mpl 22 Apr 2005 07:15:43 -0000 1.13.2.4
***************
*** 2397,2401 ****
if type([this],[`aim/MultiQuestion/Instance`]) then
! error(__("Multipart questions not supported in XML framework."));
fi;
--- 2397,2401 ----
if type([this],[`aim/MultiQuestion/Instance`]) then
! error(__("Multipart questions not supported in the XML framework."));
fi;
Index: Quiz.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/Quiz.mpl,v
retrieving revision 1.8.2.2
retrieving revision 1.8.2.3
diff -C2 -d -r1.8.2.2 -r1.8.2.3
*** Quiz.mpl 31 Mar 2005 12:38:12 -0000 1.8.2.2
--- Quiz.mpl 22 Apr 2005 07:15:43 -0000 1.8.2.3
***************
*** 1526,1530 ****
`HTML/ToString`(
`aim/HTMLPage`(__("AIM Quiz"),
- ["javascript",`aim/MRQuestion/Script`],
["javascript",`aim/MatrixQuestion/Script`],
["javascript",`aim/SubmitScript`],
--- 1526,1529 ----
Index: TextQuestion.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/TextQuestion.mpl,v
retrieving revision 1.13.2.1
retrieving revision 1.13.2.2
diff -C2 -d -r1.13.2.1 -r1.13.2.2
*** TextQuestion.mpl 10 Mar 2005 21:13:55 -0000 1.13.2.1
--- TextQuestion.mpl 22 Apr 2005 07:15:44 -0000 1.13.2.2
***************
*** 296,347 ****
],
- ['Method','AnswerBoxXML'::`XML/Element`,
- "Return an XML structure representing the answer box that
- students can use to enter their answers.
- ",
- proc(this,disabled_::boolean)
- local b,rawans;
-
- # Ken Monks set things up so that AnswerBoxWidth=0 gives no
- # answer box. I'm not sure what that is for, but I have
- # replicated it here anyway; this may be the wrong thing
- # to do.
- if this['AnswerBoxWidth'] = 0 then
- return(NULL);
- fi;
-
- b :=
- `new/XML/Element`(
- ["aim:AnswerBox",
- `if`(this['AnswerBoxHeight'] > 1,
- op(["widget" = "textarea",
- "height" = this['AnswerBoxHeight'],
- "width" = this['AnswerBoxWidth']]),
- op(["widget" = "inputbox",
- "width" = this['AnswerBoxWidth']])
- )
- ]);
-
- if nargs > 1 and disabled_ = true then
- b['SetAttribs',"disabled" = "true"];
- fi;
-
- if this['Prompt'] <> "" then
- b['AddContents',["aim:Prompt",this['Prompt']]];
- fi;
-
- rawans := this['Attempt']['RawAnswer'];
- if rawans <> "" then
- b['AddContents',["aim:Answer",`XML/Escape`(rawans)]];
- fi;
-
- if this['PostPrompt'] <> "" then
- b['AddContents',["aim:PostPrompt",this['PostPrompt']]];
- fi;
-
- return(eval(b));
- end
- ],
-
['Method','AnswerBoxSubstitute'::`HTML/String`,
"Return the HTML string specifying a disabled text box with grey
--- 296,299 ----
***************
*** 431,462 ****
],
- ['Method','LastAnswerXML'::`XML/Element`,
- "",
- proc(this)
- local attempt,xml;
-
- attempt := eval(this['Attempt']);
-
- if attempt['RawAnswer'] = "" then
- return(`new/XML/Element`("aim:LastAnswer"));
- else
- if attempt['Answer'] <> NULL then
- ### Check the escapology
- if type([attempt['Answer']],[string]) then
- return(`new/XML/Element`(
- ["aim:LastAnswer", "raw"="true"],
- `XML/Escape`(attempt['Answer'])));
- else
- return(`new/XML/Element`(
- ["aim:LastAnswer", "raw"="false"],
- `XML/Escape`(`aim/LaTeX`(attempt['Answer']))));
- fi;
- else
- return(`new/XML/Element`("aim:LastAnswer"));
- fi;
- fi;
- end
- ],
-
['Method','ReportRightAnswer'::`HTML/String`,
"Return the HTML representation of the right answer to this
--- 383,386 ----
***************
*** 471,482 ****
__("The teacher's answer was: "),
"\n<latex>\\[",
! # KM We don't need to surround the teacher's answer
# with quotes in this situation because the students
# don't type them anyway
- # WAS: `aim/LaTeX`(rightans),
`if`(type(rightans,string),
cat("\\mbox{",TeX(rightans),"}"),
`aim/LaTeX`(rightans)),
- # END KM
"\\]</latex>\n<br/>\n");
--- 395,404 ----
__("The teacher's answer was: "),
"\n<latex>\\[",
! # We don't need to surround the teacher's answer
# with quotes in this situation because the students
# don't type them anyway
`if`(type(rightans,string),
cat("\\mbox{",TeX(rightans),"}"),
`aim/LaTeX`(rightans)),
"\\]</latex>\n<br/>\n");
***************
*** 523,531 ****
rawans := attempt['RawAnswer'];
- # KM
- # WAS: if reqtype = string then
- # WAS: if subtype(reqtype,string) then
if subtype(reqtype,string) or type(reqtype,specfunc(type,'String')) then
- # END
# don't allow the empty string to be valid or it will cause
# a penalty to be given if the student answers it correctly
--- 445,449 ----
***************
*** 533,537 ****
# request for the quiz to be marked
if rawans = "" then attempt['IsValid']:=false; RETURN(false) fi;
- # KM
# check that the string matches the required type in the case
# where the user has specified a subtype of type string
--- 451,454 ----
***************
*** 554,558 ****
RETURN(false);
fi;
- # END KM
attempt['Answer'] := rawans;
RETURN(true);
--- 471,474 ----
Index: SOAP.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/Attic/SOAP.mpl,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** SOAP.mpl 1 Apr 2005 01:42:55 -0000 1.1.2.2
--- SOAP.mpl 22 Apr 2005 07:15:44 -0000 1.1.2.3
***************
*** 97,101 ****
['Output',"hintAvailable"::`XML/boolean` = false],
['Output',"validationPossible"::`XML/boolean` = true],
! ['Output',"maxScore"::`XML/unsignedInt` = 100],
['Output',"length"::`XML/unsignedInt` = 1],
--- 97,101 ----
['Output',"hintAvailable"::`XML/boolean` = false],
['Output',"validationPossible"::`XML/boolean` = true],
! ['Output',"maxScore"::`XML/unsignedInt` = 1],
['Output',"length"::`XML/unsignedInt` = 1],
***************
*** 130,141 ****
['Input',"source"::`XML/string`],
['Input',"format"::`XML/anyURI`],
- ['Input',"seed"::`XML/unsignedInt`],
- ['Output',"seed"::`XML/unsignedInt`],
['Output',"templateVars"::`RQP/ArrayOfvariable` = []],
['Process',
proc(inp,out)
! out["seed"] = `if`(inp["seed"] = 0,rand(),inp["seed"]);
end
]
--- 130,139 ----
['Input',"source"::`XML/string`],
['Input',"format"::`XML/anyURI`],
['Output',"templateVars"::`RQP/ArrayOfvariable` = []],
['Process',
proc(inp,out)
! out["templateVars"] = ["seed" = [sprintf("%d",rand())]];
end
]
***************
*** 152,161 ****
['Input',"format"::`XML/anyURI`],
['Input',"index"::`XML/unsignedInt` = 0],
- ['Input',"seed"::`XML/unsignedInt` = 0],
['Input',"templateVars"::`RQP/ArrayOfvariable` = []],
['Input',"persistentData"::`XML/MapleExpression`],
- ['Input',"embedPrefix"::`XML/QName`],
- ['Output',"seed"::`XML/unsignedInt`],
['Output',"templateVars"::`RQP/ArrayOfvariable` = []],
['Output',"correctResponses"::`RQP/ArrayOfinput` = []],
--- 150,156 ----
***************
*** 165,172 ****
local vrsion,f;
vrsion := `aim/SOAP/GetItemVersion`(inp);
! out["seed"] := inp["seed"];
! f := proc(x,p) [cat(p,x[1]),x[2]]; end;
! out["correctResponses"] :=
! map(f,vrsion['RightRawAnswerList'],inp["embedPrefix"]);
end
]
--- 160,165 ----
local vrsion,f;
vrsion := `aim/SOAP/GetItemVersion`(inp);
! out["templateVars"] := ["seed" = [sprintf("%d",vrsion['Seed'])]];
! out["correctResponses"] := vrsion['RightRawAnswerList'];
end
]
***************
*** 184,193 ****
['Input',"format"::`XML/anyURI`],
['Input',"index"::`XML/unsignedInt` = 0],
- ['Input',"seed"::`XML/unsignedInt` = 0],
['Input',"templateVars"::`RQP/ArrayOfvariable`],
['Input',"persistentData"::`XML/MapleExpression`],
['Input',"responses"::`RQP/ArrayOfinput`],
['Input',"advanceState"::`XML/boolean`],
! ['Input',"embedPrefix"::`XML/QName`],
['Input',"appletBase"::`XML/anyURI`],
['Input',"mediaBase"::`XML/anyURI`],
--- 177,185 ----
['Input',"format"::`XML/anyURI`],
['Input',"index"::`XML/unsignedInt` = 0],
['Input',"templateVars"::`RQP/ArrayOfvariable`],
['Input',"persistentData"::`XML/MapleExpression`],
['Input',"responses"::`RQP/ArrayOfinput`],
['Input',"advanceState"::`XML/boolean`],
! ['Input',"namePrefix"::`XML/QName`],
['Input',"appletBase"::`XML/anyURI`],
['Input',"mediaBase"::`XML/anyURI`],
***************
*** 195,199 ****
['Input',"modalFormat"::`XML/anyURI`],
- ['Output',"seed"::`XML/unsignedInt` = 0],
['Output',"templateVars"::`RQP/ArrayOfvariable` = []],
['Output',"persistentData"::`XML/MapleExpression` = ""],
--- 187,190 ----
***************
*** 236,240 ****
attempt := inst['Attempt'];
! out["seed"] := vrsion['Seed'];
out["persistentData"] := eval(history);
t := [
--- 227,231 ----
attempt := inst['Attempt'];
! out["templateVars"] := ["seed" = [sprintf("%d",vrsion['Seed'])]];
out["persistentData"] := eval(history);
t := [
***************
*** 309,319 ****
"",
proc(inp::table)
! local item,seed,vrsion,bits,subj,quiz;
item := `aim/SOAP/GetItem`(inp);
! seed := inp["seed"];
! if seed = 0 then
seed := rand();
- inp["seed"] := seed;
fi;
--- 300,312 ----
"",
proc(inp::table)
! local item,seeds,seed,vrsion,bits,subj,quiz;
item := `aim/SOAP/GetItem`(inp);
! seed := subs(inp["templateVars"],"seed");
! if type([seed],[[string]]) then
! seed := op(sscanf(op(seed),"%d"));
! fi;
! if not(type([seed],[integer])) then
seed := rand();
fi;
***************
*** 342,347 ****
######################################################################
-
-
`RPC/DeclareOperation`(
`aim/RPC/DefaultOperation`,
--- 335,338 ----
Index: MatrixQuestion.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/MatrixQuestion.mpl,v
retrieving revision 1.4.2.2
retrieving revision 1.4.2.3
diff -C2 -d -r1.4.2.2 -r1.4.2.3
*** MatrixQuestion.mpl 31 Mar 2005 12:37:54 -0000 1.4.2.2
--- MatrixQuestion.mpl 22 Apr 2005 07:15:43 -0000 1.4.2.3
***************
*** 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;
--- 139,147 ----
***************
*** 230,236 ****
local savedframe,attempt,mapletype,err,msg,ans,rightans,
ok,rawmark,tlimit;
- # KM
global Config;
- # END KM
attempt := eval(`aim/Question/MakeAttempt`(x));
--- 225,229 ----
***************
*** 265,272 ****
tlimit := this['TimeLimit'];
if not(type([tlimit],[numeric])) then
- # KM
- # DIST tlimit := 2.0;
tlimit := Config['TimeLimit'];
- # END KM
fi;
--- 258,262 ----
***************
*** 380,384 ****
",
proc(this)
! local html,i,j,label,cgilabel,rows,cols,boxsize,rawans,rawmat;
label := this['Label'];
--- 370,374 ----
",
proc(this)
! local html,i,j,label,cgilabel,rows,cols,boxsize,rawans,rawmat,onchange;
label := this['Label'];
***************
*** 399,402 ****
--- 389,410 ----
"<table>\n";
+ onchange :=
+ sprintf("document.getElementById('%s').value=''",cgilabel);
+ for i to rows do
+ for j to cols do
+ onchange :=
+ sprintf("%s+'"'+document.getElementById('%s_Row%d_Col%d').value+'"'",
+ onchange,i,j);
+ if j < cols then
+ onchange := cat(onchange,"+'|'");
+ else
+ if i < rows then
+ onchange := cat(onchange,"+'\\n'");
+ fi;
+ fi;
+ od;
+ od;
+ onchange := cat(onchange,";");
+
for i to rows do
html := html," <tr>\n";
***************
*** 407,416 ****
sprintf(
"<input type='text'
! name='%sRow%dCol%d'
size='%d'
value='%s'
! onchange=\"squashmatrix('%s');\"/>
",
! cgilabel,i,j,boxsize,rawmat[i,j],cgilabel),
"</td>\n";
od;
--- 415,425 ----
sprintf(
"<input type='text'
! name='%s_Row%d_Col%d'
! id='%s_Row%d_Col%d'
size='%d'
value='%s'
! onchange=\"%s\"/>
",
! cgilabel,i,j,boxsize,rawmat[i,j],onchange),
"</td>\n";
od;
|