[LON-CAPA-cvs] cvs: loncom /homework grades.pm /homework/templates customhints.problem customhints.problem.meta doc/loncapafiles loncapafiles.lpml

www www@source.lon-capa.org
Sun, 25 Apr 2010 13:18:37 -0000


www		Sun Apr 25 13:18:37 2010 EDT

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

  Modified files:              
    /doc/loncapafiles	loncapafiles.lpml 
    /loncom/homework	grades.pm 
  Log:
  Example for the use of custom hints.
  
  
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.680 doc/loncapafiles/loncapafiles.lpml:1.681
--- doc/loncapafiles/loncapafiles.lpml:1.680	Fri Apr  2 16:06:33 2010
+++ doc/loncapafiles/loncapafiles.lpml	Sun Apr 25 13:18:28 2010
@@ -2,7 +2,7 @@
  "http://lpml.sourceforge.net/DTD/lpml.dtd">
 <!-- loncapafiles.lpml -->
 
-<!-- $Id: loncapafiles.lpml,v 1.680 2010/04/02 16:06:33 raeburn Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.681 2010/04/25 13:18:28 www Exp $ -->
 
 <!--
 
@@ -1296,6 +1296,8 @@
 optional_criteria.task.meta;
 ClickImageExample.problem;
 ClickImageExample.problem.meta;
+customhints.problem;
+customhints.problem.meta;
 custompartial.problem;
 custompartial.problem.meta;
 CustomResponse.problem;
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.630 loncom/homework/grades.pm:1.631
--- loncom/homework/grades.pm:1.630	Thu Apr 22 13:00:24 2010
+++ loncom/homework/grades.pm	Sun Apr 25 13:18:32 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.630 2010/04/22 13:00:24 www Exp $
+# $Id: grades.pm,v 1.631 2010/04/25 13:18:32 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2344,7 +2344,7 @@
 	    (split(/[,;\s]+/,$record->{'resource.'.$part.'.collaborators'})) { 
 	    $possible_collaborator =~ s/[\$\^\(\)]//g;
 	    next if ($possible_collaborator eq '');
-	    my ($co_name,$co_dom) = split(/\@|:/,$possible_collaborator);
+	    my ($co_name,$co_dom) = split(/:/,$possible_collaborator);
 	    $co_dom = $udom if (! defined($co_dom) || $co_dom =~ /^domain$/i);
 	    next if ($co_name eq $uname && $co_dom eq $udom);
 	    # Doing this grep allows 'fuzzy' specification

Index: loncom/homework/templates/customhints.problem
+++ loncom/homework/templates/customhints.problem
<problem>
<script type="loncapa/perl"># Construct an Egyptian Fraction that can be represented by three terms with denominators between 3 and 12
@denominators=(&random_permutation(&random(1,1000,1),(3..12)))[0..2];
$egyptian='1/'.(join('+1/',sort{$a<=>$b}(@denominators)));
$possible="A possible solution is $egyptian";

# Let the CAS figure out the value
$solution=&cas('maxima',$egyptian);

# Subroutine that checks if the provided term is indeed an Egyptian Fraction
sub analyze {
    my ($expression)=@_;
    $expression=~s/\s//gs;
    $expression=~s/\+?1\//\,/gs;
     if ($expression=~/^(\,[0-9]+)+$/) {
# Format is indeed 1/n+1/m+...
        $last=-1;
        foreach $number (sort { $a<=>$b } split(/\,/,$expression)) {
# Is a number used twice?
             if ($last==$number) { return(0,1); }
             $last=$number;
          }
          return(0,0);
     }
     return(1,0);
}
</script>

<startouttext />

Write $solution as an Egyptian Fraction<br />
<endouttext />

<customresponse answerdisplay="$possible" id="11">
    <answer type="loncapa/perl"># Analyze the format
($formaterror,$doubleerror)=&analyze($submission);
if ($formaterror || $doubleerror) { return 'BAD_FORMULA'; }
# It is an Egyptian Fraction, is the value correct?
if (&cas('maxima',$submission.'-('.$egyptian.')') eq '0') {
    return 'EXACT_ANS';
}
return 'INCORRECT';</answer>
    <textline readonly="no" size="40" />

 <customhint name="format" id="12">
      <answer type="loncapa/perl">if ((&analyze($submission))[0]) { return 'EXACT_ANS'; }
return 'INCORRECT';</answer>
</customhint>
<hintpart on="format">
<startouttext />
<p>
Egyptian Fractions have a format of 1/number+1/number+..., for example 1/3+1/17+1/52. 
</p>
<endouttext />
</hintpart>
 <customhint name="double" id="13">
      <answer type="loncapa/perl">if ((&analyze($submission))[1]) { return 'EXACT_ANS'; }
return 'INCORRECT';</answer>
</customhint>
<hintpart on="double">
<startouttext />
<p>
Egyptian Fractions cannot have the same denominator more than once. For example, 1/3+1/17+1/4+/17 is not an Egyptian Fraction, as it has 17 twice as denominator.
</p>
<endouttext />
</hintpart>
</customresponse>
</problem>


Index: loncom/homework/templates/customhints.problem.meta
+++ loncom/homework/templates/customhints.problem.meta
<title>Custom Response using Computer Algebra System and Hints</title>
<category>Free Form Problems</category>
<help>Custom_Response_Problems</help>