Annotation of loncom/interface/lonmeta.pm, revision 1.112
1.1 www 1: # The LearningOnline Network with CAPA
1.8 albertel 2: # Metadata display handler
3: #
1.112 ! banghart 4: # $Id: lonmeta.pm,v 1.111 2005/10/14 04:24:12 banghart Exp $
1.8 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
1.1 www 14: #
1.8 albertel 15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
1.100 banghart 20: # You should have received a copy of the GNU General Public License
1.8 albertel 21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
1.44 www 27:
1.1 www 28:
29: package Apache::lonmeta;
30:
31: use strict;
1.63 matthew 32: use LONCAPA::lonmetadata();
1.1 www 33: use Apache::Constants qw(:common);
1.96 albertel 34: use Apache::lonnet;
1.10 www 35: use Apache::loncommon();
1.100 banghart 36: use Apache::lonhtmlcommon();
1.23 www 37: use Apache::lonmsg;
38: use Apache::lonpublisher;
1.35 www 39: use Apache::lonlocal;
1.43 www 40: use Apache::lonmysql;
1.49 www 41: use Apache::lonmsg;
1.1 www 42:
1.44 www 43:
1.80 matthew 44: ############################################################
45: ############################################################
46: ##
47: ## &get_dynamic_metadata_from_sql($url)
48: ##
49: ## Queries sql database for dynamic metdata
50: ## Returns a hash of hashes, with keys of urls which match $url
51: ## Returned fields are given below.
52: ##
53: ## Examples:
54: ##
55: ## %DynamicMetadata = &Apache::lonmeta::get_dynmaic_metadata_from_sql
56: ## ('/res/msu/korte/');
57: ##
58: ## $DynamicMetadata{'/res/msu/korte/example.problem'}->{$field}
59: ##
60: ############################################################
61: ############################################################
62: sub get_dynamic_metadata_from_sql {
63: my ($url) = shift();
64: my ($authordom,$author)=($url=~m:^/res/(\w+)/(\w+)/:);
65: if (! defined($authordom)) {
66: $authordom = shift();
67: }
68: if (! defined($author)) {
69: $author = shift();
70: }
71: if (! defined($authordom) || ! defined($author)) {
72: return ();
73: }
1.83 www 74: my @Fields = ('url','count','course',
1.80 matthew 75: 'goto','goto_list',
76: 'comefrom','comefrom_list',
77: 'sequsage','sequsage_list',
78: 'stdno','stdno_list',
1.83 www 79: 'dependencies',
1.80 matthew 80: 'avetries','avetries_list',
81: 'difficulty','difficulty_list',
82: 'disc','disc_list',
83: 'clear','technical','correct',
84: 'helpful','depth');
85: #
86: my $query = 'SELECT '.join(',',@Fields).
87: ' FROM metadata WHERE url LIKE "'.$url.'%"';
88: my $server = &Apache::lonnet::homeserver($author,$authordom);
89: my $reply = &Apache::lonnet::metadata_query($query,undef,undef,
90: ,[$server]);
91: return () if (! defined($reply) || ref($reply) ne 'HASH');
92: my $filename = $reply->{$server};
93: if (! defined($filename) || $filename =~ /^error/) {
94: return ();
95: }
96: my $max_time = time + 10; # wait 10 seconds for results at most
97: my %ReturnHash;
98: #
99: # Look for results
100: my $finished = 0;
101: while (! $finished && time < $max_time) {
102: my $datafile=$Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/'.$filename;
103: if (! -e "$datafile.end") { next; }
104: my $fh;
105: if (!($fh=Apache::File->new($datafile))) { next; }
106: while (my $result = <$fh>) {
107: chomp($result);
108: next if (! $result);
109: my @Data =
110: map {
111: &Apache::lonnet::unescape($_);
112: } split(',',$result);
113: my $url = $Data[0];
114: for (my $i=0;$i<=$#Fields;$i++) {
115: $ReturnHash{$url}->{$Fields[$i]}=$Data[$i];
116: }
117: }
118: $finished = 1;
119: }
120: #
121: return %ReturnHash;
122: }
123:
124:
1.64 matthew 125: # Fetch and evaluate dynamic metadata
1.9 www 126: sub dynamicmeta {
127: my $url=&Apache::lonnet::declutter(shift);
128: $url=~s/\.meta$//;
129: my ($adomain,$aauthor)=($url=~/^(\w+)\/(\w+)\//);
1.19 www 130: my $regexp=$url;
1.9 www 131: $regexp=~s/(\W)/\\$1/g;
1.10 www 132: $regexp='___'.$regexp.'___';
1.16 albertel 133: my %evaldata=&Apache::lonnet::dump('nohist_resevaldata',$adomain,
134: $aauthor,$regexp);
1.63 matthew 135: my %DynamicData = &LONCAPA::lonmetadata::process_reseval_data(\%evaldata);
136: my %Data = &LONCAPA::lonmetadata::process_dynamic_metadata($url,
137: \%DynamicData);
1.40 matthew 138: #
1.46 www 139: # Deal with 'count' separately
1.63 matthew 140: $Data{'count'} = &access_count($url,$aauthor,$adomain);
1.67 matthew 141: #
142: # Debugging code I will probably need later
143: if (0) {
144: &Apache::lonnet::logthis('Dynamic Metadata');
145: while(my($k,$v)=each(%Data)){
146: &Apache::lonnet::logthis(' "'.$k.'"=>"'.$v.'"');
147: }
148: &Apache::lonnet::logthis('-------------------');
149: }
1.63 matthew 150: return %Data;
1.40 matthew 151: }
152:
153: sub access_count {
154: my ($src,$author,$adomain) = @_;
155: my %countdata=&Apache::lonnet::dump('nohist_accesscount',$adomain,
156: $author,$src);
157: if (! exists($countdata{$src})) {
1.47 www 158: return &mt('Not Available');
1.40 matthew 159: } else {
160: return $countdata{$src};
161: }
1.25 www 162: }
163:
1.64 matthew 164: # Try to make an alt tag if there is none
1.25 www 165: sub alttag {
1.26 www 166: my ($base,$src)=@_;
167: my $fullpath=&Apache::lonnet::hreflocation($base,$src);
168: my $alttag=&Apache::lonnet::metadata($fullpath,'title').' '.
1.64 matthew 169: &Apache::lonnet::metadata($fullpath,'subject').' '.
170: &Apache::lonnet::metadata($fullpath,'abstract');
1.26 www 171: $alttag=~s/\s+/ /gs;
172: $alttag=~s/\"//gs;
173: $alttag=~s/\'//gs;
174: $alttag=~s/\s+$//gs;
175: $alttag=~s/^\s+//gs;
1.64 matthew 176: if ($alttag) {
177: return $alttag;
178: } else {
179: return &mt('No information available');
180: }
1.9 www 181: }
1.1 www 182:
1.64 matthew 183: # Author display
1.29 www 184: sub authordisplay {
185: my ($aname,$adom)=@_;
1.64 matthew 186: return &Apache::loncommon::aboutmewrapper
187: (&Apache::loncommon::plainname($aname,$adom),
188: $aname,$adom,'preview').' <tt>['.$aname.'@'.$adom.']</tt>';
1.29 www 189: }
190:
1.64 matthew 191: # Pretty display
1.12 www 192: sub evalgraph {
193: my $value=shift;
1.65 matthew 194: if (! $value) {
195: return '';
196: }
1.12 www 197: my $val=int($value*10.+0.5)-10;
1.71 matthew 198: my $output='<table border="0" cellpadding="0" cellspacing="0"><tr>';
1.12 www 199: if ($val>=20) {
1.71 matthew 200: $output.='<td width="20" bgcolor="#555555">  </td>';
1.12 www 201: } else {
1.71 matthew 202: $output.='<td width="'.($val).'" bgcolor="#555555"> </td>'.
203: '<td width="'.(20-$val).'" bgcolor="#FF3333"> </td>';
1.12 www 204: }
205: $output.='<td bgcolor="#FFFF33"> </td>';
206: if ($val>20) {
1.71 matthew 207: $output.='<td width="'.($val-20).'" bgcolor="#33FF33"> </td>'.
208: '<td width="'.(40-$val).'" bgcolor="#555555"> </td>';
1.12 www 209: } else {
1.71 matthew 210: $output.='<td width="20" bgcolor="#555555">  </td>';
1.12 www 211: }
1.71 matthew 212: $output.='<td> ('.sprintf("%5.2f",$value).') </td></tr></table>';
1.12 www 213: return $output;
214: }
215:
216: sub diffgraph {
217: my $value=shift;
1.65 matthew 218: if (! $value) {
219: return '';
220: }
1.12 www 221: my $val=int(40.0*$value+0.5);
1.13 www 222: my @colors=('#FF9933','#EEAA33','#DDBB33','#CCCC33',
223: '#BBDD33','#CCCC33','#DDBB33','#EEAA33');
1.71 matthew 224: my $output='<table border="0" cellpadding="0" cellspacing="0"><tr>';
1.12 www 225: for (my $i=0;$i<8;$i++) {
226: if ($val>$i*5) {
1.71 matthew 227: $output.='<td width="5" bgcolor="'.$colors[$i].'"> </td>';
1.12 www 228: } else {
1.71 matthew 229: $output.='<td width="5" bgcolor="#555555"> </td>';
1.12 www 230: }
231: }
1.71 matthew 232: $output.='<td> ('.sprintf("%3.2f",$value).') </td></tr></table>';
1.12 www 233: return $output;
234: }
235:
1.44 www 236:
1.64 matthew 237: # The field names
1.45 www 238: sub fieldnames {
1.90 banghart 239: my $file_type=shift;
1.93 matthew 240: my %fields =
1.112 ! banghart 241: ('metadata.title' => 'Title',
! 242: 'metadata.author' =>'Author(s)',
! 243: 'metadata.authorspace' => 'Author Space',
! 244: 'metadata.modifyinguser' => 'Last Modifying User',
! 245: 'metadata.subject' => 'Subject',
! 246: 'metadata.keywords' => 'Keyword(s)',
! 247: 'metadata.notes' => 'Notes',
! 248: 'metadata.abstract' => 'Abstract',
! 249: 'metadata.lowestgradelevel' => 'Lowest Grade Level',
! 250: 'metadata.highestgradelevel' => 'Highest Grade Level');
1.93 matthew 251: if (! defined($file_type) || $file_type ne 'portfolio') {
252: %fields =
253: (%fields,
254: 'domain' => 'Domain',
1.64 matthew 255: 'standards' => 'Standards',
256: 'mime' => 'MIME Type',
257: 'language' => 'Language',
258: 'creationdate' => 'Creation Date',
259: 'lastrevisiondate' => 'Last Revision Date',
260: 'owner' => 'Publisher/Owner',
261: 'copyright' => 'Copyright/Distribution',
262: 'customdistributionfile' => 'Custom Distribution File',
1.84 banghart 263: 'sourceavail' => 'Source Available',
1.78 taceyjo1 264: 'sourcerights' => 'Source Custom Distribution File',
1.64 matthew 265: 'obsolete' => 'Obsolete',
266: 'obsoletereplacement' => 'Suggested Replacement for Obsolete File',
267: 'count' => 'Network-wide number of accesses (hits)',
268: 'course' => 'Network-wide number of courses using resource',
269: 'course_list' => 'Network-wide courses using resource',
270: 'sequsage' => 'Number of resources using or importing resource',
271: 'sequsage_list' => 'Resources using or importing resource',
272: 'goto' => 'Number of resources that follow this resource in maps',
273: 'goto_list' => 'Resources that follow this resource in maps',
274: 'comefrom' => 'Number of resources that lead up to this resource in maps',
275: 'comefrom_list' => 'Resources that lead up to this resource in maps',
276: 'clear' => 'Material presented in clear way',
277: 'depth' => 'Material covered with sufficient depth',
278: 'helpful' => 'Material is helpful',
279: 'correct' => 'Material appears to be correct',
280: 'technical' => 'Resource is technically correct',
281: 'avetries' => 'Average number of tries till solved',
282: 'stdno' => 'Total number of students who have worked on this problem',
1.73 matthew 283: 'difficulty' => 'Degree of difficulty',
284: 'disc' => 'Degree of discrimination',
1.83 www 285: 'dependencies' => 'Resources used by this resource',
1.64 matthew 286: );
1.93 matthew 287: }
288: return &Apache::lonlocal::texthash(%fields);
1.45 www 289: }
1.46 www 290:
1.100 banghart 291: sub select_course {
292: my ($r)=@_;
1.111 banghart 293: my @courses;
294: foreach my $key (keys (%env)) {
295:
296: if ($key =~ m/^(course\..+)\.metadata\..+\.options/) {
297: my $course_key = $1;
298: $course_key .= '.description';
299: $r->print($env{$course_key}.' of '.$course_key.'<br />');
300: push @courses, $key;
301: }
302: }
303: foreach (@courses) {
304: $r->print($_.' was found<br />');
305: }
306: $r->print('<h3>Portfolio Meta-Data</h3><br />');
1.100 banghart 307: $r->print('<form action="" method="post">');
1.111 banghart 308: $r->print('Select your test course<br />');
1.100 banghart 309: $r->print('<select name="metacourse" >');
1.103 banghart 310: my $meta_not_found = 1;
1.111 banghart 311: foreach my $key (keys (%env)) {
312:
1.100 banghart 313: if ($key =~ /\.metadata\./) {
1.103 banghart 314: if ($meta_not_found) {
315: undef($meta_not_found);
1.111 banghart 316: $r->print('<h3>Portfolio Meta-Data</h3><br />');
1.103 banghart 317: $r->print('<form action="" method="post">');
318: $r->print('Select your course<br />');
319: $r->print('<select name="metacourse" >');
320: }
1.101 banghart 321: my $course_key = $key;
322: $course_key =~ s/\.metadata\..*//;
1.102 banghart 323: $r->print('<option value="'.$course_key.'">');
1.101 banghart 324: $r->print($env{$course_key.'.description'});
1.100 banghart 325: $r->print('</option>');
326: }
327: }
1.103 banghart 328: unless ($meta_not_found) {
329: $r->print('</select><br />');
1.111 banghart 330: $r->print('<input type="submit" value="Assign Portfolio Metadata" />');
1.103 banghart 331: $r->print('</form>');
332: }
1.100 banghart 333: return 'ok';
334: }
1.64 matthew 335: # Pretty printing of metadata field
1.46 www 336:
337: sub prettyprint {
1.82 www 338: my ($type,$value,$target,$prefix,$form,$noformat)=@_;
339: # $target,$prefix,$form are optional and for filecrumbs only
1.65 matthew 340: if (! defined($value)) {
341: return ' ';
342: }
1.64 matthew 343: # Title
1.46 www 344: if ($type eq 'title') {
345: return '<font size="+1" face="arial">'.$value.'</font>';
346: }
1.64 matthew 347: # Dates
1.46 www 348: if (($type eq 'creationdate') ||
349: ($type eq 'lastrevisiondate')) {
1.55 www 350: return ($value?&Apache::lonlocal::locallocaltime(
351: &Apache::lonmysql::unsqltime($value)):
352: &mt('not available'));
1.46 www 353: }
1.64 matthew 354: # Language
1.46 www 355: if ($type eq 'language') {
356: return &Apache::loncommon::languagedescription($value);
357: }
1.64 matthew 358: # Copyright
1.46 www 359: if ($type eq 'copyright') {
360: return &Apache::loncommon::copyrightdescription($value);
361: }
1.78 taceyjo1 362: # Copyright
363: if ($type eq 'sourceavail') {
364: return &Apache::loncommon::source_copyrightdescription($value);
365: }
1.64 matthew 366: # MIME
1.46 www 367: if ($type eq 'mime') {
1.64 matthew 368: return '<img src="'.&Apache::loncommon::icon($value).'" /> '.
369: &Apache::loncommon::filedescription($value);
370: }
371: # Person
1.46 www 372: if (($type eq 'author') ||
373: ($type eq 'owner') ||
374: ($type eq 'modifyinguser') ||
375: ($type eq 'authorspace')) {
376: $value=~s/(\w+)(\:|\@)(\w+)/&authordisplay($1,$3)/gse;
377: return $value;
378: }
1.64 matthew 379: # Gradelevel
1.48 www 380: if (($type eq 'lowestgradelevel') ||
381: ($type eq 'highestgradelevel')) {
382: return &Apache::loncommon::gradeleveldescription($value);
383: }
1.64 matthew 384: # Only for advance users below
1.96 albertel 385: if (! $env{'user.adv'}) {
1.65 matthew 386: return '<i>- '.&mt('not displayed').' -</i>';
387: }
1.64 matthew 388: # File
1.46 www 389: if (($type eq 'customdistributionfile') ||
390: ($type eq 'obsoletereplacement') ||
391: ($type eq 'goto_list') ||
392: ($type eq 'comefrom_list') ||
1.82 www 393: ($type eq 'sequsage_list') ||
1.83 www 394: ($type eq 'dependencies')) {
1.82 www 395: return '<ul><font size="-1">'.join("\n",map {
1.70 matthew 396: my $url = &Apache::lonnet::clutter($_);
1.72 matthew 397: my $title = &Apache::lonnet::gettitle($url);
398: if ($title eq '') {
399: $title = 'Untitled';
400: if ($url =~ /\.sequence$/) {
401: $title .= ' Sequence';
402: } elsif ($url =~ /\.page$/) {
403: $title .= ' Page';
404: } elsif ($url =~ /\.problem$/) {
405: $title .= ' Problem';
406: } elsif ($url =~ /\.html$/) {
407: $title .= ' HTML document';
408: } elsif ($url =~ m:/syllabus$:) {
409: $title .= ' Syllabus';
410: }
411: }
1.82 www 412: $_ = '<li>'.$title.' '.
413: &Apache::lonhtmlcommon::crumbs($url,$target,$prefix,$form,'-1',$noformat).
414: '</li>'
415: } split(/\s*\,\s*/,$value)).'</ul></font>';
1.46 www 416: }
1.64 matthew 417: # Evaluations
1.46 www 418: if (($type eq 'clear') ||
419: ($type eq 'depth') ||
420: ($type eq 'helpful') ||
421: ($type eq 'correct') ||
422: ($type eq 'technical')) {
423: return &evalgraph($value);
424: }
1.64 matthew 425: # Difficulty
1.73 matthew 426: if ($type eq 'difficulty' || $type eq 'disc') {
1.46 www 427: return &diffgraph($value);
428: }
1.64 matthew 429: # List of courses
1.46 www 430: if ($type=~/\_list/) {
1.72 matthew 431: my @Courses = split(/\s*\,\s*/,$value);
432: my $Str;
433: foreach my $course (@Courses) {
434: my %courseinfo = &Apache::lonnet::coursedescription($course);
435: if (! exists($courseinfo{'num'}) || $courseinfo{'num'} eq '') {
436: next;
437: }
438: if ($Str ne '') { $Str .= '<br />'; }
439: $Str .= '<a href="/public/'.$courseinfo{'domain'}.'/'.
440: $courseinfo{'num'}.'/syllabus" target="preview">'.
441: $courseinfo{'description'}.'</a>';
442: }
443: return $Str;
1.46 www 444: }
1.64 matthew 445: # No pretty print found
1.46 www 446: return $value;
447: }
448:
1.64 matthew 449: # Pretty input of metadata field
1.54 www 450: sub direct {
451: return shift;
452: }
453:
1.48 www 454: sub selectbox {
455: my ($name,$value,$functionref,@idlist)=@_;
1.65 matthew 456: if (! defined($functionref)) {
457: $functionref=\&direct;
458: }
1.48 www 459: my $selout='<select name="'.$name.'">';
460: foreach (@idlist) {
461: $selout.='<option value=\''.$_.'\'';
462: if ($_ eq $value) {
463: $selout.=' selected>'.&{$functionref}($_).'</option>';
464: }
465: else {$selout.='>'.&{$functionref}($_).'</option>';}
466: }
467: return $selout.'</select>';
468: }
469:
1.54 www 470: sub relatedfield {
471: my ($show,$relatedsearchflag,$relatedsep,$fieldname,$relatedvalue)=@_;
1.65 matthew 472: if (! $relatedsearchflag) {
473: return '';
474: }
475: if (! defined($relatedsep)) {
476: $relatedsep=' ';
477: }
478: if (! $show) {
479: return $relatedsep.' ';
480: }
1.54 www 481: return $relatedsep.'<input type="checkbox" name="'.$fieldname.'_related"'.
482: ($relatedvalue?' checked="1"':'').' />';
483: }
1.48 www 484:
1.46 www 485: sub prettyinput {
1.54 www 486: my ($type,$value,$fieldname,$formname,
1.74 matthew 487: $relatedsearchflag,$relatedsep,$relatedvalue,$size)=@_;
1.75 matthew 488: if (! defined($size)) {
489: $size = 80;
490: }
1.64 matthew 491: # Language
1.48 www 492: if ($type eq 'language') {
493: return &selectbox($fieldname,
494: $value,
495: \&Apache::loncommon::languagedescription,
1.54 www 496: (&Apache::loncommon::languageids)).
1.64 matthew 497: &relatedfield(0,$relatedsearchflag,$relatedsep);
1.48 www 498: }
1.64 matthew 499: # Copyright
1.48 www 500: if ($type eq 'copyright') {
501: return &selectbox($fieldname,
502: $value,
503: \&Apache::loncommon::copyrightdescription,
1.54 www 504: (&Apache::loncommon::copyrightids)).
1.64 matthew 505: &relatedfield(0,$relatedsearchflag,$relatedsep);
1.48 www 506: }
1.78 taceyjo1 507: # Source Copyright
508: if ($type eq 'sourceavail') {
509: return &selectbox($fieldname,
510: $value,
511: \&Apache::loncommon::source_copyrightdescription,
512: (&Apache::loncommon::source_copyrightids)).
513: &relatedfield(0,$relatedsearchflag,$relatedsep);
514: }
1.64 matthew 515: # Gradelevels
1.48 www 516: if (($type eq 'lowestgradelevel') ||
517: ($type eq 'highestgradelevel')) {
1.54 www 518: return &Apache::loncommon::select_level_form($value,$fieldname).
1.64 matthew 519: &relatedfield(0,$relatedsearchflag,$relatedsep);
1.48 www 520: }
1.64 matthew 521: # Obsolete
1.48 www 522: if ($type eq 'obsolete') {
523: return '<input type="checkbox" name="'.$fieldname.'"'.
1.54 www 524: ($value?' checked="1"':'').' />'.
1.64 matthew 525: &relatedfield(0,$relatedsearchflag,$relatedsep);
1.48 www 526: }
1.64 matthew 527: # Obsolete replacement file
1.48 www 528: if ($type eq 'obsoletereplacement') {
529: return '<input type="text" name="'.$fieldname.
530: '" size="60" value="'.$value.'" /><a href="javascript:openbrowser'.
531: "('".$formname."','".$fieldname."'".
1.54 www 532: ",'')\">".&mt('Select').'</a>'.
1.64 matthew 533: &relatedfield(0,$relatedsearchflag,$relatedsep);
534: }
535: # Customdistribution file
1.48 www 536: if ($type eq 'customdistributionfile') {
537: return '<input type="text" name="'.$fieldname.
538: '" size="60" value="'.$value.'" /><a href="javascript:openbrowser'.
539: "('".$formname."','".$fieldname."'".
1.54 www 540: ",'rights')\">".&mt('Select').'</a>'.
1.64 matthew 541: &relatedfield(0,$relatedsearchflag,$relatedsep);
1.48 www 542: }
1.78 taceyjo1 543: # Source Customdistribution file
544: if ($type eq 'sourcerights') {
545: return '<input type="text" name="'.$fieldname.
546: '" size="60" value="'.$value.'" /><a href="javascript:openbrowser'.
547: "('".$formname."','".$fieldname."'".
548: ",'rights')\">".&mt('Select').'</a>'.
549: &relatedfield(0,$relatedsearchflag,$relatedsep);
550: }
1.64 matthew 551: # Dates
1.48 www 552: if (($type eq 'creationdate') ||
553: ($type eq 'lastrevisiondate')) {
1.64 matthew 554: return
555: &Apache::lonhtmlcommon::date_setter($formname,$fieldname,$value).
556: &relatedfield(0,$relatedsearchflag,$relatedsep);
1.48 www 557: }
1.64 matthew 558: # No pretty input found
1.48 www 559: $value=~s/^\s+//gs;
560: $value=~s/\s+$//gs;
561: $value=~s/\s+/ /gs;
1.77 matthew 562: $value=~s/\"/\"\;/gs;
1.54 www 563: return
1.74 matthew 564: '<input type="text" name="'.$fieldname.'" size="'.$size.'" '.
1.64 matthew 565: 'value="'.$value.'" />'.
566: &relatedfield(1,$relatedsearchflag,$relatedsep,$fieldname,
567: $relatedvalue);
1.46 www 568: }
569:
1.64 matthew 570: # Main Handler
1.1 www 571: sub handler {
1.64 matthew 572: my $r=shift;
573: #
1.67 matthew 574: my $uri=$r->uri;
575: #
576: # Set document type
577: &Apache::loncommon::content_type($r,'text/html');
578: $r->send_http_header;
579: return OK if $r->header_only;
1.64 matthew 580: #
1.76 matthew 581: my ($resdomain,$resuser)=
582: (&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//);
1.92 albertel 583: my $html=&Apache::lonxml::xmlbegin();
584: $r->print($html.'<head><title>'.
1.67 matthew 585: 'Catalog Information'.
586: '</title></head>');
1.66 matthew 587: if ($uri=~m:/adm/bombs/(.*)$:) {
1.67 matthew 588: $r->print(&Apache::loncommon::bodytag('Error Messages'));
1.66 matthew 589: # Looking for all bombs?
590: &report_bombs($r,$uri);
1.89 banghart 591: } elsif ($uri=~/\/portfolio\//) {
1.109 albertel 592: ($resdomain,$resuser)=
593: (&Apache::lonnet::declutter($uri)=~m|^(\w+)/(\w+)/portfolio|);
1.89 banghart 594: $r->print(&Apache::loncommon::bodytag
595: ('Edit Portfolio File Information','','','',$resdomain));
1.106 banghart 596: &present_editable_metadata($r,$uri,'portfolio');
597: &select_course($r);
1.66 matthew 598: } elsif ($uri=~/^\/\~/) {
599: # Construction space
1.67 matthew 600: $r->print(&Apache::loncommon::bodytag
601: ('Edit Catalog Information','','','',$resdomain));
1.66 matthew 602: &present_editable_metadata($r,$uri);
603: } else {
1.67 matthew 604: $r->print(&Apache::loncommon::bodytag
1.85 albertel 605: ('Catalog Information','','','',$resdomain));
1.66 matthew 606: &present_uneditable_metadata($r,$uri);
607: }
1.67 matthew 608: $r->print('</body></html>');
1.66 matthew 609: return OK;
610: }
611:
1.67 matthew 612: #####################################################
613: #####################################################
614: ### ###
615: ### Report Bombs ###
616: ### ###
617: #####################################################
618: #####################################################
1.66 matthew 619: sub report_bombs {
620: my ($r,$uri) = @_;
621: # Set document type
1.67 matthew 622: $uri =~ s:/adm/bombs/::;
623: $uri = &Apache::lonnet::declutter($uri);
1.66 matthew 624: $r->print('<h1>'.&Apache::lonnet::clutter($uri).'</h1>');
625: my ($domain,$author)=($uri=~/^(\w+)\/(\w+)\//);
626: if (&Apache::loncacc::constructaccess('/~'.$author.'/',$domain)) {
1.98 www 627: if ($env{'form.clearbombs'}) {
628: &Apache::lonmsg::clear_author_res_msg($uri);
629: }
630: my $clear=&mt('Clear all Messages in Subdirectory');
631: $r->print(<<ENDCLEAR);
632: <form method="post">
633: <input type="submit" name="clearbombs" value="$clear" />
634: </form>
635: ENDCLEAR
1.67 matthew 636: my %brokenurls =
637: &Apache::lonmsg::all_url_author_res_msg($author,$domain);
638: foreach (sort(keys(%brokenurls))) {
1.66 matthew 639: if ($_=~/^\Q$uri\E/) {
1.70 matthew 640: $r->print
641: ('<a href="'.&Apache::lonnet::clutter($_).'">'.$_.'</a>'.
642: &Apache::lonmsg::retrieve_author_res_msg($_).
643: '<hr />');
1.64 matthew 644: }
645: }
1.66 matthew 646: } else {
647: $r->print(&mt('Not authorized'));
648: }
649: return;
650: }
651:
1.67 matthew 652: #####################################################
653: #####################################################
654: ### ###
655: ### Uneditable Metadata Display ###
656: ### ###
657: #####################################################
658: #####################################################
1.66 matthew 659: sub present_uneditable_metadata {
660: my ($r,$uri) = @_;
661: #
662: my %content=();
663: # Read file
664: foreach (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) {
665: $content{$_}=&Apache::lonnet::metadata($uri,$_);
666: }
667: # Render Output
668: # displayed url
669: my ($thisversion)=($uri=~/\.(\d+)\.(\w+)\.meta$/);
670: $uri=~s/\.meta$//;
671: my $disuri=&Apache::lonnet::clutter($uri);
672: # version
673: my $currentversion=&Apache::lonnet::getversion($disuri);
674: my $versiondisplay='';
675: if ($thisversion) {
676: $versiondisplay=&mt('Version').': '.$thisversion.
677: ' ('.&mt('most recent version').': '.
678: ($currentversion>0 ?
679: $currentversion :
680: &mt('information not available')).')';
681: } else {
682: $versiondisplay='Version: '.$currentversion;
683: }
1.72 matthew 684: # crumbify displayed URL uri target prefix form size
685: $disuri=&Apache::lonhtmlcommon::crumbs($disuri,undef, undef, undef,'+1');
686: $disuri =~ s:<br />::g;
1.66 matthew 687: # obsolete
688: my $obsolete=$content{'obsolete'};
689: my $obsoletewarning='';
1.96 albertel 690: if (($obsolete) && ($env{'user.adv'})) {
1.66 matthew 691: $obsoletewarning='<p><font color="red">'.
692: &mt('This resource has been marked obsolete by the author(s)').
693: '</font></p>';
694: }
695: #
696: my %lt=&fieldnames();
697: my $table='';
1.72 matthew 698: my $title = $content{'title'};
699: if (! defined($title)) {
700: $title = 'Untitled Resource';
701: }
1.66 matthew 702: foreach ('title',
703: 'author',
704: 'subject',
705: 'keywords',
706: 'notes',
707: 'abstract',
708: 'lowestgradelevel',
709: 'highestgradelevel',
710: 'standards',
711: 'mime',
712: 'language',
713: 'creationdate',
714: 'lastrevisiondate',
715: 'owner',
716: 'copyright',
1.78 taceyjo1 717: 'customdistributionfile',
718: 'sourceavail',
719: 'sourcerights',
1.66 matthew 720: 'obsolete',
721: 'obsoletereplacement') {
722: $table.='<tr><td bgcolor="#AAAAAA">'.$lt{$_}.
723: '</td><td bgcolor="#CCCCCC">'.
724: &prettyprint($_,$content{$_}).'</td></tr>';
725: delete $content{$_};
726: }
727: #
728: $r->print(<<ENDHEAD);
1.72 matthew 729: <h2>$title</h2>
730: <p>
731: $disuri<br />
1.36 www 732: $obsoletewarning
1.72 matthew 733: $versiondisplay
734: </p>
1.88 banghart 735: <table cellspacing="2" border="0">
1.45 www 736: $table
1.11 www 737: </table>
1.1 www 738: ENDHEAD
1.96 albertel 739: if ($env{'user.adv'}) {
1.68 matthew 740: &print_dynamic_metadata($r,$uri,\%content);
1.67 matthew 741: }
742: return;
743: }
744:
745: sub print_dynamic_metadata {
1.68 matthew 746: my ($r,$uri,$content) = @_;
747: #
1.69 matthew 748: my %content = %$content;
1.68 matthew 749: my %lt=&fieldnames();
1.67 matthew 750: #
751: my $description = 'Dynamic Metadata (updated periodically)';
752: $r->print('<h3>'.&mt($description).'</h3>'.
1.70 matthew 753: &mt('Processing'));
1.67 matthew 754: $r->rflush();
755: my %items=&fieldnames();
756: my %dynmeta=&dynamicmeta($uri);
757: #
758: # General Access and Usage Statistics
1.70 matthew 759: if (exists($dynmeta{'count'}) ||
760: exists($dynmeta{'sequsage'}) ||
761: exists($dynmeta{'comefrom'}) ||
762: exists($dynmeta{'goto'}) ||
763: exists($dynmeta{'course'})) {
764: $r->print('<h4>'.&mt('Access and Usage Statistics').'</h4>'.
1.88 banghart 765: '<table cellspacing="2" border="0">');
1.70 matthew 766: foreach ('count',
767: 'sequsage','sequsage_list',
768: 'comefrom','comefrom_list',
769: 'goto','goto_list',
770: 'course','course_list') {
771: $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.
772: '<td bgcolor="#CCCCCC">'.
773: &prettyprint($_,$dynmeta{$_})."</td></tr>\n");
774: }
775: $r->print('</table>');
776: } else {
777: $r->print('<h4>'.&mt('No Access or Usages Statistics are available for this resource.').'</h4>');
1.67 matthew 778: }
1.69 matthew 779: #
780: # Assessment statistics
1.73 matthew 781: if ($uri=~/\.(problem|exam|quiz|assess|survey|form)$/) {
782: if (exists($dynmeta{'stdno'}) ||
783: exists($dynmeta{'avetries'}) ||
784: exists($dynmeta{'difficulty'}) ||
785: exists($dynmeta{'disc'})) {
786: # This is an assessment, print assessment data
787: $r->print('<h4>'.
788: &mt('Overall Assessment Statistical Data').
789: '</h4>'.
1.88 banghart 790: '<table cellspacing="2" border="0">');
1.73 matthew 791: $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{'stdno'}.'</td>'.
1.66 matthew 792: '<td bgcolor="#CCCCCC">'.
1.73 matthew 793: &prettyprint('stdno',$dynmeta{'stdno'}).
794: '</td>'."</tr>\n");
795: foreach ('avetries','difficulty','disc') {
796: $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.
797: '<td bgcolor="#CCCCCC">'.
798: &prettyprint($_,sprintf('%5.2f',$dynmeta{$_})).
799: '</td>'."</tr>\n");
800: }
801: $r->print('</table>');
802: }
803: if (exists($dynmeta{'stats'})) {
804: #
805: # New assessment statistics
806: $r->print('<h4>'.
807: &mt('Detailed Assessment Statistical Data').
808: '</h4>');
1.88 banghart 809: my $table = '<table cellspacing="2" border="0">'.
1.73 matthew 810: '<tr>'.
811: '<th>Course</th>'.
812: '<th>Section(s)</th>'.
813: '<th>Num Students</th>'.
814: '<th>Mean Tries</th>'.
815: '<th>Degree of Difficulty</th>'.
816: '<th>Degree of Discrimination</th>'.
817: '<th>Time of computation</th>'.
818: '</tr>'.$/;
819: foreach my $identifier (sort(keys(%{$dynmeta{'stats'}}))) {
820: my $data = $dynmeta{'stats'}->{$identifier};
821: my $course = $data->{'course'};
822: my %courseinfo = &Apache::lonnet::coursedescription($course);
823: if (! exists($courseinfo{'num'}) || $courseinfo{'num'} eq '') {
824: &Apache::lonnet::logthis('lookup for '.$course.' failed');
825: next;
826: }
827: $table .= '<tr>';
828: $table .=
829: '<td><nobr>'.$courseinfo{'description'}.'</nobr></td>';
830: $table .=
831: '<td align="right">'.$data->{'sections'}.'</td>';
832: $table .=
833: '<td align="right">'.$data->{'stdno'}.'</td>';
834: foreach ('avetries','difficulty','disc') {
835: $table .= '<td align="right">';
836: if (exists($data->{$_})) {
837: $table .= sprintf('%.2f',$data->{$_}).' ';
838: } else {
839: $table .= '';
840: }
841: $table .= '</td>';
842: }
843: $table .=
844: '<td><nobr>'.
845: &Apache::lonlocal::locallocaltime($data->{'timestamp'}).
846: '</nobr></td>';
847: $table .=
848: '</tr>'.$/;
849: }
850: $table .= '</table>'.$/;
851: $r->print($table);
852: } else {
853: $r->print('No new dynamic data found.');
1.66 matthew 854: }
1.70 matthew 855: } else {
1.73 matthew 856: $r->print('<h4>'.
857: &mt('No Assessment Statistical Data is available for this resource').
858: '</h4>');
1.67 matthew 859: }
1.73 matthew 860:
861: #
862: #
1.70 matthew 863: if (exists($dynmeta{'clear'}) ||
864: exists($dynmeta{'depth'}) ||
865: exists($dynmeta{'helpful'}) ||
866: exists($dynmeta{'correct'}) ||
867: exists($dynmeta{'technical'})){
868: $r->print('<h4>'.&mt('Evaluation Data').'</h4>'.
1.88 banghart 869: '<table cellspacing="2" border="0">');
1.70 matthew 870: foreach ('clear','depth','helpful','correct','technical') {
871: $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.
872: '<td bgcolor="#CCCCCC">'.
873: &prettyprint($_,$dynmeta{$_})."</td></tr>\n");
874: }
875: $r->print('</table>');
876: } else {
877: $r->print('<h4>'.&mt('No Evaluation Data is available for this resource.').'</h4>');
1.67 matthew 878: }
879: $uri=~/^\/res\/(\w+)\/(\w+)\//;
1.96 albertel 880: if ((($env{'user.domain'} eq $1) && ($env{'user.name'} eq $2))
881: || ($env{'user.role.ca./'.$1.'/'.$2})) {
1.70 matthew 882: if (exists($dynmeta{'comments'})) {
883: $r->print('<h4>'.&mt('Evaluation Comments').' ('.
884: &mt('visible to author and co-authors only').
885: ')</h4>'.
886: '<blockquote>'.$dynmeta{'comments'}.'</blockquote>');
887: } else {
888: $r->print('<h4>'.&mt('There are no Evaluation Comments on this resource.').'</h4>');
889: }
890: my $bombs = &Apache::lonmsg::retrieve_author_res_msg($uri);
891: if (defined($bombs) && $bombs ne '') {
892: $r->print('<a name="bombs" /><h4>'.&mt('Error Messages').' ('.
893: &mt('visible to author and co-authors only').')'.
894: '</h4>'.$bombs);
895: } else {
896: $r->print('<h4>'.&mt('There are currently no Error Messages for this resource.').'</h4>');
897: }
1.67 matthew 898: }
1.69 matthew 899: #
1.67 matthew 900: # All other stuff
901: $r->print('<h3>'.
902: &mt('Additional Metadata (non-standard, parameters, exports)').
1.81 www 903: '</h3><table border="0" cellspacing="1">');
1.67 matthew 904: foreach (sort(keys(%content))) {
905: my $name=$_;
906: if ($name!~/\.display$/) {
907: my $display=&Apache::lonnet::metadata($uri,
908: $name.'.display');
909: if (! $display) {
910: $display=$name;
911: };
912: my $otherinfo='';
913: foreach ('name','part','type','default') {
914: if (defined(&Apache::lonnet::metadata($uri,
915: $name.'.'.$_))) {
916: $otherinfo.=' '.$_.'='.
917: &Apache::lonnet::metadata($uri,
918: $name.'.'.$_).'; ';
919: }
1.64 matthew 920: }
1.81 www 921: $r->print('<tr><td bgcolor="#bbccbb"><font size="-1" color="#556655">'.$display.'</font></td><td bgcolor="#ccddcc"><font size="-1" color="#556655">'.$content{$name});
1.67 matthew 922: if ($otherinfo) {
923: $r->print(' ('.$otherinfo.')');
1.64 matthew 924: }
1.81 www 925: $r->print("</font></td></tr>\n");
1.64 matthew 926: }
1.66 matthew 927: }
1.81 www 928: $r->print("</table>");
1.67 matthew 929: return;
1.66 matthew 930: }
1.105 banghart 931:
1.102 banghart 932:
933:
1.67 matthew 934: #####################################################
935: #####################################################
936: ### ###
937: ### Editable metadata display ###
938: ### ###
939: #####################################################
940: #####################################################
1.66 matthew 941: sub present_editable_metadata {
1.90 banghart 942: my ($r,$uri, $file_type) = @_;
1.66 matthew 943: # Construction Space Call
944: # Header
945: my $disuri=$uri;
946: my $fn=&Apache::lonnet::filelocation('',$uri);
947: $disuri=~s/^\/\~/\/priv\//;
948: $disuri=~s/\.meta$//;
1.110 albertel 949: $disuri=~s|^/editupload||;
1.66 matthew 950: my $target=$uri;
1.96 albertel 951: $target=~s/^\/\~/\/res\/$env{'request.role.domain'}\//;
1.66 matthew 952: $target=~s/\.meta$//;
953: my $bombs=&Apache::lonmsg::retrieve_author_res_msg($target);
954: if ($bombs) {
1.99 www 955: my $showdel=1;
1.96 albertel 956: if ($env{'form.delmsg'}) {
1.66 matthew 957: if (&Apache::lonmsg::del_url_author_res_msg($target) eq 'ok') {
958: $bombs=&mt('Messages deleted.');
1.99 www 959: $showdel=0;
1.66 matthew 960: } else {
961: $bombs=&mt('Error deleting messages');
1.64 matthew 962: }
1.66 matthew 963: }
1.98 www 964: if ($env{'form.clearmsg'}) {
965: my $cleardir=$target;
966: $cleardir=~s/\/[^\/]+$/\//;
967: if (&Apache::lonmsg::clear_author_res_msg($cleardir) eq 'ok') {
968: $bombs=&mt('Messages cleared.');
1.99 www 969: $showdel=0;
1.98 www 970: } else {
971: $bombs=&mt('Error clearing messages');
972: }
973: }
974: my $del=&mt('Delete Messages for this Resource');
975: my $clear=&mt('Clear all Messages in Subdirectory');
1.99 www 976: my $goback=&mt('Back to Source File');
1.66 matthew 977: $r->print(<<ENDBOMBS);
1.52 www 978: <h1>$disuri</h1>
979: <form method="post" name="defaultmeta">
1.99 www 980: ENDBOMBS
981: if ($showdel) {
982: $r->print(<<ENDDEL);
1.59 www 983: <input type="submit" name="delmsg" value="$del" />
1.98 www 984: <input type="submit" name="clearmsg" value="$clear" />
1.99 www 985: ENDDEL
986: } else {
987: $r->print('<a href="'.$disuri.'" />'.$goback.'</a>');
988: }
989: $r->print('<br />'.$bombs);
1.66 matthew 990: } else {
991: my $displayfile='Catalog Information for '.$disuri;
992: if ($disuri=~/\/default$/) {
993: my $dir=$disuri;
994: $dir=~s/default$//;
995: $displayfile=
996: &mt('Default Cataloging Information for Directory').' '.
997: $dir;
998: }
999: %Apache::lonpublisher::metadatafields=();
1000: %Apache::lonpublisher::metadatakeys=();
1.94 banghart 1001: my $result=&Apache::lonnet::getfile($fn);
1002: if ($result == -1){
1.110 albertel 1003: $r->print('Creating new '.$disuri);
1.94 banghart 1004: } else {
1005: &Apache::lonpublisher::metaeval($result);
1006: }
1.66 matthew 1007: $r->print(<<ENDEDIT);
1.23 www 1008: <h1>$displayfile</h1>
1.48 www 1009: <form method="post" name="defaultmeta">
1.23 www 1010: ENDEDIT
1.66 matthew 1011: $r->print('<script language="JavaScript">'.
1.86 albertel 1012: &Apache::loncommon::browser_and_searcher_javascript().
1.66 matthew 1013: '</script>');
1.90 banghart 1014: my %lt=&fieldnames($file_type);
1.87 albertel 1015: my $output;
1.90 banghart 1016: my @fields;
1017: if ($file_type eq 'portfolio') {
1.111 banghart 1018: @fields = ('author','metadata.title','metadata.subject','metadata.keywords','abstract','notes','lowestgradelevel',
1.91 banghart 1019: 'highestgradelevel');
1.90 banghart 1020: } else {
1021: @fields = ('author','title','subject','keywords','abstract','notes',
1.66 matthew 1022: 'copyright','customdistributionfile','language',
1023: 'standards',
1.78 taceyjo1 1024: 'lowestgradelevel','highestgradelevel','sourceavail','sourcerights',
1.90 banghart 1025: 'obsolete','obsoletereplacement');
1026: }
1027: foreach (@fields) {
1.96 albertel 1028: if (defined($env{'form.new_'.$_})) {
1.66 matthew 1029: $Apache::lonpublisher::metadatafields{$_}=
1.96 albertel 1030: $env{'form.new_'.$_};
1.66 matthew 1031: }
1032: if (! $Apache::lonpublisher::metadatafields{'copyright'}) {
1033: $Apache::lonpublisher::metadatafields{'copyright'}=
1034: 'default';
1.64 matthew 1035: }
1.87 albertel 1036: $output.=('<p>'.$lt{$_}.': '.
1037: &prettyinput($_,
1038: $Apache::lonpublisher::metadatafields{$_},
1039: 'new_'.$_,'defaultmeta').'</p>');
1.106 banghart 1040: if ($env{'form.metacourse'}) {
1.108 banghart 1041: $r->print('This is the instructor metadata area<br />');
1042: # have to find all the metadata items, so we'll loop through and find them
1043: $r->print('<form method="post" action="" size="3" >');
1044: $r->print('The course is: '.$env{'form.metacourse'}.'<br>');
1045: foreach my $key (sort keys %env) {
1046: if ($key=~m/^($env{'form.metacourse'}\.metadata\.)(\d+)\.title/) {
1047: my $key_base = $1;
1048: my $item_num = $2;
1049: # found one, so let's display it
1050: my $title = $env{$key_base.$item_num.'.title'};
1051: my $type = $env{$key_base.$item_num.'.type'};
1052: my @choices = sort(split /, /,$env{$key_base.$item_num.'.values'});
1053: $r->print($title.'<br />');
1054: $r->print($type.'<br />');
1055:
1056: foreach my $word (@choices) {
1057: my $checked;
1058: if ($Apache::lonpublisher::metadatafields{'coursekeyword'}=~ m/$word/) {
1059: $checked = 1;
1060: } else {
1061: undef($checked);
1062: }
1063: $r->print(&Apache::lonhtmlcommon::checkbox('instmeta_'.$env{'form.metacourse'}.'_'.$item_num,$checked,$word).$word.'<br />');
1064: }
1.107 banghart 1065: }
1.108 banghart 1066: }
1.106 banghart 1067: $r->print('<br /><input type="submit" name="store" value="Assign Meta-data" />');
1068: $r->print('</form>');
1069: return 'ok';
1070: }
1.66 matthew 1071: }
1.96 albertel 1072: if ($env{'form.store'}) {
1.66 matthew 1073: my $mfh;
1.107 banghart 1074: my $formname='store';
1.94 banghart 1075: my $file_content;
1.108 banghart 1076: foreach my $meta_field (keys %env) {
1077: if ($meta_field=~m/^form.instmeta_(.+)_(\d+)$/) {
1078: $r->print('Found a field<br>');
1079: }
1080: if (&Apache::loncommon::get_env_multiple('form.keywords')) {
1081: $Apache::lonpublisher::metadatafields{'coursekeyword'} =
1.106 banghart 1082: join (', ', &Apache::loncommon::get_env_multiple('form.keywords'));
1.108 banghart 1083: }
1.106 banghart 1084: }
1.94 banghart 1085: foreach (sort keys %Apache::lonpublisher::metadatafields) {
1086: next if ($_ =~ /\./);
1087: my $unikey=$_;
1088: $unikey=~/^([A-Za-z]+)/;
1089: my $tag=$1;
1090: $tag=~tr/A-Z/a-z/;
1091: $file_content.= "\n\<$tag";
1092: foreach (split(/\,/,
1093: $Apache::lonpublisher::metadatakeys{$unikey})
1094: ) {
1095: my $value=
1096: $Apache::lonpublisher::metadatafields{$unikey.'.'.$_};
1097: $value=~s/\"/\'\'/g;
1098: $file_content.=' '.$_.'="'.$value.'"' ;
1099: # print $mfh ' '.$_.'="'.$value.'"';
1100: }
1101: $file_content.= '>'.
1102: &HTML::Entities::encode
1103: ($Apache::lonpublisher::metadatafields{$unikey},
1104: '<>&"').
1105: '</'.$tag.'>';
1106: }
1107: if ($fn =~ /\/portfolio\//) {
1108: $fn =~ /\/portfolio\/(.*)$/;
1109: my $new_fn = '/'.$1;
1.96 albertel 1110: $env{'form.'.$formname}=$file_content;
1111: $env{'form.'.$formname.'.filename'}=$new_fn;
1.94 banghart 1112: &Apache::lonnet::userfileupload('uploaddoc','',
1.96 albertel 1113: 'portfolio'.$env{'form.currentpath'});
1.94 banghart 1114: my $status =&Apache::lonnet::userfileupload($formname,'','portfolio');
1115: if (&Apache::lonnet::userfileupload($formname,'','portfolio') eq 'error: no uploaded file') {
1116: $r->print('<p><font color="red">'.
1117: &mt('Could not write metadata').', '.
1118: &mt('FAIL').'</font></p>');
1119: } else {
1120: $r->print('<p><font color="blue">'.&mt('Wrote Metadata').
1121: ' '.&Apache::lonlocal::locallocaltime(time).
1122: '</font></p>');
1123: }
1.66 matthew 1124: } else {
1.94 banghart 1125: if (! ($mfh=Apache::File->new('>'.$fn))) {
1126: $r->print('<p><font color="red">'.
1127: &mt('Could not write metadata').', '.
1128: &mt('FAIL').'</font></p>');
1129: } else {
1130: print $mfh $file_content;
1.95 albertel 1131: $r->print('<p><font color="blue">'.&mt('Wrote Metadata').
1132: ' '.&Apache::lonlocal::locallocaltime(time).
1133: '</font></p>');
1.64 matthew 1134: }
1135: }
1136: }
1.87 albertel 1137: $r->print($output.'<br /><input type="submit" name="store" value="'.
1.67 matthew 1138: &mt('Store Catalog Information').'">');
1.64 matthew 1139: }
1.67 matthew 1140: $r->print('</form>');
1.66 matthew 1141: return;
1.1 www 1142: }
1.64 matthew 1143:
1.1 www 1144: 1;
1145: __END__
1.97 banghart 1146:
1.98 www 1147:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>