--- loncom/interface/londocs.pm 2005/07/26 16:41:43 1.198 +++ loncom/interface/londocs.pm 2006/03/06 17:15:29 1.223 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.198 2005/07/26 16:41:43 raeburn Exp $ +# $Id: londocs.pm,v 1.223 2006/03/06 17:15:29 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -166,7 +166,10 @@ sub dumpcourse { $crs=~s/\_/\//g; foreach (keys %replacehash) { my $newfilename=$title.'/'.$replacehash{$_}; + $newfilename=~s/\.(\w+)$//; + my $ext=$1; $newfilename=&clean($newfilename); + $newfilename.='.'.$ext; my @dirs=split(/\//,$newfilename); my $path='/home/'.$ca.'/public_html'; my $makepath=$path; @@ -252,7 +255,7 @@ sub exportbutton { return ''. ''. - &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs'); + &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs'); } sub exportcourse { @@ -490,10 +493,21 @@ sub create_ims_store { ' identifier="MANIFEST-'.$env{'request.course.id'}.'-'.$now.'"'. ' xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'. ' http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n". +' + + + + '.$env{'request.course.id'}.' + + '.$env{'course.'.$env{'request.course.id'}.'.description'}.' + + + + '."\n". ' '."\n". ' '."\n". -' '.$env{'request.'.$env{'request.course.id'}.'.description'}.'' +' '.$env{'course.'.$env{'request.course.id'}.'.description'}.'' } else { $$outcome .= 'An error occurred opening the IMS manifest file.
' ; @@ -541,7 +555,6 @@ sub build_package { $count = 0; my $imsresources; my $pkgdepth; - my $included = 0; while ($curRes = $it->next()) { if ($curRes == $it->BEGIN_MAP()) { $prevdepth = $depth; @@ -564,10 +577,13 @@ sub build_package { unless ($curRes->is_sequence()) { $resourceref = 'identifierref="RES-'.$env{'request.course.id'}.'-'.$count.'"'; } - if (($depth <= $prevdepth) && ($count > 1) && ($included)) { - print $ims_manifest "\n".' '."\n"; + my $step = $prevdepth - $depth; + if (($step >= 0) && ($count > 1)) { + while ($step >= 0) { + print $ims_manifest "\n".' '."\n"; + $step --; + } } - $included = 1; $prevdepth = $depth; my $itementry = @@ -609,8 +625,6 @@ sub build_package { } } $pkgdepth = $depth; - } else { - $included = 0; } } } @@ -645,7 +659,6 @@ sub process_content { my ($count,$curRes,$cdom,$cnum,$symb,$content_file,$href,$copyresult,$tempexport) = @_; my $content_type; my $message; -# find where user is author or co-author my @uploads = (); if ($curRes->is_sequence()) { $content_type = 'sequence'; @@ -699,6 +712,7 @@ sub process_content { if ($2 eq $env{'user.domain'} && $3 eq $env{'user.name'}) { $canedit= 1; } +# only include problem code where current user is author if ($canedit) { $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource'); } else { @@ -1100,7 +1114,7 @@ sub editor { if ($cmd eq 'del') { my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]); if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) && - ($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library)$/)) { + ($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) { &Apache::lonnet::removeuploadedurl($url); } else { &Apache::lonratedt::makezombie($Apache::lonratedt::order[$idx]); @@ -1176,22 +1190,25 @@ sub editor { } } # Loading a complete map - if (($env{'form.importmap'}) && ($env{'form.loadmap'})) { - foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) { - my ($title,$url,$ext,$type)=split(/\:/,$_); - my $idx=&Apache::lonratedt::getresidx($url); - $Apache::lonratedt::resources[$idx]=$_; - $Apache::lonratedt::order - [$#Apache::lonratedt::order+1]=$idx; - } - + if ($env{'form.loadmap'}) { + if ($env{'form.importmap'}=~/\w/) { + foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) { + my ($title,$url,$ext,$type)=split(/\:/,$_); + my $idx=&Apache::lonratedt::getresidx($url); + $Apache::lonratedt::resources[$idx]=$_; + $Apache::lonratedt::order + [$#Apache::lonratedt::order+1]=$idx; + } # Store the changed version - ($errtext,$fatal)=&storemap($coursenum,$coursedom, + ($errtext,$fatal)=&storemap($coursenum,$coursedom, $folder.'.'.$container); - if ($fatal) { - $r->print('

'.$errtext.'

'); - return; - } + if ($fatal) { + $r->print('

'.$errtext.'

'); + return; + } + } else { + $r->print('

'.&mt('No map selected.').'

'); + } } } # ---------------------------------------------------------------- End commands @@ -1201,6 +1218,8 @@ sub editor { $r->print(''); foreach (@Apache::lonratedt::order) { my ($name,$url)=split(/\:/,$Apache::lonratedt::resources[$_]); + $name=&Apache::lonratsrv::qtescape($name); + $url=&Apache::lonratsrv::qtescape($url); unless ($name) { $name=(split(/\//,$url))[-1]; } unless ($name) { $idx++; next; } $r->print(&entryline($idx,$name,$url,$folder,$allowed,$_,$coursenum)); @@ -1357,7 +1376,7 @@ sub process_secondary_uploads { if (($folder eq 'default') || ($folder eq 'supplemental')) { $destination .= 'default/'; } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) { - $destination .= $1.'/'; + $destination .= $2.'/'; } $destination .= $newidx; my ($url,$filename); @@ -1384,6 +1403,7 @@ sub entryline { &Apache::loncommon::plainname($2,$3).':
'. $foldertitle; } + $renametitle=~s/\\/\\\\/g; $renametitle=~s/\"\;/\\\"/g; my $line=''; # Edit commands @@ -1437,7 +1457,24 @@ sub entryline { 'ct' => 'Cut', 'rn' => 'Rename', 'cp' => 'Copy'); + my $nocopy=0; + if ($url=~/\.(page|sequence)$/) { + foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url))) { + my ($title,$url,$ext,$type)=split(/\:/,$_); + if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) { + $nocopy=1; + last; + } + } + } + my $copylink=' '; if ($env{'form.pagepath'}) { + unless ($nocopy) { + $copylink=(< +$lt{'cp'} +ENDCOPY + } $line.=(< @@ -1461,10 +1498,15 @@ sub entryline { $lt{'ct'} $lt{'rn'} - -$lt{'cp'} +$copylink END } else { + unless ($nocopy) { + $copylink=(< +$lt{'cp'} +ENDCOPY + } $line.=(< @@ -1487,8 +1529,7 @@ END $lt{'ct'} $lt{'rn'} - -$lt{'cp'} +$copylink END } } @@ -1518,7 +1559,7 @@ END &Apache::lonnet::allowuploaded('/adm/coursedoc',$url); } } - $url=~s/^http\&colon\;\/\//\/adm\/wrapper\/ext\//; + $url=~s-^http(\&colon\;|:)//-/adm/wrapper/ext/-; if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) { my $symb=&Apache::lonnet::symbclean( &Apache::lonnet::declutter('uploaded/'. @@ -1551,7 +1592,7 @@ END } } my $parameterset=' '; - if ($isfolder) { + if ($isfolder || $extension eq 'sequence') { my $foldername=&Apache::lonnet::escape($foldertitle); my $folderpath=$env{'form.folderpath'}; if ($folderpath) { $folderpath.='&' }; @@ -1585,7 +1626,7 @@ END } $line.=''. - ""; + ""; if (($allowed) && ($folder!~/^supplemental/)) { my %lt=&Apache::lonlocal::texthash( 'hd' => 'Hidden', @@ -1629,6 +1670,7 @@ sub tiehash { sub untiehash { if ($hashtied) { untie %hash; } $hashtied=0; + return OK; } # --------------------------------------------------------------- check on this @@ -1705,6 +1747,24 @@ sub checkonthis { # +# ----------------------------------------------------------------- List Symbs +# +sub list_symbs { + my $r=shift; + my $html=&Apache::lonxml::xmlbegin(); + $r->print($html.'Symb List'. + &Apache::loncommon::bodytag('Symb List')); + my $navmap = Apache::lonnavmaps::navmap->new(); + $r->print("
\n");
+   foreach my $res ($navmap->retrieveResources()) {
+       $r->print($res->compTitle()."\t".$res->symb()."\n");
+   }
+   $r->print("\n
\n"); + $r->print(''.&mt('Return to DOCS').''); +} + + +# # -------------------------------------------------------------- Verify Content # sub verifycontent { @@ -2048,14 +2108,14 @@ sub handler { return OK if $r->header_only; # --------------------------------------------- Initialize help topics for this - foreach ('Adding_Course_Doc','Main_Course_Documents', - 'Adding_External_Resource','Navigate_Content', - 'Adding_Folders','Docs_Overview', 'Load_Map', - 'Supplemental','Score_Upload_Form','Adding_Pages', - 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive', - 'Check_Resource_Versions','Verify_Content') { - $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_); - } + foreach ('Adding_Course_Doc','Main_Course_Documents', + 'Adding_External_Resource','Navigate_Content', + 'Adding_Folders','Docs_Overview', 'Load_Map', + 'Supplemental','Score_Upload_Form','Adding_Pages', + 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive', + 'Check_Resource_Versions','Verify_Content') { + $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_); + } # Composite help files $help{'Syllabus'} = &Apache::loncommon::help_open_topic( 'Docs_About_Syllabus,Docs_Editing_Templated_Pages'); @@ -2069,13 +2129,18 @@ sub handler { 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages'); $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching'); - if ($env{'form.verify'}) { +# does this user have privileges to modify docs + my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); + + if ($allowed && $env{'form.verify'}) { &verifycontent($r); - } elsif ($env{'form.versions'}) { + } elsif ($allowed && $env{'form.listsymbs'}) { + &list_symbs($r); + } elsif ($allowed && $env{'form.versions'}) { &checkversions($r); - } elsif ($env{'form.dumpcourse'}) { + } elsif ($allowed && $env{'form.dumpcourse'}) { &dumpcourse($r); - } elsif ($env{'form.exportcourse'}) { + } elsif ($allowed && $env{'form.exportcourse'}) { &exportcourse($r); } else { # is this a standard course? @@ -2084,7 +2149,6 @@ sub handler { my $forcestandard = 0; my $forcesupplement; my $script=''; - my $allowed; my $events=''; my $showdoc=0; my $containertag; @@ -2110,13 +2174,11 @@ sub handler { } unless ($showdoc) { # got called from remote if (($env{'form.folder'}=~/^default_/) || - ($env{'form.folder'} =~ m#^\d+/(pages|sequences)/#)) { + ($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) { $forcestandard = 1; } $forcesupplement=($env{'form.folder'}=~/^supplemental_/); -# does this user have privileges to post, etc? - $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'}); if ($allowed) { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']); $script=&Apache::lonratedt::editscript('simple'); @@ -2206,6 +2268,15 @@ function makesmpproblem() { } } +function makedropbox() { + var title=prompt('Listed Title for the Drop Box'); + if (title) { + this.document.forms.newdropbox.importdetail.value= + title+'=/res/lib/templates/DropBox.problem'; + this.document.forms.newdropbox.submit(); + } +} + function makebulboard() { var title=prompt('Listed Title for the Bulletin Board'); if (title) { @@ -2421,6 +2492,7 @@ ENDNEWSCRIPT 'navc' => 'Navigate Contents', 'sipa' => 'Simple Page', 'sipr' => 'Simple Problem', + 'drbx' => 'Drop Box', 'scuf' => 'Score Upload Form', 'bull' => 'Bulletin Board', 'mypi' => 'My Personal Info', @@ -2438,6 +2510,7 @@ ENDNEWSCRIPT my %lt=&Apache::lonlocal::texthash( 'vc' => 'Verify Content', 'cv' => 'Check/Set Resource Versions', + 'ls' => 'List Symbs', ); my $folderpath=$env{'form.folderpath'}; @@ -2472,6 +2545,8 @@ $uploadtag $help{'Check_Resource_Versions'} $dumpbut $exportbut +
$title$title +
ENDCOURSEVERIFY @@ -2574,7 +2649,7 @@ $uploadtag value="$lt{'extr'}" /> $help{'Adding_External_Resource'} -
+
@@ -2584,7 +2659,7 @@ ENDFORM $r->print(''); unless ($env{'form.pagepath'}) { $r->print(< +
@@ -2593,7 +2668,7 @@ onClick="javascript:makenewfolder(this.f value="$lt{'newf'}" />$help{'Adding_Folders'} -
+
@@ -2602,7 +2677,7 @@ onClick="javascript:makenewpage(this.for value="$lt{'newp'}" />$help{'Adding_Pages'}
-
+
$uploadtag @@ -2611,7 +2686,7 @@ value="Syllabus=/public/$coursedom/$cour $help{'Syllabus'}
-
+
$uploadtag @@ -2620,7 +2695,7 @@ value="Navigate Content=/adm/navmaps"> $help{'Navigate_Content'}
-
+
$uploadtag @@ -2628,7 +2703,7 @@ $uploadtag onClick="javascript:makesmppage();" /> $help{'Simple Page'}
-
+
$uploadtag @@ -2636,7 +2711,15 @@ $uploadtag onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
-
+
+$uploadtag + + + + +
+
$uploadtag @@ -2645,7 +2728,7 @@ onClick="javascript:makeexamupload();" / $help{'Score_Upload_Form'}
-
+
$uploadtag @@ -2654,7 +2737,7 @@ onClick="javascript:makebulboard();" /> $help{'Bulletin Board'}
-
+
$uploadtag @@ -2663,7 +2746,7 @@ value="$plainname=/adm/$udom/$uname/abou $help{'My Personal Info'}
-
+
$uploadtag @@ -2683,7 +2766,7 @@ $uploadtag onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
-
+
$uploadtag @@ -2756,7 +2839,7 @@ onClick="javascript:makenewfolder(this.f value="$lt{'newf'}" /> $help{'Adding_Folders'}
-
+
@@ -2765,7 +2848,7 @@ onClick="javascript:makenewext('supnewex value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
-
+
@@ -2774,7 +2857,7 @@ value="Syllabus=/public/$coursedom/$cour $help{'Syllabus'}
-
+