--- loncom/html/res/adm/pages/annotator/admannotations.pm 2007/04/24 23:26:26 1.27 +++ loncom/html/res/adm/pages/annotator/admannotations.pm 2018/12/29 22:31:16 1.36 @@ -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.36 2018/12/29 22:31:16 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -27,6 +27,7 @@ # ################## + package Apache::admannotations; use strict; @@ -40,8 +41,7 @@ use Apache::lonlocal; sub write_annotation { my ($symb, $enc, $annotation) = @_; - return if (!$annotation); - + $annotation=~s/^\s*$//; my $key = $symb; if (!$enc) { $key = @@ -52,19 +52,6 @@ sub write_annotation { 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 { @@ -88,6 +75,12 @@ sub construct_editor { my $get_symb = &js_get_symb(); + my %lt = &Apache::lonlocal::texthash( + 'close no save' => 'Close', + 'save' => 'Save', + 'cancel' => 'Cancel', + ); + my $js = < var timeout; @@ -102,6 +95,11 @@ function changed() { } timeout=setTimeout('changed();','1000'); } + +function renameButton(){ + document.getElementById("close").value="$lt{'cancel'}"; +} + ENDJS @@ -115,20 +113,17 @@ ENDJS my $end_page = &Apache::loncommon::end_page(); - my %lt = ( 'close no save' => "Close (no save)", - 'save' => "Save and Update",); - %lt = &Apache::lonlocal::texthash(%lt); return(< -
-
+ +
-
@@ -152,14 +147,15 @@ ENDJS {'only_body' => 1,}); my $end_page = &Apache::loncommon::end_page(); - my %lt = ( 'close' => "Close", - 'button' => $button_name,); - %lt = &Apache::lonlocal::texthash(%lt); + my %lt = &Apache::lonlocal::texthash( + 'close' => 'Close', + 'button' => $button_name, + ); return(< -
+
@@ -179,15 +175,6 @@ $end_page 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 @@ -198,11 +185,10 @@ sub handler { $r->send_http_header; return OK if $r->header_only; - 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'},1); + my ($symb_new,$symb_new_enc) = &Apache::loncommon::clean_symb($env{'form.symbnew'},1); my $annotation=$env{'form.annotation'}; @@ -214,7 +200,7 @@ sub handler { $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'}); @@ -227,3 +213,41 @@ sub handler { 1; __END__ +=pod + +=head1 NAME + +Apache::admannotations + +=head1 SYNOPSIS + +This will take annotations and then plug them into a page. + +This is part of the LearningOnline Network with CAPA project +described at http://www.lon-capa.org. + +=head1 OVERVIEW + +(empty) + +=head1 SUBROUTINES + +=over write_annotation() + +Put annotation + +=item js_get_symb() + +Construct editor + +=item construct_editor() + +=item construct_error() + +=item handler() + +=back + +=cut + +