[LON-CAPA-cvs] cvs: loncom /homework inputtags.pm

www www@source.lon-capa.org
Fri, 29 Apr 2011 01:41:12 -0000


www		Fri Apr 29 01:41:12 2011 EDT

  Modified files:              
    /loncom/homework	inputtags.pm 
  Log:
  Bug #6453: hidden submission line
  
  
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.285 loncom/homework/inputtags.pm:1.286
--- loncom/homework/inputtags.pm:1.285	Mon Mar  7 22:38:09 2011
+++ loncom/homework/inputtags.pm	Fri Apr 29 01:41:12 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.285 2011/03/07 22:38:09 www Exp $
+# $Id: inputtags.pm,v 1.286 2011/04/29 01:41:12 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -60,7 +60,7 @@
  
 
 BEGIN {
-    &Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline'));
+    &Apache::lonxml::register('Apache::inputtags',('hiddensubmission','hiddenline','textfield','textline'));
 }
 
 =pod
@@ -478,6 +478,49 @@
     return "";
 }
 
+
+sub start_hiddensubmission {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+    my $result = "";
+    my $input_id = &start_input($parstack,$safeeval);
+    if ($target eq 'web') {
+        $Apache::lonxml::evaluate--;
+        if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
+            my $partid=$Apache::inputtags::part;
+            my $id=$Apache::inputtags::response[-1];
+            if ($Apache::lonhomework::type ne 'exam') {
+                my $value = &Apache::lonxml::get_param('value',$parstack,$safeeval);
+                $value = &HTML::Entities::encode($value,'<>&"');
+                $result= '<input type="hidden" name="HWVAL_'.$id.'" value="'.$value.'" />';
+            }
+        }
+    } elsif ($target eq 'edit') {
+        $result=&Apache::edit::tag_start($target,$token);
+        $result.=&Apache::edit::text_arg('Value:','value',$token,'15');
+        $result.=&Apache::edit::end_row();
+        $result.=&Apache::edit::end_table();
+    } elsif ($target eq 'modified') {
+        my $constructtag=&Apache::edit::get_new_args($token,$parstack,
+                                                     $safeeval,'value');
+        if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
+    }
+
+    if ( ($target eq 'web' || $target eq 'tex')
+         && $Apache::lonhomework::type eq 'exam'
+         && &needs_exam_box($tagstack)) {
+        $result.=&exam_box($target);
+    }
+    return $result;
+}
+
+sub end_hiddensubmission {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+    if    ($target eq 'web') { $Apache::lonxml::evaluate++; }
+    elsif ($target eq 'edit') { return ('','no'); }
+    &end_input();
+    return "";
+}
+
 =pod
 
 =item file_selector()