--- loncom/xml/lonxml.pm 2003/08/11 20:05:53 1.270 +++ loncom/xml/lonxml.pm 2003/09/11 22:37:54 1.275 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.270 2003/08/11 20:05:53 albertel Exp $ +# $Id: lonxml.pm,v 1.275 2003/09/11 22:37:54 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -69,6 +69,7 @@ use Safe::Hole(); use Math::Cephes(); use Math::Random(); use Opcode(); +use POSIX qw(strftime); sub register { @@ -183,6 +184,7 @@ sub xmlend { } $crs=~s/\_/\//g; my $seeid=&Apache::lonnet::allowed('rin',$crs); + my $viewgrades=&Apache::lonnet::allowed('vgr',$crs); unless ($symb) { $symb=&Apache::lonnet::symbread(); } @@ -249,7 +251,11 @@ sub xmlend { $sender=''.$screenname.''; } } - $discussion.='
'.$sender.' ('. + my $vgrlink; + if ($viewgrades) { + $vgrlink=&Apache::loncommon::submlink('Submissions',$contrib{$idx.':sendername'},$contrib{$idx.':senderdomain'},$symb); + } + $discussion.='
'.$sender.' '.$vgrlink.' ('. localtime($contrib{$idx.':timestamp'}). '):
'.$message. ''; @@ -477,24 +483,25 @@ sub htmlclean { } sub latex_special_symbols { - my ($current_token,$stack,$parstack,$where)=@_; + my ($string,$where)=@_; if ($where eq 'header') { - $current_token =~ s/(\\|_|\^)/ /g; - $current_token =~ s/(\$|%|\#|&|\{|\})/\\$1/g; + $string =~ s/(\\|_|\^)/ /g; + $string =~ s/(\$|%|\#|&|\{|\})/\\$1/g; + $string =~ s/_/ /g; } else { - $current_token=~s/\\ /\\char92 /g; - $current_token=~s/\^/\\char94 /g; - $current_token=~s/\~/\\char126 /g; - $current_token=~s/(&[^A-Za-z\#])/\\$1/g; - $current_token=~s/([^&])\#/$1\\#/g; - $current_token=~s/(\$|_|{|})/\\$1/g; - $current_token=~s/\\char92 /\\texttt{\\char92}/g; - $current_token=~s/(>|<)/\$$1\$/g; #more or less - if ($current_token=~m/\d%/) {$current_token =~ s/(\d)%/$1\\%/g;} #percent after digit - if ($current_token=~m/\s%/) {$current_token =~ s/(\s)%/$1\\%/g;} #persent after space - if ($current_token eq '%.') {$current_token = '\%.';} #persent at the end of statement + $string=~s/\\ /\\char92 /g; + $string=~s/\^/\\char94 /g; + $string=~s/\~/\\char126 /g; + $string=~s/(&[^A-Za-z\#])/\\$1/g; + $string=~s/([^&])\#/$1\\#/g; + $string=~s/(\$|_|{|})/\\$1/g; + $string=~s/\\char92 /\\texttt{\\char92}/g; + $string=~s/(>|<)/\$$1\$/g; #more or less + if ($string=~m/\d%/) {$string =~ s/(\d)%/$1\\%/g;} #percent after digit + if ($string=~m/\s%/) {$string =~ s/(\s)%/$1\\%/g;} #percent after space + if ($string eq '%.') {$string = '\%.';} #percent at the end of statement } - return $current_token; + return $string; } sub inner_xmlparse { @@ -584,7 +591,7 @@ sub inner_xmlparse { if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) { #Style file definitions should be correct if ($target eq 'tex' && ($Apache::lonxml::usestyle)) { - $result=&latex_special_symbols($result,$stack,$parstack); + $result=&latex_special_symbols($result); } } @@ -1137,8 +1144,10 @@ sub storefile { if (my $fh=Apache::File->new('>'.$file)) { print $fh $contents; $fh->close(); + return 1; } else { - &warning("Unable to save file $file"); + &warning("Unable to save file $file"); + return 0; } } @@ -1160,16 +1169,35 @@ SIMPLECONTENT return $filecontents; } +sub createnewsty { + my $filecontents=(<