[LON-CAPA-cvs] cvs: loncom /html/res/adm/pages/annotator admannotations.pm

tempelho lon-capa-cvs-allow@mail.lon-capa.org
Thu, 11 Sep 2008 20:44:54 -0000


tempelho		Thu Sep 11 16:44:54 2008 EDT

  Modified files:              
    /loncom/html/res/adm/pages/annotator	admannotations.pm 
  Log:
  Extracting the functions clean_symb() and get_annotation() and moved them to loncommon.pm.
  Also fixed a non lited bug entering empty comments.
  
  
Index: loncom/html/res/adm/pages/annotator/admannotations.pm
diff -u loncom/html/res/adm/pages/annotator/admannotations.pm:1.27 loncom/html/res/adm/pages/annotator/admannotations.pm:1.28
--- loncom/html/res/adm/pages/annotator/admannotations.pm:1.27	Tue Apr 24 19:26:26 2007
+++ loncom/html/res/adm/pages/annotator/admannotations.pm	Thu Sep 11 16:44:54 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # This will take annotations and then plug them into a page.
 #
-# $Id: admannotations.pm,v 1.27 2007/04/24 23:26:26 albertel Exp $
+# $Id: admannotations.pm,v 1.28 2008/09/11 20:44:54 tempelho Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -40,8 +40,8 @@
 sub write_annotation {
     my ($symb, $enc, $annotation) = @_;
 
-    return if (!$annotation);
-
+    
+    $annotation=~s/$^\s*$//;
     my $key = $symb;
     if (!$enc) {
 	$key = 
@@ -52,19 +52,6 @@
     return;
 }
 
-# --------------------------------------------------------------Get annotation
-
-sub get_annotation {
-    my ($symb,$enc) = @_;
-
-    my $key = $symb;
-    if (!$enc) {
-	$key = 
-	    &Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
-    }
-    my %annotation=&Apache::lonnet::get('nohist_annotations',[$key]);
-    return $annotation{$key};
-}
 
 # ------------------------------------------------------------Construct editor
 sub js_get_symb {
@@ -179,15 +166,6 @@
 END_HTML2
 }
 
-sub clean_symb {
-    my ($symb) = @_;
-
-    &Apache::lonenc::check_decrypt(\$symb);
-    my $enc = $env{'request.enc'};
-    delete($env{'request.enc'});
-    
-    return ($symb,$enc);
-}
 
 # ---------------------------------------------------------------Main Handler
 
@@ -201,8 +179,8 @@
 
     my $page;
 
-    my ($symb_old,$symb_old_enc) = &clean_symb($env{'form.symbold'});
-    my ($symb_new,$symb_new_enc) = &clean_symb($env{'form.symbnew'});
+    my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($env{'form.symbold'});
+    my ($symb_new,$symb_new_enc) = &Apache::loncommon::clean_symb($env{'form.symbnew'});
 
     my $annotation=$env{'form.annotation'};
 
@@ -214,7 +192,7 @@
 	    $page=&construct_error(&mt("Cannot annotate current window. Please point your browser to a LON-CAPA page and then 'continue'."),"continue");
 	} else {
 	    if ($symb_old ne $symb_new) {
-		$annotation=&get_annotation($symb_new,$symb_new_enc);
+		$annotation=&Apache::loncommon::get_annotation($symb_new,$symb_new_enc);
 	    }
 	    # pass same symb through.
 	    $page=&construct_editor($annotation,$env{'form.symbnew'});