--- loncom/imspackages/imsimport.pm 2013/09/23 17:35:05 1.44 +++ loncom/imspackages/imsimport.pm 2013/09/30 17:42:12 1.45 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: imsimport.pm,v 1.44 2013/09/23 17:35:05 bisitz Exp $ +# $Id: imsimport.pm,v 1.45 2013/09/30 17:42:12 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -133,6 +133,20 @@ sub jscript_two { $course_list = '"'.join('","',@crslist).'"'; $$numcrs = @crslist; + my %lt = &Apache::lonlocal::texthash( + sel => 'Please select', + impto => 'Import topics only', + imptpa => 'Import topics + posts (with author)', + imptpn => 'Import topics + posts (no author)', + enrst => 'Enroll students only', + enrall => 'Enroll all users', + notreq => 'Not required', + errao => 'You must select one of the additional options when importing Discussion Boards.', + errtd => 'You must select a target course when importing Discussion Boards.', + errap => 'You must select one of the additional options when importing Enrollment.', + errte => 'You must select a target course when importing enrollment information.', + errcc => 'You must check at least one Content Type.', + ); return <<"END_OF_TWO"; function checkCourse() { @@ -181,7 +195,7 @@ function setCourse(step2Form,call) { step2Form.targetcourse.length = 0 if (call == 'add') { step2Form.targetcourse.length = 0 - step2Form.targetcourse.options[0] = new Option("Please Select","0",true,true) + step2Form.targetcourse.options[0] = new Option("$lt{'sel'}","0",true,true) for (var i=0; i 0) { @@ -234,7 +248,7 @@ function verify(caller) { totcheck ++ if (opForm.elements[2*i].name == "board") { if (opForm.elements[2*i+1].selectedIndex == 0) { - alert("You must select one of the additional options when importing Discussion Boards ") + alert("$lt{'errao'}") return false } if (numCrs == 0) { @@ -243,14 +257,14 @@ function verify(caller) { } else { if (opForm.targetcourse.selectedIndex == 0) { - alert("You must select a target course when importing Discussion Boards") + alert("$lt{'errtd'}") return false } } } if (opForm.elements[2*i].name == "users") { if (opForm.elements[2*i+1].selectedIndex == 0) { - alert("You must select one of the additional options when importing Enrollment") + alert("$lt{'errap'}") return false } if (numCrs == 0) { @@ -259,7 +273,7 @@ function verify(caller) { } else { if (opForm.targetcourse.selectedIndex == 0) { - alert("You must select a target course when importing enrollment information") + alert("$lt{'errte'}") return false } } @@ -267,7 +281,7 @@ function verify(caller) { } } if (totcheck == 0) { - alert("You must check the Checkbox for at least one Content Type"); + alert("$lt{'errcc'}"); return false } return true @@ -290,7 +304,7 @@ sub display_one { &Apache::lonhtmlcommon::topic_bar(1,&mt('Specify the Course Management system used to create the package')). &mt('Choose the CMS used to create your IMS content package.').'  
'."\n". &Apache::lonhtmlcommon::topic_bar(2,&mt('Create a directory where you will unpack your IMS package'))."\n". - &mt('Create a destination LON-CAPA directory in which to store the contents of the IMS package file.').'  

+ &mt('Create a destination LON-CAPA directory in which to store the contents of the IMS package file.').'  

     @@ -465,7 +479,11 @@ sub display_two { $r->print($lt{'unpa'}); } } else { - $r->print($lt{'proc'}); + $r->print( + '
'.&Apache::loncommon::confirmwrapper( + &Apache::lonhtmlcommon::confirm_success($lt{'proc'},1) + .'
'.&mt('Error: [_1]',$unzip_result)) + ); } } @@ -598,20 +616,32 @@ sub display_three { &Apache::imsprocessor::build_structure($cms,'CSTR',$destdir,\%items,\%resinfo,\%resources,\@targets,\%hrefs,$udom,$uname,$dirpath,$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\@pools,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames,\@packages,\%includeditems,\%randompicks); - $r->print("

IMS import completed

"); + my $message = + &Apache::lonhtmlcommon::confirm_success( + &mt('IMS import completed')) + .'
'.$lt{'yims'}.' '; if ($cms eq 'angel5') { - $r->print($lt{'yims'}.' '.&mt('A total of [quant,_1,sequence], [quant,_2,composite page], and [quant,_3,discussion board] have been created, and [quant,_4,file] copied.',$total{seq},$total{page},$total{board},$total{file})."\n"); + $message .= &mt('A total of [quant,_1,sequence], [quant,_2,composite page], and [quant,_3,discussion board] have been created, and [quant,_4,file] copied.',$total{seq},$total{page},$total{board},$total{file})."\n"; } else { - $r->print($lt{'yims'}.' '.&mt('A total of [quant,_1,sequence], [quant,_2,composite page], [quant,_3,discussion board], [quant,_4,quiz,quizzes], [quant,_5,survey], and [quant,_6,problem] have been created, and [quant,_7,file] copied.',$total{seq},$total{page},$total{board},$total{quiz},$total{surv},$total{prob},$total{file})."\n"); + $message .= &mt('A total of [quant,_1,sequence], [quant,_2,composite page], [quant,_3,discussion board], [quant,_4,quiz,quizzes], [quant,_5,survey], and [quant,_6,problem] have been created, and [quant,_7,file] copied.',$total{seq},$total{page},$total{board},$total{quiz},$total{surv},$total{prob},$total{file})."\n"; } - $r->print('

'.$lt{'plsv'}.' '.$lt{'tseq'}.'

'.$lt{'tfin'}.'

'.$lt{'disp'}.''); + $r->print( + '
'.&Apache::loncommon::confirmwrapper($message) + .'

'.$lt{'plsv'}.' '.$lt{'tseq'}.'

' + .'

'.$lt{'tfin'}.'

' + .&Apache::lonhtmlcommon::actionbox( + [''.$lt{'disp'}.'']) + ); my $londocroot = $r->dir_config('lonDocRoot'); if ($destdir =~ m{^\Q$londocroot/priv/$udom/$uname/$dirpath\E}) { system (" rm -r -f $destdir/temp"); } } elsif ($manifest_result eq 'nomanifest') { - $r->print($lt{'proc'}); + $r->print( + '
'.&Apache::loncommon::confirmwrapper( + &Apache::lonhtmlcommon::confirm_success($lt{'proc'},1)) + ); } } @@ -749,6 +779,12 @@ END_JS my $flag = &Apache::lonupload::phasetwo($r,$fn,'imsimport'); if ($flag eq 'ok') { &display_one($r,$fn,$fullpath,$formname_one); + } else { + $r->print( + '
'.&Apache::loncommon::confirmwrapper( + &Apache::lonhtmlcommon::confirm_success( + &mt('Error uploading IMS package'),1)) + ); } } elsif ( ($env{'form.phase'} eq 'three') || ($env{'form.phase'} eq 'four') ) { my $destdir = $env{'form.newdir'};