File:
[LON-CAPA] /
loncom /
interface /
londocs.pm
Revision
1.160:
download - view:
text,
annotated -
select for diffs
Thu Dec 23 17:28:31 2004 UTC (19 years, 5 months ago) by
raeburn
Branches:
MAIN
CVS tags:
HEAD
If user has an active co-author role for construction space where source for a particular problem used in a course is stored, he/she will no longer be permitted to export source code for the problem when exporting the course to IMS; HTML of the rendered problem will be exported instead.
1: # The LearningOnline Network
2: # Documents
3: #
4: # $Id: londocs.pm,v 1.160 2004/12/23 17:28:31 raeburn Exp $
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.
14: #
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: #
20: # You should have received a copy of the GNU General Public License
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/
27: #
28:
29: package Apache::londocs;
30:
31: use strict;
32: use Apache::Constants qw(:common :http);
33: use Apache::imsexport;
34: use Apache::lonnet;
35: use Apache::loncommon;
36: use Apache::lonratedt;
37: use Apache::lonratsrv;
38: use Apache::lonxml;
39: use Apache::loncreatecourse;
40: use Apache::lonnavmaps;
41: use HTML::Entities;
42: use GDBM_File;
43: use Apache::lonlocal;
44: use Cwd;
45:
46: my $iconpath;
47:
48: my %hash;
49:
50: my $hashtied;
51: my %alreadyseen=();
52:
53: my $hadchanges;
54:
55: # Available help topics
56:
57: my %help=();
58:
59: # Mapread read maps into lonratedt::global arrays
60: # @order and @resources, determines status
61: # sets @order - pointer to resources in right order
62: # sets @resources - array with the resources with correct idx
63: #
64:
65: sub mapread {
66: my ($coursenum,$coursedom,$map)=@_;
67: return
68: &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
69: $map);
70: }
71:
72: sub storemap {
73: my ($coursenum,$coursedom,$map)=@_;
74: my ($outtext,$errtext)=
75: &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
76: $map,1);
77: if ($errtext) { return ($errtext,2); }
78:
79: $hadchanges=1;
80: return ($errtext,0);
81: }
82:
83: # ----------------------------------------- Return hash with valid author names
84:
85: sub authorhosts {
86: my %outhash=();
87: my $home=0;
88: my $other=0;
89: foreach (keys %ENV) {
90: if ($_=~/^user\.role\.(au|ca)\.(.+)$/) {
91: my $role=$1;
92: my $realm=$2;
93: my ($start,$end)=split(/\./,$ENV{$_});
94: if (($start) && ($start>time)) { next; }
95: if (($end) && (time>$end)) { next; }
96: my $ca; my $cd;
97: if ($1 eq 'au') {
98: $ca=$ENV{'user.name'};
99: $cd=$ENV{'user.domain'};
100: } else {
101: ($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/);
102: }
103: my $allowed=0;
104: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
105: my @ids=&Apache::lonnet::current_machine_ids();
106: foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } }
107: if ($allowed) {
108: $home++;
109: $outhash{'home_'.$ca.'@'.$cd}=1;
110: } else {
111: $outhash{'otherhome_'.$ca.'@'.$cd}=$myhome;
112: $other++;
113: }
114: }
115: }
116: return ($home,$other,%outhash);
117: }
118: # ------------------------------------------------------ Generate "dump" button
119:
120: sub dumpbutton {
121: my ($home,$other,%outhash)=&authorhosts();
122: if ($home+$other==0) { return ''; }
123: my $output='</td><td bgcolor="#DDDDCC">';
124: if ($home) {
125: return '</td><td bgcolor="#DDDDCC">'.
126: '<input type="submit" name="dumpcourse" value="'.
127: &mt('Dump Course DOCS to Construction Space').'" />'.
128: &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs');
129: } else {
130: return'</td><td bgcolor="#DDDDCC">'.
131: &mt('Dump Course DOCS to Construction Space: available on other servers');
132: }
133: }
134:
135: # -------------------------------------------------------- Actually dump course
136:
137: sub dumpcourse {
138: my $r=shift;
139: $r->print('<html><head><title>Dump DOCS</title></head>'.
140: &Apache::loncommon::bodytag('Dump Course DOCS to Construction Space').
141: '<form name="dumpdoc" method="post">');
142: my ($home,$other,%outhash)=&authorhosts();
143: unless ($home) { return ''; }
144: my $origcrsid=$ENV{'request.course.id'};
145: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
146: if (($ENV{'form.authorspace'}) && ($ENV{'form.authorfolder'}=~/\w/)) {
147: # Do the dumping
148: unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; }
149: my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'});
150: $r->print('<h3>'.&mt('Copying Files').'</h3>');
151: my $title=$ENV{'form.authorfolder'};
152: $title=~s/[^\w\/]+/\_/g;
153: my %replacehash=();
154: foreach (keys %ENV) {
155: if ($_=~/^form\.namefor\_(.+)/) {
156: $replacehash{$1}=$ENV{$_};
157: }
158: }
159: my $crs='/uploaded/'.$ENV{'request.course.id'}.'/';
160: $crs=~s/\_/\//g;
161: foreach (keys %replacehash) {
162: my $newfilename=$title.'/'.$replacehash{$_};
163: $newfilename=~s/[^\w\/\.\/]+/\_/g;
164: my @dirs=split(/\//,$newfilename);
165: my $path='/home/'.$ca.'/public_html';
166: my $makepath=$path;
167: my $fail=0;
168: for (my $i=0;$i<$#dirs;$i++) {
169: $makepath.='/'.$dirs[$i];
170: unless (-e $makepath) {
171: unless(mkdir($makepath,0777)) { $fail=1; }
172: }
173: }
174: $r->print('<br /><tt>'.$_.'</tt> => <tt>'.$newfilename.'</tt>: ');
175: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
176: if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
177: print $fh &Apache::loncreatecourse::rewritefile(
178: &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_),
179: (%replacehash,$crs => '')
180: );
181: } else {
182: print $fh
183: &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_);
184: }
185: $fh->close();
186: } else {
187: $fail=1;
188: }
189: if ($fail) {
190: $r->print('<font color="red">fail</font>');
191: } else {
192: $r->print('<font color="green">ok</font>');
193: }
194: }
195: } else {
196: # Input form
197: unless ($home==1) {
198: $r->print(
199: '<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">');
200: }
201: foreach (sort keys %outhash) {
202: if ($_=~/^home_(.+)$/) {
203: if ($home==1) {
204: $r->print(
205: '<input type="hidden" name="authorspace" value="'.$1.'" />');
206: } else {
207: $r->print('<option value="'.$1.'">'.$1.' - '.
208: &Apache::loncommon::plainname(split(/\@/,$1)).'</option>');
209: }
210: }
211: }
212: unless ($home==1) {
213: $r->print('</select>');
214: }
215: my $title=$origcrsdata{'description'};
216: $title=~s/\s+/\_/gs;
217: $title=~s/\W//gs;
218: $r->print('<h3>'.&mt('Folder in Construction Space').'</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
219: &tiehash();
220: $r->print('<h3>'.&mt('Filenames in Construction Space').'</h3><table border="2"><tr><th>'.&mt('Internal Filename').'</th><th>'.&mt('Title').'</th><th>'.&mt('Save as ...').'</th></tr>');
221: foreach (&Apache::loncreatecourse::crsdirlist($origcrsid,'userfiles')) {
222: $r->print('<tr><td>'.$_.'</td>');
223: my ($ext)=($_=~/\.(\w+)$/);
224: my $title=$hash{'title_'.$hash{
225: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
226: $r->print('<td>'.($title?$title:' ').'</td>');
227: unless ($title) {
228: $title=$_;
229: }
230: $title=~s/\.(\w+)$//;
231: $title=~s/[^\w\/]+/\_/gs;
232: $title.='.'.$ext;
233: $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");
234: }
235: $r->print("</table>\n");
236: &untiehash();
237: $r->print(
238: '<p><input type="submit" name="dumpcourse" value="'.&mt('Dump Course DOCS').'" /></p></form>');
239: }
240: }
241:
242: # ------------------------------------------------------ Generate "export" button
243:
244: sub exportbutton {
245: return '</td><td bgcolor="#DDDDCC">'.
246: '<input type="submit" name="exportcourse" value="'.
247: &mt('Export Course to IMS').'" />'.
248: &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs');
249: }
250:
251: sub exportcourse {
252: my $r=shift;
253: my %discussiontime = &Apache::lonnet::dump('discussiontimes',
254: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
255: my $numdisc = keys %discussiontime;
256: my $navmap = Apache::lonnavmaps::navmap->new();
257: my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
258: my $curRes;
259: my $outcome;
260:
261: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
262: ['finishexport']);
263: if ($ENV{'form.finishexport'}) {
264: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
265: ['archive','discussion']);
266:
267: my @exportitems = ();
268: if (defined($ENV{'form.archive'})) {
269: if (ref($ENV{'form.archive'}) eq 'ARRAY') {
270: @exportitems = @{$ENV{'form.archive'}};
271: } else {
272: $exportitems[0] = $ENV{'form.archive'};
273: }
274: }
275: my @discussions = ();
276: if (defined($ENV{'form.discussion'})) {
277: if (ref($ENV{'form.discussion'}) eq 'ARRAY') {
278: @discussions = $ENV{'form.discussion'};
279: } else {
280: $discussions[0] = $ENV{'form.discussion'};
281: }
282: }
283: if (@exportitems == 0 && @discussions == 0) {
284: $outcome = '<br />As you did not select any content items or discussions for export, an IMS package has not been created. Please <a href="javascript:history.go(-1)">go back</a> to select either content items or discussions for export';
285: } else {
286: my $now = time;
287: my %symbs;
288: my $manifestok = 0;
289: my $imsresources;
290: my $tempexport;
291: my $copyresult;
292: my $ims_manifest = &create_ims_store($now,\$manifestok,\$outcome,\$tempexport);
293: if ($manifestok) {
294: &build_package($now,$navmap,\@exportitems,\@discussions,\$outcome,$tempexport,\$copyresult,$ims_manifest);
295: close($ims_manifest);
296:
297: #Create zip file in prtspool
298: my $imszipfile = '/prtspool/'.
299: $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
300: time.'_'.rand(1000000000).'.zip';
301: # zip can cause an sh launch which can pass along all of %ENV
302: # which can be too large for /bin/sh to handle
303: my %oldENV=%ENV;
304: undef(%ENV);
305: my $cwd = &Cwd::getcwd();
306: my $imszip = '/home/httpd/'.$imszipfile;
307: chdir $tempexport;
308: open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
309: close(OUTPUT);
310: chdir $cwd;
311: %ENV=%oldENV;
312: undef(%oldENV);
313: $outcome .= 'Download the zip file from <a href="'.$imszipfile.'">IMS course archive</a><br />';
314: if ($copyresult) {
315: $outcome .= 'The following errors occurred during export - '.$copyresult;
316: }
317: } else {
318: $outcome = '<br />Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.<br />';
319: }
320: }
321:
322: $r->print('<html><head><title>Export Course</title></head>'.
323: &Apache::loncommon::bodytag('Export course to IMS content package'));
324: $r->print($outcome);
325: $r->print('</body></html>');
326: } else {
327: my $display;
328: $display = '<form name="exportdoc" method="post">'."\n";
329: $display .= 'Choose which items you wish to export from your course.<br /><br />';
330: $display .= '<table border="0" cellspacing="0" cellpadding="3">'.
331: '<tr><td><fieldset><legend> <b>Content items</b></legend>'.
332: '<input type="button" value="check all" '.
333: 'onclick="javascript:checkAll(document.exportdoc.archive)" />'.
334: ' <input type="button" value="uncheck all"'.
335: ' onclick="javascript:uncheckAll(document.exportdoc.archive)" /></fieldset></td>'.
336: '<td> </td><td> </td>'.
337: '<td align="right"><fieldset><legend> <b>Discussion posts'.
338: '</b></legend><input type="button" value="check all"'.
339: ' onclick="javascript:checkAll(document.exportdoc.discussion)" />'.
340: ' <input type="button" value="uncheck all"'.
341: ' onclick="javascript:uncheckAll(document.exportdoc.discussion)" /></fieldset></td>'.
342: '</tr></table>';
343: my $curRes;
344: my $depth = 0;
345: my $count = 0;
346: my $boards = 0;
347: my $startcount = 5;
348: my %parent = ();
349: my %children = ();
350: my $lastcontainer = $startcount;
351: my @bgcolors = ('#F6F6F6','#FFFFFF');
352: $display .= '<table cellspacing="0"><tr>'.
353: '<td><b>Export content item?<br /></b></td><td> </td><td align="right">'."\n";
354: if ($numdisc > 0) {
355: $display.='<b>Export discussion posts?</b>'."\n";
356: }
357: $display.=' </td></tr>';
358: while ($curRes = $it->next()) {
359: if (ref($curRes)) {
360: $count ++;
361: }
362: if ($curRes == $it->BEGIN_MAP()) {
363: $depth++;
364: $parent{$depth} = $lastcontainer;
365: }
366: if ($curRes == $it->END_MAP()) {
367: $depth--;
368: $lastcontainer = $parent{$depth};
369: }
370: if (ref($curRes)) {
371: my $symb = $curRes->symb();
372: my $ressymb = $symb;
373: if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) {
374: unless ($ressymb =~ m|adm/wrapper/adm|) {
375: $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
376: }
377: }
378: my $color = $count%2;
379: $display .='<tr bgcolor='.$bgcolors[$color].'><td>'."\n".
380: '<input type="checkbox" name="archive" value="'.$count.'" ';
381: if (($curRes->is_sequence()) || ($curRes->is_page())) {
382: my $checkitem = $count + $boards + $startcount;
383: $display .= 'onClick="javascript:propagateCheck('."'$checkitem'".')"';
384: }
385: $display .= ' />'."\n";
386: for (my $i=0; $i<$depth; $i++) {
387: $display .= '<img src="/adm/lonIcons/whitespace1.gif" width="25" height="1" alt="" border="0" /><img src="/adm/lonIcons/whitespace1.gif" width="25" height="1" alt="" border="0" />'."\n";
388: }
389: if ($curRes->is_sequence()) {
390: $display .= '<img src="/adm/lonIcons/navmap.folder.open.gif"> '."\n";
391: $lastcontainer = $count + $startcount + $boards;
392: } elsif ($curRes->is_page()) {
393: $display .= '<img src="/adm/lonIcons/navmap.page.open.gif"> '."\n";
394: $lastcontainer = $count + $startcount + $boards;
395: }
396: my $currelem = $count+$boards+$startcount;
397: $children{$parent{$depth}} .= $currelem.':';
398: $display .= ' '.$curRes->title().'</td>';
399: if ($discussiontime{$ressymb} > 0) {
400: $boards ++;
401: $currelem = $count+$boards+$startcount;
402: $display .= '<td> </td><td align="right"><input type="checkbox" name="discussion" value="'.$count.'" /> </td>'."\n";
403: } else {
404: $display .= '<td colspan="2"> </td>'."\n";
405: }
406: }
407: }
408: my $scripttag = qq|
409: <script>
410:
411: function checkAll(field) {
412: if (field.length > 0) {
413: for (i = 0; i < field.length; i++) {
414: field[i].checked = true ;
415: }
416: } else {
417: field.checked = true
418: }
419: }
420:
421: function uncheckAll(field) {
422: if (field.length > 0) {
423: for (i = 0; i < field.length; i++) {
424: field[i].checked = false ;
425: }
426: } else {
427: field.checked = false ;
428: }
429: }
430:
431: function propagateCheck(item) {
432: if (document.exportdoc.elements[item].checked == true) {
433: containerCheck(item)
434: }
435: }
436:
437: function containerCheck(item) {
438: document.exportdoc.elements[item].checked = true
439: var numitems = $count + $boards + $startcount
440: var parents = new Array(numitems)
441: for (var i=$startcount; i<numitems; i++) {
442: parents[i] = new Array
443: }
444: |;
445:
446: foreach my $container (sort { $a <=> $b } keys %children) {
447: my @contents = split/:/,$children{$container};
448: for (my $i=0; $i<@contents; $i ++) {
449: $scripttag .= ' parents['.$container.']['.$i.'] = '.$contents[$i]."\n";
450: }
451: }
452:
453: $scripttag .= qq|
454: if (parents[item].length > 0) {
455: for (var j=0; j<parents[item].length; j++) {
456: containerCheck(parents[item][j])
457: }
458: }
459: }
460:
461: </script>
462: |;
463: $r->print('<html><head><title>Export Course</title>'.$scripttag.'</head>'.
464: &Apache::loncommon::bodytag('Export course to IMS content package'
465: ));
466:
467: $r->print($display.'</table>'.
468: '<p><input type="hidden" name="finishexport" value="1">'.
469: '<input type="submit" name="exportcourse" value="'.
470: &mt('Export Course DOCS').'" /></p></form></body></html>');
471: }
472: }
473:
474: sub create_ims_store {
475: my ($now,$manifestok,$outcome,$tempexport) = @_;
476: $$tempexport = $Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/ims_exports';
477: my $ims_manifest;
478: if (!-e $$tempexport) {
479: mkdir($$tempexport,0700);
480: }
481: $$tempexport .= '/'.$now;
482: if (!-e $$tempexport) {
483: mkdir($$tempexport,0700);
484: }
485: $$tempexport .= '/'.$ENV{'user.domain'}.'_'.$ENV{'user.name'};
486: if (!-e $$tempexport) {
487: mkdir($$tempexport,0700);
488: }
489: if (!-e "$$tempexport/resources") {
490: mkdir("$$tempexport/resources",0700);
491: }
492: # open manifest file
493: my $manifest = '/imsmanifest.xml';
494: my $manifestfilename = $$tempexport.$manifest;
495: if ($ims_manifest = Apache::File->new('>'.$manifestfilename)) {
496: $$manifestok=1;
497: print $ims_manifest
498: '<?xml version="1.0" encoding="UTF-8"?>'."\n".
499: '<manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"'.
500: ' xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"'.
501: ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'.
502: ' identifier="MANIFEST-'.$ENV{'request.course.id'}.'-'.$now.'"'.
503: ' xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'.
504: ' http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n".
505: ' <organizations default="ORG-'.$ENV{'request.course.id'}.'-'.$now.'">'."\n".
506: ' <organization identifier="ORG-'.$ENV{'request.course.id'}.'-'.$now.'"'.
507: ' structure="hierarchical">'."\n".
508: ' <title>'.$ENV{'request.'.$ENV{'request.course.id'}.'.description'}.'</title>'
509: } else {
510: $$outcome .= 'An error occurred opening the IMS manifest file.<br />'
511: ;
512: }
513: return $ims_manifest;
514: }
515:
516: sub build_package {
517: my ($now,$navmap,$exportitems,$discussions,$outcome,$tempexport,$copyresult,$ims_manifest) = @_;
518: # first iterator to look for dependencies
519: my $it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
520: my $curRes;
521: my $count = 0;
522: my $depth = 0;
523: my $lastcontainer = 0;
524: my %parent = ();
525: my @dependencies = ();
526: my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
527: my $cdom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
528: while ($curRes = $it->next()) {
529: if (ref($curRes)) {
530: $count ++;
531: }
532: if ($curRes == $it->BEGIN_MAP()) {
533: $depth++;
534: $parent{$depth} = $lastcontainer;
535: }
536: if ($curRes == $it->END_MAP()) {
537: $depth--;
538: $lastcontainer = $parent{$depth};
539: }
540: if (ref($curRes)) {
541: if ($curRes->is_sequence() || $curRes->is_page()) {
542: $lastcontainer = $count;
543: }
544: if (grep/^$count$/,@$exportitems) {
545: &get_dependencies($exportitems,\%parent,$depth,\@dependencies);
546: }
547: }
548: }
549: # second iterator to build manifest and store resources
550: $it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
551: $depth = 0;
552: my $prevdepth;
553: $count = 0;
554: my $imsresources;
555: my $pkgdepth;
556: my $included = 0;
557: while ($curRes = $it->next()) {
558: if ($curRes == $it->BEGIN_MAP()) {
559: $prevdepth = $depth;
560: $depth++;
561: }
562: if ($curRes == $it->END_MAP()) {
563: $prevdepth = $depth;
564: $depth--;
565: }
566:
567: if (ref($curRes)) {
568: $count ++;
569: if ((grep/^$count$/,@$exportitems) || (grep/^$count$/,@dependencies)) {
570: my $symb = $curRes->symb();
571: my $isvisible = 'true';
572: my $resourceref;
573: if ($curRes->randomout()) {
574: $isvisible = 'false';
575: }
576: unless ($curRes->is_sequence()) {
577: $resourceref = 'identifierref="RES-'.$ENV{'request.course.id'}.'-'.$count.'"';
578: }
579: if (($depth <= $prevdepth) && ($count > 1) && ($included)) {
580: print $ims_manifest "\n".' </item>'."\n";
581: }
582: $included = 1;
583: $prevdepth = $depth;
584:
585: my $itementry =
586: '<item identifier="ITEM-'.$ENV{'request.course.id'}.'-'.$count.
587: '" isvisible="'.$isvisible.'" '.$resourceref.'>'.
588: '<title>'.$curRes->title().'</title>';
589: print $ims_manifest "\n".$itementry;
590:
591: unless ($curRes->is_sequence()) {
592: my $content_file;
593: my @hrefs = ();
594: &process_content($count,$curRes,$cdom,$cnum,$symb,\$content_file,\@hrefs,$copyresult,$tempexport);
595: if ($content_file) {
596: $imsresources .= "\n".
597: ' <resource identifier="RES-'.$ENV{'request.course.id'}.'-'.$count.
598: '" type="webcontent" href="'.$content_file.'">'."\n".
599: ' <file href="'.$content_file.'" />'."\n";
600: foreach (@hrefs) {
601: $imsresources .=
602: ' <file href="'.$_.'" />'."\n";
603: }
604: if (grep/^$count$/,@$discussions) {
605: my $ressymb = $symb;
606: my $mode;
607: if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) {
608: unless ($ressymb =~ m|adm/wrapper/adm|) {
609: $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
610: }
611: $mode = 'board';
612: }
613: my %extras = (
614: caller => 'imsexport',
615: tempexport => $tempexport.'/resources',
616: count => $count
617: );
618: my $discresult = &Apache::lonfeedback::list_discussion($mode,undef,$ressymb,\%extras);
619: }
620: $imsresources .= ' </resource>'."\n";
621: }
622: }
623: $pkgdepth = $depth;
624: } else {
625: $included = 0;
626: }
627: }
628: }
629: while ($pkgdepth > 0) {
630: print $ims_manifest " </item>\n";
631: $pkgdepth --;
632: }
633: my $resource_text = qq|
634: </organization>
635: </organizations>
636: <resources>
637: $imsresources
638: </resources>
639: </manifest>
640: |;
641: print $ims_manifest $resource_text;
642: }
643:
644: sub get_dependencies {
645: my ($exportitems,$parent,$depth,$dependencies) = @_;
646: if ($depth > 1) {
647: if ((!grep/^$$parent{$depth}$/,@$exportitems) && (!grep/^$$parent{$depth}$/,@$dependencies)) {
648: push @$dependencies, $$parent{$depth};
649: if ($depth > 2) {
650: &get_dependencies($exportitems,$parent,$depth-1,$dependencies);
651: }
652: }
653: }
654: }
655:
656: sub process_content {
657: my ($count,$curRes,$cdom,$cnum,$symb,$content_file,$href,$copyresult,$tempexport) = @_;
658: my $content_type;
659: my $message;
660: # find where user is author or co-author
661: my @uploads = ();
662: if ($curRes->is_sequence()) {
663: $content_type = 'sequence';
664: } elsif ($curRes->is_page()) {
665: $content_type = 'page'; # need to handle individual items in pages.
666: } elsif ($symb =~ m-public/$cdom/$cnum/syllabus$-) {
667: $content_type = 'syllabus';
668: my $contents = &Apache::imsexport::templatedpage($content_type);
669: if ($contents) {
670: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
671: }
672: } elsif ($symb =~ m-\.sequence___\d+___ext-) {
673: $content_type = 'external';
674: my $title = $curRes->title;
675: my $contents = &Apache::imsexport::external($symb,$title);
676: if ($contents) {
677: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
678: }
679: } elsif ($symb =~ m-adm/navmaps$-) {
680: $content_type = 'navmap';
681: } elsif ($symb =~ m-adm/[^/]+/[^/]+/(\d+)/smppg$-) {
682: $content_type = 'simplepage';
683: my $contents = &Apache::imsexport::templatedpage($content_type,$1,$count,\@uploads);
684: if ($contents) {
685: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
686: }
687: } elsif ($symb =~ m-lib/templates/simpleproblem\.problem$-) {
688: $content_type = 'simpleproblem';
689: my $contents = &Apache::imsexport::simpleproblem($symb);
690: if ($contents) {
691: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
692: }
693: } elsif ($symb =~ m-lib/templates/examupload\.problem-m) {
694: $content_type = 'examupload';
695: } elsif ($symb =~ m-adm/(\w+)/(\w+)/(\d+)/bulletinboard$-) {
696: $content_type = 'bulletinboard';
697: my $contents = &Apache::imsexport::templatedpage($content_type,$3,$count,\@uploads,$1,$2);
698: if ($contents) {
699: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
700: }
701: } elsif ($symb =~ m-adm/([^/]+)/([^/]+)/aboutme$-) {
702: $content_type = 'aboutme';
703: my $contents = &Apache::imsexport::templatedpage($content_type,undef,$count,\@uploads,$1,$2);
704: if ($contents) {
705: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
706: }
707: } elsif ($symb =~ m-uploaded/$cdom/$cnum-) {
708: $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
709: } elsif ($symb =~ m-\.(sequence|page)___\d+___uploaded/$cdom/$cnum/-) {
710: $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
711: } elsif ($symb =~ m-\.(sequence|page)___\d+___([^/])/([^/])-) {
712: my $coauth = $3.':'.$2.':ca';
713: my $canedit = 0;
714: if ($2 eq $ENV{'user.domain'} && $3 eq $ENV{'user.name'}) {
715: $canedit= 1;
716: }
717: if ($canedit) {
718: $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource');
719: } else {
720: $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'noedit');
721: }
722: }
723: if (@uploads > 0) {
724: foreach my $item (@uploads) {
725: my $uploadmsg = '';
726: &replicate_content($cdom,$cnum,$tempexport,$item,$count,\$uploadmsg,$href,'templateupload');
727: if ($uploadmsg) {
728: $$copyresult .= $uploadmsg."\n";
729: }
730: }
731: }
732: if ($message) {
733: $$copyresult .= $message."\n";
734: }
735: }
736:
737: sub replicate_content {
738: my ($cdom,$cnum,$tempexport,$symb,$count,$message,$href,$caller) = @_;
739: my ($map,$ind,$url);
740: if ($caller eq 'templateupload') {
741: $url = $symb;
742: $url =~ s#//#/#g;
743: } else {
744: ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
745: }
746: my $content;
747: my $filename;
748: my $repstatus;
749: my $content_name;
750: if ($url =~ m-/([^/]+)$-) {
751: $filename = $1;
752: if (!-e $tempexport.'/resources') {
753: mkdir($tempexport.'/resources',0700);
754: }
755: if (!-e $tempexport.'/resources/'.$count) {
756: mkdir($tempexport.'/resources/'.$count,0700);
757: }
758: my $destination = $tempexport.'/resources/'.$count.'/'.$filename;
759: my $copiedfile;
760: if ($copiedfile = Apache::File->new('>'.$destination)) {
761: my $content;
762: if ($caller eq 'resource') {
763: $content = &Apache::lonnet::getfile($url);
764: if ($content eq -1) {
765: $$message = 'Could not copy file '.$filename;
766: } else {
767: &extract_media($content,$count,$tempexport,$href,'resource');
768: $repstatus = 'ok';
769: }
770: } elsif ($caller eq 'noedit' || $caller eq 'uploaded' || $caller eq 'templateupload') {
771: my $rtncode;
772: $repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode);
773: if ($repstatus eq 'ok') {
774: if ($url =~ /\.html?$/i) {
775: &extract_media(\$content,$count,$tempexport,$href,'uploaded');
776: }
777: } else {
778: $$message = 'Could not render '.$url.' server message - '.$rtncode;
779: }
780: }
781: if ($repstatus eq 'ok') {
782: print $copiedfile $content;
783: }
784: close($copiedfile);
785: } else {
786: $$message = 'Could not open destination file for '.$filename."\n";
787: }
788: } else {
789: $$message = 'Could not determine name of file for '.$symb."\n";
790: }
791: if ($repstatus eq 'ok') {
792: $content_name = $count.'/'.$filename;
793: }
794: return $content_name;
795: }
796:
797: sub extract_media {
798: my ($content,$count,$tempexport,$href,$caller) = @_;
799: # @$href will contain path to any embedded resources in the content.
800: # For LON-CAPA problems this would be images. applets etc.
801: # For uploaded HTML files this would be images etc.
802: # paths will be in the form $count/res/$file, and urls in the $content will be rewritten with the new paths.
803: return;
804: }
805:
806: sub store_template {
807: my ($contents,$tempexport,$count,$content_type) = @_;
808: if ($contents) {
809: if ($tempexport) {
810: if (!-e $tempexport.'/resources') {
811: mkdir($tempexport.'/resources',0700);
812: }
813: if (!-e $tempexport.'/resources/'.$count) {
814: mkdir($tempexport.'/resources/'.$count,0700);
815: }
816: my $destination = $tempexport.'/resources/'.$count.'/'.$content_type.'.xml';
817: my $storetemplate;
818: if ($storetemplate = Apache::File->new('>'.$destination)) {
819: print $storetemplate $contents;
820: close($storetemplate);
821: }
822: if ($content_type eq 'external') {
823: return $count.'/'.$content_type.'.html';
824: } else {
825: return $count.'/'.$content_type.'.xml';
826: }
827: }
828: }
829: }
830:
831: # Imports the given (name, url) resources into the course
832: # coursenum, coursedom, and folder must precede the list
833: sub group_import {
834: my $coursenum = shift;
835: my $coursedom = shift;
836: my $folder = shift;
837: my $container = shift;
838: my $caller = shift;
839: while (@_) {
840: my $name = shift;
841: my $url = shift;
842: if (($url =~ m#^/uploaded/$coursedom/$coursenum/(default_\d+\.)(page|sequence)$#) && ($caller eq 'londocs')) {
843: my $errtext = '';
844: my $fatal = 0;
845: my $newmapstr = '<map>'."\n".
846: '<resource id="1" src="" type="start"></resource>'."\n".
847: '<link from="1" to="2" index="1"></link>'."\n".
848: '<resource id="2" src="" type="finish"></resource>'."\n".
849: '</map>';
850: $ENV{'form.output'}=$newmapstr;
851: my $home=&Apache::lonnet::homeserver($coursenum,$coursedom);
852: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$home,
853: 'output',$1.$2);
854: if ($result != m|^/uploaded/|) {
855: $errtext.='Map not saved: A network error occured when trying to save the new map. ';
856: $fatal = 2;
857: }
858: if ($fatal) {
859: return ($errtext,$fatal);
860: }
861: }
862: if ($url) {
863: my $idx = $#Apache::lonratedt::resources + 1;
864: $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx;
865: my $ext = 'false';
866: if ($url=~/^http:\/\//) { $ext = 'true'; }
867: $url =~ s/:/\:/g;
868: $name =~ s/:/\:/g;
869: $Apache::lonratedt::resources[$idx] =
870: join ':', ($name, $url, $ext, 'normal', 'res');
871: }
872: }
873: return &storemap($coursenum, $coursedom, $folder.'.'.$container);
874: }
875:
876: sub breadcrumbs {
877: my ($where)=@_;
878: &Apache::lonhtmlcommon::clear_breadcrumbs();
879: my (@folders);
880: if ($ENV{'form.pagepath'}) {
881: @folders = split('&',$ENV{'form.pagepath'});
882: } else {
883: @folders=split('&',$ENV{'form.folderpath'});
884: }
885: my $folderpath;
886: while (@folders) {
887: my $folder=shift(@folders);
888: my $foldername=shift(@folders);
889: if ($folderpath) {$folderpath.='&';}
890: $folderpath.=$folder.'&'.$foldername;
891: my $url='/adm/coursedocs?folderpath='.
892: &Apache::lonnet::escape($folderpath);
893: &Apache::lonhtmlcommon::add_breadcrumb(
894: {'href'=>$url,
895: 'title'=>&Apache::lonnet::unescape($foldername),
896: 'text'=>'<font size="+1">'.
897: &Apache::lonnet::unescape($foldername).'</font>'
898: });
899:
900:
901: }
902: return &Apache::lonhtmlcommon::breadcrumbs(undef,undef,undef,undef,undef,
903: 0,'nohelp');
904: }
905:
906: sub editor {
907: my ($r,$coursenum,$coursedom,$folder,$allowed)=@_;
908:
909: $r->print(&breadcrumbs($folder));
910: my $errtext='';
911: my $fatal=0;
912: my $container='sequence';
913: if ($ENV{'form.pagepath'}) {
914: $container='page';
915: }
916: ($errtext,$fatal)=
917: &mapread($coursenum,$coursedom,$folder.'.'.$container);
918: if ($#Apache::lonratedt::order<1) {
919: $Apache::lonratedt::order[0]=1;
920: $Apache::lonratedt::resources[1]='';
921: }
922: if ($fatal) {
923: $r->print('<p><font color="red">'.$errtext.'</font></p>');
924: } else {
925: # ------------------------------------------------------------ Process commands
926:
927: # ---------------- if they are for this folder and user allowed to make changes
928: if (($allowed) && ($ENV{'form.folder'} eq $folder)) {
929: # set parameters and change order
930: if (defined($ENV{'form.setparms'})) {
931: my $idx=$ENV{'form.setparms'};
932: # set parameters
933: if ($ENV{'form.randpick_'.$idx}) {
934: &Apache::lonratedt::storeparameter($idx,'parameter_randompick',$ENV{'form.randpick_'.$idx},'int_pos');
935: } else {
936: &Apache::lonratedt::delparameter($idx,'parameter_randompick');
937: }
938: if ($ENV{'form.hidprs_'.$idx}) {
939: &Apache::lonratedt::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno');
940: } else {
941: &Apache::lonratedt::delparameter($idx,'parameter_hiddenresource');
942: }
943: if ($ENV{'form.encprs_'.$idx}) {
944: &Apache::lonratedt::storeparameter($idx,'parameter_encrypturl','yes','string_yesno');
945: } else {
946: &Apache::lonratedt::delparameter($idx,'parameter_encrypturl');
947: }
948:
949: if ($ENV{'form.newpos'}) {
950: # change order
951:
952: my $newpos=$ENV{'form.newpos'}-1;
953: my $currentpos=$ENV{'form.currentpos'}-1;
954: my $i;
955: my @neworder=();
956: if ($newpos>$currentpos) {
957: # moving stuff up
958: for ($i=0;$i<$currentpos;$i++) {
959: $neworder[$i]=$Apache::lonratedt::order[$i];
960: }
961: for ($i=$currentpos;$i<$newpos;$i++) {
962: $neworder[$i]=$Apache::lonratedt::order[$i+1];
963: }
964: $neworder[$newpos]=$Apache::lonratedt::order[$currentpos];
965: for ($i=$newpos+1;$i<=$#Apache::lonratedt::order;$i++) {
966: $neworder[$i]=$Apache::lonratedt::order[$i];
967: }
968: } else {
969: # moving stuff down
970: for ($i=0;$i<$newpos;$i++) {
971: $neworder[$i]=$Apache::lonratedt::order[$i];
972: }
973: $neworder[$newpos]=$Apache::lonratedt::order[$currentpos];
974: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
975: $neworder[$i]=$Apache::lonratedt::order[$i-1];
976: }
977: for ($i=$currentpos+1;$i<=$#Apache::lonratedt::order;$i++) {
978: $neworder[$i]=$Apache::lonratedt::order[$i];
979: }
980: }
981: @Apache::lonratedt::order=@neworder;
982: }
983: # store the changed version
984:
985: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
986: if ($fatal) {
987: $r->print('<p><font color="red">'.$errtext.'</font></p>');
988: return;
989: }
990:
991: }
992:
993: # upload a file, if present
994: if (($ENV{'form.uploaddoc.filename'}) &&
995: ($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
996: if ( ($folder=~/^$1/) || ($1 eq 'default') ) {
997: # this is for a course, not a user, so set coursedoc flag
998: # probably the only place in the system where this should be "1"
999: my $url=&Apache::lonnet::userfileupload('uploaddoc',1,'docs');
1000: my $ext='false';
1001: if ($url=~/^http\:\/\//) { $ext='true'; }
1002: $url=~s/\:/\:/g;
1003: my $comment=$ENV{'form.comment'};
1004: $comment=~s/\</\<\;/g;
1005: $comment=~s/\>/\>\;/g;
1006: $comment=~s/\:/\:/g;
1007: if ($folder=~/^supplemental/) {
1008: $comment=time.'___&&&___'.$ENV{'user.name'}.'___&&&___'.
1009: $ENV{'user.domain'}.'___&&&___'.$comment;
1010: }
1011: my $newidx=$#Apache::lonratedt::resources+1;
1012: $Apache::lonratedt::resources[$newidx]=
1013: $comment.':'.$url.':'.$ext.':normal:res';
1014: $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=
1015: $newidx;
1016:
1017: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
1018: if ($fatal) {
1019: $r->print('<p><font color="red">'.$errtext.'</font></p>');
1020: return;
1021: }
1022: }
1023: }
1024: if ($ENV{'form.cmd'}) {
1025: my ($cmd,$idx)=split(/\_/,$ENV{'form.cmd'});
1026: if ($cmd eq 'del') {
1027: my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]);
1028: if ($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) {
1029: &Apache::lonnet::removeuploadedurl($url);
1030: }
1031: for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) {
1032: $Apache::lonratedt::order[$i]=
1033: $Apache::lonratedt::order[$i+1];
1034: }
1035: $#Apache::lonratedt::order--;
1036: } elsif ($cmd eq 'up') {
1037: if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) {
1038: my $i=$Apache::lonratedt::order[$idx-1];
1039: $Apache::lonratedt::order[$idx-1]=
1040: $Apache::lonratedt::order[$idx];
1041: $Apache::lonratedt::order[$idx]=$i;
1042: }
1043: } elsif ($cmd eq 'down') {
1044: if (defined($Apache::lonratedt::order[$idx+1])) {
1045: my $i=$Apache::lonratedt::order[$idx+1];
1046: $Apache::lonratedt::order[$idx+1]=
1047: $Apache::lonratedt::order[$idx];
1048: $Apache::lonratedt::order[$idx]=$i;
1049: }
1050: } elsif ($cmd eq 'rename') {
1051: my $ratstr = $Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]];
1052: my ($rtitle,@rrest)=split(/\:/,
1053: $Apache::lonratedt::resources[
1054: $Apache::lonratedt::order[$idx]]);
1055: my $comment=
1056: &HTML::Entities::decode($ENV{'form.title'});
1057: $comment=~s/\</\<\;/g;
1058: $comment=~s/\>/\>\;/g;
1059: $comment=~s/\:/\:/g;
1060: if ($comment=~/\S/) {
1061: $Apache::lonratedt::resources[
1062: $Apache::lonratedt::order[$idx]]=
1063: $comment.':'.join(':',@rrest);
1064: }
1065: }
1066: # Store the changed version
1067: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1068: $folder.'.'.$container);
1069: if ($fatal) {
1070: $r->print('<p><font color="red">'.$errtext.'</font></p>');
1071: return;
1072: }
1073: }
1074: # Group import/search
1075: if ($ENV{'form.importdetail'}) {
1076: my @imports;
1077: foreach (split(/\&/,$ENV{'form.importdetail'})) {
1078: if (defined($_)) {
1079: my ($name,$url)=split(/\=/,$_);
1080: $name=&Apache::lonnet::unescape($name);
1081: $url=&Apache::lonnet::unescape($url);
1082: push @imports, $name, $url;
1083: }
1084: }
1085: # Store the changed version
1086: ($errtext,$fatal)=group_import($coursenum, $coursedom, $folder,
1087: $container,'londocs',@imports);
1088: if ($fatal) {
1089: $r->print('<p><font color="red">'.$errtext.'</font></p>');
1090: return;
1091: }
1092: }
1093: # Loading a complete map
1094: if (($ENV{'form.importmap'}) && ($ENV{'form.loadmap'})) {
1095: foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) {
1096: my $idx=$#Apache::lonratedt::resources;
1097: $idx++;
1098: $Apache::lonratedt::resources[$idx]=$_;
1099: $Apache::lonratedt::order
1100: [$#Apache::lonratedt::order+1]=$idx;
1101: }
1102:
1103: # Store the changed version
1104: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1105: $folder.'.'.$container);
1106: if ($fatal) {
1107: $r->print('<p><font color="red">'.$errtext.'</font></p>');
1108: return;
1109: }
1110: }
1111: }
1112: # ---------------------------------------------------------------- End commands
1113: # ---------------------------------------------------------------- Print screen
1114: my $idx=0;
1115: my $shown=0;
1116: $r->print('<table>');
1117: foreach (@Apache::lonratedt::order) {
1118: my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]);
1119: unless ($name) { $name=(split(/\//,$url))[-1]; }
1120: unless ($name) { $idx++; next; }
1121: $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum));
1122: $idx++;
1123: $shown++;
1124: }
1125: unless ($shown) {
1126: $r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
1127: }
1128: $r->print('</table>');
1129: }
1130: }
1131:
1132: # --------------------------------------------------------------- An entry line
1133:
1134: sub entryline {
1135: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
1136: $title=~s/\&colon\;/\:/g;
1137: $title=&HTML::Entities::encode(&HTML::Entities::decode(
1138: &Apache::lonnet::unescape($title)),'"<>&\'');
1139: my $renametitle=$title;
1140: my $foldertitle=$title;
1141: my $pagetitle=$title;
1142: my $orderidx=$Apache::lonratedt::order[$index];
1143: if ($title=~ /^(\d+)___&&&___(\w+)___&&&___(\w+)___&&&___(.*)$/ ) {
1144: $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
1145: $renametitle=$4;
1146: $title='<i>'.&Apache::lonlocal::locallocaltime($1).'</i> '.
1147: &Apache::loncommon::plainname($2,$3).': <br />'.
1148: $foldertitle;
1149: }
1150: $renametitle=~s/\"\;/\\\"/g;
1151: my $line='<tr>';
1152: # Edit commands
1153: my $container;
1154: my $folderpath;
1155: if ($ENV{'form.folderpath'}) {
1156: $container = 'sequence';
1157: $folderpath=&Apache::lonnet::escape($ENV{'form.folderpath'});
1158: # $htmlfoldername=&HTML::Entities::encode($ENV{'form.foldername'},'<>&"');
1159: }
1160: my ($pagepath,$pagesymb);
1161: if ($ENV{'form.pagepath'}) {
1162: $container = 'page';
1163: $pagepath=&Apache::lonnet::escape($ENV{'form.pagepath'});
1164: $pagesymb=&Apache::lonnet::escape($ENV{'form.pagesymb'});
1165: }
1166: if ($allowed) {
1167: my $incindex=$index+1;
1168: my $selectbox='';
1169: if ($folder!~/^supplemental/) {
1170: $selectbox=
1171: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1172: '<select name="newpos" onChange="this.form.submit()">';
1173: for (my $i=1;$i<=$#Apache::lonratedt::order+1;$i++) {
1174: if ($i==$incindex) {
1175: $selectbox.='<option value="" selected="1">('.$i.')</option>';
1176: } else {
1177: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
1178: }
1179: }
1180: $selectbox.='</select>';
1181: }
1182: my %lt=&Apache::lonlocal::texthash(
1183: 'up' => 'Move Up',
1184: 'dw' => 'Move Down',
1185: 'rm' => 'Remove',
1186: 'rn' => 'Rename');
1187: if ($ENV{'form.pagepath'}) {
1188: $line.=(<<END);
1189: <form name="entry_$index" action="/adm/coursedocs" method="post">
1190: <input type="hidden" name="pagepath" value="$ENV{'form.pagepath'}" />
1191: <input type="hidden" name="pagesymb" value="$ENV{'form.pagesymb'}" />
1192: <input type="hidden" name="setparms" value="$orderidx" />
1193: <td><table border='0' cellspacing='2' cellpadding='0'>
1194: <tr><td bgcolor="#DDDDDD">
1195: <a href='/adm/coursedocs?cmd=up_$index&pagepath=$pagepath&pagesymb=$pagesymb'>
1196: <img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr>
1197: <tr><td bgcolor="#DDDDDD">
1198: <a href='/adm/coursedocs?cmd=down_$index&pagepath=$pagepath&pagesymb=$pagesymb'>
1199: <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr>
1200: </table></td>
1201: <td>$selectbox
1202: </td><td bgcolor="#DDDDDD">
1203: <a href='javascript:removeres("$pagepath","$index","$renametitle","page","$pagesymb");'>
1204: <font size="-2" color="#990000">$lt{'rm'}</font></a>
1205: <a href='javascript:changename("$pagepath","$index","$renametitle","page","$pagesymb");'>
1206: <font size="-2" color="#009900">$lt{'rn'}</font></a></td>
1207: END
1208: } else {
1209: $line.=(<<END);
1210: <form name="entry_$index" action="/adm/coursedocs" method="post">
1211: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
1212: <input type="hidden" name="setparms" value="$orderidx" />
1213: <td><table border='0' cellspacing='2' cellpadding='0'>
1214: <tr><td bgcolor="#DDDDDD">
1215: <a href='/adm/coursedocs?cmd=up_$index&folderpath=$folderpath'>
1216: <img src="${iconpath}move_up.gif" alt='$lt{'up'}' border='0' /></a></td></tr>
1217: <tr><td bgcolor="#DDDDDD">
1218: <a href='/adm/coursedocs?cmd=down_$index&folderpath=$folderpath'>
1219: <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' border='0' /></a></td></tr>
1220: </table></td>
1221: <td>$selectbox
1222: </td><td bgcolor="#DDDDDD">
1223: <a href='javascript:removeres("$folderpath","$index","$renametitle","sequence");'>
1224: <font size="-2" color="#990000">$lt{'rm'}</font></a>
1225: <a href='javascript:changename("$folderpath","$index","$renametitle","sequence");'>
1226: <font size="-2" color="#009900">$lt{'rn'}</font></a></td>
1227: END
1228: }
1229: }
1230: # Figure out what kind of a resource this is
1231: my ($extension)=($url=~/\.(\w+)$/);
1232: my $uploaded=($url=~/^\/*uploaded\//);
1233: my $icon=&Apache::loncommon::icon($url);
1234: my $isfolder=0;
1235: my $ispage=0;
1236: my $folderarg;
1237: my $pagearg;
1238: my $pagefile;
1239: if ($uploaded) {
1240: if ($extension eq 'sequence') {
1241: $icon=$iconpath.'/folder_closed.gif';
1242: $url=~/$coursenum\/([\/\w]+)\.sequence$/;
1243: $url='/adm/coursedocs?';
1244: $folderarg=$1;
1245: $isfolder=1;
1246: } elsif ($extension eq 'page') {
1247: $icon=$iconpath.'/page.gif';
1248: $url=~/$coursenum\/([\/\w]+)\.page$/;
1249: $pagearg=$1;
1250: $url='/adm/coursedocs?';
1251: $ispage=1;
1252: } else {
1253: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
1254: }
1255: }
1256: $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//;
1257: if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
1258: my $symb=&Apache::lonnet::symbclean(
1259: &Apache::lonnet::declutter('uploaded/'.
1260: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'.
1261: $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/'.$folder.
1262: '.sequence').
1263: '___'.$residx.'___'.
1264: &Apache::lonnet::declutter($url));
1265: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
1266: $url=&Apache::lonnet::clutter($url);
1267: if ($url=~/^\/*uploaded\//) {
1268: $url=~/\.(\w+)$/;
1269: my $embstyle=&Apache::loncommon::fileembstyle($1);
1270: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
1271: $url='/adm/wrapper'.$url;
1272: } elsif ($embstyle eq 'ssi') {
1273: #do nothing with these
1274: } elsif ($url!~/\.(sequence|page)$/) {
1275: $url='/adm/coursedocs/showdoc'.$url;
1276: }
1277: } elsif ($url=~m|^/ext/|) {
1278: $url='/adm/wrapper'.$url;
1279: }
1280: $url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb);
1281: if ($container eq 'page') {
1282: my $symb=$ENV{'form.pagesymb'};
1283:
1284: $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
1285: $url.=(($url=~/\?/)?'&':'?').'symb='.&Apache::lonnet::escape($symb);
1286: }
1287: }
1288: my $parameterset=' ';
1289: if ($isfolder) {
1290: my $foldername=&Apache::lonnet::escape($foldertitle);
1291: my $folderpath=$ENV{'form.folderpath'};
1292: if ($folderpath) { $folderpath.='&' };
1293: $folderpath.=$folderarg.'&'.$foldername;
1294: $url.='folderpath='.&Apache::lonnet::escape($folderpath);
1295: $parameterset='<label>'.&mt('Randomly Pick: ').
1296: '<input type="text" size="4" name="randpick_'.$orderidx.'" value="'.
1297: (&Apache::lonratedt::getparameter($orderidx,
1298: 'parameter_randompick'))[0].
1299: '" />'.'</label>';
1300:
1301: }
1302: if ($ispage) {
1303: my $pagename=&Apache::lonnet::escape($pagetitle);
1304: my $pagepath;
1305: my $folderpath=$ENV{'form.folderpath'};
1306: if ($folderpath) { $pagepath = $folderpath.'&' };
1307: $pagepath.=$pagearg.'&'.$pagename;
1308: my $symb=$ENV{'form.pagesymb'};
1309: if (!$symb) {
1310: my $path='uploaded/'.
1311: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}.'/'.
1312: $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.'/';
1313: $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
1314: $residx,
1315: $path.$pagearg.'.page');
1316: }
1317: $url.='pagepath='.&Apache::lonnet::escape($pagepath).
1318: '&pagesymb='.&Apache::lonnet::escape($symb);
1319: }
1320: $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="'.$icon.
1321: '" border="0"></a></td>'.
1322: "<td bgcolor='#FFFFBB'><a href='$url'>$title</a></td>";
1323: if (($allowed) && ($folder!~/^supplemental/)) {
1324: my %lt=&Apache::lonlocal::texthash(
1325: 'hd' => 'Hidden',
1326: 'ec' => 'URL hidden',
1327: 'sp' => 'Store Parameters');
1328: my $enctext=
1329: ((&Apache::lonratedt::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':'');
1330: my $hidtext=
1331: ((&Apache::lonratedt::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':'');
1332: $line.=(<<ENDPARMS);
1333: <td bgcolor="#BBBBFF"><font size='-2'>
1334: <nobr><label><input type="checkbox" name="hidprs_$orderidx" $hidtext/> $lt{'hd'}</label></nobr></td>
1335: <td bgcolor="#BBBBFF"><font size='-2'>
1336: <nobr><label><input type="checkbox" name="encprs_$orderidx" $enctext/> $lt{'ec'}</label></nobr></td>
1337: <td bgcolor="#BBBBFF"><font size="-2">$parameterset</font></td>
1338: <td bgcolor="#BBBBFF"><font size='-2'>
1339: <input type="submit" value="$lt{'sp'}" />
1340: </font></td>
1341: ENDPARMS
1342: }
1343: $line.="</form></tr>";
1344: return $line;
1345: }
1346:
1347: # ---------------------------------------------------------------- tie the hash
1348:
1349: sub tiehash {
1350: my ($mode)=@_;
1351: $hashtied=0;
1352: if ($ENV{'request.course.fn'}) {
1353: if ($mode eq 'write') {
1354: if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
1355: &GDBM_WRCREAT(),0640)) {
1356: $hashtied=2;
1357: }
1358: } else {
1359: if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.".db",
1360: &GDBM_READER(),0640)) {
1361: $hashtied=1;
1362: }
1363: }
1364: }
1365: }
1366:
1367: sub untiehash {
1368: if ($hashtied) { untie %hash; }
1369: $hashtied=0;
1370: }
1371:
1372: # --------------------------------------------------------------- check on this
1373:
1374: sub checkonthis {
1375: my ($r,$url,$level,$title)=@_;
1376: $url=&Apache::lonnet::unescape($url);
1377: $alreadyseen{$url}=1;
1378: $r->rflush();
1379: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
1380: $r->print("\n<br />");
1381: for (my $i=0;$i<=$level*5;$i++) {
1382: $r->print(' ');
1383: }
1384: $r->print('<a href="'.$url.'" target="cat">'.
1385: ($title?$title:$url).'</a> ');
1386: if ($url=~/^\/res\//) {
1387: my $result=&Apache::lonnet::repcopy(
1388: &Apache::lonnet::filelocation('',$url));
1389: if ($result==OK) {
1390: $r->print('<font color="green">'.&mt('ok').'</font>');
1391: $r->rflush();
1392: &Apache::lonnet::countacc($url);
1393: $url=~/\.(\w+)$/;
1394: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
1395: $r->print('<br />');
1396: $r->rflush();
1397: for (my $i=0;$i<=$level*5;$i++) {
1398: $r->print(' ');
1399: }
1400: $r->print('- '.&mt('Rendering').': ');
1401: my $oldpath=$ENV{'request.filename'};
1402: $ENV{'request.filename'}=&Apache::lonnet::filelocation('',$url);
1403: &Apache::lonxml::xmlparse($r,'web',
1404: &Apache::lonnet::getfile(
1405: &Apache::lonnet::filelocation('',$url)));
1406: undef($Apache::lonhomework::parsing_a_problem);
1407: $ENV{'request.filename'}=$oldpath;
1408: if (($Apache::lonxml::errorcount) ||
1409: ($Apache::lonxml::warningcount)) {
1410: if ($Apache::lonxml::errorcount) {
1411: $r->print('<img src="/adm/lonMisc/bomb.gif" /><font color="red"><b>'.
1412: $Apache::lonxml::errorcount.' '.
1413: &mt('error(s)').'</b></font> ');
1414: }
1415: if ($Apache::lonxml::warningcount) {
1416: $r->print('<font color="blue">'.
1417: $Apache::lonxml::warningcount.' '.
1418: &mt('warning(s)').'</font>');
1419: }
1420: } else {
1421: $r->print('<font color="green">'.&mt('ok').'</font>');
1422: }
1423: $r->rflush();
1424: }
1425: my $dependencies=
1426: &Apache::lonnet::metadata($url,'dependencies');
1427: foreach (split(/\,/,$dependencies)) {
1428: if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
1429: &checkonthis($r,$_,$level+1);
1430: }
1431: }
1432: } elsif ($result==HTTP_SERVICE_UNAVAILABLE) {
1433: $r->print('<font color="red"><b>'.&mt('connection down').'</b></font>');
1434: } elsif ($result==HTTP_NOT_FOUND) {
1435: unless ($url=~/\$/) {
1436: $r->print('<font color="red"><b>'.&mt('not found').'</b></font>');
1437: } else {
1438: $r->print('<font color="yellow"><b>'.&mt('unable to verify variable URL').'</b></font>');
1439: }
1440: } else {
1441: $r->print('<font color="red"><b>'.&mt('access denied').'</b></font>');
1442: }
1443: }
1444: }
1445: }
1446:
1447:
1448: #
1449: # -------------------------------------------------------------- Verify Content
1450: #
1451: sub verifycontent {
1452: my $r=shift;
1453: my $loaderror=&Apache::lonnet::overloaderror($r);
1454: if ($loaderror) { return $loaderror; }
1455:
1456: $r->print('<html><head><title>Verify Content</title></head>'.
1457: &Apache::loncommon::bodytag('Verify Course Documents'));
1458: $hashtied=0;
1459: undef %alreadyseen;
1460: %alreadyseen=();
1461: &tiehash();
1462: foreach (keys %hash) {
1463: if ($hash{$_}=~/\.(page|sequence)$/) {
1464: if (($_=~/^src_/) && ($alreadyseen{&Apache::lonnet::unescape($hash{$_})})) {
1465: $r->print('<hr /><font color="red">'.
1466: &mt('The following sequence or page is included more than once in your course: ').
1467: &Apache::lonnet::unescape($hash{$_}).'</font><br />'.
1468: &mt('Note that grading records for problems included in this sequence or folder will overlap.<hr />'));
1469: }
1470: }
1471: if (($_=~/^src\_(.+)$/) && (!$alreadyseen{&Apache::lonnet::unescape($hash{$_})})) {
1472: &checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
1473: }
1474: }
1475: &untiehash();
1476: $r->print('<h1>'.&mt('Done').'.</h1>'.'<a href="/adm/coursedocs">'.
1477: &mt('Return to DOCS').'</a>');
1478: }
1479:
1480: # -------------------------------------------------------------- Check Versions
1481:
1482: sub checkversions {
1483: my $r=shift;
1484: $r->print('<html><head><title>Check Versions</title></head>'.
1485: &Apache::loncommon::bodytag('Check Course Document Versions'));
1486: my $header='';
1487: my $startsel='';
1488: my $monthsel='';
1489: my $weeksel='';
1490: my $daysel='';
1491: my $allsel='';
1492: my %changes=();
1493: my $starttime=0;
1494: my $haschanged=0;
1495: my %setversions=&Apache::lonnet::dump('resourceversions',
1496: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1497: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1498:
1499: $hashtied=0;
1500: &tiehash();
1501: my %newsetversions=();
1502: if ($ENV{'form.setmostrecent'}) {
1503: $haschanged=1;
1504: foreach (keys %hash) {
1505: if ($_=~/^ids\_(\/res\/.+)$/) {
1506: $newsetversions{$1}='mostrecent';
1507: }
1508: }
1509: } elsif ($ENV{'form.setcurrent'}) {
1510: $haschanged=1;
1511: foreach (keys %hash) {
1512: if ($_=~/^ids\_(\/res\/.+)$/) {
1513: my $getvers=&Apache::lonnet::getversion($1);
1514: if ($getvers>0) {
1515: $newsetversions{$1}=$getvers;
1516: }
1517: }
1518: }
1519: } elsif ($ENV{'form.setversions'}) {
1520: $haschanged=1;
1521: foreach (keys %ENV) {
1522: if ($_=~/^form\.set_version_(.+)$/) {
1523: my $src=$1;
1524: if (($ENV{$_}) && ($ENV{$_} ne $setversions{$src})) {
1525: $newsetversions{$src}=$ENV{$_};
1526: }
1527: }
1528: }
1529: }
1530: if ($haschanged) {
1531: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
1532: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1533: $ENV{'course.'.$ENV{'request.course.id'}.'.num'}) eq 'ok') {
1534: $r->print('<h1>'.&mt('Your Version Settings have been Stored').'</h1>');
1535: } else {
1536: $r->print('<h1><font color="red">'.&mt('An Error Occured while Attempting to Store your Version Settings').'</font></h1>');
1537: }
1538: &mark_hash_old();
1539: }
1540: &changewarning($r,'');
1541: if ($ENV{'form.timerange'} eq 'all') {
1542: # show all documents
1543: $header=&mt('All Documents in Course');
1544: $allsel=1;
1545: foreach (keys %hash) {
1546: if ($_=~/^ids\_(\/res\/.+)$/) {
1547: my $src=$1;
1548: $changes{$src}=1;
1549: }
1550: }
1551: } else {
1552: # show documents which changed
1553: %changes=&Apache::lonnet::dump
1554: ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1555: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1556: my $firstkey=(keys %changes)[0];
1557: unless ($firstkey=~/^error\:/) {
1558: unless ($ENV{'form.timerange'}) {
1559: $ENV{'form.timerange'}=604800;
1560: }
1561: my $seltext=&mt('during the last').' '.$ENV{'form.timerange'}.' '
1562: .&mt('seconds');
1563: if ($ENV{'form.timerange'}==-1) {
1564: $seltext='since start of course';
1565: $startsel='selected';
1566: $ENV{'form.timerange'}=time;
1567: }
1568: $starttime=time-$ENV{'form.timerange'};
1569: if ($ENV{'form.timerange'}==2592000) {
1570: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1571: $monthsel='selected';
1572: } elsif ($ENV{'form.timerange'}==604800) {
1573: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1574: $weeksel='selected';
1575: } elsif ($ENV{'form.timerange'}==86400) {
1576: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1577: $daysel='selected';
1578: }
1579: $header=&mt('Content changed').' '.$seltext;
1580: } else {
1581: $header=&mt('No content modifications yet.');
1582: }
1583: }
1584: %setversions=&Apache::lonnet::dump('resourceversions',
1585: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
1586: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1587: my %lt=&Apache::lonlocal::texthash
1588: ('st' => 'Version changes since start of Course',
1589: 'lm' => 'Version changes since last Month',
1590: 'lw' => 'Version changes since last Week',
1591: 'sy' => 'Version changes since Yesterday',
1592: 'al' => 'All Resources (possibly large output)',
1593: 'sd' => 'Display',
1594: 'fi' => 'File',
1595: 'md' => 'Modification Date',
1596: 'mr' => 'Most recently published Version',
1597: 've' => 'Version used in Course',
1598: 'vu' => 'Set Version to be used in Course',
1599: 'sv' => 'Set Versions to be used in Course according to Selections below',
1600: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
1601: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1602: 'di' => 'Differences');
1603: $r->print(<<ENDHEADERS);
1604: <form action="/adm/coursedocs" method="post">
1605: <input type="hidden" name="versions" value="1" />
1606: <input type="submit" name="setmostrecent" value="$lt{'sm'}" />
1607: <input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr />
1608: <select name="timerange">
1609: <option value='all' $allsel>$lt{'al'}</option>
1610: <option value="-1" $startsel>$lt{'st'}</option>
1611: <option value="2592000" $monthsel>$lt{'lm'}</option>
1612: <option value="604800" $weeksel>$lt{'lw'}</option>
1613: <option value="86400" $daysel>$lt{'sy'}</option>
1614: </select>
1615: <input type="submit" name="display" value="$lt{'sd'}" />
1616: <h3>$header</h3>
1617: <input type="submit" name="setversions" value="$lt{'sv'}" />
1618: <table border="0">
1619: ENDHEADERS
1620: foreach (sort keys %changes) {
1621: if ($changes{$_}>$starttime) {
1622: my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
1623: my $currentversion=&Apache::lonnet::getversion($_);
1624: if ($currentversion<0) {
1625: $currentversion=&mt('Could not be determined.');
1626: }
1627: my $linkurl=&Apache::lonnet::clutter($_);
1628: $r->print(
1629: '<tr><td colspan="5"><br /><br /><font size="+1"><b>'.
1630: &Apache::lonnet::gettitle($linkurl).
1631: '</b></font></td></tr>'.
1632: '<tr><td> </td>'.
1633: '<td colspan="4">'.
1634: '<a href="'.$linkurl.'" target="cat">'.$linkurl.
1635: '</a></td></tr>'.
1636: '<tr><td></td>'.
1637: '<td title="'.$lt{'md'}.'">'.
1638: &Apache::lonlocal::locallocaltime(
1639: &Apache::lonnet::metadata($root.'.'.$extension,
1640: 'lastrevisiondate')
1641: ).
1642: '</td>'.
1643: '<td title="'.$lt{'mr'}.'"><nobr>Most Recent: '.
1644: '<font size="+1">'.$currentversion.'</font>'.
1645: '</nobr></td>'.
1646: '<td title="'.$lt{'ve'}.'"><nobr>In Course: '.
1647: '<font size="+1">');
1648: # Used in course
1649: my $usedversion=$hash{'version_'.$linkurl};
1650: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1651: $r->print($usedversion);
1652: } else {
1653: $r->print($currentversion);
1654: }
1655: $r->print('</font></nobr></td><td title="'.$lt{'vu'}.'">'.
1656: '<nobr>Use: ');
1657: # Set version
1658: $r->print(&Apache::loncommon::select_form($setversions{$linkurl},
1659: 'set_version_'.$linkurl,
1660: ('select_form_order' =>
1661: ['',1..$currentversion,'mostrecent'],
1662: '' => '',
1663: 'mostrecent' => 'most recent',
1664: map {$_,$_} (1..$currentversion))));
1665: $r->print('</nobr></td></tr><tr><td></td>');
1666: my $lastold=1;
1667: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
1668: my $url=$root.'.'.$prevvers.'.'.$extension;
1669: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
1670: $starttime) {
1671: $lastold=$prevvers;
1672: }
1673: }
1674: #
1675: # Code to figure out how many version entries should go in
1676: # each of the four columns
1677: my $entries_per_col = 0;
1678: my $num_entries = ($currentversion-$lastold);
1679: if ($num_entries % 4 == 0) {
1680: $entries_per_col = $num_entries/4;
1681: } else {
1682: $entries_per_col = $num_entries/4 + 1;
1683: }
1684: my $entries_count = 0;
1685: $r->print('<td valign="top"><font size="-2">');
1686: my $cols_output = 1;
1687: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
1688: my $url=$root.'.'.$prevvers.'.'.$extension;
1689: $r->print('<nobr><a href="'.&Apache::lonnet::clutter($url).
1690: '">'.&mt('Version').' '.$prevvers.'</a> ('.
1691: &Apache::lonlocal::locallocaltime(
1692: &Apache::lonnet::metadata($url,
1693: 'lastrevisiondate')
1694: ).
1695: ')');
1696: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
1697: $r->print(' <a href="/adm/diff?filename='.
1698: &Apache::lonnet::clutter($root.'.'.$extension).
1699: '&versionone='.$prevvers.
1700: '">'.&mt('Diffs').'</a>');
1701: }
1702: $r->print('</nobr><br />');
1703: if (++$entries_count % $entries_per_col == 0) {
1704: $r->print('</font></td>');
1705: if ($cols_output != 4) {
1706: $r->print('<td valign="top"><font size="-2">');
1707: $cols_output++;
1708: }
1709: }
1710: }
1711: while($cols_output++ < 4) {
1712: $r->print('</font></td><td><font>')
1713: }
1714: $r->print('</font></td></tr>'."\n");
1715: }
1716: }
1717: $r->print('</table></form>');
1718: $r->print('<h1>'.&mt('Done').'.</h1>');
1719:
1720: &untiehash();
1721: }
1722:
1723: sub mark_hash_old {
1724: my $retie_hash=0;
1725: if ($hashtied) {
1726: $retie_hash=1;
1727: &untiehash();
1728: }
1729: &tiehash('write');
1730: $hash{'old'}=1;
1731: &untiehash();
1732: if ($retie_hash) { &tiehash(); }
1733: }
1734:
1735: sub is_hash_old {
1736: my $untie_hash=0;
1737: if (!$hashtied) {
1738: $untie_hash=1;
1739: &tiehash();
1740: }
1741: my $return=$hash{'old'};
1742: if ($untie_hash) { &untiehash(); }
1743: return $return;
1744: }
1745:
1746: sub changewarning {
1747: my ($r,$postexec)=@_;
1748: if (!&is_hash_old()) { return; }
1749: my $pathvar='folderpath';
1750: my $path=&Apache::lonnet::escape($ENV{'form.folderpath'});
1751: if (defined($ENV{'form.pagepath'})) {
1752: $pathvar='pagepath';
1753: $path=&Apache::lonnet::escape($ENV{'form.pagepath'});
1754: $path.='&symb='.&Apache::lonnet::escape($ENV{'form.pagesymb'});
1755: }
1756: $r->print(
1757: '<script>function reinit(tf) { tf.submit();'.$postexec.' }</script>'.
1758: '<form method="post" action="/adm/roles" target="loncapaclient">'.
1759: '<input type="hidden" name="orgurl" value="/adm/coursedocs?'.
1760: $pathvar.'='.$path.
1761: '" /><input type="hidden" name="selectrole" value="1" /><h3><font color="red">'.
1762: &mt('Changes will become active for your current session after').
1763: ' <input type="hidden" name="'.
1764: $ENV{'request.role'}.'" value="1" /><input type="button" value="'.
1765: &mt('re-initializing course').'" onClick="reinit(this.form)"/>'.&mt(', or the next time you log in.').
1766: $help{'Caching'}.'</font></h3></form>');
1767: }
1768:
1769: # ================================================================ Main Handler
1770: sub handler {
1771: my $r = shift;
1772: &Apache::loncommon::content_type($r,'text/html');
1773: $r->send_http_header;
1774: return OK if $r->header_only;
1775:
1776: # --------------------------------------------- Initialize help topics for this
1777: foreach ('Adding_Course_Doc','Main_Course_Documents',
1778: 'Adding_External_Resource','Navigate_Content',
1779: 'Adding_Folders','Docs_Overview', 'Load_Map',
1780: 'Supplemental','Score_Upload_Form','Adding_Pages',
1781: 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
1782: 'Check_Resource_Versions','Verify_Content') {
1783: $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
1784: }
1785: # Composite help files
1786: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
1787: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
1788: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
1789: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
1790: $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
1791: 'Option_Response_Simple');
1792: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
1793: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1794: $help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
1795: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1796: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1797:
1798: if ($ENV{'form.verify'}) {
1799: &verifycontent($r);
1800: } elsif ($ENV{'form.versions'}) {
1801: &checkversions($r);
1802: } elsif ($ENV{'form.dumpcourse'}) {
1803: &dumpcourse($r);
1804: } elsif ($ENV{'form.exportcourse'}) {
1805: &exportcourse($r);
1806: } else {
1807: # is this a standard course?
1808:
1809: my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
1810: my $forcestandard = 0;
1811: my $forcesupplement;
1812: my $script='';
1813: my $allowed;
1814: my $events='';
1815: my $showdoc=0;
1816: my $containertag;
1817: my $uploadtag;
1818: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1819: ['folderpath','pagepath','pagesymb']);
1820: if ($ENV{'form.folderpath'}) {
1821: my (@folderpath)=split('&',$ENV{'form.folderpath'});
1822: $ENV{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath));
1823: $ENV{'form.folder'}=pop(@folderpath);
1824: }
1825: if ($ENV{'form.pagepath'}) {
1826: my (@pagepath)=split('&',$ENV{'form.pagepath'});
1827: $ENV{'form.pagename'}=&Apache::lonnet::unescape(pop(@pagepath));
1828: $ENV{'form.folder'}=pop(@pagepath);
1829: $containertag = '<input type="hidden" name="pagepath" value="" />'.
1830: '<input type="hidden" name="pagesymb" value="" />';
1831: $uploadtag = '<input type="hidden" name="pagepath" value="'.$ENV{'form.pagepath'}.'" />'.
1832: '<input type="hidden" name="pagesymb" value="'.$ENV{'form.pagesymb'}.'" />';
1833: }
1834: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
1835: $showdoc='/'.$1;
1836: }
1837: unless ($showdoc) { # got called from remote
1838: if (($ENV{'form.folder'}=~/^default_/) ||
1839: ($ENV{'form.folder'} =~ m#^\d+/(pages|sequences)/#)) {
1840: $forcestandard = 1;
1841: }
1842: $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
1843:
1844: # does this user have privileges to post, etc?
1845: $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
1846: if ($allowed) {
1847: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
1848: $script=&Apache::lonratedt::editscript('simple');
1849: }
1850: } else { # got called in sequence from course
1851: $allowed=0;
1852: $script='</script>'.&Apache::lonmenu::registerurl(1,undef).'<script>';
1853: $events='onLoad="'.&Apache::lonmenu::loadevents.
1854: '" onUnload="'.&Apache::lonmenu::unloadevents.'"';
1855: }
1856:
1857: # get course data
1858: my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
1859: my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
1860:
1861: # get personal data
1862:
1863: my $uname=$ENV{'user.name'};
1864: my $udom=$ENV{'user.domain'};
1865: my $plainname=&Apache::lonnet::escape(
1866: &Apache::loncommon::plainname($uname,$udom));
1867:
1868: # graphics settings
1869:
1870: $iconpath = $r->dir_config('lonIconsURL') . "/";
1871:
1872: my $now=time;
1873:
1874: # print screen
1875: $r->print(<<ENDDOCUMENT);
1876: <html>
1877: <head>
1878: <title>The LearningOnline Network with CAPA</title>
1879: <script>
1880: $script
1881: </script>
1882: ENDDOCUMENT
1883: if ($allowed) {
1884: $r->print(<<ENDNEWSCRIPT);
1885: <script>
1886: function makenewfolder(targetform,folderseq) {
1887: var foldername=prompt('Name of New Folder','New Folder');
1888: if (foldername) {
1889: targetform.importdetail.value=foldername+"="+folderseq;
1890: targetform.submit();
1891: }
1892: }
1893:
1894: function makenewpage(targetform,folderseq) {
1895: var pagename=prompt('Name of New Page','New Page');
1896: if (pagename) {
1897: targetform.importdetail.value=pagename+"="+folderseq;
1898: targetform.submit();
1899: }
1900: }
1901:
1902: function makenewext(targetname) {
1903: this.document.forms.extimport.useform.value=targetname;
1904: window.open('/adm/rat/extpickframe.html');
1905: }
1906:
1907: function makeexamupload() {
1908: var title=prompt('Listed Title for the Uploaded Score');
1909: if (title) {
1910: this.document.forms.newexamupload.importdetail.value=
1911: title+'=/res/lib/templates/examupload.problem';
1912: this.document.forms.newexamupload.submit();
1913: }
1914: }
1915:
1916: function makesmppage() {
1917: var title=prompt('Listed Title for the Page');
1918: if (title) {
1919: this.document.forms.newsmppg.importdetail.value=
1920: title+'=/adm/$udom/$uname/$now/smppg';
1921: this.document.forms.newsmppg.submit();
1922: }
1923: }
1924:
1925: function makesmpproblem() {
1926: var title=prompt('Listed Title for the Problem');
1927: if (title) {
1928: this.document.forms.newsmpproblem.importdetail.value=
1929: title+'=/res/lib/templates/simpleproblem.problem';
1930: this.document.forms.newsmpproblem.submit();
1931: }
1932: }
1933:
1934: function makebulboard() {
1935: var title=prompt('Listed Title for the Bulletin Board');
1936: if (title) {
1937: this.document.forms.newbul.importdetail.value=
1938: title+'=/adm/$udom/$uname/$now/bulletinboard';
1939: this.document.forms.newbul.submit();
1940: }
1941: }
1942:
1943: function makeabout() {
1944: var user=prompt("Enter user\@domain for User's 'About Me' Page");
1945: if (user) {
1946: var comp=new Array();
1947: comp=user.split('\@');
1948: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
1949: if ((comp[0]) && (comp[1])) {
1950: this.document.forms.newaboutsomeone.importdetail.value=
1951: 'About '+user+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1952: this.document.forms.newaboutsomeone.submit();
1953: }
1954: }
1955: }
1956: }
1957:
1958: function makeims() {
1959: var caller = document.forms.ims.folder.value
1960: var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one"
1961: newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes")
1962: newWindow.location.href = newlocation
1963: }
1964:
1965:
1966: function finishpick() {
1967: var title=this.document.forms.extimport.title.value;
1968: var url=this.document.forms.extimport.url.value;
1969: var form=this.document.forms.extimport.useform.value;
1970: eval
1971: ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
1972: '";this.document.forms.'+form+'.submit();');
1973: }
1974:
1975: function changename(folderpath,index,oldtitle,container,pagesymb) {
1976: var title=prompt('New Title',oldtitle);
1977: if (title) {
1978: this.document.forms.renameform.title.value=title;
1979: this.document.forms.renameform.cmd.value='rename_'+index;
1980: if (container == 'sequence') {
1981: this.document.forms.renameform.folderpath.value=folderpath;
1982: }
1983: if (container == 'page') {
1984: this.document.forms.renameform.pagepath.value=folderpath;
1985: this.document.forms.renameform.pagesymb.value=pagesymb;
1986: }
1987: this.document.forms.renameform.submit();
1988: }
1989: }
1990:
1991: function removeres(folderpath,index,oldtitle,container,pagesymb) {
1992: if (confirm('Remove "'+oldtitle+'"?')) {
1993: this.document.forms.renameform.cmd.value='del_'+index;
1994: if (container == 'sequence') {
1995: this.document.forms.renameform.folderpath.value=folderpath;
1996: }
1997: if (container == 'page') {
1998: this.document.forms.renameform.pagepath.value=folderpath;
1999: this.document.forms.renameform.pagesymb.value=pagesymb;
2000: }
2001: this.document.forms.renameform.submit();
2002: }
2003: }
2004:
2005: </script>
2006:
2007: ENDNEWSCRIPT
2008: }
2009: # -------------------------------------------------------------------- Body tag
2010: $r->print('</head>'.
2011: &Apache::loncommon::bodytag('Course Documents','',$events,
2012: '','',$showdoc).
2013: &Apache::loncommon::help_open_menu('','','','',273,'RAT'));
2014: unless ($showdoc) {
2015: # -----------------------------------------------------------------------------
2016: my %lt=&Apache::lonlocal::texthash(
2017: 'uplm' => 'Upload a new main course document',
2018: 'upls' => 'Upload a new supplemental course document',
2019: 'impp' => 'Import a published document',
2020: 'spec' => 'Special documents',
2021: 'upld' => 'Upload Document',
2022: 'srch' => 'Search',
2023: 'impo' => 'Import',
2024: 'selm' => 'Select Map',
2025: 'load' => 'Load Map',
2026: 'newf' => 'New Folder',
2027: 'newp' => 'New Composite Page',
2028: 'extr' => 'External Resource',
2029: 'syll' => 'Syllabus',
2030: 'navc' => 'Navigate Contents',
2031: 'sipa' => 'Simple Page',
2032: 'sipr' => 'Simple Problem',
2033: 'scuf' => 'Score Upload Form',
2034: 'bull' => 'Bulletin Board',
2035: 'mypi' => 'My Personal Info',
2036: 'abou' => 'About User',
2037: 'imsf' => 'Import IMS package',
2038: 'file' => 'File',
2039: 'title' => 'Title',
2040: 'comment' => 'Comment'
2041: );
2042: # -----------------------------------------------------------------------------
2043: if ($allowed) {
2044: my $dumpbut=&dumpbutton();
2045: my $exportbut=&exportbutton();
2046: my %lt=&Apache::lonlocal::texthash(
2047: 'vc' => 'Verify Content',
2048: 'cv' => 'Check/Set Resource Versions',
2049: );
2050:
2051: my $folderpath=$ENV{'form.folderpath'};
2052: if (!$folderpath) {
2053: if ($ENV{'form.folder'} eq '' ||
2054: $ENV{'form.folder'} eq 'supplemental') {
2055: $folderpath='default&'.
2056: &Apache::lonnet::escape(&mt('Main Course Documents'));
2057: }
2058: }
2059: unless ($ENV{'form.pagepath'}) {
2060: $containertag = '<input type="hidden" name="folderpath" value="" />';
2061: $uploadtag = '<input type="hidden" name="folderpath" value="'.$folderpath.'" />';
2062: }
2063:
2064: $r->print(<<ENDCOURSEVERIFY);
2065: <form name="renameform" method="post" action="/adm/coursedocs">
2066: <input type="hidden" name="title" />
2067: <input type="hidden" name="cmd" />
2068: $containertag
2069: </form>
2070: <form name="simpleedit" method="post" action="/adm/coursedocs">
2071: <input type=hidden name="importdetail" value="">
2072: $uploadtag
2073: </form>
2074: <form action="/adm/coursedocs" method="post" name="courseverify">
2075: <table bgcolor="#AAAAAA" width="100%" cellspacing="4" cellpadding="4">
2076: <tr><td bgcolor="#DDDDCC">
2077: <input type="submit" name="verify" value="$lt{'vc'}" />$help{'Verify_Content'}
2078: </td><td bgcolor="#DDDDCC">
2079: <input type="submit" name="versions" value="$lt{'cv'}" />$help{'Check_Resource_Versions'}
2080: $dumpbut
2081: $exportbut
2082: </td></tr></table>
2083: </form>
2084: ENDCOURSEVERIFY
2085: $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
2086: &mt('Editing the Table of Contents for your Course')));
2087: }
2088: # --------------------------------------------------------- Standard documents
2089: $r->print('<table border=2 cellspacing=4 cellpadding=4>');
2090: if (($standard) && ($allowed) && (!$forcesupplement)) {
2091: $r->print('<tr><td bgcolor="#BBBBBB">');
2092: # '<h2>'.&mt('Main Course Documents').
2093: # ($allowed?' '.$help{'Main_Course_Documents'}:'').'</h2>');
2094: my $folder=$ENV{'form.folder'};
2095: if ($folder eq '' || $folder eq 'supplemental') {
2096: $folder='default';
2097: $ENV{'form.folderpath'}='default&'.&Apache::lonnet::escape(&mt('Main Course Documents'));
2098: }
2099: my $postexec='';
2100: if ($folder eq 'default') {
2101: $r->print('<script>this.window.name="loncapaclient";</script>');
2102: } else {
2103: #$postexec='self.close();';
2104: }
2105: $hadchanges=0;
2106: &editor($r,$coursenum,$coursedom,$folder,$allowed);
2107: if ($hadchanges) {
2108: &mark_hash_old()
2109: }
2110: &changewarning($r,$postexec);
2111: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
2112: '.sequence';
2113: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
2114: '.page';
2115:
2116: $r->print(<<ENDFORM);
2117: <table cellspacing=4 cellpadding=4><tr>
2118: <th bgcolor="#DDDDDD">$lt{'uplm'}</th>
2119: <th bgcolor="#DDDDDD">$lt{'impp'}</th>
2120: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
2121: </tr>
2122: <tr><td bgcolor="#DDDDDD">
2123: $lt{'file'}:<br />
2124: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
2125: <input type="file" name="uploaddoc" size="40">
2126: <br />
2127: $lt{'title'}:<br />
2128: <input type="text" size="50" name="comment">
2129: $uploadtag
2130: <input type="hidden" name="cmd" value="upload_default">
2131: <nobr>
2132: <input type="submit" value="$lt{'upld'}">
2133: $help{'Uploading_From_Harddrive'}
2134: </nobr>
2135: </form>
2136: </td>
2137: <td bgcolor="#DDDDDD">
2138: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
2139: $uploadtag
2140: <input type=button onClick="javascript:groupsearch()" value="$lt{'srch'}">
2141: <nobr>
2142: <input type=button onClick="javascript:groupimport();" value="$lt{'impo'}">
2143: $help{'Importing_LON-CAPA_Resource'}
2144: </nobr>
2145: <p>
2146: <hr />
2147: <input type="text" size="20" name="importmap"><br />
2148: <nobr><input type=button
2149: onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
2150: value="$lt{'selm'}"> <input type="submit" name="loadmap" value="$lt{'load'}">
2151: $help{'Load_Map'}</nobr>
2152: </p>
2153: </form>
2154: </td>
2155: <td bgcolor="#DDDDDD">
2156: ENDFORM
2157: unless ($ENV{'form.pagepath'}) {
2158: $r->print(<<ENDFORM);
2159: <form action="/adm/coursedocs" method="post" name="newfolder">
2160: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
2161: <input type=hidden name="importdetail" value="">
2162: <nobr>
2163: <input name="newfolder" type="button"
2164: onClick="javascript:makenewfolder(this.form,'$folderseq');"
2165: value="$lt{'newf'}" />$help{'Adding_Folders'}
2166: </nobr>
2167: </form>
2168: <form action="/adm/coursedocs" method="post" name="newpage">
2169: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
2170: <input type=hidden name="importdetail" value="">
2171: <nobr>
2172: <input name="newpage" type="button"
2173: onClick="javascript:makenewpage(this.form,'$pageseq');"
2174: value="$lt{'newp'}" />$help{'Adding_Pages'}
2175: </nobr>
2176: </form>
2177: <form action="/adm/coursedocs" method="post" name="newext">
2178: $uploadtag
2179: <input type=hidden name="importdetail" value="">
2180: <nobr>
2181: <input name="newext" type="button" onClick="javascript:makenewext('newext');"
2182: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
2183: </nobr>
2184: </form>
2185: <form action="/adm/coursedocs" method="post" name="newsyl">
2186: $uploadtag
2187: <input type=hidden name="importdetail"
2188: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
2189: <nobr>
2190: <input name="newsyl" type="submit" value="$lt{'syll'}" />
2191: $help{'Syllabus'}
2192: </nobr>
2193: </form>
2194: <form action="/adm/coursedocs" method="post" name="newnav">
2195: $uploadtag
2196: <input type=hidden name="importdetail"
2197: value="Navigate Content=/adm/navmaps">
2198: <nobr>
2199: <input name="newnav" type="submit" value="$lt{'navc'}" />
2200: $help{'Navigate_Content'}
2201: </nobr>
2202: </form>
2203: <form action="/adm/coursedocs" method="post" name="newsmppg">
2204: $uploadtag
2205: <input type=hidden name="importdetail" value="">
2206: <nobr>
2207: <input name="newsmppg" type="button" value="$lt{'sipa'}"
2208: onClick="javascript:makesmppage();" /> $help{'Simple Page'}
2209: </nobr>
2210: </form>
2211: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
2212: $uploadtag
2213: <input type=hidden name="importdetail" value="">
2214: <nobr>
2215: <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
2216: onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
2217: </nobr>
2218: </form>
2219: <form action="/adm/coursedocs" method="post" name="newexamupload">
2220: $uploadtag
2221: <input type=hidden name="importdetail" value="">
2222: <nobr>
2223: <input name="newexamupload" type="button" value="$lt{'scuf'}"
2224: onClick="javascript:makeexamupload();" />
2225: $help{'Score_Upload_Form'}
2226: </nobr>
2227: </form>
2228: <form action="/adm/coursedocs" method="post" name="newbul">
2229: $uploadtag
2230: <input type=hidden name="importdetail" value="">
2231: <nobr>
2232: <input name="newbulletin" type="button" value="$lt{'bull'}"
2233: onClick="javascript:makebulboard();" />
2234: $help{'Bulletin Board'}
2235: </nobr>
2236: </form>
2237: <form action="/adm/coursedocs" method="post" name="newaboutme">
2238: $uploadtag
2239: <input type=hidden name="importdetail"
2240: value="$plainname=/adm/$udom/$uname/aboutme">
2241: <nobr>
2242: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
2243: $help{'My Personal Info'}
2244: </nobr>
2245: </form>
2246: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
2247: $uploadtag
2248: <input type=hidden name="importdetail" value="">
2249: <nobr>
2250: <input name="newaboutsomeone" type="button" value="$lt{'abou'}"
2251: onClick="javascript:makeabout();" />
2252: </nobr>
2253: ENDFORM
2254: }
2255: if ($ENV{'form.pagepath'}) {
2256: $r->print(<<ENDBLOCK);
2257: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
2258: $uploadtag
2259: <input type=hidden name="importdetail" value="">
2260: <nobr>
2261: <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
2262: onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
2263: </nobr>
2264: </form>
2265: <form action="/adm/coursedocs" method="post" name="newexamupload">
2266: $uploadtag
2267: <input type=hidden name="importdetail" value="">
2268: <nobr>
2269: <input name="newexamupload" type="button" value="$lt{'scuf'}"
2270: onClick="javascript:makeexamupload();" />
2271: $help{'Score_Upload_Form'}
2272: </nobr>
2273: </form>
2274: ENDBLOCK
2275: } else {
2276: $r->print(<<ENDFORM);
2277: </form>
2278: <form action="/adm/imsimportdocs" method="post" name="ims">
2279: <input type="hidden" name="folder" value="$folder" />
2280: <input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
2281: </nobr>
2282: </form>
2283: ENDFORM
2284: }
2285: $r->print('</td></tr>'."\n".
2286: '</table>');
2287: $r->print('</td></tr>');
2288: }
2289: # ----------------------------------------------------- Supplemental documents
2290: if (!$forcestandard) {
2291: $r->print('<tr><td bgcolor="#BBBBBB">');
2292: # '<h2>'.&mt('Supplemental Course Documents').
2293: # ($allowed?' '.$help{'Supplemental'}:'').'</h2>');
2294: my $folder=$ENV{'form.folder'};
2295: unless ($folder=~/^supplemental/) {
2296: $folder='supplemental';
2297: }
2298: if ($folder =~ /^supplemental$/ &&
2299: $ENV{'form.folderpath'} =~ /^default\&/) {
2300: $ENV{'form.folderpath'}='supplemental&'.
2301: &Apache::lonnet::escape(&mt('Supplemental Course Documents'));
2302: }
2303: &editor($r,$coursenum,$coursedom,$folder,$allowed);
2304: if ($allowed) {
2305: my $folderseq=
2306: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
2307: '.sequence';
2308:
2309: $r->print(<<ENDSUPFORM);
2310: <table cellspacing=4 cellpadding=4><tr>
2311: <th bgcolor="#DDDDDD">$lt{'upls'}</th>
2312: <th bgcolor="#DDDDDD">$lt{'spec'}</th>
2313: </tr>
2314: <tr><td bgcolor="#DDDDDD">
2315: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
2316: <input type="file" name="uploaddoc" size="40">
2317: <br />$lt{'comment'}:<br />
2318: <textarea cols=50 rows=4 name='comment'>
2319: </textarea>
2320: <br />
2321: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
2322: <input type="hidden" name="cmd" value="upload_supplemental">
2323: <nobr>
2324: <input type="submit" value="$lt{'upld'}">
2325: $help{'Uploading_From_Harddrive'}
2326: </nobr>
2327: </form>
2328: </td>
2329: <td bgcolor="#DDDDDD">
2330: <form action="/adm/coursedocs" method="post" name="supnewfolder">
2331: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
2332: <input type=hidden name="importdetail" value="">
2333: <nobr>
2334: <input name="newfolder" type="button"
2335: onClick="javascript:makenewfolder(this.form,'$folderseq');"
2336: value="$lt{'newf'}" /> $help{'Adding_Folders'}
2337: </nobr>
2338: </form>
2339: <form action="/adm/coursedocs" method="post" name="supnewext">
2340: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
2341: <input type=hidden name="importdetail" value="">
2342: <nobr>
2343: <input name="newext" type="button"
2344: onClick="javascript:makenewext('supnewext');"
2345: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
2346: </nobr>
2347: </form>
2348: <form action="/adm/coursedocs" method="post" name="supnewsyl">
2349: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
2350: <input type=hidden name="importdetail"
2351: value="Syllabus=/public/$coursedom/$coursenum/syllabus">
2352: <nobr>
2353: <input name="newsyl" type="submit" value="$lt{'syll'}" />
2354: $help{'Syllabus'}
2355: </nobr>
2356: </form>
2357: <form action="/adm/coursedocs" method="post" name="subnewaboutme">
2358: <input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
2359: <input type=hidden name="importdetail"
2360: value="$plainname=/adm/$udom/$uname/aboutme">
2361: <nobr>
2362: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
2363: $help{'My Personal Info'}
2364: </nobr>
2365: </form>
2366: </td></tr>
2367: </table></td></tr>
2368: ENDSUPFORM
2369: }
2370: }
2371: if ($allowed) {
2372: $r->print('<form name="extimport"><input type="hidden" name="title"><input type="hidden" name="url"><input type="hidden" name="useform"></form>');
2373: }
2374: $r->print('</table>');
2375: } else {
2376: # -------------------------------------------------------- This is showdoc mode
2377: $r->print("<h1>".&mt('Uploaded Document').' - '.
2378: &Apache::lonnet::gettitle($r->uri).'</h1><p>'.
2379: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><p><table>".
2380: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table></p>');
2381: }
2382: }
2383: $r->print('</body></html>');
2384: return OK;
2385: }
2386:
2387: 1;
2388: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>