version 1.156, 2006/05/20 06:40:53
|
version 1.160, 2006/07/19 15:31:05
|
Line 39 use Apache::lonpublisher;
|
Line 39 use Apache::lonpublisher;
|
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonmysql; |
use Apache::lonmysql; |
use Apache::lonmsg; |
use Apache::lonmsg; |
|
use lib '/home/httpd/lib/perl/'; |
|
use LONCAPA; |
|
|
|
|
############################################################ |
############################################################ |
Line 71 sub get_dynamic_metadata_from_sql {
|
Line 73 sub get_dynamic_metadata_from_sql {
|
if (! defined($authordom) || ! defined($author)) { |
if (! defined($authordom) || ! defined($author)) { |
return (); |
return (); |
} |
} |
my @Fields = ('url','count','course','course_list', |
my $query = 'SELECT * FROM metadata WHERE url LIKE "'.$url.'%"'; |
'goto','goto_list', |
|
'comefrom','comefrom_list', |
|
'sequsage','sequsage_list', |
|
'stdno','stdno_list', |
|
'dependencies', |
|
'avetries','avetries_list', |
|
'difficulty','difficulty_list', |
|
'disc','disc_list', |
|
'clear','technical','correct', |
|
'helpful','depth'); |
|
# |
|
my $query = 'SELECT '.join(',',@Fields). |
|
' FROM metadata WHERE url LIKE "'.$url.'%"'; |
|
my $server = &Apache::lonnet::homeserver($author,$authordom); |
my $server = &Apache::lonnet::homeserver($author,$authordom); |
my $reply = &Apache::lonnet::metadata_query($query,undef,undef, |
my $reply = &Apache::lonnet::metadata_query($query,undef,undef, |
,[$server]); |
,[$server]); |
Line 106 sub get_dynamic_metadata_from_sql {
|
Line 95 sub get_dynamic_metadata_from_sql {
|
while (my $result = <$fh>) { |
while (my $result = <$fh>) { |
chomp($result); |
chomp($result); |
next if (! $result); |
next if (! $result); |
my @Data = |
my %hash=&LONCAPA::lonmetadata::metadata_col_to_hash(map { &unescape($_) } split(/\,/,$result)); |
map { |
foreach my $key (keys(%hash)) { |
&Apache::lonnet::unescape($_); |
$ReturnHash{$hash{'url'}}->{$key}=$hash{$key}; |
} split(',',$result); |
|
my $url = $Data[0]; |
|
for (my $i=0;$i<=$#Fields;$i++) { |
|
$ReturnHash{$url}->{$Fields[$i]}=$Data[$i]; |
|
} |
} |
} |
} |
$finished = 1; |
$finished = 1; |
Line 302 sub portfolio_linked_path {
|
Line 287 sub portfolio_linked_path {
|
if ($group) { |
if ($group) { |
$start = "groups/$group/".$start; |
$start = "groups/$group/".$start; |
} |
} |
my $result = &Apache::portfolio::make_anchor($port_path,$start,'/', |
my $result = &Apache::portfolio::make_anchor($port_path,$start,'/'); |
undef,undef,undef,$group); |
|
|
|
my $fullpath = '/'; |
my $fullpath = '/'; |
my (undef,@tree) = split('/',$path); |
my (undef,@tree) = split('/',$path); |
Line 311 sub portfolio_linked_path {
|
Line 295 sub portfolio_linked_path {
|
foreach my $dir (@tree) { |
foreach my $dir (@tree) { |
$fullpath .= $dir.'/'; |
$fullpath .= $dir.'/'; |
$result .= '/'; |
$result .= '/'; |
$result .= &Apache::portfolio::make_anchor($port_path,$dir,$fullpath, |
$result .= &Apache::portfolio::make_anchor($port_path,$dir,$fullpath); |
undef,undef,undef,$group); |
|
} |
} |
$result .= "/$filename"; |
$result .= "/$filename"; |
return $result; |
return $result; |
Line 331 sub get_port_path_and_group {
|
Line 314 sub get_port_path_and_group {
|
} else { |
} else { |
$port_path = '/adm/portfolio'; |
$port_path = '/adm/portfolio'; |
} |
} |
|
if ($env{'form.group'} ne $group) { |
|
$env{'form.group'} = $group) { |
|
} |
return ($port_path,$group); |
return ($port_path,$group); |
} |
} |
|
|
Line 1262 ENDEDIT
|
Line 1248 ENDEDIT
|
'<>&"'). |
'<>&"'). |
'</'.$tag.'>'; |
'</'.$tag.'>'; |
} |
} |
if ($fn =~ m|/portfolio/|) { |
if ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles/portfolio/|) { |
my ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|); |
my ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|); |
$env{'form.'.$formname}=$file_content."\n"; |
$r->print(&store_portfolio_metadata($formname,$file_content,$path, |
$env{'form.'.$formname.'.filename'}=$new_fn; |
$new_fn)); |
my $result =&Apache::lonnet::userfileupload($formname,'', |
} elsif ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles/groups/\w+/portfolio/|) { |
$path); |
my ($path, $new_fn) = ($fn =~ m|/(groups/\w+/portfolio.*)/([^/]*)$|); |
|
$r->print(&store_portfolio_metadata($formname,$file_content,$path,$new_fn)); |
if ($result =~ /(error|notfound)/) { |
|
$r->print('<p><font color="red">'. |
|
&mt('Could not write metadata').', '. |
|
&mt('FAIL').'</font></p>'); |
|
} else { |
|
$r->print('<p><font color="blue">'.&mt('Wrote Metadata'). |
|
' '.&Apache::lonlocal::locallocaltime(time). |
|
'</font></p>'); |
|
} |
|
} else { |
} else { |
if (! ($mfh=Apache::File->new('>'.$fn))) { |
if (! ($mfh=Apache::File->new('>'.$fn))) { |
$r->print('<p><font color="red">'. |
$r->print('<p><font color="red">'. |
Line 1297 ENDEDIT
|
Line 1274 ENDEDIT
|
|
|
if ($file_type eq 'portfolio') { |
if ($file_type eq 'portfolio') { |
my ($port_path,$group) = &get_port_path_and_group($uri); |
my ($port_path,$group) = &get_port_path_and_group($uri); |
|
if ($group) { |
|
$r->print('<input type="hidden" name="group" value="'.$group.'" />'); |
|
} |
$r->print('</form> |
$r->print('</form> |
<br /><br /><form method="POST" action="'.$port_path.'">'. |
<br /><br /><form method="POST" action="'.$port_path.'">'. |
'<input type="hidden" name="group" value="'.$group.'" />'. |
'<input type="hidden" name="group" value="'.$group.'" />'. |
Line 1310 ENDEDIT
|
Line 1290 ENDEDIT
|
return; |
return; |
} |
} |
|
|
|
sub store_portfolio_metadata { |
|
my ($formname,$content,$path,$new_fn) = @_; |
|
$env{'form.'.$formname}=$content."\n"; |
|
$env{'form.'.$formname.'.filename'}=$new_fn; |
|
my $result =&Apache::lonnet::userfileupload($formname,'',$path); |
|
if ($result =~ /(error|notfound)/) { |
|
return '<p><font color="red">'. |
|
&mt('Could not write metadata').', '. |
|
&mt('FAIL').'</font></p>'; |
|
} else { |
|
return '<p><font color="blue">'.&mt('Wrote Metadata'). |
|
' '.&Apache::lonlocal::locallocaltime(time).'</font></p>'; |
|
} |
|
} |
|
|
1; |
1; |
__END__ |
__END__ |
|
|
|
|