version 1.653, 2018/04/14 02:29:44
|
version 1.654, 2018/04/24 11:17:58
|
Line 5460 sub handler {
|
Line 5460 sub handler {
|
$r->internal_redirect($redirect); |
$r->internal_redirect($redirect); |
return OK; |
return OK; |
} |
} |
|
} else { |
|
$r->internal_redirect($redirect); |
} |
} |
} |
} |
} |
} |
Line 8637 sub makenewproblem {
|
Line 8639 sub makenewproblem {
|
if ($env{'form.newsubdir'}) { |
if ($env{'form.newsubdir'}) { |
if ($env{'form.newsubdirname'} ne '') { |
if ($env{'form.newsubdirname'} ne '') { |
$newsubdir = $env{'form.newsubdirname'}; |
$newsubdir = $env{'form.newsubdirname'}; |
} |
} |
} |
} |
if ($env{'form.newresourcename'}) { |
if ($env{'form.newresourcename'}) { |
$filename = $env{'form.newresourcename'}; |
$filename = $env{'form.newresourcename'}; |
Line 8720 END
|
Line 8722 END
|
<subject></subject> |
<subject></subject> |
<title></title> |
<title></title> |
END |
END |
close($fh); |
close($fh); |
} |
|
if ((-e $sourcerights) && (-e "$sourcerights.meta")) { |
|
if (!-e "$docroot/res/$coursedom") { |
|
mkdir("$docroot/res/$coursedom",0755); |
|
} |
|
if (!-e "$docroot/res/$coursedom/$coursenum") { |
|
mkdir("$docroot/res/$coursedom/$coursenum",0755); |
|
} |
|
if ((-e "$docroot/res/$coursedom/$coursenum") && (!-e $targetrights)) { |
|
my $nokeyref = &Apache::lonpublisher::getnokey($r->dir_config('lonIncludes')); |
|
my $output = &Apache::lonpublisher::batchpublish($r,$sourcerights,$targetrights,$nokeyref,1); |
|
} |
|
} |
} |
} |
} |
if ($env{'form.newresourceadd'}) { |
if ((-e $sourcerights) && (-e "$sourcerights.meta")) { |
my $template = $env{'form.template'}; |
if (!-e "$docroot/res/$coursedom") { |
my $source = $docroot.$redirect; |
mkdir("$docroot/res/$coursedom",0755); |
my $target = $redirect; |
} |
$target =~ s{^/priv/}{/res/}; |
if (!-e "$docroot/res/$coursedom/$coursenum") { |
$target = $docroot.$target; |
mkdir("$docroot/res/$coursedom/$coursenum",0755); |
if (!-e $source) { |
|
my $copyfrom; |
|
if ($template) { |
|
my %templates; |
|
my @files = &Apache::lonhomework::get_template_list('problem'); |
|
foreach my $poss (@files) { |
|
if (ref($poss) eq 'ARRAY') { |
|
if ($template eq $poss->[0]) { |
|
$templates{$template} = 1; |
|
last; |
|
} |
|
} |
|
} |
|
if ($templates{$template}) { |
|
$copyfrom = $template; |
|
} |
|
} |
|
unless ($copyfrom) { |
|
$copyfrom = $r->dir_config('lonIncludes').'/templates/blank.problem'; |
|
} |
|
&File::Copy::copy($copyfrom,$source); |
|
} |
} |
if (!-e "$source.meta") { |
if ((-e "$docroot/res/$coursedom/$coursenum") && (!-e $targetrights)) { |
my $cid = $coursedom.'_'.$coursenum; |
my $nokeyref = &Apache::lonpublisher::getnokey($r->dir_config('lonIncludes')); |
my $now = time; |
my $output = &Apache::lonpublisher::batchpublish($r,$sourcerights,$targetrights,$nokeyref,1); |
if (open(my $fh,">$source.meta")) { |
} |
my $author=$env{'environment.firstname'}.' '. |
} |
$env{'environment.middlename'}.' '. |
my $source = $docroot.$redirect; |
$env{'environment.lastname'}.' '. |
if (!-e "$source.meta") { |
$env{'environment.generation'}; |
my $cid = $coursedom.'_'.$coursenum; |
$author =~ s/\s+$//; |
my $now = time; |
my $title = $env{'form.newresourcetitle'}; |
if (open(my $fh,">$source.meta")) { |
$title =~ s/^\s+|\s+$//g; |
my $author=$env{'environment.firstname'}.' '. |
print $fh <<END; |
$env{'environment.middlename'}.' '. |
|
$env{'environment.lastname'}.' '. |
|
$env{'environment.generation'}; |
|
$author =~ s/\s+$//; |
|
my $title = $env{'form.newresourcetitle'}; |
|
$title =~ s/^\s+|\s+$//g; |
|
print $fh <<END; |
|
|
<abstract></abstract> |
<abstract></abstract> |
<author>$author</author> |
<author>$author</author> |
Line 8800 END
|
Line 8775 END
|
<subject></subject> |
<subject></subject> |
<title>$title</title> |
<title>$title</title> |
END |
END |
close($fh); |
close($fh); |
} |
|
} |
} |
} |
} |
} |
} |
Line 8829 END
|
Line 8803 END
|
} |
} |
|
|
sub finishnewprob { |
sub finishnewprob { |
my ($url,$path,$subdir,$newsubdir,$filename) = @_; |
my ($url,$path,$subdir,$newsubdir,$filename,$context) = @_; |
unless (-d $path) { |
unless (-d $path) { |
unless (mkdir($path,02770)) { |
unless (mkdir($path,02770)) { |
return; |
return; |
Line 8872 sub finishnewprob {
|
Line 8846 sub finishnewprob {
|
$redirect = "$url/$filename"; |
$redirect = "$url/$filename"; |
} |
} |
} |
} |
|
if ((!-e $dest) && ($context ne 'upload')) { |
|
my $template = $env{'form.template'}; |
|
my $copyfrom; |
|
if ($template ne '') { |
|
my %templates; |
|
my @files = &Apache::lonhomework::get_template_list('problem'); |
|
foreach my $poss (@files) { |
|
if (ref($poss) eq 'ARRAY') { |
|
if ($template eq $poss->[0]) { |
|
$templates{$template} = 1; |
|
last; |
|
} |
|
} |
|
} |
|
if ($templates{$template}) { |
|
$copyfrom = $template; |
|
} |
|
} |
|
if ($filename =~ /\.problem$/) { |
|
unless ($copyfrom) { |
|
$copyfrom = $Apache::lonnet::perlvar{'lonIncludes'}.'/templates/blank.problem'; |
|
} |
|
&File::Copy::copy($copyfrom,$dest); |
|
} |
|
} |
return $redirect; |
return $redirect; |
} |
} |
|
|