[LON-CAPA-cvs] cvs: loncom /interface londocs.pm /publisher loncoursepub.pm
raeburn
raeburn at source.lon-capa.org
Tue Apr 24 07:18:10 EDT 2018
raeburn Tue Apr 24 11:18:10 2018 EDT
Modified files:
/loncom/interface londocs.pm
/loncom/publisher loncoursepub.pm
Log:
- Course Editor "Standard Problem" item (Grading tab) for creation
of a new problem in user's Authoring Space.
-------------- next part --------------
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.653 loncom/interface/londocs.pm:1.654
--- loncom/interface/londocs.pm:1.653 Sat Apr 14 02:29:44 2018
+++ loncom/interface/londocs.pm Tue Apr 24 11:17:58 2018
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.653 2018/04/14 02:29:44 raeburn Exp $
+# $Id: londocs.pm,v 1.654 2018/04/24 11:17:58 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -5460,6 +5460,8 @@
$r->internal_redirect($redirect);
return OK;
}
+ } else {
+ $r->internal_redirect($redirect);
}
}
}
@@ -8637,7 +8639,7 @@
if ($env{'form.newsubdir'}) {
if ($env{'form.newsubdirname'} ne '') {
$newsubdir = $env{'form.newsubdirname'};
- }
+ }
}
if ($env{'form.newresourcename'}) {
$filename = $env{'form.newresourcename'};
@@ -8720,61 +8722,34 @@
<subject></subject>
<title></title>
END
- 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);
- }
+ close($fh);
}
}
- if ($env{'form.newresourceadd'}) {
- my $template = $env{'form.template'};
- my $source = $docroot.$redirect;
- my $target = $redirect;
- $target =~ s{^/priv/}{/res/};
- $target = $docroot.$target;
- 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 $sourcerights) && (-e "$sourcerights.meta")) {
+ if (!-e "$docroot/res/$coursedom") {
+ mkdir("$docroot/res/$coursedom",0755);
}
- if (!-e "$source.meta") {
- my $cid = $coursedom.'_'.$coursenum;
- my $now = time;
- if (open(my $fh,">$source.meta")) {
- my $author=$env{'environment.firstname'}.' '.
- $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;
+ 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);
+ }
+ }
+ my $source = $docroot.$redirect;
+ if (!-e "$source.meta") {
+ my $cid = $coursedom.'_'.$coursenum;
+ my $now = time;
+ if (open(my $fh,">$source.meta")) {
+ my $author=$env{'environment.firstname'}.' '.
+ $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>
<author>$author</author>
@@ -8800,8 +8775,7 @@
<subject></subject>
<title>$title</title>
END
- close($fh);
- }
+ close($fh);
}
}
}
@@ -8829,7 +8803,7 @@
}
sub finishnewprob {
- my ($url,$path,$subdir,$newsubdir,$filename) = @_;
+ my ($url,$path,$subdir,$newsubdir,$filename,$context) = @_;
unless (-d $path) {
unless (mkdir($path,02770)) {
return;
@@ -8872,6 +8846,31 @@
$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;
}
Index: loncom/publisher/loncoursepub.pm
diff -u loncom/publisher/loncoursepub.pm:1.1 loncom/publisher/loncoursepub.pm:1.2
--- loncom/publisher/loncoursepub.pm:1.1 Fri Jul 1 19:59:56 2016
+++ loncom/publisher/loncoursepub.pm Tue Apr 24 11:18:09 2018
@@ -2,7 +2,7 @@
# Handler to store uploaded files etc. in Course's Authoring
# Space,
#
-# $Id: loncoursepub.pm,v 1.1 2016/07/01 19:59:56 raeburn Exp $
+# $Id: loncoursepub.pm,v 1.2 2018/04/24 11:18:09 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -65,7 +65,7 @@
}
if ($newfilename ne '') {
my $path = $londocroot.$toppath;
- my $redirect = &Apache::londocs::finishnewprob($toppath,$path,$relpath,$newsubdir,$newfilename);
+ my $redirect = &Apache::londocs::finishnewprob($toppath,$path,$relpath,$newsubdir,$newfilename,'upload');
if ($redirect) {
my $url = $redirect;
my $srcfile = $londocroot.$url;
More information about the LON-CAPA-cvs
mailing list