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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 06 May 2003 15:31:45 -0000


albertel		Tue May  6 11:31:45 2003 EDT

  Modified files:              
    /loncom/homework	inputtags.pm 
  Log:
  - adding new tag <hiddenline /> as an input type. could be used to receive
    an input from a user but not show it on screen. Probably still needs some
    positive on screen feedback when it has received an answer.
  
  
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.97 loncom/homework/inputtags.pm:1.98
--- loncom/homework/inputtags.pm:1.97	Wed Apr 30 09:44:30 2003
+++ loncom/homework/inputtags.pm	Tue May  6 11:31:45 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.97 2003/04/30 13:44:30 sakharuk Exp $
+# $Id: inputtags.pm,v 1.98 2003/05/06 15:31:45 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -33,7 +33,7 @@
 use Apache::loncommon;
 
 BEGIN {
-  &Apache::lonxml::register('Apache::inputtags',('textfield','textline'));
+  &Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline'));
 }
 
 
@@ -200,6 +200,34 @@
   return "";
 }
 
+sub start_hiddenline {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+    my $result = "";
+    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];
+	    my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"});
+	    if ($Apache::lonhomework::type ne 'exam') {
+		$result= '<input type="hidden" name="HWVAL_'.$id.'" value="'.
+		    $oldresponse.'" />';
+	    }
+	}
+    } elsif ($target eq 'edit') {
+	$result=&Apache::edit::tag_start($target,$token);
+	$result.=&Apache::edit::end_table;
+    }
+    return $result;
+}
+
+sub end_hiddenline {
+  my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+  if    ($target eq 'web') { $Apache::lonxml::evaluate++; }
+  elsif ($target eq 'edit') { return ('','no'); }
+  return "";
+}
+
 sub finalizeawards {
   my $result='';
   my $award;
@@ -350,8 +378,8 @@
   } else {
       $message = "Unknown message: $award";
       $button=1;
-  } 
-  if (lc($Apache::lonhomework::problemstatus) ne 'yes') {
+  }
+  if (lc($Apache::lonhomework::problemstatus) eq 'no') {
       $message = "Answer Submitted";
       $button=1;
   }