[LON-CAPA-cvs] cvs: loncom /homework response.pm /homework/templates custompartial.problem custompartial.problem.meta /html/adm/help/tex Custom_Response_Problems.tex doc/loncapafiles loncapafiles.lpml

www www@source.lon-capa.org
Sun, 24 May 2009 13:08:35 -0000


www		Sun May 24 13:08:35 2009 EDT

  Added files:                 
    /loncom/homework/templates	custompartial.problem 
                              	custompartial.problem.meta 

  Modified files:              
    /doc/loncapafiles	loncapafiles.lpml 
    /loncom/homework	response.pm 
    /loncom/html/adm/help/tex	Custom_Response_Problems.tex 
  Log:
  Bug #2802: partial credit multiple answers
  
  
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.645 doc/loncapafiles/loncapafiles.lpml:1.646
--- doc/loncapafiles/loncapafiles.lpml:1.645	Wed May 20 09:49:57 2009
+++ doc/loncapafiles/loncapafiles.lpml	Sun May 24 13:08:09 2009
@@ -2,7 +2,7 @@
  "http://lpml.sourceforge.net/DTD/lpml.dtd">
 <!-- loncapafiles.lpml -->
 
-<!-- $Id: loncapafiles.lpml,v 1.645 2009/05/20 09:49:57 bisitz Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.646 2009/05/24 13:08:09 www Exp $ -->
 
 <!--
 
@@ -1243,6 +1243,8 @@
 optional_criteria.task.meta;
 ClickImageExample.problem;
 ClickImageExample.problem.meta;
+custompartial.problem;
+custompartial.problem.meta;
 CustomResponse.problem;
 CustomResponse.problem.meta;
 Essay.problem;
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.215 loncom/homework/response.pm:1.216
--- loncom/homework/response.pm:1.215	Mon May  4 16:45:44 2009
+++ loncom/homework/response.pm	Sun May 24 13:08:18 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.215 2009/05/04 16:45:44 bisitz Exp $
+# $Id: response.pm,v 1.216 2009/05/24 13:08:18 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -439,7 +439,7 @@
 	    ${$safeeval->varglob('LONCAPA::customresponse_submission')}=
 		$response;
 	    
-	    my $award = &Apache::run::run('{ my $submission=$LONCAPA::customresponse_submission;'.$Apache::response::custom_answer[-1].'}',$safeeval);
+	    my ($award,$score) = &Apache::run::run('{ my $submission=$LONCAPA::customresponse_submission;'.$Apache::response::custom_answer[-1].'}',$safeeval);
 	    if (!&Apache::inputtags::valid_award($award)) {
 		$error = $award;
 		$award = 'ERROR';
@@ -447,6 +447,9 @@
 	    &Apache::response::handle_previous(\%previous,$award);
 	    $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=
 		$award;
+            if ($award eq 'ASSIGNED_SCORE') {
+                $Apache::lonhomework::results{"resource.$part.$id.awarded"}=1.0*$score;
+            }
 	    if ($error) {
 		$Apache::lonhomework::results{"resource.$part.$id.awardmsg"}=
 		    $error;
Index: loncom/html/adm/help/tex/Custom_Response_Problems.tex
diff -u loncom/html/adm/help/tex/Custom_Response_Problems.tex:1.4 loncom/html/adm/help/tex/Custom_Response_Problems.tex:1.5
--- loncom/html/adm/help/tex/Custom_Response_Problems.tex:1.4	Thu May 10 21:04:02 2007
+++ loncom/html/adm/help/tex/Custom_Response_Problems.tex	Sun May 24 13:08:35 2009
@@ -2,12 +2,15 @@
 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. The most common response are:
+For a single textfield, the student's answer will be in a variable \$submission. If the Custom Response has multiple textfields, the answers will be in an array
+reference, and can be accessed as \$\$submission[0], \$\$submission[1], etc.
+
+The student answer needs to be evaluated by Perl code inside the <answer>-tag. Custom Response needs to return a standard LON-CAPA. The most common response are:
 \begin{itemize}
 \item EXACT\_ANS: return if solved exactly correctly
 \item APPROX\_ANS: return if solved approximately
 \item INCORRECT: return if not correct, uses up a try
+\item ASSIGNED\_SCORE: partial credit (also return the credit factor, e.g. return(ASSIGNED\_SCORE,0.3);)
 \item SIG\_FAIL, NO\_UNIT, EXTRA\_ANSWER, MISSING\_ANSWER, BAD\_FORMULA, 
 WANTED\_NUMERIC: return if not correct for different reasons, does not use up a try
 \end{itemize}
@@ -42,7 +45,7 @@
 \item WANTED\_NUMERIC: expected a numeric answer and didn't get one
 \item SIG\_FAIL: incorrect number of Significant Figures
 \item UNIT\_FAIL: incorrect unit
-\item UNIT\_NOTNEEDED: Submitted a unit when one shouldn't
+\item UNIT\_NOTNEEDED: submitted a unit when one shouldn't
 \item UNIT\_INVALID\_INSTRUCTOR: the unit provided by the author of the problem is unparsable
 \item UNIT\_INVALID\_STUDENT: the unit provided by the student is unparasable
 \item UNIT\_IRRECONCIBLE: the unit from the student and the instructor are of different types
@@ -53,9 +56,8 @@
 \item DRAFT: submission only stored
 \item MISORDERED\_RANK: student submitted a poorly order rank response
 \item ERROR: unable to get a grade
-\item ASSIGNED\_SCORE: there is a resource.partid.responseid.awarded the real awarded should be set to the average of the individual awards
-\item TOO\_LONG: answer submission to CAPA engine longer than 500 characters
+\item ASSIGNED\_SCORE: partial credit; the customresponse needs to return the award followed by the partial credit factor  
+\item TOO\_LONG: answer submission was deemed too long
 \item INVALID\_FILETYPE: student tried to upload a file that was of an extension that was not specifically allowed 
 \item COMMA\_FAIL: answer requires the use of comma grouping and it wasn't provided or was incorrect
-
-\end{itemize}
\ No newline at end of file
+\end{itemize}

Index: loncom/homework/templates/custompartial.problem
+++ loncom/homework/templates/custompartial.problem
<problem>
<startouttext />Complete the sentence:<endouttext />
<customresponse id="11">
<notsolved>
<startouttext />
The q<textline readonly="no" size="5" /> brown fox jum<textline readonly="no" size="3" /> over the <textline readonly="no" size="3" />zy d<textline readonly="no" size="3" />.
<endouttext />
</notsolved>
<solved>
<startouttext />
The q<b>uick</b> brown fox jum<b>ps</b> over the <b>la</b>zy d<b>og</b>.
<endouttext />
</solved>

    <answer type="loncapa/perl">@answer=('uick','ps','la','og');
$correct=0;
for ($i=0;$i<=$#$submission;$i++) {
    $$submission[$i]=~s/\s//gs;
    if ($$submission[$i] eq $answer[$i]) { $correct++; }
}
if ($correct==$#answer+1) { return 'EXACT_ANS'; }
if ($correct==0) { return 'INCORRECT'; }
return('ASSIGNED_SCORE',$correct/($#answer+1));</answer>
</customresponse>
</problem>



Index: loncom/homework/templates/custompartial.problem.meta
+++ loncom/homework/templates/custompartial.problem.meta
<title>Custom Response with Partial Credit</title>
<category>Free Form Problems</category>
<help>Custom_Response_Problems</help>