Update of /cvsroot/aimmath/AIM/WEB-INF/maple/aim/admin
In directory sc8-pr-cvs1:/tmp/cvs-serv8886
Modified Files:
Subject.mpl
Added Files:
CompileSubject.mpl
Log Message:
Several new packages and modifications... see posting to developer's list
--- NEW FILE: CompileSubject.mpl ---
# Copyright (C) 2003 Neil Strickland
# Distributed without warranty under the GPL - see README for details
read("Package.mpl"):
Package("aim/admin/CompileSubject","
This package defines the reporting page showing the administrator the results of attempting to compile all question source files in all non-hidden quizzes in a given subject.
"
):
######################################################################
`aim/admin/Command/Declare`('`admin/CompileSubject`',
['Parameter',"SubjectName" = 'required',""],
['Parameter',"QuizName" = "",""],
['Parameter',"QuestionName" = "",""],
##################################################
['Action',"TryQuestion",
"Try the compiled question.",
['Command' = "try/Question",
'Arguments' = ["QuestionName"],
'LinkText' = __("Try it")]],
##################################################
['Template',
[["a", "name" = "top"]],
{"title"},
[["hr", "noshade"]],
[["table","width" = "100%"],
["tr",
[["td","align" = "left","width" = "10%"],`HTML/CloseButton`],
[["td","align" = "left","width" = "16%"],
[["a", "href" = "#bottom"],__("Bottom")]]
]],
[["hr", "noshade"]],
{"compreport"},
[["hr", "noshade"]],
[["table","width" = "100%"],
["tr",
[["td","align" = "left","width" = "10%"],`HTML/CloseButton`],
[["td","align" = "left","width" = "16%"],
[["a", "href" = "#top"],__("Top")]]
]],
[["hr", "noshade"]],
[["a", "name" = "bottom"]]
],
##################################################
['Process',
proc(page::`aim/admin/Page`,p::table)
local subject,subjname,subjtitle,
quiz,quizname,quiztitle,
question,questions,questionname,
action,dir,fulldir,srcdir,srcfile,fullsrcfile,
compreport,msg,qname,errline,lines,i,rows,
sourcetext,err,title,shorttitle,filelist;
subject := eval(page['Subject']);
subjname := subject['Name'];
subjtitle := subject['Title'];
shorttitle := cat("Compiling Subject:",subjname);
title :=
"<center><h1>",__("AIM question compilation results"),"</h1></center>\n",
"<table>",
"<tr><td>",__("Compiling all questions for subject:"),"</td>\n",
"<td>",subjtitle,"</td></tr>\n",
"</table>";
compreport := "";
for quizname in subject['QuizNames'] do
compreport := compreport,"<b>",__("Quiz:  ");
try
quiz := eval(subject['GetQuiz',quizname]);
catch : end:
if not type([quiz],[`aim/Quiz`]) then
compreport := compreport,quizname,"</b><br/>\n"
"<font color='red'>Unable to load this quiz.</font><br/>\n"
else
quiztitle := quiz['Title'];
compreport := compreport,quiztitle,"</b><br/>\n";
srcdir := `Util/StripSlash`(quiz['RootDir']);
fulldir := cat(srcdir,"/source");
filelist := `OS/ListFiles`(fulldir);
for srcfile in filelist do
questions := traperror(`aim/Compile`(srcdir,srcfile));
if questions = lasterror or not type(questions,list) then
compreport := compreport,
__("Compilation error:"),"\n<pre>\n",
`HTML/Escape/String`(questions),"\n</pre>\n<br/>";
questions := [];
fi;
if nops(questions) = 0 then
compreport := compreport,"\n<br/>\n",__("No questions found"),"\n<br/>\n";
fi;
for question in questions do
if type(question,`aim/Question`) then
compreport :=
compreport,
`HTML/ToString`(`new/HTML/Tag`(
"div",
sprintf(
__("Question %s compiled OK"),
cat("<font color='green'><tt>",
question['Name'],
"</tt></font>")),
["br"]));
elif type(question,`aim/Compile/ErrorReport`) then
msg := question[1];
qname := question[2];
errline := question[3];
lines :=
map((x) -> `HTML/Escape`(x[1]," ",x[2],"\n"),question[4]);
compreport :=
compreport,
"<hr noshade/>\n",
sprintf(
__("Question <font color='red'><tt>%s</tt></font>: compilation error\n<br/>\n"),
qname),
msg;
if errline > 0 then
compreport := compreport,"\n<hr/>\n<pre>\n";
for i from 1 to errline - 1 do
compreport := compreport,lines[i];
od;
compreport :=
compreport,
"<font color='red'>\n",
lines[errline],
"\n</font>\n";
for i from errline + 1 to nops(lines) do
compreport := compreport,lines[i];
od;
compreport := compreport,"</pre>\n";
fi;
compreport := compreport,"<hr noshade/>\n";
else
compreport :=
compreport,
"<font color='red'>",
__("Error: malformed compilation report"),
"</font>\n<br/>\n<pre>\n",
`HTML/Escape`(sprintf("%q",eval(question))),
"\n</pre>\n<br/>\n";
fi;
od; # questions
od: # files
fi;
if quiz <> NULL then
# Saving the quiz automatically updates its modification time.
quiz['Save'];
AimQuizCache['RemoveQuiz',quiz];
fi;
compreport := compreport,"<hr noshade size=1>";
od: # quizzes
title := cat(title);
compreport := cat(compreport);
page['Title'] := shorttitle;
page['FillTemplate',
"title" = title,
"compreport" = compreport
];
end
]
):
EndPackage():
Index: Subject.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/admin/Subject.mpl,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Subject.mpl 25 Aug 2003 21:47:19 -0000 1.3
--- Subject.mpl 1 Sep 2003 05:56:29 -0000 1.4
***************
*** 124,127 ****
--- 124,135 ----
],
+ # KM
+ ['Action',"CompileSubject",
+ "Compile all of the source code for all of the questions in all of the quizzes that are currently not hidden.",
+ ['LinkText' = __("Compile all questions in non-hidden quizzes"),
+ 'Command' = "admin/CompileSubject"]
+ ],
+ # END KM
+
##################################################
***************
*** 234,237 ****
--- 242,252 ----
{"quiztable"},
["br"],
+ # KM
+ {["CompileSubject"]},
+ [["font","color"="red"],
+ __("  (warning: this may take a long time!)")],
+ ["br"],
+ ["hr"],
+ # END KM
__("New quiz:")," ",
[["inputtext", "name" = "QuizToCreate", "value" = ""]],
***************
*** 436,442 ****
["tr",
[["th", "align" = "left", "width" = "10%"],
! __("Quiz number")],
[["th", "align" = "left", "width" = "30%"],
! __("Name")],
[["th", "align" = "left", "width" = "10%"]," "],
[["th", "align" = "left", "width" = "10%"]," "],
--- 451,457 ----
["tr",
[["th", "align" = "left", "width" = "10%"],
! __("Quiz number")],
[["th", "align" = "left", "width" = "30%"],
! __("Name")],
[["th", "align" = "left", "width" = "10%"]," "],
[["th", "align" = "left", "width" = "10%"]," "],
***************
*** 463,470 ****
["tr",
[["td", "align" = "left"],
! [["inputtext",
! "name" = cat(nam,"Order"),
! "value" = sprintf("%A",quiznumber),
! "size" = "3"]]],
[["td","align" = "left"],nam],
[["td","align" = "left"],
--- 478,485 ----
["tr",
[["td", "align" = "left"],
! [["inputtext",
! "name" = cat(nam,"Order"),
! "value" = sprintf("%A",quiznumber),
! "size" = "3"]]],
[["td","align" = "left"],nam],
[["td","align" = "left"],
***************
*** 502,515 ****
[["td","align" = "left"],nam],
[["td","align" = "left"],
! page['ActionLink',"TryQuiz",[nam]]],
[["td","align" = "left"],
! page['ActionLink',"LoadQuizOptions",[nam]]],
[["td","align" = "left"],
! page['ActionLink',"BrowseSource",[nam]]],
[["td","align" = "left"]," "],
[["td","align" = "left"],
! page['ActionLink',"ToggleQuiz",[nam],__("Unhide")]],
[["td","align" = "left"],
! page['ActionLink',"DeleteQuiz",[nam]]]]];
od;
fi;
--- 517,530 ----
[["td","align" = "left"],nam],
[["td","align" = "left"],
! page['ActionLink',"TryQuiz",[nam]]],
[["td","align" = "left"],
! page['ActionLink',"LoadQuizOptions",[nam]]],
[["td","align" = "left"],
! page['ActionLink',"BrowseSource",[nam]]],
[["td","align" = "left"]," "],
[["td","align" = "left"],
! page['ActionLink',"ToggleQuiz",[nam],__("Unhide")]],
[["td","align" = "left"],
! page['ActionLink',"DeleteQuiz",[nam]]]]];
od;
fi;
|