--- loncom/xml/lonxml.pm 2003/03/29 22:50:22 1.242
+++ loncom/xml/lonxml.pm 2003/08/07 19:31:16 1.266.2.1
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.242 2003/03/29 22:50:22 www Exp $
+# $Id: lonxml.pm,v 1.266.2.1 2003/08/07 19:31:16 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -70,6 +70,7 @@ use Math::Cephes();
use Math::Random();
use Opcode();
+
sub register {
my ($space,@taglist) = @_;
foreach my $temptag (@taglist) {
@@ -95,6 +96,8 @@ use Apache::run();
use Apache::londefdef();
use Apache::scripttag();
use Apache::edit();
+use Apache::inputtags();
+use Apache::outputtags();
use Apache::lonnet();
use Apache::File();
use Apache::loncommon();
@@ -151,6 +154,10 @@ $Apache::lonxml::counter_changed=0;
#internal check on whether to look at style defs
$Apache::lonxml::usestyle=1;
+#locations used to store the parameter string for style substitutions
+$Apache::lonxml::style_values='';
+$Apache::lonxml::style_end_values='';
+
sub xmlbegin {
my $output='';
if ($ENV{'browser.mathml'}) {
@@ -196,6 +203,13 @@ sub xmlend {
my $message=$contrib{$idx.':message'};
$message=~s/\n/\
/g;
$message=&Apache::lontexconvert::msgtexconverted($message);
+ if ($contrib{$idx.':attachmenturl'}) {
+ my ($fname,$ft)
+ =($contrib{$idx.':attachmenturl'}=~/\/(\w+)\.(\w+)$/);
+ $message.='
Attachment: '.$fname.'.'.$ft.'';
+ }
if ($message) {
if ($hidden) {
$message=''.$message.'';
@@ -248,7 +262,7 @@ sub xmlend {
}
if ($discussiononly) {
$discussion.=(<'.$displayfile.
- '
';
- $result=&inserteditinfo($result,$filecontents);
+ unless ($ENV{'request.state'} eq 'published') {
+ if ($ENV{'form.editmode'} && (!($ENV{'form.viewmode'}))) {
+ my $displayfile=$request->uri;
+ $displayfile=~s/^\/[^\/]*//;
+ $result=''.$displayfile.
+ '
';
+ $result=&inserteditinfo($result,$filecontents);
+ }
}
- }
-
- writeallows($request->uri);
-
- $request->print($result);
-
- return OK;
+
+ writeallows($request->uri);
+
+
+ $request->print($result);
+
+ return OK;
+}
+
+sub display_title {
+ my $result;
+ if ($ENV{'request.state'} eq 'construct') {
+ my $title=&Apache::lonnet::gettitle();
+ if (!defined($title) || $title eq '') {
+ $title = $ENV{'request.filename'};
+ $title = substr($title, rindex($title, '/') + 1);
+ }
+ $result = "";
+ }
+ return $result;
}
sub debug {
@@ -1273,8 +1326,11 @@ sub error {
sub warning {
$warningcount++;
- if ($ENV{'request.state'} eq 'construct') {
- print "WARNING:".join('
',@_)."
\n";
+
+ if ($ENV{'form.grade_target'} ne 'tex') {
+ if ($ENV{'request.state'} eq 'construct' || $Apache::lonxml::debug) {
+ print "WARNING:".join('
',@_)."
\n";
+ }
}
}
@@ -1383,10 +1439,11 @@ sub description {
# calls to lonnet functions for this setup.
# - looks for form.grade_ parameters
sub whichuser {
- my ($symb,$courseid,$domain,$name);
+ my ($passedsymb)=@_;
+ my ($symb,$courseid,$domain,$name,$publicuser);
if (defined($ENV{'form.grade_symb'})) {
my $tmp_courseid=$ENV{'form.grade_courseid'};
- my $allowed=&Apache::lonnet::allowed('mgr',$tmp_courseid);
+ my $allowed=&Apache::lonnet::allowed('vgr',$tmp_courseid);
if ($allowed) {
$symb=$ENV{'form.grade_symb'};
$courseid=$ENV{'form.grade_courseid'};
@@ -1394,12 +1451,22 @@ sub whichuser {
$name=$ENV{'form.grade_username'};
}
} else {
- $symb=&Apache::lonnet::symbread();
- $courseid=$ENV{'request.course.id'};
- $domain=$ENV{'user.domain'};
- $name=$ENV{'user.name'};
+ if (!$passedsymb) {
+ $symb=&Apache::lonnet::symbread();
+ } else {
+ $symb=$passedsymb;
+ }
+ $courseid=$ENV{'request.course.id'};
+ $domain=$ENV{'user.domain'};
+ $name=$ENV{'user.name'};
+ if ($name eq 'public' && $domain eq 'public') {
+ if (!defined($ENV{'form.username'})) {
+ $ENV{'form.username'}.=time.rand(10000000);
+ }
+ $name.=$ENV{'form.username'};
+ }
}
- return ($symb,$courseid,$domain,$name);
+ return ($symb,$courseid,$domain,$name,$publicuser);
}
1;