Update of /cvsroot/aimmath/AIM/WEB-INF/maple/aim
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5478/WEB-INF/maple/aim
Modified Files:
Tag: aim-xml
MultiQuestion.mpl Question.mpl SOAP.mpl
Log Message:
Index: MultiQuestion.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/MultiQuestion.mpl,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -C2 -d -r1.7 -r1.7.2.1
*** MultiQuestion.mpl 17 Sep 2004 14:02:05 -0000 1.7
--- MultiQuestion.mpl 1 Apr 2005 01:42:55 -0000 1.7.2.1
***************
*** 251,254 ****
--- 251,262 ----
],
+ ['Method','RightRawAnswerList'::list(string=string),
+ "",
+ proc(this)
+ [map((q) -> op(q['RightRawAnswerList']),
+ this['TopSubQuestions'])]
+ end
+ ],
+
['Method','Initialize'::'void',
"Initialize the question version. This basically just invokes the
Index: Question.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/Question.mpl,v
retrieving revision 1.13.2.2
retrieving revision 1.13.2.3
diff -C2 -d -r1.13.2.2 -r1.13.2.3
*** Question.mpl 31 Mar 2005 12:37:54 -0000 1.13.2.2
--- Question.mpl 1 Apr 2005 01:42:55 -0000 1.13.2.3
***************
*** 252,258 ****
if partlabel = "" then
! RETURN(eval(this))
else
! ERROR(sprintf(__("Question %s%s has no parts."),this['FullName']));
fi;
end
--- 252,258 ----
if partlabel = "" then
[...1075 lines suppressed...]
--- 3605,3609 ----
recordsdir := cat(dir,"/records");
if not(`OS/FileExists`(recordsdir)) then
! error(__("No records directory"));
fi;
***************
*** 3606,3610 ****
analysis['Save'];
! RETURN(eval(analysis));
end
):
--- 3625,3629 ----
analysis['Save'];
! return(eval(analysis));
end
):
Index: SOAP.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/Attic/SOAP.mpl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** SOAP.mpl 31 Mar 2005 14:50:01 -0000 1.1.2.1
--- SOAP.mpl 1 Apr 2005 01:42:55 -0000 1.1.2.2
***************
*** 23,85 ****
):
- `Class/Declare`(
- `aim/RQP/ItemCache/Entry`,
- "",
- ['Field','Content'],
- ['Field','LastAccessTime'::`Date/RawDate` = 0],
- ['Constructor',
- "",
- proc(this,x_,date_::`Date/RawDate`)
- if nargs > 1 then
- this['Content'] := eval(x_);
- if nargs > 2 then
- this['LastAccessTime'] := date_;
- else
- this['LastAccessTime'] := `Date/CurrentRawDate`();
- fi;
- fi;
- end
- ]
- ):
-
- `Class/Declare`(
- `aim/RQP/ItemCache`,
- "",
- ['Constructor',
- "",
- proc(this)
- this['Entries'] := table([]);
- end
- ],
-
- ['Field','Entries'::table],
-
- ['Method','GetEntry',
- "",
- proc(this,guid::string,seed_::integer)
- local i,x,e;
- e := eval(this['Entries']);
- i := args[2..-1];
- if assigned(e[i]) then
- x := e[i];
- x['LastAccessTime'] := `Date/CurrentRawDate`();
- return(eval(x['Content']));
- else
- return(NULL);
- fi;
- end
- ],
-
- ['Method','AddEntry'::'void',
- "",
- proc(this,x,guid::string,seed_::integer)
- local i,a;
- this['Entries'][args[3..-1]] :=
- eval(`new/aim/RQP/ItemCache/Entry`(x));
- NULL;
- end
- ]
- ):
-
`aim/RPC/Service`['AddOperation',
`aim/RPC/Hello`,
--- 23,26 ----
***************
*** 115,140 ****
['OutputMessageName',"ServerInformationResponse"],
! ['Output',"description"::`XML/string` =
"AiM server. See http://www.aiminfo.net"],
['Output',"cloning"::`XML/boolean` = false],
['Output',"implicitCloning"::`XML/boolean` = true],
['Output',"rendering"::`XML/boolean` = true],
! ['Output',"templateCaching"::`XML/boolean` = false],
! ['Output',"itemCaching"::`XML/boolean` = true],
! ['Output',"inputFormats"::`RQP/ArrayOfanyURI` =
! ["http://formats.aiminfo.net/aim"]],
! ['Output',"outputFormats"::`RQP/ArrayOfoutputFormat` =
! [
! ["http://rqp.org/content-types/text",
! ["http://rqp.org/content-types/text/xhtml-1.0"]],
! ["http://rqp.org/content-types/image",
! ["http://rqp.org/content-types/image/gif"]],
! ["http://rqp.org/content-types/graph",
! ["http://rqp.org/content-types/graph/gif"]]
! ]
! ],
- ['Output',"outputTemplates"::`RQP/ArrayOfanyURI` = []],
-
['Process',
proc(inp,out)
--- 56,74 ----
['OutputMessageName',"ServerInformationResponse"],
! ['Output',"identifier"::`XML/anyURI` =
! "http://www.aiminfo.net/aimid#20050330"],
! ['Output',"name"::`XML/string` = "AiM"],
! ['Output',"description"::`XML/string` =
"AiM server. See http://www.aiminfo.net"],
['Output',"cloning"::`XML/boolean` = false],
['Output',"implicitCloning"::`XML/boolean` = true],
['Output',"rendering"::`XML/boolean` = true],
! ['Output',"itemFormats"::`RQP/ArrayOfanyURI` =
! ["http://www.aiminfo.net/itemFormats/aimsource",
! "http://www.aiminfo.net/itemFormats/location"
! ]],
! ['Output',"renderFormats"::`RQP/ArrayOfanyURI` =
! ["http://rqp.org/formats/xhtml-1.0-web"]],
['Process',
proc(inp,out)
***************
*** 150,169 ****
['OutputMessageName',"ItemInformationResponse"],
- ['Input',"guid"::`RQP/guid`],
['Input',"source"::`XML/string`],
['Input',"format"::`XML/anyURI`],
! ['Input',"cache"::`XML/boolean`],
- ['Output',"warnings"::`RQP/ArrayOfwarning`=[]],
- ['Output',"sourceCached"::`XML/boolean` = true],
['Output',"format"::`XML/anyURI`=""],
['Output',"sourceErrors"::`RQP/ArrayOferror`=[]],
! ['Output',"template"::`XML/boolean` = false],
['Output',"adaptive"::`XML/boolean` = true],
['Output',"timeDependent"::`XML/boolean` = false],
['Output',"canComputerScore"::`XML/boolean` = true],
['Output',"solutionAvailable"::`XML/boolean` = true],
! ['Output',"hintsAvailable"::`XML/boolean` = false],
['Output',"maxScore"::`XML/unsignedInt` = 100],
['Process',
--- 84,102 ----
['OutputMessageName',"ItemInformationResponse"],
['Input',"source"::`XML/string`],
['Input',"format"::`XML/anyURI`],
! ['Input',"index"::`XML/unsignedInt` = 0],
['Output',"format"::`XML/anyURI`=""],
['Output',"sourceErrors"::`RQP/ArrayOferror`=[]],
! ['Output',"template"::`XML/boolean` = true],
['Output',"adaptive"::`XML/boolean` = true],
['Output',"timeDependent"::`XML/boolean` = false],
['Output',"canComputerScore"::`XML/boolean` = true],
['Output',"solutionAvailable"::`XML/boolean` = true],
! ['Output',"hintAvailable"::`XML/boolean` = false],
! ['Output',"validationPossible"::`XML/boolean` = true],
['Output',"maxScore"::`XML/unsignedInt` = 100],
+ ['Output',"length"::`XML/unsignedInt` = 1],
['Process',
***************
*** 189,192 ****
--- 122,178 ----
`aim/RPC/Service`['AddOperation',
+ `aim/RPC/ProcessTemplate`,
+ "",
+ ['Name',"RQP_ProcessTemplate"],
+ ['InputMessageName',"ProcessTemplate"],
+ ['OutputMessageName',"ProcessTemplateResponse"],
+
+ ['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
+ ]
+ ]:
+
+ `aim/RPC/Service`['AddOperation',
+ `aim/RPC/SessionInformation`,
+ "",
+ ['Name',"RQP_SessionInformation"],
+ ['InputMessageName',"SessionInformation"],
+ ['OutputMessageName',"SessionInformationResponse"],
+
+ ['Input',"source"::`XML/string`],
+ ['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` = []],
+
+ ['Process',
+ proc(inp,out)
+ 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
+ ]
+ ]:
+
+
+ `aim/RPC/Service`['AddOperation',
`aim/RPC/Render`,
"",
***************
*** 195,255 ****
['OutputMessageName',"RenderResponse"],
- ['Input',"guid"::`RQP/guid`],
['Input',"source"::`XML/string`],
['Input',"format"::`XML/anyURI`],
! ['Input',"cache"::`XML/boolean`],
! ['Input',"seed"::`XML/unsignedInt`],
['Input',"templateVars"::`RQP/ArrayOfvariable`],
! ['Input',"persistentData"::`XML/string`],
! ['Input',"inputData"::`XML/string`],
['Input',"embedPrefix"::`XML/QName`],
- ['Input',"state"::`XML/anyURI`],
- ['Input',"interactive"::`XML/boolean`],
- ['Input',"renderFormatTemplate"::`XML/anyURI`],
- ['Input',"renderFormat"::`RQP/ArrayOfoutputFormat`],
- ['Input',"modalFormatTemplate"::`XML/anyURI`],
- ['Input',"modalFormat"::`RQP/ArrayOfoutputFormat`],
['Input',"appletBase"::`XML/anyURI`],
['Input',"mediaBase"::`XML/anyURI`],
- ['Output',"warnings"::`RQP/ArrayOfwarning` = []],
- ['Output',"sourceCached"::`XML/boolean` = true],
['Output',"seed"::`XML/unsignedInt` = 0],
['Output',"templateVars"::`RQP/ArrayOfvariable` = []],
! ['Output',"persistentData"::`XML/string` = ""],
['Output',"outcomeVars"::`RQP/ArrayOfvariable` = []],
! ['Output',"bodyParts"::`RQP/ArrayOfoutputSection` = []],
! ['Output',"modalParts"::`RQP/ArrayOfoutputSection` = []],
['Process',
proc(inp,out)
! local cache,vrsion,inputdata,label,history,historytable,pdata,
! context,inst,attempt;
! cache := evalb(inp["cache"] = true);
! vrsion := eval(`aim/SOAP/GetItemVersion`(inp,cache));
! vrsion['CGIPrefix'] := inp["embedPrefix"];
! inputdata :=
! `Util/HTTPPostParse`(inp["inputData"],inp["embedPrefix"]);
! pdata := inp["persistentData"];
! if pdata = "" or pdata = NULL then
history := `new/aim/Question/History`(vrsion);
- else
- try
- history := sscanf(pdata,"%m")[1];
- catch:
- error(__("Cannot parse persistent data."));
- end try;
- if not(type([history],[`aim/Question/History`])) then
- error(__("Cannot parse persistent data."));
- fi;
fi;
historytable :=
table([vrsion['Label'] = eval(history)]);
context :=
`aim/SOAP/MakeQuizContext`(
! inp["interactive"],
! evalb(inputdata["MarkRequested"] <> "false"),
true, # show feedback
true, # show marks
--- 181,229 ----
['OutputMessageName',"RenderResponse"],
['Input',"source"::`XML/string`],
['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`],
+ ['Input',"renderFormat"::`XML/anyURI`],
+ ['Input',"modalFormat"::`XML/anyURI`],
['Output',"seed"::`XML/unsignedInt` = 0],
['Output',"templateVars"::`RQP/ArrayOfvariable` = []],
! ['Output',"persistentData"::`XML/MapleExpression` = ""],
['Output',"outcomeVars"::`RQP/ArrayOfvariable` = []],
! ['Output',"output"::`RQP/ArrayOfoutput` = []],
['Process',
proc(inp,out)
! local vrsion,responses,history,historytable,context,
! attempt,inst,t;
! vrsion := eval(`aim/SOAP/GetItemVersion`(inp));
! vrsion['CGIPrefix'] :=
! cat(inp["embedPrefix"],"RawAnswer");
! responses := table(inp["responses"]);
!
! history := eval(inp["persistentData"]);
! if history = "" or history = NULL then
history := `new/aim/Question/History`(vrsion);
fi;
+ if not(type([history],[`aim/Question/History`])) then
+ error(__("Cannot parse persistent data."));
+ fi;
+
historytable :=
table([vrsion['Label'] = eval(history)]);
context :=
`aim/SOAP/MakeQuizContext`(
! true, # invite answers
! inp["advanceState"], # marking requested
true, # show feedback
true, # show marks
***************
*** 259,274 ****
inst :=
`aim/Question/MakeInstance/Recursive`(
! vrsion,inputdata,historytable,context);
attempt := inst['Attempt'];
out["seed"] := vrsion['Seed'];
! out["persistentData"] := sprintf("%m",eval(history));
! out["outcomeVars"] :=
! [["SCORE", [sprintf("%d",round(100*history['Mark']))]],
! ["RAW_SCORE", [sprintf("%d",round(100*attempt['RawMark']))]],
! ["IsValid", [sprintf("%A",attempt['IsValid'])]],
! ["ValidationNote", [attempt['ValidationNote']]],
! ["AnswerNote", [attempt['AnswerNote']]]];
! out["bodyParts"] := inst['ShowParts',context];
NULL;
end
--- 233,256 ----
inst :=
`aim/Question/MakeInstance/Recursive`(
! vrsion,responses,historytable,context);
attempt := inst['Attempt'];
out["seed"] := vrsion['Seed'];
! out["persistentData"] := eval(history);
! t := [
! "completion" = history['CompletionStatus'],
! "grade" = sprintf("%A",history['Mark']),
! "rawScore" = sprintf("%A",history['RawMark']),
! "valid" = sprintf("%A",attempt['IsValid']),
! "validation" = "true",
! "hint" = "false",
! "solution" = "true"
! ];
! t :=
! map((x) ->
! cat("http://rqp.org/outcomes/",lhs(x)) = [rhs(x)],
! t);
! out["outcomeVars"] := eval(t);
! out["outputs"] := inst['ShowParts',context];
NULL;
end
***************
*** 279,337 ****
`aim/SOAP/GetItem`,
"",
! proc(inp::table,cache_::boolean)
! local cache,itemGUID,itemFormat,itemSource,item,vrsion,bits,subj,quiz;
! global AimRQPCache;
!
! cache := `if`(nargs > 1,cache_,true);
- itemGUID := inp["guid"];
itemFormat := inp["format"];
itemSource := inp["source"];
! if itemGUID <> "" then
! item := AimRQPCache['GetEntry',itemGUID];
! if item <> NULL then
! return(eval(item));
! fi;
! ###TODO: in production mode, remove or protect the following:
! if `Util/StartsWith`(itemGUID,"AIMFILE") then
! try
! bits := [`Util/ColonSplit`(itemGUID)];
! subj := eval(DefaultZone['GetSubject',bits[2]]);
! quiz := eval(subj['GetQuiz',bits[3]]);
! item := eval(quiz['GetQuestion',bits[4]]);
! if not(type([item],[`aim/Question`])) then
! error(
! "SOAP Fault",
! "Client",
! cat("RQP Error: ",__("Malformed question")),
! "http://rqp.org/errors/itemNotCached");
! fi;
! catch:
! error(
! "SOAP Fault:",
! "Client",
! cat("RQP Error: ",__("Could not load specified question")),
! "http://rqp.org/errors/invalidSource");
! end try;
! if not(type([item],[`aim/Question`])) then
! error(
! "SOAP Fault:",
! "Client",
! cat("RQP Error: ",__("Could not load specified question")),
! "http://rqp.org/errors/invalidSource");
! fi;
! return(eval(item));
! fi;
! fi;
!
! if itemGUID = "" then
! itemGUID := `Util/MakeGUID`();
! fi;
!
! if `Util/StripEndSpaces`(itemSource) = "" then
! error(__("Item is not in the cache, and no source provided"));
! fi;
! if itemFormat = "http://aiminfo.net/formats/location" then
try
bits := [`Util/ColonSplit`(itemSource)];
--- 261,271 ----
`aim/SOAP/GetItem`,
"",
! proc(inp::table)
! local itemFormat,itemSource,item,vrsion,bits,subj,quiz;
itemFormat := inp["format"];
itemSource := inp["source"];
! if itemFormat = "http://aiminfo.net/itemFormats/location" then
try
bits := [`Util/ColonSplit`(itemSource)];
***************
*** 366,376 ****
error("Compilation failure: %0",item)
fi;
- item['ItemGUID'] := itemGUID;
fi;
-
- if cache then
- AimRQPCache['AddEntry',eval(item),itemGUID];
- fi;
-
return(eval(item));
end
--- 300,304 ----
***************
*** 380,424 ****
`aim/SOAP/GetItemVersion`,
"",
! proc(inp::table,cache_::boolean)
! local cache,itemGUID,versionSeed,question,vrsion;
! global AimRQPCache;
!
! cache := `if`(nargs > 1,cache_,true);
! itemGUID := inp["guid"];
! versionSeed := inp["seed"];
! if not(type([versionSeed],[integer])) then
! versionSeed := 1;
! fi;
! if versionSeed = 0 then
! versionSeed := rand();
fi;
! vrsion := AimRQPCache['GetEntry',itemGUID,versionSeed];
!
! if vrsion <> NULL then
! return(eval(vrsion));
! else
! question := `aim/SOAP/GetItem`(inp);
! vrsion := question['MakeVersion',versionSeed];
!
! if not(type([vrsion],[`aim/Question/Version`])) then
! error(
! "SOAP Fault:",
! "Client",
! cat("RQP Error: ",__("Could not make version of question")),
! "http://rqp.org/errors/templateProcessingFailed");
! fi;
!
! if cache then
! AimRQPCache['AddEntry',
! eval(vrsion),itemGUID,versionSeed];
! fi;
!
! return(eval(vrsion));
! fi;
end
):
`Package/Assign`(
`aim/SOAP/MakeQuizContext`::`aim/Quiz/Context`,
--- 308,326 ----
`aim/SOAP/GetItemVersion`,
"",
! 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;
! return(item['MakeVersion',seed]);
end
):
+
`Package/Assign`(
`aim/SOAP/MakeQuizContext`::`aim/Quiz/Context`,
***************
*** 441,484 ****
- # `RPC/DeclareOperation`(
- # `aim/RPC/ProcessTemplate`,
- # "",
- # ['Name',"RQP_ProcessTemplate"],
- # ['InputMessageName',"ProcessTemplate"],
- # ['OutputMessageName',"ProcessTemplateResponse"],
- #
- #
- # ['Input',"guid"::`RQP/guid`],
- # ['Input',"source"::`XML/string`],
- # ['Input',"format"::`XML/anyURI`],
- # ['Input',"cache"::`XML/boolean`],
- # ['Input',"seed"::`XML/unsignedInt`],
- #
- # ['Output',"warnings"::`RQP/ArrayOfwarning`],
- # ['Output',"sourceCached"::`XML/boolean` = true],
- # ['Output',"cloneCached"::`XML/boolean` = true],
- # ['Output',"seed"::`XML/unsignedInt`=0],
- # ['Output',"templateVars"::`RQP/ArrayOfvariable`]
- # ):
- #
- # `RPC/DeclareOperation`(
- # `aim/RPC/Clone`,
- # "",
- # ['Name',"Clone"],
- #
- # ['Input',"guid"::`RQP/guid`],
- # ['Input',"source"::`XML/string`],
- # ['Input',"format"::`XML/anyURI`],
- # ['Input',"cache"::`XML/boolean`],
- # ['Input',"seed"::`XML/unsignedInt`],
- # ['Input',"templateVars"::`RQP/ArrayOfvariable`],
- #
- # ['Output',"warnings"::`RQP/ArrayOfwarning`],
- # ['Output',"sourceCached"::`XML/boolean` = true],
- # ['Output',"cloneCached"::`XML/boolean` = true],
- # ['Output',"seed"::`XML/unsignedInt`],
- # ['Output',"templateVars"::`RQP/ArrayOfvariable`],
- # ['Output',"clone"::`XML/string`=""]
- # ):
`RPC/DeclareOperation`(
--- 343,346 ----
|