--- loncom/homework/edit.pm 2005/06/07 01:33:19 1.93
+++ loncom/homework/edit.pm 2006/02/06 21:59:44 1.100
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# edit mode helpers
#
-# $Id: edit.pm,v 1.93 2005/06/07 01:33:19 albertel Exp $
+# $Id: edit.pm,v 1.100 2006/02/06 21:59:44 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -92,10 +92,12 @@ sub start_table {
foreach my $namespace (reverse @Apache::lonxml::namespace) {
my $testtag=$namespace.'::'.$tag;
$tagnum=$Apache::lonxml::insertlist{"$testtag.num"};
+ &Apache::lonxml::debug(" $testtag ");
if (defined($tagnum)) { last; }
}
if (!defined ($tagnum)) {$tagnum=$Apache::lonxml::insertlist{"$tag.num"};}
my $color = $Apache::lonxml::insertlist{"$tagnum.color"};
+ &Apache::lonxml::debug(" $tagnum -- $color");
if (!defined($color)) {
$color = $Apache::edit::colorlist[$Apache::edit::colordepth];
}
@@ -109,7 +111,7 @@ sub start_table {
sub end_table {
$Apache::edit::colordepth--;
my $result='';
- $result.="
";
+ $result.='';
my ($tagname,$closingtag);
if (defined($Apache::edit::inserttag[-2])) {
@@ -119,7 +121,7 @@ sub end_table {
$closingtag=$Apache::edit::inserttag[-1];
}
$result.=&innerinsertlist('edit',$tagname,$closingtag).
- " |
";
+ " |
";
pop(@Apache::edit::inserttag);
return $result;
}
@@ -161,7 +163,7 @@ sub handle_delete {
}
if (!$result) {
my $endtag='/'.$token->[1];
- my $bodytext=&Apache::lonxml::get_all_text($endtag,$parser);
+ my $bodytext=&Apache::lonxml::get_all_text($endtag,$parser,$style);
$$parser['-1']->get_token();
&Apache::lonxml::debug("Deleting :$bodytext: for $token->[1]");
&Apache::lonxml::end_tag($tagstack,$parstack,$token);
@@ -309,6 +311,25 @@ sub insert_numericalresponse {
';
}
+sub insert_customresponse {
+ return '
+
+
+
+
+
+
+
+';
+}
+
+sub insert_customresponse_answer {
+ return '
+
+
+';
+}
+
sub insert_stringresponse {
return '
@@ -477,6 +498,44 @@ sub insert_script {
return "\n";
}
+sub js_change_detection {
+ my $unsaved=&mt("There are unsaved changes");
+ return (<
+SCRIPT
+}
+
+sub form_change_detection {
+ return ' onsubmit="is_submit=true;" ';
+}
+
+sub element_change_detection {
+ return ' onchange="unClean();" ';
+}
+
+sub submit_ask_anyway {
+ return ' onclick="still_ask=true;" ';
+}
+
sub textarea_sizes {
my ($data)=@_;
my $count=0;
@@ -495,10 +554,11 @@ sub editline {
my ($tag,$data,$description,$size)=@_;
$data=&HTML::Entities::encode($data,'<>&"');
if ($description) { $description="
".$description."
"; }
+ my $change_code = &element_change_detection();
my $result = <<"END";
$description
+ value="$data" size="$size" $change_code />
END
return $result;
}
@@ -523,7 +583,7 @@ sub editfield {
return $description."\n".' '.
($usehtmlarea?&Apache::lonhtmlcommon::spelllink('lonhomework',
'homework_edit_'.$Apache::lonxml::curdepth):'')."\n";
@@ -623,7 +683,7 @@ sub checked_arg {
$text=$option;
$value='value="'.$option.'"';
}
- $result.="$text\n";
+ $result.=&element_change_detection()." />$text\n";
}
return $result;
}
@@ -642,7 +702,8 @@ sub text_arg {
if (!defined $size) { $size=20; }
my $arg=$token->[2]{$name};
$result=&mt($description).' ';
+ '" type="text" value="'.$arg.'" size="'.$size.'" '.
+ &element_change_detection().'/>';
return ''.$result.'';
}
@@ -668,7 +729,7 @@ sub select_arg {
}
}
$result.=''.$description.' ';
return $result;
@@ -701,6 +762,7 @@ sub select_or_text_arg {
((!$found)?' selected="selected"':'').
">".&mt('Type-in value')."\n";
#
+ my $change_code=&element_change_detection();
my $element=&html_element_name($name);
my $selectelement='select_list_'.$element;
my $typeinelement='type_in_'.$element;
@@ -725,7 +787,7 @@ $optionlist
value="$typeinvalue"
onChange="$hiddenvalue=$typedinvalue;"
onFocus="$selectedindex=$selecttypeinindex-1;" />
-
+
ENDSELECTORTYPE
}