version 1.107, 2005/08/25 20:46:32
|
version 1.119, 2005/10/26 23:37:51
|
Line 290 sub fieldnames {
|
Line 290 sub fieldnames {
|
|
|
sub select_course { |
sub select_course { |
my ($r)=@_; |
my ($r)=@_; |
$r->print('<h3>Instructor Selected Meta-Data</h3><br />'); |
my %courses; |
|
foreach my $key (keys (%env)) { |
|
if ($key =~ m/\.metadata\./) { |
|
$key =~ m/^course\.(.+)(\.metadata.+$)/; |
|
my $course = $1; |
|
my $coursekey = 'course.'.$course.'.description'; |
|
my $value = $env{$coursekey}; |
|
$courses{$coursekey} = $value; |
|
} |
|
} |
|
$r->print('<h3>Course Related Meta-Data</h3><br />'); |
$r->print('<form action="" method="post">'); |
$r->print('<form action="" method="post">'); |
$r->print('Select your course<br />'); |
$r->print('Select your test course<br />'); |
$r->print('<select name="metacourse" >'); |
$r->print('<select name="metacourse" >'); |
my $meta_not_found = 1; |
my $meta_not_found = 1; |
foreach my $key (keys %env) { |
foreach my $key (keys (%courses)) { |
if ($key =~ /\.metadata\./) { |
if ($meta_not_found) { |
if ($meta_not_found) { |
undef($meta_not_found); |
undef($meta_not_found); |
$r->print('<h3>Portfolio Meta-Data</h3><br />'); |
$r->print('<h3>Instructor Selected Meta-Data</h3><br />'); |
$r->print('<form action="" method="post">'); |
$r->print('<form action="" method="post">'); |
$r->print('Select your course<br />'); |
$r->print('Select your course<br />'); |
$r->print('<select name="metacourse" >'); |
$r->print('<select name="metacourse" >'); |
} |
} |
$r->print('<option value="'.$key.'">'); |
my $course_key = $key; |
$r->print($courses{$key}); |
$course_key =~ s/\.metadata\..*//; |
$r->print('</option>'); |
$r->print('<option value="'.$course_key.'">'); |
|
$r->print($env{$course_key.'.description'}); |
|
$r->print('</option>'); |
|
} |
|
} |
} |
unless ($meta_not_found) { |
unless ($meta_not_found) { |
$r->print('</select><br />'); |
$r->print('</select><br />'); |
$r->print('<input type="submit" value="Assign Instructor Metadata" />'); |
$r->print('<input type="submit" value="Assign Portfolio Metadata" />'); |
$r->print('</form>'); |
$r->print('</form>'); |
} |
} |
return 'ok'; |
return 'ok'; |
Line 470 sub relatedfield {
|
Line 476 sub relatedfield {
|
|
|
sub prettyinput { |
sub prettyinput { |
my ($type,$value,$fieldname,$formname, |
my ($type,$value,$fieldname,$formname, |
$relatedsearchflag,$relatedsep,$relatedvalue,$size)=@_; |
$relatedsearchflag,$relatedsep,$relatedvalue,$size,$course_key)=@_; |
if (! defined($size)) { |
if (! defined($size)) { |
$size = 80; |
$size = 80; |
} |
} |
|
if (defined($course_key)) { |
|
my $stu_add; |
|
my $only_one; |
|
my $values = $env{$course_key.'.metadata.'.$_.'.values'}; |
|
if ($env{$course_key.'.metadata.'.$_.'.options'} =~ m/stuadd/) { |
|
$stu_add = 'true'; |
|
} |
|
if ($env{$course_key.'.metadata.'.$_.'.options'} =~ m/onlyone/) { |
|
$only_one = 'true'; |
|
} |
|
if ($type eq 'author') { |
|
} |
|
if ($type eq 'authorspace') { |
|
} |
|
if ($type eq 'modifyinguser') { |
|
} |
|
if ($type eq 'subject') { |
|
} |
|
if ($type eq 'keywords') { |
|
my %hash; |
|
my $def; |
|
foreach (split(/,/,$values)) { |
|
$hash{$_} = $_; |
|
} |
|
if ($only_one) { |
|
return(&Apache::loncommon::select_form($def,'new_keywords',%hash)); |
|
} else { |
|
return(&Apache::loncommon::multiple_select_form('new_keywords',undef,undef,%hash)); |
|
} |
|
} |
|
if ($type eq 'notes') { |
|
} |
|
if ($type eq 'abstract') { |
|
} |
|
|
|
if (($type eq 'lowestgradelevel') || |
|
($type eq 'highestgradelevel')) { |
|
return &Apache::loncommon::select_level_form($value,$fieldname). |
|
&relatedfield(0,$relatedsearchflag,$relatedsep); |
|
} |
|
return(); |
|
} |
# Language |
# Language |
if ($type eq 'language') { |
if ($type eq 'language') { |
return &selectbox($fieldname, |
return &selectbox($fieldname, |
Line 575 sub handler {
|
Line 623 sub handler {
|
# Looking for all bombs? |
# Looking for all bombs? |
&report_bombs($r,$uri); |
&report_bombs($r,$uri); |
} elsif ($uri=~/\/portfolio\//) { |
} elsif ($uri=~/\/portfolio\//) { |
|
($resdomain,$resuser)= |
|
(&Apache::lonnet::declutter($uri)=~m|^(\w+)/(\w+)/portfolio|); |
$r->print(&Apache::loncommon::bodytag |
$r->print(&Apache::loncommon::bodytag |
('Edit Portfolio File Information','','','',$resdomain)); |
('Edit Portfolio File Information','','','',$resdomain)); |
&present_editable_metadata($r,$uri,'portfolio'); |
&present_editable_metadata($r,$uri,'portfolio'); |
Line 930 sub present_editable_metadata {
|
Line 980 sub present_editable_metadata {
|
my $fn=&Apache::lonnet::filelocation('',$uri); |
my $fn=&Apache::lonnet::filelocation('',$uri); |
$disuri=~s/^\/\~/\/priv\//; |
$disuri=~s/^\/\~/\/priv\//; |
$disuri=~s/\.meta$//; |
$disuri=~s/\.meta$//; |
|
$disuri=~s|^/editupload||; |
my $target=$uri; |
my $target=$uri; |
$target=~s/^\/\~/\/res\/$env{'request.role.domain'}\//; |
$target=~s/^\/\~/\/res\/$env{'request.role.domain'}\//; |
$target=~s/\.meta$//; |
$target=~s/\.meta$//; |
Line 983 ENDDEL
|
Line 1034 ENDDEL
|
%Apache::lonpublisher::metadatakeys=(); |
%Apache::lonpublisher::metadatakeys=(); |
my $result=&Apache::lonnet::getfile($fn); |
my $result=&Apache::lonnet::getfile($fn); |
if ($result == -1){ |
if ($result == -1){ |
$r->print('Creating new '.$fn); |
$r->print('Creating new '.$disuri); |
} else { |
} else { |
&Apache::lonpublisher::metaeval($result); |
&Apache::lonpublisher::metaeval($result); |
} |
} |
Line 1016 ENDEDIT
|
Line 1067 ENDEDIT
|
$Apache::lonpublisher::metadatafields{'copyright'}= |
$Apache::lonpublisher::metadatafields{'copyright'}= |
'default'; |
'default'; |
} |
} |
$output.=('<p>'.$lt{$_}.': '. |
if ($env{'form.metacourse'}) { |
&prettyinput($_, |
# handle restrictions here |
|
$env{'form.metacourse'} =~ m/(^.+)\.description$/; |
|
my $key_base = $1; |
|
if ($env{$key_base.'.metadata.'.$_.'.options'} =~ m/active/) { |
|
$output.=('<p>'.$lt{$_}.': '. |
|
&prettyinput($_, |
|
$Apache::lonpublisher::metadatafields{$_}, |
|
'new_'.$_,'defaultmeta',undef,undef,undef,undef,$key_base).'</p>'); |
|
} |
|
} else { |
|
$output.=('<p>'.$lt{$_}.': '. |
|
&prettyinput($_, |
$Apache::lonpublisher::metadatafields{$_}, |
$Apache::lonpublisher::metadatafields{$_}, |
'new_'.$_,'defaultmeta').'</p>'); |
'new_'.$_,'defaultmeta').'</p>'); |
if ($env{'form.metacourse'}) { |
|
|
|
$r->print('This is the instructor metadata area<br />'); |
|
my @keywords = sort(split /, /,$env{$env{'form.metacourse'}.'.metadata.keywords'}); |
|
$r->print($env{'form.metacourse'}.'<br />'); |
|
$r->print('<form method="post" action="" size="3" >'); |
|
foreach my $word (@keywords) { |
|
my $checked; |
|
if ($Apache::lonpublisher::metadatafields{'coursekeyword'}=~ m/$word/) { |
|
$checked = 1; |
|
} else { |
|
undef($checked); |
|
} |
|
$r->print(&Apache::lonhtmlcommon::checkbox('keywords',$checked,$word).$word.'<br />'); |
|
} |
|
$r->print('<br /><input type="submit" name="store" value="Assign Meta-data" />'); |
|
$r->print('</form>'); |
|
return 'ok'; |
|
} |
} |
} |
} |
if ($env{'form.store'}) { |
if ($env{'form.store'}) { |
my $mfh; |
my $mfh; |
my $formname='store'; |
my $formname='store'; |
my $file_content; |
my $file_content; |
if (&Apache::loncommon::get_env_multiple('form.keywords')) { |
foreach my $meta_field (keys %env) { |
$Apache::lonpublisher::metadatafields{'coursekeyword'} = |
if (&Apache::loncommon::get_env_multiple('form.keywords')) { |
|
$Apache::lonpublisher::metadatafields{'coursekeyword'} = |
join (', ', &Apache::loncommon::get_env_multiple('form.keywords')); |
join (', ', &Apache::loncommon::get_env_multiple('form.keywords')); |
|
} |
} |
} |
foreach (sort keys %Apache::lonpublisher::metadatafields) { |
foreach (sort keys %Apache::lonpublisher::metadatafields) { |
next if ($_ =~ /\./); |
next if ($_ =~ /\./); |
Line 1077 ENDEDIT
|
Line 1123 ENDEDIT
|
$env{'form.'.$formname.'.filename'}=$new_fn; |
$env{'form.'.$formname.'.filename'}=$new_fn; |
&Apache::lonnet::userfileupload('uploaddoc','', |
&Apache::lonnet::userfileupload('uploaddoc','', |
'portfolio'.$env{'form.currentpath'}); |
'portfolio'.$env{'form.currentpath'}); |
my $status =&Apache::lonnet::userfileupload($formname,'','portfolio'); |
|
if (&Apache::lonnet::userfileupload($formname,'','portfolio') eq 'error: no uploaded file') { |
if (&Apache::lonnet::userfileupload($formname,'','portfolio') eq 'error: no uploaded file') { |
$r->print('<p><font color="red">'. |
$r->print('<p><font color="red">'. |
&mt('Could not write metadata').', '. |
&mt('Could not write metadata').', '. |