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

raeburn raeburn@source.lon-capa.org
Mon, 16 May 2011 01:02:57 -0000


raeburn		Mon May 16 01:02:57 2011 EDT

  Modified files:              (Branch: version_2_10_X)
    /loncom/homework	inputtags.pm 
  Log:
  - Backport 1.286.
  
  
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.271.2.6 loncom/homework/inputtags.pm:1.271.2.7
--- loncom/homework/inputtags.pm:1.271.2.6	Sat Mar  5 23:01:35 2011
+++ loncom/homework/inputtags.pm	Mon May 16 01:02:57 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.271.2.6 2011/03/05 23:01:35 raeburn Exp $
+# $Id: inputtags.pm,v 1.271.2.7 2011/05/16 01:02:57 raeburn 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
@@ -479,6 +479,48 @@
     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()