Annotation of loncom/imspackages/imsimportdocs.pm, revision 1.7
1.7 ! raeburn 1: # Copyright Michigan State University Board of Trustees
! 2: #
! 3: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
! 4: #
! 5: # LON-CAPA is free software; you can redistribute it and/or modify
! 6: # it under the terms of the GNU General Public License as published by
! 7: # the Free Software Foundation; either version 2 of the License, or
! 8: # (at your option) any later version.
! 9: #
! 10: # LON-CAPA is distributed in the hope that it will be useful,
! 11: # but WITHOUT ANY WARRANTY; without even the implied warranty of
! 12: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! 13: # GNU General Public License for more details.
! 14: #
! 15: # You should have received a copy of the GNU General Public License
! 16: # along with LON-CAPA; if not, write to the Free Software
! 17: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! 18: #
! 19: # /home/httpd/html/adm/gpl.txt
! 20: #
! 21: # http://www.lon-capa.org/
! 22: #
! 23:
1.1 raeburn 24: package Apache::imsimportdocs;
25:
1.2 raeburn 26: use Apache::Constants qw(:common :http :methods);
1.1 raeburn 27: use Apache::lonnet;
1.2 raeburn 28: use Apache::londocs;
1.1 raeburn 29: use Apache::loncommon;
30: use Apache::lonlocal;
31: use Apache::imsprocessor;
32: use LONCAPA::Configuration;
1.2 raeburn 33: use strict;
1.1 raeburn 34:
35: sub jscript_one {
36: my $javascript = shift;
37: $$javascript = qq#
38: function verify() {
39: if ((document.forms.pickcms.uploadname.value == '') || (!document.forms.pickcms.uploadname.value)) {
40: alert("You must provide the name of the IMS package to be imported")
41: return false
42: }
43: if (document.forms.pickcms.source.selectedIndex == 0) {
44: alert("You must choose the Course Management System from which the IMS package was exported");
45: return false
46: }
47: return true
48: }
49:
50: function nextPage() {
51: if (verify()) {
52: document.forms.pickcms.submit()
53: }
54: }
55: #;
56:
57: }
58:
59: sub jscript_two {
60: my $javascript = shift;
61: $$javascript = qq#
62: function setOptions(caller,itemnum) {
63: var opForm = document.forms.pickoptions
64: var menu = 1 + itemnum*2
65: opForm.elements[menu].length = 0
66: if (opForm.elements[itemnum*2].checked == true) {
67: if (caller == "board") {
68: opForm.elements[menu].options[0] = new Option("Select","-1",true,true)
69: opForm.elements[menu].options[1] = new Option("Import topics only","topics",true,true)
1.4 raeburn 70: opForm.elements[menu].options[2] = new Option("Import topics + posts (with author)","allpost",true,true)
71: opForm.elements[menu].options[3] = new Option("Import topics + posts (no author)","allanon",true,true)
1.1 raeburn 72: }
73: else {
74: if (caller == "users") {
75: opForm.elements[menu].length = 0
76: opForm.elements[menu].options[0] = new Option("Select","-1",true,true)
77: opForm.elements[menu].options[1] = new Option("Enroll students only","students",true,true)
78: opForm.elements[menu].options[2] = new Option("Enroll all users","all",true,true)
79: }
80: }
81: }
82: else {
83: opForm.elements[menu].options[0] = new Option("Not required","0",true,true)
84: }
85: opForm.elements[menu].selectedIndex = 0
86: }
87:
88: function verify(caller) {
89: var opForm = document.forms.pickoptions
90: var totcheck = 0;
91: for (var i=0; i<caller; i++) {
92: if (opForm.elements[2*i].checked == true) {
93: totcheck ++
94: if (opForm.elements[2*i].name == "board") {
95: if (opForm.elements[2*i+1].selectedIndex == 0) {
96: alert("You must select one of the additional options when importing Discussion Boards ")
97: return false
98: }
99: }
100: if (opForm.elements[2*i].name == "users") {
101: if (opForm.elements[2*i+1].selectedIndex == 0) {
102: alert("You must select one of the additional options when importing Enrollment")
103: return false
104: }
105: }
106: }
107: }
108: if (totcheck == 0) {
109: alert("You must check the Checkbox for at least one Content Type");
110: return false
111: }
112: return true
113: }
114:
115: function nextPage(caller) {
116: if (verify(caller)) {
117: document.forms.pickoptions.submit()
118: }
119: }
120: #;
121: }
122:
1.2 raeburn 123: sub jscript_three {
124: my $javascript = shift;
125: $$javascript = qq|
126: function init(tf) {
127: setTimeout("self.close()",3000)
128: tf.submit();
129: }
130: |;
131: }
132:
1.1 raeburn 133: sub handler {
134: my $r = shift;
135: my $javascript = '';
136: &Apache::loncommon::content_type($r,'text/html');
137: $r->send_http_header;
138: return OK if $r->header_only;
139:
1.3 raeburn 140: my @areas = ();
1.1 raeburn 141: my %cmsmap = ();
1.3 raeburn 142: my %areaname = ();
143: &Apache::imsprocessor::ims_config(\@areas,\%cmsmap,\%areaname);
1.1 raeburn 144:
145: # get course data
146: my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
147: my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
148: my $coursehome=$ENV{'course.'.$ENV{'request.course.id'}.'.home'};
149:
150: # get personal data
151:
152: my $uname=$ENV{'user.name'};
153: my $udom=$ENV{'user.domain'};
154: my $plainname=&Apache::lonnet::escape(
155: &Apache::loncommon::plainname($uname,$udom));
156:
157: # does this user have privileges to post, etc?
158: my $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
159: unless ($allowed) {
160: $r->print("<html><head><title>The LearningOnline Network with CAPA</title></head>");
161: $r->print(&Apache::loncommon::bodytag('Import IMS package'));
162: $r->print('<h3>'.&mt('Modification of Course Contents Disallowed').'</h3>'.&mt('Your current role does not grant you the right to modify course content in this course.').'</body></html>');
163: return OK;
164: }
165:
166: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
167: ['phase']);
168:
169: if ($ENV{'form.phase'} eq 'one') {
170: &jscript_one(\$javascript);
171: } elsif ($ENV{'form.phase'} eq 'two') {
172: &jscript_two(\$javascript);
1.2 raeburn 173: } elsif ($ENV{'form.phase'} eq 'three') {
174: &jscript_three(\$javascript);
1.1 raeburn 175: }
176:
177: # print screen
178: $r->print(<<ENDHEAD);
179: <html>
180: <head>
181: <title>The LearningOnline Network with CAPA</title>
182: <script type="text/javascript">
183: <!--
184: $javascript
185: -->
186: </script>
187: </head>
188: ENDHEAD
189: # -------------------------------------------------------------------- Body tag
190: $r->print(&Apache::loncommon::bodytag('Import IMS package'));
191: if ($ENV{'form.phase'} eq 'one') {
192: &display_one($r);
193: } elsif ($ENV{'form.phase'} eq 'two') {
1.3 raeburn 194: &display_two($r,$coursenum,\@areas,\%areaname,%cmsmap);
1.1 raeburn 195: } elsif ($ENV{'form.phase'} eq 'three') {
1.2 raeburn 196: &display_three($r,$coursenum,$coursedom,$coursehome,$uname,$udom,\@areas,%cmsmap);
1.1 raeburn 197: }
198: $r->print("</body><html>");
1.2 raeburn 199: return OK;
1.1 raeburn 200: }
201:
202:
203: sub display_one {
1.2 raeburn 204: my ($r) = @_;
1.1 raeburn 205: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder']);
206:
207: $r->print(<<ENDBLOCK);
208: <form action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" name="pickcms">
209: <table border='0' bgcolor='#F6F6F6' cellspacing='0' cellpadding ='0' width='100%'>
210: <tr>
211: <td colspan='2'>
212: <table border='0' cellspacing='0' cellpadding='0'>
213: <tr>
214: <td colspan='2' align='left'>
215: </td>
216: </tr>
217: <tr bgcolor='#CCCCFF'>
218: <td valign='middle'><img src='/res/adm/pages/bl_step1.gif'>
219: </td>
220: <td width='100%' align='left'>
221: <font face='arial,helvetica,sans-serif'><b>Specify the Course Management system used to create the package.</b>
222: </font>
223: </td>
224: </tr>
225: <tr>
226: <td colspan='2'> </td>
227: </tr>
228: <tr>
229: <td> </td>
230: <td>
231: <font face='Arial,Helvetica,sans-serif'>
232: Please choose the CMS used to create your IMS content package.
233: <select name="source">
234: <option value='-1' selected="true">Please select
235: <option value='bb5'>Blackboard 5
1.7 ! raeburn 236: <option value='bb6'>Blackboard 6
1.1 raeburn 237: <option value='angel'>ANGEL
238: </select>
239: </font>
240: </td>
241: </tr>
242: <tr>
243: <td colspan='2'> </td>
244: </tr>
245: <tr>
246: <td colspan='2'> </td>
247: </tr>
248: <tr bgcolor='#CCCCFF'>
249: <td valign='middle'><img src='/res/adm/pages/bl_step2.gif'>
250: </td>
251: <td width='100%' align='left'>
252: <font face='arial,helvetica,sans-serif'><b>Locate the IMS content package you wish to upload.</b>
253: </font>
254: </td>
255: </tr>
256: <tr>
257: <td colspan='2'> </td>
258: </tr>
259: <tr>
260: <td colspan='2'>
261: <input type="hidden" name="folder" value="$ENV{'form.folder'}" />
262: <input type="hidden" name="phase" value="two" />
263: <input type="file" name="uploadname" size="40" />
264: </td>
265: </tr>
266: <tr>
267: <td colspan='2'> </td>
268: </tr>
269: <tr>
270: <td> </td>
271: <td><font face='arial,helvetica,sans-serif'>If you have selected the CMS, and located the IMS package, you should click the 'Upload IMS package' button to upload the file to the server.</font></td>
272: </tr>
273: <tr>
274: <td colspan='2'> </td>
275: </tr>
276: <tr
277: <td colspan='2'>
278: <table border='0' cellspacing='0' cellpadding='0' width="100%">
279: <tr>
280: <td align='left'>
281: <input type="button" name="exitpage" value="Exit now" onClick="javascript:self.close()">
282: </td>
283: <td align='right'>
284: <input type="button" name="nextpage" value="Upload IMS package" onClick="javascript:nextPage()">
285: </td>
286: </tr>
287: </table>
288: </td>
289: </tr>
290: </table>
291: </td>
292: </tr>
293: </table>
294: </form>
295: ENDBLOCK
296: }
297:
298:
299: sub display_two {
1.3 raeburn 300: my ($r,$crs,$areasref,$areaname,%cmsmap) = @_;
1.1 raeburn 301: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder','source']);
302: my $cms = $ENV{'form.source'};
1.2 raeburn 303: my $timenow = time;
304: my $tempdir = &Apache::imsprocessor::create_tempdir('DOCS',$crs,$timenow);
1.3 raeburn 305: my $fname = &Apache::imsprocessor::uploadzip('DOCS',$tempdir);
1.1 raeburn 306: my $unzip_result = '';
307: my $manifest_result = '';
308: unless ($tempdir eq '') {
309: $unzip_result = &Apache::imsprocessor::expand_zip($tempdir,$fname);
310: }
311: my %resources = ();
312: my %items = ();
313: my %hrefs = ();
1.2 raeburn 314: my %resinfo = ();
1.1 raeburn 315: my %count = ();
316: my @bgcolors = ("#eeeeee","#dddddd");
317:
318: my $counter = 0;
319: my $iter = 0;
320: my %count = (
321: announce => 0,
322: board => 0,
323: doc => 0,
324: extlink => 0,
325: msg => 0,
326: pool => 0,
327: quiz => 0,
328: staff => 0,
329: survey => 0,
330: users => 0,
331: );
332:
333: if ($unzip_result eq 'ok') {
1.2 raeburn 334: $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo);
1.1 raeburn 335: if ($manifest_result eq 'ok') {
336: foreach my $res (sort keys %resources) {
1.7 ! raeburn 337: if ($cms eq 'bb5' || $cms eq 'bb6') {
1.1 raeburn 338: foreach my $area (keys %{$cmsmap{$cms}}) {
339: if ($resources{$res}{type} eq $cmsmap{$cms}{$area}) {
340: $count{$area} ++;
341: }
342: }
343: } elsif ($cms eq 'angel') {
344: foreach my $area (keys %{$cmsmap{$cms}}) {
345: if ($area eq 'doc') {
346: if (grep/^$resources{$res}{type}$/,@{$cmsmap{$cms}{doc}}) {
347: $count{$area} ++;
348: }
349: } elsif ($resources{$res}{type} eq $cmsmap{$cms}{$area}) {
350: $count{$area} ++;
351: }
352: }
353: }
354: }
355: $r->print(<<ENDBLOCK);
356: <form name="pickoptions" method="post">
357: <table border='0' bgcolor='#F6F6F6'' cellspacing='0' cellpadding ='0' width='100%'>
358: <tr>
359: <td colspan='2'>
360: <table border='0' cellspacing='0' cellpadding='0'>
361: <tr>
362: <td colspan='2' align='left'>
363: </td>
364: </tr>
365: <tr bgcolor='#CCCCFF'>
366: <td valign='middle'><img src='/res/adm/pages/bl_step3.gif'>
367: </td>
368: <td width='100%' align='left'>
369: <font face='arial,helvetica,sans-serif'><b>Choose which content types you wish to import</b></font>
370: </td>
371: </tr>
372: <tr>
373: <td colspan='2'> </td>
374: </tr>
375: <tr>
376: <td> </td>
377: <td>
378: <table border='0' cellspacing='0' cellpadding='1' bgcolor='#000000'>
379: <tr>
380: <td>
381: <table border='0' cellspacing='0' cellpadding='0' bgcolor='#ffffff' width='100%'>
382: <tr>
383: <td>
384: <table border='0' cellspacing='1' cellpadding='1' bgcolor='#ffffff' width='100%'>
385: <tr bgcolor='#CCCCFF'>
386: <td align='center'><font face='arial,helvetica,sans-serif'><b>Import?</b></font></td>
387: <td align='center'><font face='arial,helvetica,sans-serif'><b>Content type</b></font></td>
388: <td align='center'><font face='arial,helvetica,sans-serif'><b>Additional options</b></font></td>
389: </tr>
390: ENDBLOCK
391: foreach my $area (@{$areasref}) {
392: if ($count{$area} > 0) {
393: my $count_tag = 'flag_'.$counter;
394: $r->print(" <tr bgcolor='@bgcolors[$iter]'>
395: <td align='left'><font face='arial,helvetica,sans-serif'><input name='$area' type='checkbox' ");
396: if ($area eq 'board' || $area eq 'users') {
397: $r->print(qq|onClick='javascript:setOptions("$area","$counter")'|);
398: }
399: $r->print("/></font></td>
1.3 raeburn 400: <td align='left'><font face='arial,helvetica,sans-serif'> $$areaname{$area} - $count{$area} item(s)</font></td>");
1.1 raeburn 401: if ($area eq 'board') {
402: $r->print(" <td align='left'><font face='arial,helvetica,sans-serif'>
1.2 raeburn 403: <select name='db_handling'>
1.1 raeburn 404: <option value='-2'><-- Check Import first
405: </select></font>
406: </td>");
407: } elsif ($area eq 'users') {
408: $r->print(" <td align='left'><font face='arial,helvetica,sans-serif'>
409: <select name='user_handling'>
410: <option value='-2'><-- Check Import first
411: </select>
412: </font>
413: </td>");
414: } else {
415: $r->print(" <td align='left'><font face='arial,helvetica,sans-serif'> None<input type='hidden' name='$count_tag' /></font></td>");
416: }
417: $counter ++;
418: $iter = $counter%2;
419: }
420: }
421: $r->print(<<ENDDOCUMENT);
422: </tr>
423: </table>
424: </td>
425: </tr>
426: </table>
427: </td>
428: </tr>
429: </table>
430: </td>
431: </tr>
432: <tr>
433: <td colspan='2'> <br /><br /></td>
434: </tr>
1.2 raeburn 435: <tr bgcolor='#CCCCFF'>
436: <td valign='middle'><img src='/res/adm/pages/bl_step4.gif'>
437: </td>
438: <td width='100%' align='left'>
439: <font face='arial,helvetica,sans-serif'><b>Choose display options for listing of contents of top level of package.</b></font>
440: </td>
441: </tr>
442: <tr>
443: <td colspan='2'> </td>
444: </tr>
1.1 raeburn 445: <tr>
446: <td> </td>
1.2 raeburn 447: <td>
448: <table border='0'>
449: <tr>
450: <td><font face='arial,helvetica,sans-serif'><input type="radio" name="toplevel" value="newfolder" />Display listing of contents in a new folder, with folder name: <input type="text" name="foldername" size="15" value="Type Name Here" /></font></td>
451: </tr>
452: <tr>
453: <td><font face='arial,helvetica,sans-serif'><input type="radio" name="toplevel" value="oldfolder" />Append listing of contents of top level of package to contents list for the current folder.</font></td>
454: </tr>
455: </table>
456: </td>
457: </tr>
458: <tr>
459: <td colspan='2'> </td>
460: </tr>
461: <tr>
462: <td> </td>
463: <td><font face='arial,helvetica,sans-serif'>Once you have checked the checkboxes for all areas you wish to import from the IMS package, selected options (if available), and selected a display option for the package contents you should click the 'Complete Import' button.</font></td>
1.1 raeburn 464: </tr>
465: <tr>
466: <td colspan='2'>
467: <input type="hidden" name="folder" value="$ENV{'form.folder'}" />
468: <input type="hidden" name="source" value="$cms" />
469: <input type="hidden" name="tempdir" value="$tempdir" />
470: <input type="hidden" name="phase" value="three" />
471: </td>
472: </tr>
473: <tr>
474: <td colspan='2'>
475: <table border='0' cellspacing='0' cellpadding='0' width="100%">
476: <tr>
477: <td align='left'>
478: <input type='button' name='exitpage' value='Exit now' onClick="javascript:self.close()">
479: </td>
480: <td align='right'>
481: <input type="button" name="nextpage" value="Complete Import" onClick="javascript:nextPage($counter)">
482: </td>
483: </tr>
484: </table>
485: </td>
486: </tr>
487: </table>
488: </td>
489: </tr>
490: </table>
491: ENDDOCUMENT
492: } else {
493: $r->print("Unpacking of your IMS package failed because an IMS manifest file was not located in the package\n");
494: }
495: } else {
496: $r->print("Processing of your IMS package failed because the file you uploaded could not be unzipped\n");
497: }
498: }
499:
500:
501: sub display_three {
1.2 raeburn 502: my ($r,$crs,$cdom,$chome,$uname,$udom,$areas,%cmsmap) = @_;
503: my $folder = $ENV{'form.folder'};
504: my $cms = $ENV{'form.source'};
505: my $tempdir = $ENV{'form.tempdir'};
506: my $longcrs = '';
507: if ($crs =~ m/^(\d)(\d)(\d)/) {
508: $longcrs = $1.'/'.$2.'/'.$3.'/'.$crs;
509: }
510: my %imports = ();
511: my @targets = ();
512: my %resources = ();
513: my %items = ();
514: my %hrefs = ();
515: my %urls = ();
516: my %resinfo = ();
517: my %total = (
518: page => 0,
519: prob => 0,
520: seq => 0,
521: board => 0,
522: quiz => 0,
523: surv => 0,
524: );
525: my @pages = ();
526: my @sequences = ();
527: my @resrcfiles = ();
528:
529: my $timenow = time;
530:
531: my $destdir = $Apache::lonnet::perlvar{'lonDocRoot'}.'/userfiles/'.$cdom.'/'.$crs.'/'.$timenow;
532: my $seqstem = "/uploaded/$cdom/$crs/$timenow";
533: my $db_handling = '';
534: my $user_handling = '';
535:
536: my $toplevel = '';
537: my $foldername = '';
538: my %topitems = ();
539: if (defined($ENV{'form.toplevel'}) ) {
540: $toplevel = $ENV{'form.toplevel'};
541: }
542: if (defined($ENV{'form.foldername'}) ) {
543: $foldername = $ENV{'form.foldername'};
544: }
545:
546: foreach my $area (@{$areas}) {
547: if (defined($ENV{"form.$area"}) ) {
548: if ($cms eq 'angel' && $area eq 'doc') {
549: foreach (@{$cmsmap{$cms}{$area}}) {
550: $imports{$_} = 1;
551: }
552: } else {
553: $imports{$cmsmap{$cms}{$area}} = 1;
554: }
555: if ($area eq 'board') {
556: $db_handling = $ENV{'form.db_handling'};
557: } elsif ($area eq 'users') {
558: $user_handling = $ENV{'form.user_handling'};
559: }
560: }
561: }
1.1 raeburn 562:
1.2 raeburn 563: my $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo);
564: if ($manifest_result eq 'ok') {
1.5 raeburn 565: my @path = ($cdom,$crs,$timenow);
566: my $fullpath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/userfiles';
567: foreach my $item (@path) {
568: $fullpath .= '/'.$item;
569: if (!-e "$fullpath") {
570: mkdir("$fullpath",0770);
571: }
572: }
573: my @namedirs = ("resfiles","sequences","pages","problems");
574: foreach my $name (@namedirs) {
575: if (!-e "$fullpath/$name") {
576: mkdir("$fullpath/$name",0770);
577: }
578: }
1.2 raeburn 579: &Apache::imsprocessor::target_resources(\%resources,\%imports,\@targets);
580:
581: my @boards = ();
582: my @announcements = ();
583: my @quizzes = ();
584: my @surveys = ();
585: my @groups = ();
586: my %messages = ();
587: my @timestamp = ();
588: my %boardnum = ();
589: my @topurls = ();
590: my @topnames = ();
1.7 ! raeburn 591: my @packages = ();
1.2 raeburn 592:
1.7 ! raeburn 593: &Apache::imsprocessor::process_resinfo($cms,'DOCS',$tempdir,$destdir,\%items,\%resources,\@boards,\@announcements,\@quizzes,\@surveys,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$seqstem,$seqstem,\@resrcfiles,\@packages,\%hrefs);
! 594:
! 595: my $copy_result = &Apache::imsprocessor::copy_resources('DOCS',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$chome,$destdir,$timenow);
1.2 raeburn 596:
1.7 ! raeburn 597: &Apache::imsprocessor::build_structure($cms,'DOCS',$destdir,\%items,\%resinfo,\%resources,\%hrefs,$udom,$uname,'',$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames,\@packages);
1.2 raeburn 598:
599: foreach my $item (@pages) {
1.3 raeburn 600: my $filename = $timenow.'/pages/'.$item;
601: my $fetchresult= &Apache::lonnet::process_coursefile('propagate',$crs,$cdom,$chome,$filename,'');
1.2 raeburn 602: }
603: foreach my $item (@sequences) {
604: unless ($item eq 'Top.sequence' && $toplevel eq 'oldfolder') {
1.3 raeburn 605: my $filename = $timenow.'/sequences/'.$item;
606: my $fetchresult= &Apache::lonnet::process_coursefile('propagate',$crs,$cdom,$chome,$filename,'');
1.2 raeburn 607: }
608: }
609: foreach my $item (@resrcfiles) {
1.3 raeburn 610: my $filename = $timenow.'/resfiles/'.$item;
611: my $fetchresult= &Apache::lonnet::process_coursefile('propagate',$crs,$cdom,$chome,$filename,'');
1.2 raeburn 612: }
613:
614: my @imports = ();
615: if ($toplevel eq 'oldfolder') {
616: for (my $i=0; $i<@topurls; $i++) {
617: my $url = &Apache::lonnet::unescape($topurls[$i]);
618: my $name = &Apache::lonnet::unescape($topnames[$i]);
619: push @imports, $name, $url;
620: }
621: } elsif ($toplevel eq 'newfolder') {
622: my $url = &Apache::lonnet::unescape("/uploaded/$cdom/$crs/$timenow/sequences/Top.sequence");
623: my $name = &Apache::lonnet::unescape("$ENV{'form.foldername'}");
624: push @imports, $name, $url;
625: }
626: my $errtext='';
627: my $fatal=0;
628: ($errtext,$fatal)= &Apache::londocs::mapread($crs,$cdom,$folder.'.sequence');
629: if ($#Apache::lonratedt::order<1) {
630: $Apache::lonratedt::order[0]=1;
631: $Apache::lonratedt::resources[1]='';
632: }
633: my ($errtext,$fatal)=&Apache::londocs::group_import($crs, $cdom, $folder,@imports);
634: if ($fatal) {
635: print STDERR "Fatal error during group_import\n";
636: }
637: }
1.3 raeburn 638: if ($tempdir =~ m/^\/home\/httpd\/perl\/tmp\/$crs\/\d{10}/) {
639: system("rm -r -f $tempdir");
640: }
1.2 raeburn 641: $r->print(<<ENDBLOCK);
642: <table border='0' bgcolor='#F6F6F6'' cellspacing='0' cellpadding ='0' width='100%'>
643: <tr>
644: <td colspan='2'>
645: <table border='0' cellspacing='0' cellpadding='0'>
646: <tr>
647: <td colspan='2' align='left'>
648: </td>
649: </tr>
650: <tr bgcolor='#CCCCFF'>
651: <td valign='middle'><img src='/res/adm/pages/bl_step5.gif'>
652: </td>
653: <td width='100%' align='left'>
654: <font face='arial,helvetica,sans-serif'><b>Your import is complete</b></font>
655: </td>
656: </tr>
657: <tr>
658: <td colspan='2'> </td>
659: </tr>
660: <tr>
661: <td> </td>
662: <td>
663: ENDBLOCK
664: my $initblock = qq|
665: <form method="post" action="/adm/roles" target="loncapaclient" name="importDone">
666: <input type="hidden" name="orgurl" value="/adm/coursedocs" />
667: <input type="hidden" name="selectrole" value="1" />
668: <h3><font color="red">Changes will become active for your current session after
669: <input type="hidden" name="$ENV{'request.role'}" value="1" />
670: <input type="button" value="|;
671: $initblock .= &mt('re-initializing course');
672: $initblock .= qq|" onClick="javascript:init(this.form)"/>|;
673: $initblock .= &mt('or the next time you log in.');
674: $initblock .= qq|</font></h3></form>|;
675: $r->print($initblock);
676: $r->print(<<ENDBLOCKTWO);
677: </table>
678: </td>
679: </tr>
680: </table>
681: ENDBLOCKTWO
1.1 raeburn 682: }
683:
684: 1;
685: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>