--- loncom/interface/londocs.pm 2010/12/11 14:28:12 1.447 +++ loncom/interface/londocs.pm 2012/01/03 01:54:39 1.474 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.447 2010/12/11 14:28:12 www Exp $ +# $Id: londocs.pm,v 1.474 2012/01/03 01:54:39 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,6 +41,7 @@ use Apache::lonratedt(); use Apache::lonxml; use Apache::lonclonecourse; use Apache::lonnavmaps; +use Apache::lonnavdisplay(); use HTML::Entities; use GDBM_File; use Apache::lonlocal; @@ -176,7 +177,7 @@ sub dumpcourse { $newfilename=&clean($newfilename); $newfilename.='.'.$ext; my @dirs=split(/\//,$newfilename); - my $path='/home/'.$ca.'/public_html'; + my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca"; my $makepath=$path; my $fail=0; for (my $i=0;$i<$#dirs;$i++) { @@ -280,6 +281,7 @@ sub exportcourse { my %discussiontime = &Apache::lonnet::dump('discussiontimes', $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); my $numdisc = keys(%discussiontime); + my $numprobs = 0; my $navmap = Apache::lonnavmaps::navmap->new(); if (!defined($navmap)) { $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package'). @@ -310,6 +312,7 @@ sub exportcourse { &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['archive','discussion']); + my $format = $env{'form.format'}; my @exportitems = &Apache::loncommon::get_env_multiple('form.archive'); my @discussions = &Apache::loncommon::get_env_multiple('form.discussion'); if (@exportitems == 0 && @discussions == 0) { @@ -331,9 +334,10 @@ sub exportcourse { my $imsresources; my $tempexport; my $copyresult; - my $ims_manifest = &create_ims_store($now,\$manifestok,\$outcome,\$tempexport); + my $testbank; + my $ims_manifest = &create_ims_store($now,\$manifestok,\$outcome,\$tempexport,$format,\$testbank); if ($manifestok) { - &build_package($now,$navmap,\@exportitems,\@discussions,\$outcome,$tempexport,\$copyresult,$ims_manifest); + &build_package($now,$navmap,\@exportitems,\@discussions,\$outcome,$tempexport,\$copyresult,$ims_manifest,$format,$testbank); close($ims_manifest); #Create zip file in prtspool @@ -435,6 +439,8 @@ sub exportcourse { if (($curRes->is_sequence()) || ($curRes->is_page())) { $lastcontainer = $currelem; $display .= 'onclick="javascript:propagateCheck('."'$currelem'".')"'; + } elsif ($curRes->is_problem()) { + $numprobs ++; } $display .= ' />'."\n"; for (my $i=0; $i<$depth; $i++) { @@ -519,6 +525,16 @@ function containerCheck(item) { $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package', $scripttag)); $r->print(&Apache::lonhtmlcommon::breadcrumbs('IMS Export')); + if ($numprobs > 0) { + $display .= '
'. + &mt('Export format for LON-CAPA problems:'). + ''.(' ' x3). + ''.(' ' x3). + '
'; + } $r->print($display. ''.
''."\n".
' '
+ $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
+ .' '.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').' '.&mt('Unable to save file [_1].',''.$filename.'').' '.$errtext.'
'
;
@@ -580,7 +600,8 @@ sub create_ims_store {
}
sub build_package {
- my ($now,$navmap,$exportitems,$discussions,$outcome,$tempexport,$copyresult,$ims_manifest) = @_;
+ my ($now,$navmap,$exportitems,$discussions,$outcome,$tempexport,$copyresult,
+ $ims_manifest,$format,$testbank) = @_;
# first iterator to look for dependencies
my $it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
my $curRes;
@@ -619,6 +640,7 @@ sub build_package {
$count = 0;
my $imsresources;
my $pkgdepth;
+ my $currdirpath = 'Top';
while ($curRes = $it->next()) {
if ($curRes == $it->BEGIN_MAP()) {
$prevdepth = $depth;
@@ -656,10 +678,28 @@ sub build_package {
'
Incorrect:\E)\Q
Correct:\E(|\Q\E)\Q
\E}) {
+ $line =~ s/^(\s+|\s+)$//g;
+ $line =~ s{^\Q\E([^<]+)\Q\E$}{1};
+ $tosave[$foilcounter] .= $line.' ';
+ }
+ $content = join("\t",@tosave);
+ if ($mc_answer) {
+ $content .= "\t".$mc_answer."\n";
+ }
+ }
+ if (@tosave) {
+ my $qtype;
+ if ($mc_answer) {
+ $qtype = 'MC';
+ }
+ $content = $currdirpath."\t".$title."\t$qtype\t".join("\t",@tosave);
+ if ($mc_answer) {
+ $content .= "\t".$mc_answer;
+ }
+ $content .= "\n";
+ }
+ } else {
+ $content = ''.$content.'';
+ }
+ if (($caller eq 'plaintext') && ($testbank)) {
+ print $testbank $content;
+ }
+ } else {
+ $content = 'Not the owner of this resource';
+ }
+ } else {
+ $content = 'Not the owner of this resource';
+ }
$repstatus = 'ok';
- $content = 'Not the owner of this resource';
}
if ($repstatus eq 'ok') {
print $copiedfile $content;
@@ -905,7 +1012,6 @@ sub extract_media {
$repstatus = 'ok';
}
} elsif ($caller eq 'uploaded') {
-
$repstatus = &Apache::lonnet::getuploaded('GET',$embed_url,$cdom,$cnum,\$embed_content,$rtncode);
}
if ($repstatus eq 'ok') {
@@ -1022,37 +1128,33 @@ sub breadcrumbs {
my $isencrypted=0;
my $ishidden=0;
my $is_random_order=0;
- if (!$allowed) {
- my $description = $env{'course.'.$env{'request.course.id'}.'.description'};
- &Apache::lonhtmlcommon::add_breadcrumb(
- {'href' => '/adm/menu',
- 'title'=> 'Go to main menu',
- 'text' => $description,
- });
- $plain .= $description.' >';
- }
while (@folders) {
my $folder=shift(@folders);
my $foldername=shift(@folders);
if ($folderpath) {$folderpath.='&';}
$folderpath.=$folder.'&'.$foldername;
- my $url='/adm/coursedocs?folderpath='.
- &escape($folderpath);
- my $name=&unescape($foldername);
+ my $url;
+ if ($allowed) {
+ $url = '/adm/coursedocs?folderpath=';
+ } else {
+ $url = '/adm/supplemental?folderpath=';
+ }
+ $url .= &escape($folderpath);
+ my $name=&unescape($foldername);
# randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername
- $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//;
- if ($1 ne '') {
- $randompick=$1;
- } else {
- $randompick=-1;
- }
- if ($2) { $ishidden=1; }
- if ($3) { $isencrypted=1; }
- if ($4 ne '') { $is_random_order = 1; }
- if ($folder eq 'supplemental') {
- $name = &mt('Supplemental '.$crstype.' Documents');
- }
- &Apache::lonhtmlcommon::add_breadcrumb(
+ $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//;
+ if ($1 ne '') {
+ $randompick=$1;
+ } else {
+ $randompick=-1;
+ }
+ if ($2) { $ishidden=1; }
+ if ($3) { $isencrypted=1; }
+ if ($4 ne '') { $is_random_order = 1; }
+ if ($folder eq 'supplemental') {
+ $name = &mt('Supplemental '.$crstype.' Content');
+ }
+ &Apache::lonhtmlcommon::add_breadcrumb(
{'href'=>$url.$cpinfo,
'title'=>$name,
'text'=>$name,
@@ -1062,7 +1164,8 @@ sub breadcrumbs {
}
$plain=~s/\>\;\s*$//;
return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp',
- undef, undef, 1 ),$randompick,$ishidden,$isencrypted,$plain,$is_random_order);
+ undef, undef, 1 ),$randompick,$ishidden,
+ $isencrypted,$plain,$is_random_order);
}
sub log_docs {
@@ -1150,6 +1253,7 @@ sub docs_change_log {
&Apache::loncommon::restore_course_settings('docs_log',
\%saveable_parameters);
if (!$env{'form.show'}) { $env{'form.show'}=10; }
+# FIXME: internationalization seems wrong here
my %lt=('hiddenresource' => 'Resources hidden',
'encrypturl' => 'URL hidden',
'randompick' => 'Randomly pick',
@@ -1238,6 +1342,7 @@ sub docs_change_log {
$r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':');
foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
+# FIXME: internationalization seems wrong here
$r->print('
'.&mt('Move').' '
.''.&mt('Actions').' '
- .''.&mt('Document').' ');
+ .''.&mt('Document').' ';
if ($folder !~ /^supplemental/) {
- $->print(''.&mt('Settings').' ');
+ $to_show .= ''.&mt('Settings').' ';
}
- $r->print(&Apache::loncommon::end_data_table_header_row());
+ $to_show .= &Apache::loncommon::end_data_table_header_row();
}
- $r->print($output
+ $to_show .= $output.' '
.&Apache::loncommon::end_data_table()
- );
+ .'
'
+ .&Apache::loncommon::end_scrollbox();
} else {
- $r->print('
';
}
+ $$upload_output = '
- '.($url?'':'').''.($url?'':'').'
-
-
- '.($url?"":'').$title.($url?'':' '.$reinit.'').$external."
- ";
+ $line.='';
+ if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
+ $line.='';
+ } elsif ($url) {
+ $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
+ '',600,500);
+ } else {
+ $line.='';
+ }
+ $line.=' ';
+ if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
+ $line.=''.$title.'';
+ } elsif ($url) {
+ $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
+ $title,600,500);
+ } else {
+ $line.=$title.' '.$reinit.'';
+ }
+ $line.=$external." ";
if (($allowed) && ($folder!~/^supplemental/)) {
my %lt=&Apache::lonlocal::texthash(
'hd' => 'Hidden',
@@ -2101,14 +2249,13 @@ END
$form_start
$form_end
-
-
+
-
$form_start
$form_end
$form_start $rand_order_text $form_end
- $form_start $parameterset $form_end
+ $form_start $parameterset $form_end
ENDPARMS
}
$line.=&Apache::loncommon::end_data_table_row();
@@ -2513,7 +2660,7 @@ ENDHEADERS
$r->print(' '.&mt('Diffs').'');
+ '" target="diffs">'.&mt('Diffs').'');
}
$r->print('
+ $form_start $rand_order_text $form_end
');
if (++$entries_count % $entries_per_col == 0) {
@@ -2632,25 +2779,21 @@ sub create_form_ul {
sub startContentScreen {
my ($r,$mode)=@_;
$r->print(' ');
- $r->print('