[LON-CAPA-cvs] cvs: loncom /homework edit.pm functionplotresponse.pm insertlist.xml
www
www@source.lon-capa.org
Sat, 09 Oct 2010 22:31:49 -0000
www Sat Oct 9 22:31:49 2010 EDT
Modified files:
/loncom/homework edit.pm functionplotresponse.pm insertlist.xml
Log:
Recognize previous tries
Work on colorful editor
Index: loncom/homework/edit.pm
diff -u loncom/homework/edit.pm:1.129 loncom/homework/edit.pm:1.130
--- loncom/homework/edit.pm:1.129 Mon Sep 27 22:15:32 2010
+++ loncom/homework/edit.pm Sat Oct 9 22:31:49 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# edit mode helpers
#
-# $Id: edit.pm,v 1.129 2010/09/27 22:15:32 www Exp $
+# $Id: edit.pm,v 1.130 2010/10/09 22:31:49 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -400,6 +400,8 @@
sub insert_functionplotresponse {
return '
<functionplotresponse>
+<spline />
+<splinerule />
</functionplotresponse>';
}
Index: loncom/homework/functionplotresponse.pm
diff -u loncom/homework/functionplotresponse.pm:1.11 loncom/homework/functionplotresponse.pm:1.12
--- loncom/homework/functionplotresponse.pm:1.11 Sat Oct 9 20:02:02 2010
+++ loncom/homework/functionplotresponse.pm Sat Oct 9 22:31:49 2010
@@ -1,7 +1,7 @@
# LearningOnline Network with CAPA
# option list style responses
#
-# $Id: functionplotresponse.pm,v 1.11 2010/10/09 20:02:02 www Exp $
+# $Id: functionplotresponse.pm,v 1.12 2010/10/09 22:31:49 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,7 +33,7 @@
use Apache::lonnet;
BEGIN {
- &Apache::lonxml::register('Apache::functionplotresponse',('functionplotresponse','backgroundplot','spline'));
+ &Apache::lonxml::register('Apache::functionplotresponse',('functionplotresponse','backgroundplot','spline','splinerule'));
}
#
@@ -285,6 +285,21 @@
}
#
+# <splinerule ... />
+#
+sub start_splinerule {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ my $result='';
+ my $internalid = $Apache::inputtags::part.'_'.$Apache::inputtags::response[-1];
+ return $result;
+}
+
+sub end_splinerule {
+ return '';
+}
+
+
+#
# <spline label="..." order="1,2,3,4" initx="..." inity="..." scalex="..." scaley="..." />
#
# Unfortunately, GeoGebra seems to want all splines after everything else, so we need to store them
@@ -389,10 +404,40 @@
my $xaxisvisible=(&Apache::lonxml::get_param('xaxisvisible',$parstack,$safeeval)=~/on|true|yes|1/i?'true':'false');
my $yaxisvisible=(&Apache::lonxml::get_param('yaxisvisible',$parstack,$safeeval)=~/on|true|yes|1/i?'true':'false');
my $gridvisible=(&Apache::lonxml::get_param('gridvisible',$parstack,$safeeval)=~/on|true|yes|1/i?'true':'false');
+ if ($target eq 'edit') {
+ $result.=&Apache::edit::start_table($token)
+ .'<tr><td><span class="LC_nobreak">'.&mt('Function Plot Question').'</span></td>'
+ .'<td><span class="LC_nobreak">'.&mt('Delete?').' '
+ .&Apache::edit::deletelist($target,$token)
+ .'</span></td>'
+ ."<td> "
+ .&Apache::edit::end_row()
+ .&Apache::edit::start_spanning_row()
+ ."\n";
+ $result.=&Apache::edit::text_arg('Minimum x-value:','xmin',
+ $token,'4').
+ &Apache::edit::text_arg('Maximum x-value:','xmax',
+ $token,'4').
+ &Apache::edit::select_arg('x-axis visible:','xaxisvisible',
+ ['yes','no'],$token).
+ &Apache::edit::text_arg('Minimum y-value:','ymin',
+ $token,'4').
+ &Apache::edit::text_arg('Maximum y-value:','ymax',
+ $token,'4').
+ &Apache::edit::select_arg('y-axis visible:','yaxisvisible',
+ ['yes','no'],$token).
+ &Apache::edit::select_arg('Grid visible:','gridvisible',
+ ['yes','no'],$token).
+ &Apache::edit::end_row().&Apache::edit::start_spanning_row();
+ } elsif ($target eq 'modified') {
+ my $constructtag=&Apache::edit::get_new_args($token,$parstack,
+ $safeeval,'xmin','xmax','ymin','ymax',
+ 'xaxisvisible','yaxisvisible','gridvisible');
+ if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
- if ($target eq 'meta') {
+ } elsif ($target eq 'meta') {
$result=&Apache::response::meta_package_write('functionplotresponse');
- } elsif ($target eq 'web') {
+ } elsif ($target eq 'web') {
# paste in the update routine to receive stuff back from the applet
$result.=&update_script($internalid);
# start the initscript for this applet
@@ -413,7 +458,7 @@
my $partid=$Apache::inputtags::part;
my $internalid = $partid.'_'.$id;
-# if ($target eq 'edit') { $result=&Apache::edit::end_table(); }
+ if ($target eq 'edit') { $result=&Apache::edit::end_table(); }
if ($target eq 'grade'
&& &Apache::response::submitted()
&& $Apache::lonhomework::type eq 'exam') {
@@ -425,8 +470,16 @@
&& $Apache::lonhomework::type ne 'exam') {
my ($response,%coords)=&get_answer_from_form_fields($internalid);
$Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response;
- $Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}='INCORRECT';
-
+ my %previous=&Apache::response::check_for_previous($response,$partid,$id);
+#
+# Actually grade
+#
+ my $ad='INCORRECT';
+#
+# Store grading info
+#
+ $Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad;
+ &Apache::response::handle_previous(\%previous,$ad);
} elsif ($target eq 'web') {
# Now is the time to render all of the stored splines
foreach my $label (keys(%Apache::functionplotresponse::splineorder)) {
Index: loncom/homework/insertlist.xml
diff -u loncom/homework/insertlist.xml:1.18 loncom/homework/insertlist.xml:1.19
--- loncom/homework/insertlist.xml:1.18 Mon Sep 27 22:15:32 2010
+++ loncom/homework/insertlist.xml Sat Oct 9 22:31:49 2010
@@ -20,6 +20,24 @@
<description>Response: Function Plot</description>
<color>#77DD55</color>
<insert_sub>insert_functionplotresponse</insert_sub>
+ <allow>spline,backgroundplot,splinerule</allow>
+ </tag>
+ <tag name="spline">
+ <description>Spline</description>
+ <color>#aaff99</color>
+ <insert_sub>default</insert_sub>
+ <allow></allow>
+ </tag>
+ <tag name="backgroundplot">
+ <description>Background Function Plot</description>
+ <color>#DDDD55</color>
+ <insert_sub>default</insert_sub>
+ <allow></allow>
+ </tag>
+ <tag name="splinerule">
+ <description>Spline Evaluation Rule</description>
+ <color>#99ff88</color>
+ <insert_sub>default</insert_sub>
<allow></allow>
</tag>
<tag name="caparesponse::answergroup">