version 1.24, 2008/08/25 13:03:40
|
version 1.42, 2013/07/15 16:13:16
|
Line 1
|
Line 1
|
|
# The LearningOnline Network with CAPA |
|
# |
|
# $Id$ |
|
# |
# Copyright Michigan State University Board of Trustees |
# Copyright Michigan State University Board of Trustees |
# |
# |
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
# This file is part of the LearningOnline Network with CAPA (LON-CAPA). |
Line 25 package Apache::imsimport;
|
Line 29 package Apache::imsimport;
|
|
|
use strict; |
use strict; |
use Apache::Constants qw(:common :http :methods); |
use Apache::Constants qw(:common :http :methods); |
use Apache::loncacc; |
|
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::imsprocessor; |
use Apache::imsprocessor; |
Line 39 use LONCAPA;
|
Line 42 use LONCAPA;
|
|
|
# ---------------------------------------------------------------- Jscript One |
# ---------------------------------------------------------------- Jscript One |
sub jscript_one { |
sub jscript_one { |
my ($fullpath,$jsref,$formname) = @_; |
my ($fullpath,$formname) = @_; |
|
|
my %body_layout = ('rightmargin' => "0", |
my %body_layout = ('rightmargin' => "0", |
'leftmargin' => "0", |
'leftmargin' => "0", |
Line 62 sub jscript_one {
|
Line 65 sub jscript_one {
|
nndi => 'Enter the name of the new directory where you will store the contents of your IMS package.', |
nndi => 'Enter the name of the new directory where you will store the contents of your IMS package.', |
go => 'Go', |
go => 'Go', |
); |
); |
$$jsref = <<"END_OF_ONE"; |
return <<"END_OF_ONE"; |
function verify() { |
function verify() { |
if ((document.forms.$formname.newdir.value == '') || (!document.forms.$formname.newdir.value)) { |
if ((document.forms.$formname.newdir.value == '') || (!document.forms.$formname.newdir.value)) { |
alert('$lt{'ddir'}') |
alert('$lt{'ddir'}') |
Line 86 function createWin() {
|
Line 89 function createWin() {
|
newWindow = window.open("","CreateDir","HEIGHT=400,WIDTH=750,scrollbars=yes") |
newWindow = window.open("","CreateDir","HEIGHT=400,WIDTH=750,scrollbars=yes") |
newWindow.document.open() |
newWindow.document.open() |
newWindow.document.write('$start_page') |
newWindow.document.write('$start_page') |
newWindow.document.write("\\n<img border='0' src='/adm/lonInterFace/author.jpg' alt='[Author Header]'>\\n") |
newWindow.document.write("\\n<img border='0' src='/adm/lonInterFace/author.jpg' alt='[Author Header]' />\\n") |
newWindow.document.write("<table border='0' cellspacing='0' cellpadding='0' width='600'>\\n") |
newWindow.document.write("<table border='0' cellspacing='0' cellpadding='0' width='600'>\\n") |
newWindow.document.write("<tr><td width='2'> </td><td width='3'> </td>\\n") |
newWindow.document.write("<tr><td width='2'> </td><td width='3'> </td>\\n") |
newWindow.document.write("<td><h3>$lt{'loca'} <tt>$fullpath</tt></h3><h3>$lt{'newd'}</h3></td></tr>\\n") |
newWindow.document.write("<td><h3>$lt{'loca'} <tt>$fullpath</tt></h3><h3>$lt{'newd'}</h3></td></tr>\\n") |
Line 97 function createWin() {
|
Line 100 function createWin() {
|
newWindow.document.write("<input type='hidden' name='action' value='newdir' />") |
newWindow.document.write("<input type='hidden' name='action' value='newdir' />") |
newWindow.document.write("<input type='hidden' name='callingmode' value='imsimport' />") |
newWindow.document.write("<input type='hidden' name='callingmode' value='imsimport' />") |
newWindow.document.write("$fullpath<input type='text' name='newfilename' value='' />") |
newWindow.document.write("$fullpath<input type='text' name='newfilename' value='' />") |
newWindow.document.write("<input type='button' value='$lt{'go'}' onClick='document.fileaction.submit();' />") |
newWindow.document.write("<input type='button' value='$lt{'go'}' onclick='document.fileaction.submit();' />") |
newWindow.document.write("</td></tr>\\n") |
newWindow.document.write("</td></tr>\\n") |
newWindow.document.write("</table>") |
newWindow.document.write("</table>") |
newWindow.document.write('$end_page') |
newWindow.document.write('$end_page') |
Line 111 END_OF_ONE
|
Line 114 END_OF_ONE
|
|
|
# ---------------------------------------------------------------- Jscript Two |
# ---------------------------------------------------------------- Jscript Two |
sub jscript_two { |
sub jscript_two { |
my ($javascript,$user,$dom,$numcrs) = @_; |
my ($user,$dom,$numcrs) = @_; |
my %crsentry = (); |
my %crsentry = (); |
my $course_list; |
my $course_list; |
my $title_list; |
my $title_list; |
Line 130 sub jscript_two {
|
Line 133 sub jscript_two {
|
$course_list = '"'.join('","',@crslist).'"'; |
$course_list = '"'.join('","',@crslist).'"'; |
$$numcrs = @crslist; |
$$numcrs = @crslist; |
|
|
$$javascript = qq# |
return <<"END_OF_TWO"; |
|
|
function checkCourse() { |
function checkCourse() { |
courseID_array = new Array($course_list) |
courseID_array = new Array($course_list) |
Line 276 function nextPage(caller) {
|
Line 279 function nextPage(caller) {
|
} |
} |
} |
} |
|
|
#; |
END_OF_TWO |
|
|
} |
|
|
|
# ---------------------------------------------------------------- Jscript Three |
|
sub jscript_three { |
|
my $javascript = shift; |
|
} |
} |
|
|
# ---------------------------------------------------------------- Display One |
# ---------------------------------------------------------------- Display One |
sub display_one { |
sub display_one { |
my ($r,$uname,$fn,$fullpath,$formname) = @_; |
my ($r,$fn,$fullpath,$formname) = @_; |
$r->print('<form name="'.$formname.'" method="post">'. |
$r->print('<form name="'.$formname.'" method="post" action="">'. |
&Apache::lonhtmlcommon::topic_bar(1,&mt('Specify the Course Management system used to create the package')). |
&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.').' |
&mt('Choose the CMS used to create your IMS content package.').' |
<select name="source"> |
<select name="source"> |
<option value="-1" selected="true">Please select</option> |
<option value="-1" selected="selected">Please select</option> |
<option value="bb5">Blackboard 5</option> |
<option value="bb5">Blackboard 5</option> |
<option value="bb6">Blackboard 6</option> |
<option value="bb6">Blackboard 6</option> |
<option value="angel">ANGEL</option> |
<option value="angel5">ANGEL 5.5</option> |
<option value="webctce4">WebCT 4 Campus Edition</option> |
<option value="webctce4">WebCT 4 Campus Edition</option> |
<option value="webctvista4">WebCT Vista 4</option> |
<option value="webctvista4">WebCT Vista 4</option> |
</select><br />'."\n". |
</select><br />'."\n". |
&Apache::lonhtmlcommon::topic_bar(2,&mt('Create a directory where you will unpack your IMS 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.').' <input type="button" name="createdir" value="Create Directory" onClick="javascript:createWin()" /><input type="hidden" name="newdir" value="" /><br /><br /> |
&mt('Create a destination LON-CAPA directory in which to store the contents of the IMS package file.').' <input type="button" name="createdir" value="Create Directory" onclick="javascript:createWin()" /><input type="hidden" name="newdir" value="" /><br /><br /> |
<input type="hidden" name="uploaduname" value="'.$uname.'" /> |
|
<input type="hidden" name="filename" value="'.$fn.'" /> |
<input type="hidden" name="filename" value="'.$fn.'" /> |
<input type="hidden" name="phase" value="three" /> |
<input type="hidden" name="phase" value="three" /> |
<input type="button" name="nextpage" value="'.&mt('Proceed').'" onClick="javascript:nextPage();" /> |
<input type="button" name="nextpage" value="'.&mt('Proceed').'" onclick="javascript:nextPage();" /> |
<input type="button" name="exitpage" value="'.&mt('Exit now').'" onClick="javascript:location.href='."'$fullpath'".'" /> |
<input type="button" name="exitpage" value="'.&mt('Exit now').'" onclick="javascript:location.href='."'$fullpath'".'" /> |
</form>'); |
</form>'); |
} |
} |
|
|
# ---------------------------------------------------------------- Display Two |
# ---------------------------------------------------------------- Display Two |
sub display_two { |
sub display_two { |
my ($r,$zipupload,$areas,$areaname,$cmsmap,$uname,$newdir,$numcrs,$fullpath) = @_; |
my ($r,$zipupload,$areas,$areaname,$cmsmap,$fn,$numcrs,$fullpath) = @_; |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder','source']); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder','source']); |
my $cms = $env{'form.source'}; |
my $cms = $env{'form.source'}; |
my $dirname = $env{'form.newdir'}; |
my $tempdir = &Apache::imsprocessor::create_tempdir('CSTR',$env{'form.newdir'},''); |
my $tempdir = &Apache::imsprocessor::create_tempdir('CSTR',$dirname,''); |
|
my $fname = &Apache::imsprocessor::uploadzip('CSTR',$tempdir,$zipupload); |
my $fname = &Apache::imsprocessor::uploadzip('CSTR',$tempdir,$zipupload); |
my $unzip_result = ''; |
my $unzip_result = ''; |
my $manifest_result = ''; |
my $manifest_result = ''; |
Line 376 sub display_two {
|
Line 372 sub display_two {
|
$count{$area} ++; |
$count{$area} ++; |
} |
} |
} |
} |
} elsif ($cms eq 'angel') { |
} elsif ($cms eq 'angel5') { |
foreach my $area (keys %{$$cmsmap{$cms}}) { |
foreach my $area (keys %{$$cmsmap{$cms}}) { |
if ($area eq 'doc') { |
if ($area eq 'doc') { |
if (grep/^$resources{$res}{type}$/,@{$$cmsmap{$cms}{doc}}) { |
if (grep/^$resources{$res}{type}$/,@{$$cmsmap{$cms}{doc}}) { |
Line 400 sub display_two {
|
Line 396 sub display_two {
|
$conditions = 'none'; |
$conditions = 'none'; |
} |
} |
|
|
$r->print('<form name="pickoptions" method="post">'. |
$r->print('<form name="pickoptions" method="post" action="">'. |
&Apache::lonhtmlcommon::topic_bar(3,$lt{'cont'}). |
&Apache::lonhtmlcommon::topic_bar(3,$lt{'cont'}). |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row(). |
&Apache::loncommon::start_data_table_header_row(). |
Line 413 sub display_two {
|
Line 409 sub display_two {
|
$r->print(&Apache::loncommon::start_data_table_row()."\n". |
$r->print(&Apache::loncommon::start_data_table_row()."\n". |
'<td><input name="'.$area.'" type="checkbox" '); |
'<td><input name="'.$area.'" type="checkbox" '); |
if ($area eq 'board' || $area eq 'users') { |
if ($area eq 'board' || $area eq 'users') { |
$r->print('onClick="javascript:setOptions('."'$area','$counter'".');" '); |
$r->print('onclick="javascript:setOptions('."'$area','$counter'".');" '); |
} |
} |
$r->print('/></td>'. |
$r->print('/></td>'. |
'<td> '.$$areaname{$area}.' - '. |
'<td> '.$$areaname{$area}.' - '. |
Line 455 sub display_two {
|
Line 451 sub display_two {
|
<input type="hidden" name="conditions" value="'.$conditions.'" /> |
<input type="hidden" name="conditions" value="'.$conditions.'" /> |
<input type="hidden" name="source" value="'.$cms.'" /> |
<input type="hidden" name="source" value="'.$cms.'" /> |
<input type="hidden" name="tempdir" value="'.$tempdir.'" /> |
<input type="hidden" name="tempdir" value="'.$tempdir.'" /> |
<input type="hidden" name="uploaduname" value="'.$uname.'"> |
<input type="hidden" name="filename" value="'.$fn.'" /> |
<input type="hidden" name="filename" value="'.$fname.'"> |
|
<input type="hidden" name="phase" value="four" />'."\n"); |
<input type="hidden" name="phase" value="four" />'."\n"); |
if ($count{board} == 0) { |
if ($count{board} == 0) { |
$r->print('<input type="hidden" name="board" value="" />'."\n"); |
$r->print('<input type="hidden" name="board" value="" />'."\n"); |
Line 464 sub display_two {
|
Line 459 sub display_two {
|
if ($count{users} == 0) { |
if ($count{users} == 0) { |
$r->print('<input type="hidden" name="users" value="" />'."\n"); |
$r->print('<input type="hidden" name="users" value="" />'."\n"); |
} |
} |
$r->print('<input type="button" name="nextpage" value="'.$lt{'impa'}.'" onClick="javascript:nextPage('."'$counter.'".')" /> |
$r->print('<input type="button" name="nextpage" value="'.$lt{'impa'}.'" onclick="javascript:nextPage('."'$counter.'".')" /> |
<input type="button" name="exitpage" value="'.$lt{'exit'}.'" onClick="javascript:location.href='."'$fullpath'".'" /></form>'); |
<input type="button" name="exitpage" value="'.$lt{'exit'}.'" onclick="javascript:location.href='."'$fullpath'".'" /></form>'); |
} else { |
} else { |
$r->print($lt{'unpa'}); |
$r->print($lt{'unpa'}); |
} |
} |
Line 476 sub display_two {
|
Line 471 sub display_two {
|
|
|
# ---------------------------------------------------------------- Display Three |
# ---------------------------------------------------------------- Display Three |
sub display_three { |
sub display_three { |
my ($r,$uname,$udom,$areas,$areaname,$cmsmap,$destdir,$newdir) = @_; |
my ($r,$uname,$udom,$areas,$areaname,$cmsmap,$destdir,$dirpath) = @_; |
my $crs = ''; |
my $crs = ''; |
my $cdom = ''; |
my $cdom = ''; |
my $db_handling = ''; |
my $db_handling = ''; |
Line 492 sub display_three {
|
Line 487 sub display_three {
|
if ( defined($env{'form.user_crs'}) ) { |
if ( defined($env{'form.user_crs'}) ) { |
($user_cdom,$user_crs) = split/\//,$env{'form.user_crs'}; |
($user_cdom,$user_crs) = split/\//,$env{'form.user_crs'}; |
} |
} |
my $seqstem = "/res/$udom/$uname/$newdir"; |
my $seqstem = "/res/$udom/$uname/$dirpath"; |
my %importareas = (); |
my %importareas = (); |
my %includedres = (); |
my %includedres = (); |
my %includeditems = (); |
my %includeditems = (); |
Line 522 sub display_three {
|
Line 517 sub display_three {
|
|
|
foreach my $area (@{$areas}) { |
foreach my $area (@{$areas}) { |
if (defined($env{"form.$area"}) ) { |
if (defined($env{"form.$area"}) ) { |
if ($cms eq 'angel' && $area eq 'doc') { |
if ($cms eq 'angel5' && $area eq 'doc') { |
foreach (@{$$cmsmap{$cms}{$area}}) { |
foreach (@{$$cmsmap{$cms}{$area}}) { |
$importareas{$_} = 1; |
$importareas{$_} = 1; |
} |
} |
Line 541 sub display_three {
|
Line 536 sub display_three {
|
yims => 'Your IMS package has been processed successfully.', |
yims => 'Your IMS package has been processed successfully.', |
plsv => 'Please view the imported items and use the LON-CAPA editing tools to make changes.', |
plsv => 'Please view the imported items and use the LON-CAPA editing tools to make changes.', |
tseq => "The sequences directory contains a file named 'Top.sequence' which includes links to the items found at the top level of your IMS package. From there you can follow links to display all the imported items. Alternatively, you can browse the pages, sequences, problems and resfiles directories directly. Note if you rename a file, you will need to modify any .sequence files or .page files which include a reference to the renamed file.", |
tseq => "The sequences directory contains a file named 'Top.sequence' which includes links to the items found at the top level of your IMS package. From there you can follow links to display all the imported items. Alternatively, you can browse the pages, sequences, problems and resfiles directories directly. Note if you rename a file, you will need to modify any .sequence files or .page files which include a reference to the renamed file.", |
tfin => 'The final step in the IMS import process is to publish the materials you have imported into your Construction Space so that you can use them in a course. Once your files are published, subsequent re-publication will result in the storage of information about changes between the different versions.', |
tfin => 'The final step in the IMS import process is to publish the materials you have imported into your Authoring Space so that you can use them in a course. Once your files are published, subsequent re-publication will result in the storage of information about changes between the different versions.', |
disp => 'Display new directory', |
disp => 'Display new directory', |
proc => 'Processing of your IMS package failed, because the IMS content package did not contain an IMS manifest file.' |
proc => 'Processing of your IMS package failed, because the IMS content package did not contain an IMS manifest file.' |
); |
); |
Line 591 sub display_three {
|
Line 586 sub display_three {
|
|
|
my $copy_result = &Apache::imsprocessor::copy_resources('CSTR',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$destdir,$timenow,\@assessmentfiles,\%total); |
my $copy_result = &Apache::imsprocessor::copy_resources('CSTR',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$destdir,$timenow,\@assessmentfiles,\%total); |
|
|
&Apache::imsprocessor::build_structure($cms,'CSTR',$destdir,\%items,\%resinfo,\%resources,\@targets,\%hrefs,$udom,$uname,$newdir,$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\@pools,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames,\@packages,\%includeditems,\%randompicks); |
&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("<h3>IMS import completed</h3>"); |
$r->print("<h3>IMS import completed</h3>"); |
|
|
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"); |
$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 { |
} 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{'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('<br /><br />'.$lt{'plsv'}.' '.$lt{'tseq'}.'<br /><br />'.$lt{'tfin'}.'<br /><br /><a href="/priv/'.$uname.'/'.$newdir.'">'.$lt{'disp'}.'</a>'); |
$r->print('<br /><br />'.$lt{'plsv'}.' '.$lt{'tseq'}.'<br /><br />'.$lt{'tfin'}.'<br /><br /><a href="/priv/'.$udom.'/'.$uname.'/'.$dirpath.'/">'.$lt{'disp'}.'</a>'); |
if ($destdir =~ m-^/home/$uname/public_html/-) { |
my $londocroot = $r->dir_config('lonDocRoot'); |
|
if ($destdir =~ m{^\Q$londocroot/priv/$udom/$uname/$dirpath\E}) { |
system (" rm -r -f $destdir/temp"); |
system (" rm -r -f $destdir/temp"); |
} |
} |
} elsif ($manifest_result eq 'nomanifest') { |
} elsif ($manifest_result eq 'nomanifest') { |
Line 612 sub display_three {
|
Line 608 sub display_three {
|
# ---------------------------------------------------------------- Get LON-CAPA Course Coordinator roles for this user |
# ---------------------------------------------------------------- Get LON-CAPA Course Coordinator roles for this user |
sub get_ccroles { |
sub get_ccroles { |
my ($user,$dom,$crsentry,$crslist) = @_; |
my ($user,$dom,$crsentry,$crslist) = @_; |
my %roles = (); |
my %roles; |
unless ($user eq '') { |
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 $iter = 0; |
my @codes = (); |
my @codes = (); |
my %courses = (); |
my %courses = (); |
my @crslist = (); |
my @crslist = (); |
my %descrip =(); |
my %descrip =(); |
foreach my $key (keys %roles ) { |
foreach my $key (keys(%roles)) { |
if ($key =~ m{^/($LONCAPA::domain_re)/($LONCAPA::username_re)_cc$}) { |
if ($key =~ m{^/($LONCAPA::domain_re)/($LONCAPA::username_re)_cc$}) { |
my $cdom = $1; |
my $cdom = $1; |
my $crs = $2; |
my $crs = $2; |
my $role_end = 0; |
my $currcode = ''; |
my $role_start = 0; |
my %settings = &Apache::lonnet::get('environment',['internal.coursecode','description'],$cdom,$crs); |
my $active_chk = 1; |
if (defined($settings{'description'}) ) { |
if ( $roles{$key} =~ m/^cc_(\d+)/ ) { |
$descrip{$crs} = $settings{'description'}; |
$role_end = $1; |
} else { |
if ( $roles{$key} =~ m/^cc_($role_end)_(\d+)$/ ) |
$descrip{$crs} = 'Unknown'; |
{ |
|
$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; |
|
} |
|
} |
} |
if ($active_chk) { |
if (defined($settings{'internal.coursecode'}) ) { |
my $currcode = ''; |
$currcode = $settings{'internal.coursecode'}; |
my %settings = &Apache::lonnet::get('environment',['internal.coursecode','description'],$cdom,$crs); |
if ($currcode eq '') { |
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 { |
|
$currcode = "____".$iter; |
$currcode = "____".$iter; |
$iter ++; |
$iter ++; |
} |
} |
unless (grep/^$currcode$/,@codes) { |
} else { |
push @codes,$currcode; |
$currcode = "____".$iter; |
@{$courses{$currcode}} = (); |
$iter ++; |
} |
} |
push @{$courses{$currcode}}, $cdom.'/'.$crs; |
unless (grep/^$currcode$/,@codes) { |
|
push @codes,$currcode; |
|
@{$courses{$currcode}} = (); |
} |
} |
|
push @{$courses{$currcode}}, $cdom.'/'.$crs; |
} |
} |
} |
} |
foreach my $code (sort @codes) { |
foreach my $code (sort @codes) { |
Line 686 sub get_ccroles {
|
Line 661 sub get_ccroles {
|
# ---------------------------------------------------------------- Main Handler |
# ---------------------------------------------------------------- Main Handler |
sub handler { |
sub handler { |
my $r=shift; |
my $r=shift; |
my $uname; |
|
my $udom; |
|
my $javascript = ''; |
|
my $page_name = ''; |
|
my $current_page = ''; |
|
my $qcount = ''; |
|
|
|
# get personal information for this user |
my $fn=$env{'form.filename'}; |
my $user=$env{'user.name'}; |
|
my $dom=$env{'user.domain'}; |
|
|
|
# |
if ($env{'form.filename1'}) { |
# re-attach user |
$fn=$env{'form.filename1'}.$env{'form.filename2'}; |
# |
|
if ($env{'form.uploaduname'}) { |
|
$env{'form.filename'}='/priv/'.$env{'form.uploaduname'}.'/'. |
|
$env{'form.filename'}; |
|
} |
|
($uname,$udom)= |
|
&Apache::loncacc::constructaccess($env{'form.filename'}, |
|
$r->dir_config('lonDefDomain')); |
|
unless (($uname) && ($udom)) { |
|
$r->log_reason($uname.' at '.$udom. |
|
' trying to publish file '.$env{'form.filename'}. |
|
' - not authorized', |
|
$r->filename); |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
} |
|
$fn=~s{\+}{}g; |
my $fn; |
|
if ($env{'form.filename'}) { |
unless ($fn) { |
$fn=$env{'form.filename'}; |
|
$fn=~s/^http\:\/\/[^\/]+\///; |
|
$fn=~s/^\///; |
|
$fn=~s/(\~|priv\/)($LONCAPA::username_re)//; |
|
$fn=~s/\/+/\//g; |
|
} else { |
|
$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}. |
$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}. |
' unspecified filename for upload', $r->filename); |
' unspecified filename for upload', $r->filename); |
return HTTP_NOT_FOUND; |
return HTTP_NOT_FOUND; |
} |
} |
my $zipupload = '/home/'.$uname.'/public_html'.$fn; |
|
my $pathname = &File::Basename::dirname($fn); |
my ($uname,$udom) = &Apache::lonnet::constructaccess($fn); |
my $fullpath = '/priv/'.$uname.$pathname; |
if (($uname eq '') || ($udom eq '')) { |
unless ($pathname eq '/') { |
$r->log_reason($uname.' at '.$udom. |
|
' trying to publish file '.$fn.' - not authorized', |
|
$r->filename); |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
|
|
|
my $londocroot = $r->dir_config('lonDocRoot'); |
|
my $zipupload = $londocroot.$fn; |
|
my $fullpath = &File::Basename::dirname($fn); |
|
unless ($fullpath =~ m{/$}) { |
$fullpath .= '/'; |
$fullpath .= '/'; |
} |
} |
|
|
|
# get personal information for this user |
|
my $user=$env{'user.name'}; |
|
my $dom=$env{'user.domain'}; |
|
|
|
my $javascript = ''; |
|
my $page_name = ''; |
|
my $current_page = ''; |
|
my $qcount = ''; |
my @areas = (); |
my @areas = (); |
my %cmsmap = (); |
my %cmsmap = (); |
my %areaname = (); |
my %areaname = (); |
Line 746 sub handler {
|
Line 710 sub handler {
|
|
|
my $formname_one = 'info'; |
my $formname_one = 'info'; |
if ($env{'form.phase'} eq 'two') { |
if ($env{'form.phase'} eq 'two') { |
&jscript_one($fullpath,\$javascript,$formname_one); |
$javascript = &jscript_one($fullpath,$formname_one); |
} elsif ($env{'form.phase'} eq 'three') { |
} elsif ($env{'form.phase'} eq 'three') { |
&jscript_two(\$javascript,$user,$dom,\$numcrs); |
$javascript = &jscript_two($user,$dom,\$numcrs); |
} elsif ($env{'form.phase'} eq 'four') { |
|
&jscript_three(\$javascript); |
|
} |
} |
$javascript = "<script type=\"text/javascript\">\n//<!--\n$javascript\n// --></script>\n"; |
if ($javascript ne '') { |
|
$javascript = <<"END_JS"; |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
|
my $title = 'Upload IMS package to Construction Space'; |
$javascript |
|
|
|
// ]]> |
|
</script> |
|
END_JS |
|
} |
|
|
|
my $title = 'Upload IMS package to Authoring Space'; |
$r->print(&Apache::loncommon::start_page($title, $javascript)); |
$r->print(&Apache::loncommon::start_page($title, $javascript)); |
|
|
if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) { |
if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) { |
$r->print('<h3><font color=red>'.&mt('Co-Author').': '.$uname. |
$r->print('<p><span class="LC_info">' |
&mt(' at ').$udom.'</font></h3>'); |
.&mt('Co-Author [_1]',$uname.':'.$udom) |
} |
.'</span></p>' |
|
); |
|
} |
if ($env{'form.phase'} eq 'two') { |
if ($env{'form.phase'} eq 'two') { |
my $flag = &Apache::lonupload::phasetwo($r,$fn,$uname,$udom,'imsimport'); |
my $flag = &Apache::lonupload::phasetwo($r,$fn,'imsimport'); |
if ($flag eq 'ok') { |
if ($flag eq 'ok') { |
&display_one($r,$uname,$fn,$fullpath,$formname_one); |
&display_one($r,$fn,$fullpath,$formname_one); |
} |
} |
} elsif ( ($env{'form.phase'} eq 'three') || ($env{'form.phase'} eq 'four') ) { |
} elsif ( ($env{'form.phase'} eq 'three') || ($env{'form.phase'} eq 'four') ) { |
my $docroot = $env{'form.newdir'}; |
my $destdir = $env{'form.newdir'}; |
my $newdir = ''; |
my $dirpath = $destdir; |
if ($docroot =~ m|public_html/(.+)$|) { |
$dirpath =~ s{^\Q$londocroot/priv/$udom/$uname/\E}{}; |
$newdir = $1; |
|
} |
|
if ($env{'form.phase'} eq 'three') { |
if ($env{'form.phase'} eq 'three') { |
&display_two ($r,$zipupload,\@areas,\%areaname,\%cmsmap,$uname,$newdir,\$numcrs,$fullpath); |
&display_two($r,$zipupload,\@areas,\%areaname,\%cmsmap,$fn,\$numcrs,$fullpath); |
} elsif ($env{'form.phase'} eq 'four') { |
} elsif ($env{'form.phase'} eq 'four') { |
&display_three ($r,$uname,$udom,\@areas,\%areaname,\%cmsmap,$docroot,$newdir); |
&display_three($r,$uname,$udom,\@areas,\%areaname,\%cmsmap,$destdir,$dirpath); |
} |
} |
} else { |
} else { |
&Apache::lonupload::phaseone($r,$fn,$uname,$udom,'imsimport'); |
&Apache::lonupload::phaseone($r,$fn,'imsimport',$uname,$udom); |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return OK; |
return OK; |