[LON-CAPA-cvs] cvs: loncom /homework response.pm /homework/templates CustomResponse.problem CustomResponse.problem.meta /html/adm/help/tex Custom_Response_Problems.tex doc/loncapafiles loncapafiles.lpml
www
lon-capa-cvs@mail.lon-capa.org
Tue, 18 Jul 2006 17:24:45 -0000
www Tue Jul 18 13:24:45 2006 EDT
Added files:
/loncom/homework/templates CustomResponse.problem
CustomResponse.problem.meta
/loncom/html/adm/help/tex Custom_Response_Problems.tex
Modified files:
/doc/loncapafiles loncapafiles.lpml
/loncom/homework response.pm
Log:
Document custom response
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.495 doc/loncapafiles/loncapafiles.lpml:1.496
--- doc/loncapafiles/loncapafiles.lpml:1.495 Fri Jul 14 15:35:21 2006
+++ doc/loncapafiles/loncapafiles.lpml Tue Jul 18 13:24:26 2006
@@ -2,7 +2,7 @@
"http://lpml.sourceforge.net/DTD/lpml.dtd">
<!-- loncapafiles.lpml -->
-<!-- $Id: loncapafiles.lpml,v 1.495 2006/07/14 19:35:21 www Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.496 2006/07/18 17:24:26 www Exp $ -->
<!--
@@ -1374,6 +1374,8 @@
blank.problem.meta;
ClickImageExample.problem;
ClickImageExample.problem.meta;
+CustomResponse.problem;
+CustomResponse.problem.meta;
Essay.problem;
Essay.problem.meta;
examupload.problem;
@@ -2691,6 +2693,7 @@
Creating_New_Content_Pages.tex;
Creating_Online_Problems.tex;
Creating_Radio_Response_Problems.tex;
+Custom_Response_Problems.tex;
Developer_Manual_Title_Page.tex;
Developer_Tutorial.tex;
Distribute_Messages.tex;
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.143 loncom/homework/response.pm:1.144
--- loncom/homework/response.pm:1.143 Fri Jul 14 14:40:41 2006
+++ loncom/homework/response.pm Tue Jul 18 13:24:33 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# various response type definitons response definition
#
-# $Id: response.pm,v 1.143 2006/07/14 18:40:41 albertel Exp $
+# $Id: response.pm,v 1.144 2006/07/18 17:24:33 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -378,7 +378,8 @@
} elsif ($target eq 'edit') {
$result.=&Apache::edit::tag_start($target,$token);
$result.=&Apache::edit::text_arg('String to display for answer:',
- 'answerdisplay',$token);
+ 'answerdisplay',$token).
+ &Apache::loncommon::help_open_topic('Custom_Response_Problems','How to write custom responses');
$result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
} elsif ($target eq 'modified') {
my $constructtag;
Index: loncom/homework/templates/CustomResponse.problem
+++ loncom/homework/templates/CustomResponse.problem
<problem>
<startouttext />Accept an answer of around 90 or -90<endouttext />
<customresponse answerdisplay="something near 90 or -90">
<answer type="loncapa/perl">
# We do not want a vector
if ($submission=~/\,/) { return 'ANS_CNT_NOT_MATCH'; }
# No units needed
if ($submission=~/^\d+\s+\w+$/) { return 'UNIT_NOTNEEDED'; }
# Need a numerical answer here
if ($submission!~/^\d+$/) { return 'WANTED_NUMERIC'; }
$difference=abs(90-abs($submission));
if ($difference==0) { return 'EXACT_ANS'; }
if ($difference < 0.001) { return 'APPROX_ANS'; }
return 'INCORRECT';
</answer>
<textline />
</customresponse>
</problem>
Index: loncom/homework/templates/CustomResponse.problem.meta
+++ loncom/homework/templates/CustomResponse.problem.meta
<title>Custom Response</title>
Index: loncom/html/adm/help/tex/Custom_Response_Problems.tex
+++ loncom/html/adm/help/tex/Custom_Response_Problems.tex
\label{Custom_Response_Problems}
Custom Response is a way to have a problem graded based on an algorithm. The use of this response type is
generally discouraged, since the responses will not be analyzable by the LON-CAPA statistics tools.
The student answer is stored in the
variable \$submission, and needs to be evaluated by Perl code inside the <answer>-tag. Custom Response needs to return a standard LON-CAPA grading code:
\begin{itemize}
\item EXACT\_ANS: return if solved exactly correctly
\item APPROX\_ANS: return if solved approximately
\item INCORRECT: return if not correct, loose try
\item SIG\_FAIL, NO\_UNIT, ANS\_CNT\_NOT\_MATCH, BAD\_FORMULA,
WANTED\_NUMERIC: return if not correct for different reasons, do not loose try
\end{itemize}
The answer display is shown instead of the student response in 'show answer' mode.
The following example illustrates this:
\begin{verbatim}
<problem>
<startouttext />Accept an answer of around 90 or -90<endouttext />
<customresponse answerdisplay="something near 90 or -90">
<answer type="loncapa/perl">
# We do not want a vector
if ($submission=~/\,/) { return 'ANS_CNT_NOT_MATCH'; }
# Need a numerical answer here
if ($submission!~/^[\d\.\-\e]+$/i) { return 'WANTED_NUMERIC'; }
$difference=abs(90-abs($submission));
if ($difference==0) { return 'EXACT_ANS'; }
if ($difference < 0.1) { return 'APPROX_ANS'; }
return 'INCORRECT';</answer>
<textline readonly="no" />
</customresponse>
</problem>
\end{verbatim}