--- loncom/interface/londocs.pm 2011/05/27 19:02:16 1.453 +++ loncom/interface/londocs.pm 2011/07/04 13:01:53 1.454 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.453 2011/05/27 19:02:16 raeburn Exp $ +# $Id: londocs.pm,v 1.454 2011/07/04 13:01:53 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -280,6 +280,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 +311,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 +333,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 +438,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 +524,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".
'
'
;
@@ -580,7 +599,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 +639,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 +677,27 @@ sub build_package {
'
Incorrect:\E)\Q
Correct:
}) {
+ $line =~ s/^(\s+|\s+)$//g;
+ $line =~ s{^\Q\E([^<]+)\Q\E$}{1};
+ push(@tosave,$line);
+ }
+ $content = join("\t",@tosave);
+ if ($mc_answer) {
+ $content .= "\t".$mc_answer."\n";
+ }
+ }
+ if (@tosave) {
+ $content = $currdirpath."\t".$title."\t".join("\t",@tosave);
+ if ($mc_answer) {
+ $content .= "\t".$mc_answer."\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 +1004,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') {