[LON-CAPA-cvs] cvs: loncom /interface lonspreadsheet.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Fri, 12 Apr 2002 21:41:13 -0000
matthew Fri Apr 12 17:41:13 2002 EDT
Modified files:
/loncom/interface lonspreadsheet.pm
Log:
Added send_crit_msg and send_msg to send critical and normal messages.
Don't use this code yet - it currently sends multiple messages every time
the spreadsheet is recomputed.
Index: loncom/interface/lonspreadsheet.pm
diff -u loncom/interface/lonspreadsheet.pm:1.85 loncom/interface/lonspreadsheet.pm:1.86
--- loncom/interface/lonspreadsheet.pm:1.85 Thu Apr 11 10:16:32 2002
+++ loncom/interface/lonspreadsheet.pm Fri Apr 12 17:41:13 2002
@@ -1,5 +1,5 @@
#
-# $Id: lonspreadsheet.pm,v 1.85 2002/04/11 14:16:32 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.86 2002/04/12 21:41:13 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -111,6 +111,23 @@
my $includedir;
my $tmpdir;
+# ------------------------------------------------ Send critical message
+sub send_crit_msg {
+ my ($uname,$udom,$subject,$message,$sendback) = @_;
+ my $result = &Apache::lonmsg::user_crit_msg($uname,$udom,$subject,
+ $message,$sendback);
+ return ($result eq 'ok' ? 1 : 0);
+}
+
+# ------------------------------------------------ Send noncritical message
+sub send_msg {
+ my ($uname,$udom,$subject,$message) = @_;
+ my $result = &Apache::lonmsg::user_normal_msg($uname,$udom,
+ $subject,$message);
+ return ($result eq 'ok' ? 1 : 0);
+}
+
+
# =============================================================================
# ===================================== Implements an instance of a spreadsheet
@@ -122,6 +139,8 @@
$safeeval->permit("sort");
$safeeval->deny(":base_io");
$safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT');
+ $safehole->wrap(\&send_msg, $safeeval,"&send_msg");
+ $safehole->wrap(\&send_crit_msg,$safeeval,"&send_crit_msg");
my $code=<<'ENDDEFS';
# ---------------------------------------------------- Inside of the safe space
@@ -708,6 +727,40 @@
return $sum;
}
+#-------------------------------------------------------
+
+=item SEND_CRIT_MSG(subject,message)
+
+Send a critical message to a student.
+
+=cut
+
+#-------------------------------------------------------
+sub SEND_CRIT_MSG {
+ my ($subject,$message) = @_;
+ my $name = $uname;
+ my $dom = $udom;
+ return (&send_crit_msg($name,$dom,$subject,$message) ? 'Message Sent.'
+ : 'Error sending message');
+}
+
+#-------------------------------------------------------
+
+=item SEND_MSG(subject,message)
+
+Send a message to a student.
+
+=cut
+
+#-------------------------------------------------------
+sub SEND_MSG {
+ my ($subject,$message) = @_;
+ my $name = $uname;
+ my $dom = $udom;
+ return (&send_msg($name,$dom,$subject,$message) ? 'Message Sent.'
+ : 'Error sending message');
+}
+
sub expandnamed {
my $expression=shift;
if ($expression=~/^\&/) {
@@ -2419,8 +2472,8 @@
function celledit(cn,cf) {
var cnf=prompt(cn,cf);
- if (cnf!=null) {
- document.sheet.unewfield.value=cn;
+ if (cnf!=null) {
+ document.sheet.unewfield.value=cn;
document.sheet.unewformula.value=cnf;
document.sheet.submit();
}