[LON-CAPA-cvs] cvs: loncom /homework inputtags.pm
www
lon-capa-cvs@mail.lon-capa.org
Tue, 25 Nov 2003 23:04:59 -0000
www Tue Nov 25 18:04:59 2003 EDT
Modified files:
/loncom/homework inputtags.pm
Log:
Be able to specify pre-fabricated special characters or phrases to insert
into text lines and fields (for example, German umlauts).
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.123 loncom/homework/inputtags.pm:1.124
--- loncom/homework/inputtags.pm:1.123 Sat Nov 15 22:23:17 2003
+++ loncom/homework/inputtags.pm Tue Nov 25 18:04:58 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# input definitons
#
-# $Id: inputtags.pm,v 1.123 2003/11/16 03:23:17 albertel Exp $
+# $Id: inputtags.pm,v 1.124 2003/11/25 23:04:58 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -98,6 +98,16 @@
return '';
}
+sub addchars {
+ my ($fieldid,$addchars)=@_;
+ my $output='';
+ foreach (split(/\,/,$addchars)) {
+ $output.='<a href="javascript:void(document.forms.lonhomework.'.
+ $fieldid.'.value+=\''.$_.'\')">'.$_.'</a> ';
+ }
+ return $output;
+}
+
sub start_textfield {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $result = "";
@@ -112,7 +122,12 @@
if ( $cols eq '') { $cols = 80; }
my $rows = &Apache::lonxml::get_param('rows',$parstack,$safeeval);
if ( $rows eq '') { $rows = 10; }
- $result= '<textarea wrap="hard" name="HWVAL_'.$resid.'" '.
+ my $addchars=&Apache::lonxml::get_param('addchars',$parstack,$safeeval);
+ $result='';
+ if ($addchars) {
+ $result.=&addchars('HWVAL_'.$resid,$addchars);
+ }
+ $result.= '<textarea wrap="hard" name="HWVAL_'.$resid.'" '.
"rows=\"$rows\" cols=\"$cols\">".$oldresponse;
if ($oldresponse ne '') {
#get rid of any startup text if the user has already responded
@@ -135,11 +150,13 @@
$result.=&Apache::edit::tag_start($target,$token);
$result.=&Apache::edit::text_arg('Rows:','rows',$token,4);
$result.=&Apache::edit::text_arg('Columns:','cols',$token,4);
+ $result.=&Apache::edit::text_arg
+ ('Click-On Texts (comma sep):','addchars',$token,10);
my $bodytext=&Apache::lonxml::get_all_text("/textfield",$parser);
$result.=&Apache::edit::editfield($token->[1],$bodytext,'Text you want to appear by default:',80,2);
} elsif ($target eq 'modified') {
my $constructtag=&Apache::edit::get_new_args($token,$parstack,
- $safeeval,'rows','cols');
+ $safeeval,'rows','cols','addchars');
if ($constructtag) {
$result = &Apache::edit::rebuild_tag($token);
} else {
@@ -193,7 +210,12 @@
}
my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"});
if ($Apache::lonhomework::type ne 'exam') {
- $result= '<input type="text" name="HWVAL_'.$id.'" value="'.
+ my $addchars=&Apache::lonxml::get_param('addchars',$parstack,$safeeval);
+ $result='';
+ if ($addchars) {
+ $result.=&addchars('HWVAL_'.$id,$addchars);
+ }
+ $result.= '<input type="text" name="HWVAL_'.$id.'" value="'.
$oldresponse.'" size="'.$size.'" maxlength="'.$maxlength.'" />';
}
} else {
@@ -203,10 +225,12 @@
}
} elsif ($target eq 'edit') {
$result=&Apache::edit::tag_start($target,$token);
- $result.=&Apache::edit::text_arg('Size:','size',$token,'5')."</td></tr>";
+ $result.=&Apache::edit::text_arg('Size:','size',$token,'5').
+ &Apache::edit::text_arg
+ ('Click-On Texts (comma sep):','addchars',$token,10)."</td></tr>";
$result.=&Apache::edit::end_table;
} elsif ($target eq 'modified') {
- my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'size');
+ my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'size','addchars');
if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
} elsif ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') {
my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);