Update of /cvsroot/aimmath/AIM/WEB-INF/maple/aim/review
In directory sc8-pr-cvs1:/tmp/cvs-serv8131/WEB-INF/maple/aim/review
Modified Files:
Tag: develop_2_1
Quiz.mpl
Added Files:
Tag: develop_2_1
Question.mpl
Log Message:
Many changes, mostly to implement multipart questions
--- NEW FILE: Question.mpl ---
# @(#)$Id: Question.mpl,v 1.1.2.1 2003/07/10 20:10:04 npstrick Exp $
# Copyright (C) 2003 Neil Strickland
# Distributed without warranty under the GPL - see README for details
read("Package.mpl"):
Package("aim/review/Question","
This package defines the GUI allowing the administrator
to review a student's answers to a question.
"
):
######################################################################
rqc0 := `new/aim/Quiz/Context`():
rqc0['StudentIsGuest'] := false:
rqc0['StudentIsTeacher'] := true:
rqc0['QuizReviewMode'] := false:
rqc0['QuestionReviewMode'] := true:
rqc0['QuizTryMode'] := false:
rqc0['QuestionTryMode'] := false:
rqc0['UseRecordedSeed'] := true:
rqc0['UseSeedParameter'] := true:
rqc0['GenerateSeed'] := false:
rqc0['ReportSeed'] := true:
rqc0['InviteSeedSelection'] := false:
rqc0['RecordSeed'] := false:
rqc0['DeleteSeed'] := false:
rqc0['InviteAnswers'] := false:
rqc0['InviteValidation'] := false:
rqc0['InviteMarking'] := false:
rqc0['InviteNewVersion'] := false:
rqc0['InviteNewQuiz'] := false:
rqc0['AcceptAnswers'] := true:
rqc0['LoadHistory'] := true:
rqc0['SaveHistory'] := false:
rqc0['AcceptAnswers'] := true:
rqc0['UseRecordedAnswers'] := true:
rqc0['MarkRequested'] := true:
rqc0['ShowPrevious'] := true:
rqc0['ShowFeedback'] := true:
rqc0['ShowMark'] := true:
rqc0['ShowRightAnswer'] := false:
rqc0['ShowSolution'] := false:
rqc0['ShowNotes'] := true:
rqc0['ShowMarkSummary'] := true:
`Package/Assign`(
`aim/review/Question/Context/NoSol`::`aim/Quiz/Context`,
"A #`aim/Quiz/Context`# object for use in reviewing quizzes.",
eval(rqc0)
):
unassign('rqc0'):
######################################################################
rqc1 := `new/aim/Quiz/Context`():
rqc1['StudentIsGuest'] := false:
rqc1['StudentIsTeacher'] := true:
rqc1['QuizReviewMode'] := false:
rqc1['QuestionReviewMode'] := true:
rqc1['QuizTryMode'] := false:
rqc1['QuestionTryMode'] := false:
rqc1['UseRecordedSeed'] := true:
rqc1['UseSeedParameter'] := true:
rqc1['GenerateSeed'] := false:
rqc1['ReportSeed'] := true:
rqc1['InviteSeedSelection'] := false:
rqc1['RecordSeed'] := false:
rqc1['DeleteSeed'] := false:
rqc1['InviteAnswers'] := false:
rqc1['InviteValidation'] := false:
rqc1['InviteMarking'] := false:
rqc1['InviteNewVersion'] := false:
rqc1['InviteNewQuiz'] := false:
rqc1['AcceptAnswers'] := true:
rqc1['LoadHistory'] := true:
rqc1['SaveHistory'] := false:
rqc1['AcceptAnswers'] := true:
rqc1['UseRecordedAnswers'] := true:
rqc1['MarkRequested'] := true:
rqc1['ShowPrevious'] := true:
rqc1['ShowFeedback'] := true:
rqc1['ShowMark'] := true:
rqc1['ShowRightAnswer'] := true:
rqc1['ShowSolution'] := true:
rqc1['ShowNotes'] := true:
rqc1['ShowMarkSummary'] := true:
`Package/Assign`(
`aim/review/Question/Context/Sol`::`aim/Quiz/Context`,
"A #`aim/Quiz/Context`# object for use in reviewing quizzes.",
eval(rqc1)
):
unassign('rqc1'):
######################################################################
`aim/admin/Command/Declare`('`review/Question`',
['Parameter',"SubjectName" = 'required',""],
['Parameter',"QuizName" = 'required',""],
['Parameter',"QuizSeed"::integer = 0,""],
['Parameter',"QuestionLabel"::string = 'required',""],
['Parameter',"AttemptNumber"::integer = -1,""],
['Parameter',"StudentID" = 'required',""],
['Parameter',"ShowSolution"::boolean = false,""],
##################################################
['Action',"ReviewQuestion",
"Review the question",
['LinkText' = __("Review"),
'Arguments' = ["AttemptNumber"]]],
['Action',"ShowSolution",
"Show the correct answers and solutions",
['LinkText' = __("Show solutions"),
'ExtraScript' = "f.ShowSolution.value = 'true';"]],
['Action',"HideSolution",
"Hide the correct answers and solutions",
['LinkText' = __("Hide solutions"),
'ExtraScript' = "f.ShowSolution.value = 'false';"]],
['Action',"EditSource",
"Edit the source file for a question",
['Command' = "admin/SourceFile",
'LinkText' = __("Edit source file"),
'Arguments' = ["SourceFile"]]],
['Action',"LoadSubjectOptions",
"Visit the main subject admin page",
['Command' = "admin/Subject",
'LinkText' = __("Subject options")]],
['Action',"LoadQuizOptions",
"Visit the main quiz admin page",
['Command' = "admin/Quiz",
'LinkText' = __("Quiz options")]],
['Action',"ReviewSubject",
"Review this student's results in all quizzes for this subject.",
['Command' = "review/Subject",
'LinkText' = __("Review subject")]],
['Action',"ReviewQuiz",
"Review this student's results in all questions for this quiz.",
['Command' = "review/Quiz",
'LinkText' = __("Review quiz")]],
# ['Action',"EmailStudent",
# "Send email to this student",
# ['Command' = "email/Student",
# 'LinkText' = __("Email student")]],
['Action',"LoadStudentDetails",
"Edit the student's personal details",
['LinkText' = __("Student details"),
'Command' = "admin/Student"]],
##################################################
['Template',
["center",
["h1",
__("Question review page")]],
["br"],
[["hr","noshade"]],
[["table","width" = "100%"],
["tr",
[["td","width" = "16%"],`HTML/CloseButton`],
[["td","width" = "17%"],{["LoadSubjectOptions"]}],
[["td","width" = "17%"],{["LoadQuizOptions"]}],
[["td","width" = "17%"],{"emailstudent"}],
[["td","width" = "17%"],{"adminstudent"}],
[["td","width" = "17%"],{"togglesolution"}]]],
[["hr", "noshade"]],
["table",
["tr",
[["th","align" = "left"],__("Subject")],
["td",{"subjecttitle"}],
["td",{["LoadSubjectOptions"]}],
["td",{["ReviewSubject"]}]],
["tr",
[["th","align" = "left"],__("Quiz")],
["td",{"quiztitle"}],
["td",{["LoadQuizOptions"]}],
["td",{["ReviewQuiz"]}]],
["tr",
[["th","align" = "left"],__("Seed")],
["td",{"quizseed"}]],
["tr",
[["th","align" = "left"],__("Student name")],
["td",{"studentname"}],
["td",{"adminstudent"}],
["td",{"emailstudent"}]]],
{"attemptselector"},
["br"],
{"show"},
["br"],
[["hr", "noshade"]],
[["a", "name" = "bottom"]]
],
##################################################
['Process',
proc(page::`aim/admin/Page`,p::table)
local subject,register,quiz,id,
student,studentname,emailstudent,adminstudent,togglesolution,
seed,quizversion,quizinstance,history,labeltable,
question,label,rawtable,quizcontext,questionversion,
attemptnum,numattempts,subqversion,subqhistory,attempt,
questioninstance,attemptselector,i,bgcol;
subject := eval(page['Subject']);
register := eval(subject['GetRegister']);
id := p["StudentID"];
student := register['GetStudent',id];
if student = NULL then
studentname := __("Not known");
emailstudent := "";
adminstudent := "";
else
studentname := student['Name'];
emailstudent := student['EmailLink'];
adminstudent :=
page['ActionLink',"LoadStudentDetails"];
fi;
quiz := traperror(eval(subject['GetQuiz',p["QuizName"]]));
if not(type(quiz,`aim/Quiz`)) then
page['SetError',"%s: %s",__("Could not load quiz"),p["QuizName"]];
RETURN();
fi;
if p["QuizSeed"] = "0" then
seed := quiz['GetSeed',id,true];
if seed = NULL then
page['SetError',
__("Student %s (%s) has not attempted quiz %s"),
id,
`if`(student = NULL,__("name not known"),student['Name']),
quiz['Name']];
RETURN();
fi;
else
seed := traperror(sscanf(p["QuizSeed"],"%d")[1]);
if not(type(seed,posint)) then
page['SetError',__("Could not extract quiz seed")];
RETURN();
fi;
fi;
quizversion := eval(quiz['MakeVersion',seed]);
questionversion :=
eval(quizversion['LabelTable'][p["QuestionLabel"]]);
history := traperror(eval(quiz['GetHistory',id,seed]));
if not(type(history,`aim/Quiz/History`)) then
page['SetError',
__("Could not load history for quiz %s and student %s"),
quiz['Name'],
id];
RETURN();
fi;
labeltable := eval(history['LabelTable']);
attemptnum := op(sscanf(p["AttemptNumber"],"%d"));
if (attemptnum = 0) then
# Use raw answers supplied as parameters
rawtable := eval(param);
else
# Use raw answers from recorded history
rawtable := table([]);
numattempts := [];
for subqversion in questionversion['SubQuestions'] do
subqhistory :=
eval(labeltable[subqversion['Label']]);
if not(type([subqhistory],[`aim/Question/History`])) then
page['SetError',
__("Could not load history for question %s in quiz %s and student %s"),
p["QuizName"],
subqversion['Label'],
id];
RETURN();
fi;
numattempts := [op(numattempts),subqhistory['Count']];
attempt := traperror(eval(subqhistory['Attempt',attemptnum]));
if not(type([attempt],[`aim/Question/ShortAttempt`])) then
page['SetError',
__("Could not load attempt number %d for question %s in quiz %s and student %s"),
attemptnum,
subqversion['Label'],
p["QuizName"],
id];
fi;
rawtable[subqversion['CGILabel']] := attempt['RawAnswer'];
od;
fi;
if p["ShowSolution"] = "true" then
quizcontext := `aim/review/Quiz/Context/Sol`;
togglesolution := page['ActionLink',"HideSolution"];
else
quizcontext := `aim/review/Quiz/Context/NoSol`;
togglesolution := page['ActionLink',"ShowSolution"];
fi;
questioninstance :=
`aim/Question/MakeInstance/Recursive`(
eval(questionversion),eval(rawtable),eval(labeltable),
eval(quizcontext),false,attemptnum);
if numattempts = [] then
# The question has no bottom-level subquestions
attemptselector := "";
elif min(op(numattempts)) < max(op(numattempts)) then
# Something is wrong - all subquestions should have
# the same number of attempts
ERROR(
sprintf(
__("Inconsistent subquestion histories for question %s in quiz %s"),
p["QuestionLabel"],p["QuizName"]));
else
numattempts := numattempts[1];
if attemptnum < 0 then
# count backwards from the end
attemptnum := numattempts + 1 + attemptnum;
fi;
attemptselector :=
`new/HTML/Tag`(["tr"]);
if attemptnum > 1 then
attemptselector['AddContents',
["td",
page['ActionLink',
"ReviewQuestion",
[sprintf("%d",attemptnum - 1)],
__("Previous")]]];
fi;
for i from 1 to numattempts do
bgcol := `if`(i = attemptnum,"yellow","white");
attemptselector['AddContents',
[["td", "bgcolor" = bgcol],
page['ActionLink',
"ReviewQuestion",
[sprintf("%d",i)],
sprintf("%d",i)]]];
od;
if attemptnum < numattempts then
attemptselector['AddContents',
["td",
page['ActionLink',
"ReviewQuestion",
[sprintf("%d",attemptnum + 1)],
__("Next")]]];
fi;
fi;
attemptselector :=
`new/HTML/Tag`("table",eval(attemptselector));
attemptselector := attemptselector['ToString'];
page['Title'] :=
cat(__("Review:"),subject['Name'],":",
quiz['Name'],":",
questionversion['Label'],":",
student['Surname']);
page['FillTemplate',
"subjecttitle" = subject['Title'],
"quiztitle" = quiz['Title'],
"quizseed" = sprintf("%d",seed),
"studentid" = id,
"studentname" = studentname,
"emailstudent" = emailstudent,
"adminstudent" = adminstudent,
"togglesolution" = togglesolution,
"attemptselector" = attemptselector,
"show" = questioninstance['Show',quizcontext]
];
end
]
):
EndPackage():
Index: Quiz.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/review/Quiz.mpl,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -d -r1.2 -r1.2.2.1
*** Quiz.mpl 5 May 2003 03:25:46 -0000 1.2
--- Quiz.mpl 10 Jul 2003 20:10:04 -0000 1.2.2.1
***************
*** 18,21 ****
--- 18,22 ----
rqc0['StudentIsTeacher'] := true:
rqc0['QuizReviewMode'] := true:
+ rqc0['QuestionReviewMode'] := false:
rqc0['QuizTryMode'] := false:
rqc0['QuestionTryMode'] := false:
***************
*** 40,46 ****
rqc0['ShowPrevious'] := true:
rqc0['ShowFeedback'] := true:
- rqc0['ShowFeedbackMC'] := true:
rqc0['ShowMark'] := true:
- rqc0['ShowMarkMC'] := true:
rqc0['ShowRightAnswer'] := false:
rqc0['ShowSolution'] := false:
--- 41,45 ----
***************
*** 62,65 ****
--- 61,65 ----
rqc1['StudentIsTeacher'] := true:
rqc1['QuizReviewMode'] := true:
+ rqc1['QuestionReviewMode'] := true:
rqc1['QuizTryMode'] := true:
rqc1['QuestionTryMode'] := true:
***************
*** 84,90 ****
rqc1['ShowPrevious'] := true:
rqc1['ShowFeedback'] := true:
- rqc1['ShowFeedbackMC'] := true:
rqc1['ShowMark'] := true:
- rqc1['ShowMarkMC'] := true:
rqc1['ShowRightAnswer'] := true:
rqc1['ShowSolution'] := true:
--- 84,88 ----
***************
*** 125,133 ****
'ExtraScript' = "f.ShowSolution.value = 'false';"]],
! ['Action',"TryQuestion",
! "Try a question",
! ['Command' = "try/Question",
! 'LinkText' = __("Try"),
! 'Arguments' = ["QuestionName","QuestionSeed","RawAnswer"]]],
['Action',"EditSource",
--- 123,131 ----
'ExtraScript' = "f.ShowSolution.value = 'false';"]],
! ['Action',"ReviewQuestion",
! "Review a question",
! ['Command' = "review/Question",
! 'LinkText' = __("Review"),
! 'Arguments' = ["QuestionLabel","AttemptNumber"]]],
['Action',"EditSource",
***************
*** 205,209 ****
local subject,register,quiz,id,
student,studentname,emailstudent,adminstudent,togglesolution,
! seed,quizversion,quizinstance,history,questionhistory,
question,label,rawtable,quizcontext;
--- 203,207 ----
local subject,register,quiz,id,
student,studentname,emailstudent,adminstudent,togglesolution,
! seed,quizversion,quizinstance,history,labeltable,
question,label,rawtable,quizcontext;
***************
*** 260,276 ****
rawtable := table([]);
! questionhistory := eval(history['QuestionHistory']);
for question in quizversion['Questions'] do
label := question['Label'];
rawtable[cat("RawAnswer",label)] :=
! eval(questionhistory[label])['LastRawAnswer'];
od;
- quizinstance :=
- eval(quizversion['MakeInstance',
- eval(rawtable),
- eval(history),
- true]);
-
if p["ShowSolution"] = "true" then
quizcontext := `aim/review/Quiz/Context/Sol`;
--- 258,268 ----
rawtable := table([]);
! labeltable := eval(history['LabelTable']);
for question in quizversion['Questions'] do
label := question['Label'];
rawtable[cat("RawAnswer",label)] :=
! eval(labeltable[label])['LastRawAnswer'];
od;
if p["ShowSolution"] = "true" then
quizcontext := `aim/review/Quiz/Context/Sol`;
***************
*** 280,283 ****
--- 272,281 ----
togglesolution := page['ActionLink',"ShowSolution"];
fi;
+
+ quizinstance :=
+ eval(quizversion['MakeInstance',
+ eval(rawtable),
+ eval(history),
+ eval(quizcontext)]);
quizinstance['SetBody',quizcontext];
|