--- loncom/imspackages/imsimport.pm 2008/08/24 13:48:40 1.23
+++ loncom/imspackages/imsimport.pm 2011/10/24 21:58:04 1.34
@@ -1,3 +1,7 @@
+# The LearningOnline Network with CAPA
+#
+# $Id: imsimport.pm,v 1.34 2011/10/24 21:58:04 www Exp $
+#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
@@ -86,7 +90,7 @@ function createWin() {
newWindow = window.open("","CreateDir","HEIGHT=400,WIDTH=750,scrollbars=yes")
newWindow.document.open()
newWindow.document.write('$start_page')
- newWindow.document.write("\\n\\n")
+ newWindow.document.write("\\n\\n")
newWindow.document.write("
\\n")
newWindow.document.write("
\\n")
newWindow.document.write("
$lt{'loca'} $fullpath
$lt{'newd'}
\\n")
@@ -292,10 +296,10 @@ 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".
@@ -376,7 +380,7 @@ sub display_two {
$count{$area} ++;
}
}
- } elsif ($cms eq 'angel') {
+ } elsif ($cms eq 'angel5') {
foreach my $area (keys %{$$cmsmap{$cms}}) {
if ($area eq 'doc') {
if (grep/^$resources{$res}{type}$/,@{$$cmsmap{$cms}{doc}}) {
@@ -404,7 +408,7 @@ sub display_two {
&Apache::lonhtmlcommon::topic_bar(3,$lt{'cont'}).
&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
- '
'.$lt{'impo'}.'
'.$lt{'cont'}.'
'.
+ '
'.$lt{'impo'}.'
'.$lt{'type'}.'
'.
$lt{'addo'}.'
'.
&Apache::loncommon::end_data_table_header_row());
foreach my $area (@{$areas}) {
@@ -455,8 +459,8 @@ sub display_two {
-
-
+
+
'."\n");
if ($count{board} == 0) {
$r->print(''."\n");
@@ -522,7 +526,7 @@ sub display_three {
foreach my $area (@{$areas}) {
if (defined($env{"form.$area"}) ) {
- if ($cms eq 'angel' && $area eq 'doc') {
+ if ($cms eq 'angel5' && $area eq 'doc') {
foreach (@{$$cmsmap{$cms}{$area}}) {
$importareas{$_} = 1;
}
@@ -595,13 +599,13 @@ sub display_three {
$r->print("
IMS import completed
");
- if ($cms eq 'angel') {
+ if ($cms eq 'angel5') {
$r->print($lt{'yims'}.' '.&mt('A total of [quant,_1,sequence], [quant,_2,composite page], and [quant,_3,bulletin 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,bulletin 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'}.'');
- if ($destdir =~ m-^/home/$uname/public_html/-) {
+ $r->print('
'.$lt{'plsv'}.' '.$lt{'tseq'}.'
'.$lt{'tfin'}.'
'.$lt{'disp'}.'');
+ if ($destdir =~ m-^/home/httpd/html/priv/$udom/$uname/-) {
system (" rm -r -f $destdir/temp");
}
} elsif ($manifest_result eq 'nomanifest') {
@@ -612,63 +616,42 @@ sub display_three {
# ---------------------------------------------------------------- Get LON-CAPA Course Coordinator roles for this user
sub get_ccroles {
my ($user,$dom,$crsentry,$crslist) = @_;
- my %roles = ();
+ my %roles;
unless ($user eq '') {
- %roles = &Apache::lonnet::dump('roles',$dom,$user);
+ my $ccrole = 'cc';
+ %roles = &Apache::lonnet::get_my_roles($user,$dom,'userroles',undef,[$ccrole]);
}
my $iter = 0;
my @codes = ();
my %courses = ();
my @crslist = ();
my %descrip =();
- foreach my $key (keys %roles ) {
+ foreach my $key (keys(%roles)) {
if ($key =~ m{^/($LONCAPA::domain_re)/($LONCAPA::username_re)_cc$}) {
my $cdom = $1;
my $crs = $2;
- my $role_end = 0;
- my $role_start = 0;
- my $active_chk = 1;
- if ( $roles{$key} =~ m/^cc_(\d+)/ ) {
- $role_end = $1;
- if ( $roles{$key} =~ m/^cc_($role_end)_(\d+)$/ )
- {
- $role_start = $2;
- }
- }
- if ($role_start > 0) {
- if (time < $role_start) {
- $active_chk = 0;
- }
- }
- if ($role_end > 0) {
- if (time > $role_end) {
- $active_chk = 0;
- }
+ my $currcode = '';
+ my %settings = &Apache::lonnet::get('environment',['internal.coursecode','description'],$cdom,$crs);
+ if (defined($settings{'description'}) ) {
+ $descrip{$crs} = $settings{'description'};
+ } else {
+ $descrip{$crs} = 'Unknown';
}
- if ($active_chk) {
- my $currcode = '';
- my %settings = &Apache::lonnet::get('environment',['internal.coursecode','description'],$cdom,$crs);
- if (defined($settings{'description'}) ) {
- $descrip{$crs} = $settings{'description'};
- } else {
- $descrip{$crs} = 'Unknown';
- }
- if (defined($settings{'internal.coursecode'}) ) {
- $currcode = $settings{'internal.coursecode'};
- if ($currcode eq '') {
- $currcode = "____".$iter;
- $iter ++;
- }
- } else {
+ if (defined($settings{'internal.coursecode'}) ) {
+ $currcode = $settings{'internal.coursecode'};
+ if ($currcode eq '') {
$currcode = "____".$iter;
$iter ++;
}
- unless (grep/^$currcode$/,@codes) {
- push @codes,$currcode;
- @{$courses{$currcode}} = ();
- }
- push @{$courses{$currcode}}, $cdom.'/'.$crs;
+ } else {
+ $currcode = "____".$iter;
+ $iter ++;
+ }
+ unless (grep/^$currcode$/,@codes) {
+ push @codes,$currcode;
+ @{$courses{$currcode}} = ();
}
+ push @{$courses{$currcode}}, $cdom.'/'.$crs;
}
}
foreach my $code (sort @codes) {
@@ -701,7 +684,7 @@ sub handler {
# re-attach user
#
if ($env{'form.uploaduname'}) {
- $env{'form.filename'}='/priv/'.$env{'form.uploaduname'}.'/'.
+ $env{'form.filename'}='/priv/'.$dom.'/'.$env{'form.uploaduname'}.'/'.
$env{'form.filename'};
}
($uname,$udom)=
@@ -718,18 +701,18 @@ sub handler {
my $fn;
if ($env{'form.filename'}) {
$fn=$env{'form.filename'};
- $fn=~s/^http\:\/\/[^\/]+\///;
+ $fn=~s/^https?\:\/\/[^\/]+\///;
$fn=~s/^\///;
- $fn=~s/(\~|priv\/)($LONCAPA::username_re)//;
+ $fn=~s/(priv\/)($LONCAPA::domain_re)\/($LONCAPA::username_re)//;
$fn=~s/\/+/\//g;
} else {
$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
' unspecified filename for upload', $r->filename);
return HTTP_NOT_FOUND;
}
- my $zipupload = '/home/'.$uname.'/public_html'.$fn;
+ my $zipupload = '/home/httpd/html/priv/'.$udom.'/'.$uname.$fn;
my $pathname = &File::Basename::dirname($fn);
- my $fullpath = '/priv/'.$uname.$pathname;
+ my $fullpath = '/priv/'.$udom.'/'.$uname.$pathname;
unless ($pathname eq '/') {
$fullpath .= '/';
}
@@ -758,8 +741,10 @@ sub handler {
$r->print(&Apache::loncommon::start_page($title, $javascript));
if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
- $r->print('
'.&mt('Co-Author').': '.$uname.
- &mt(' at ').$udom.'
');
+ $r->print('
'
+ .&mt('Co-Author [_1]',$uname.':'.$udom)
+ .'
'
+ );
}
if ($env{'form.phase'} eq 'two') {
my $flag = &Apache::lonupload::phasetwo($r,$fn,$uname,$udom,'imsimport');