--- loncom/interface/londocs.pm 2013/12/18 23:03:43 1.572
+++ loncom/interface/londocs.pm 2016/10/31 19:48:59 1.610
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.572 2013/12/18 23:03:43 raeburn Exp $
+# $Id: londocs.pm,v 1.610 2016/10/31 19:48:59 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -43,9 +43,13 @@ use Apache::lonnavdisplay();
use Apache::lonextresedit();
use Apache::lontemplate();
use Apache::lonsimplepage();
+use Apache::lonhomework();
+use Apache::lonpublisher();
use HTML::Entities;
use HTML::TokeParser;
use GDBM_File;
+use File::MMagic;
+use File::Copy;
use Apache::lonlocal;
use Cwd;
use LONCAPA qw(:DEFAULT :match);
@@ -301,14 +305,14 @@ ENDJS
if ($contents{content}) {
$content .= '
-
Content
'.
+'.&mt('Content').'
'.
$contents{content}.'
';
}
if ($contents{webreferences}) {
$content .= '
-
Web References
'.
+'.&mt('Web References').'
'.
$contents{webreferences}.'
';
}
@@ -585,7 +589,7 @@ sub recurse_html {
}
sub group_import {
- my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
+ my ($coursenum, $coursedom, $folder, $container, $caller, $ltitoolsref, @files) = @_;
my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
%removeparam,$importuploaded,$fixuperrors);
$allmaps = {};
@@ -614,6 +618,89 @@ sub group_import {
}
}
if ($url) {
+ if ($url =~ m{^(/adm/$coursedom/$coursenum/(\d+)/exttool)s?\:?(.*)$}) {
+ $url = $1;
+ my $marker = $2;
+ my $info = $3;
+ my ($toolid,%toolhash,%toolsettings);
+ my @toolinfo = split(/:/,$info);
+ if ($residx) {
+ %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
+ $toolid = $toolsettings{'id'};
+ } else {
+ $toolid = shift(@toolinfo);
+ }
+ $toolid =~ s/\D//g;
+ ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},
+ $toolhash{'crslabel'},$toolhash{'crstitle'}) = @toolinfo;
+ $toolhash{'crslabel'} = &unescape($toolhash{'crslabel'});
+ $toolhash{'crstitle'} = &unescape($toolhash{'crstitle'});
+ if (ref($ltitoolsref) eq 'HASH') {
+ my @deleted;
+ if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
+ if ($ltitoolsref->{$toolid}->{'url'} =~ m{^https://}) {
+ $url =~ s/exttool$/exttools/;
+ }
+ $toolhash{'id'} = $toolid;
+ if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'window')) {
+ if ($toolhash{'target'} eq 'window') {
+ foreach my $item ('width','height') {
+ $toolhash{$item} =~ s/^\s+//;
+ $toolhash{$item} =~ s/\s+$//;
+ }
+ }
+ } elsif ($residx) {
+ $toolhash{'target'} = $toolsettings{'target'};
+ if ($toolhash{'target'} eq 'window') {
+ $toolhash{'width'} = $toolsettings{'width'};
+ $toolhash{'height'} = $toolsettings{'height'};
+ }
+ } elsif (ref($ltitoolsref->{$toolid}->{'display'}) eq 'HASH') {
+ $toolhash{'target'} = $ltitoolsref->{$toolid}->{'display'}->{'target'};
+ if ($toolhash{'target'} eq 'window') {
+ $toolhash{'width'} = $ltitoolsref->{$toolid}->{'display'}->{'width'};
+ $toolhash{'height'} = $ltitoolsref->{$toolid}->{'display'}->{'height'};
+ }
+ }
+ if ($toolhash{'target'} eq 'iframe') {
+ delete($toolhash{'width'});
+ delete($toolhash{'height'});
+ if ($residx) {
+ if ($toolsettings{'width'}) {
+ push(@deleted,'width');
+ }
+ if ($toolsettings{'height'}) {
+ push(@deleted,'height');
+ }
+ }
+ }
+ if (ref($ltitoolsref->{$toolid}->{'crsconf'}) eq 'HASH') {
+ foreach my $item ('label','title') {
+ if ($ltitoolsref->{$toolid}->{'crsconf'}->{$item}) {
+ $toolhash{'crs'.$item} =~ s/^\s+//;
+ $toolhash{'crs'.$item} =~ s/\s+$//;
+ if ($toolhash{'crs'.$item} eq '') {
+ delete($toolhash{'crs'.$item});
+ }
+ } else {
+ delete($toolhash{'crs'.$item});
+ }
+ if (($residx) && (exists($toolsettings{'crs'.$item}))) {
+ unless (exists($toolhash{'crs'.$item})) {
+ push(@deleted,'crs'.$item);
+ }
+ }
+ }
+ }
+ my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);
+ if ($putres eq 'ok') {
+ if (@deleted) {
+ &Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum);
+ }
+ }
+ }
+ }
+ }
if (($caller eq 'londocs') &&
($folder =~ /^default/)) {
if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
@@ -651,7 +738,7 @@ sub group_import {
} else {
$fname =~ s/\W/_/g;
}
- if (length($fname > 15)) {
+ if (length($fname) > 15) {
$fname = substr($fname,0,14);
}
my $initialtext = &mt('Replace with your own content.');
@@ -795,7 +882,8 @@ sub docs_change_log {
my $js = ''."\n";
+ .''."\n"
+ .''."\n";
# Breadcrumbs
&Apache::lonhtmlcommon::clear_breadcrumbs();
@@ -4789,6 +5261,9 @@ sub handler {
'impo' => 'Import',
'lnks' => 'Import from Stored Links',
'impm' => 'Import from Assembled Map',
+ 'imcr' => 'Import from Course Resources',
+ 'extr' => 'External Resource',
+ 'extt' => 'External Tool',
'selm' => 'Select Map',
'load' => 'Load Map',
'newf' => 'New Folder',
@@ -4798,6 +5273,9 @@ sub handler {
'sipa' => 'Simple Course Page',
'sipr' => 'Simple Problem',
'webp' => 'Blank Web Page (editable)',
+ 'stpr' => 'Standard Problem',
+ 'news' => 'New sub-directory',
+ 'crpr' => 'Create Problem',
'drbx' => 'Drop Box',
'scuf' => 'External Scores (handgrade, upload, clicker)',
'bull' => 'Discussion Board',
@@ -4811,13 +5289,63 @@ sub handler {
'se' => 'Select',
'file' => 'File',
'title' => 'Title',
+ 'addp' => 'Add Placeholder to course?',
+ 'uste' => 'Use Template?',
+ 'fnam' => 'File Name:',
+ 'loca' => 'Location:',
+ 'dire' => 'Directory:',
+ 'cate' => 'Category:',
+ 'tmpl' => 'Template:',
'comment' => 'Comment',
'parse' => 'Upload embedded images/multimedia files if HTML file',
- );
+ 'bb5' => 'Blackboard 5',
+ 'bb6' => 'Blackboard 6',
+ 'angel5' => 'ANGEL 5.5',
+ 'webctce4' => 'WebCT 4 Campus Edition',
+ 'yes' => 'Yes',
+ 'no' => 'No',
+ );
# -----------------------------------------------------------------------------
+
+ # Calculate free quota space for a user or course. A javascript function checks
+ # file size to determine if upload should be allowed.
+ my $quotatype = 'unofficial';
+ if ($crstype eq 'Community') {
+ $quotatype = 'community';
+ } elsif ($crstype eq 'Placement') {
+ $quotatype = 'placement';
+ } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.coursecode'}) {
+ $quotatype = 'official';
+ } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
+ $quotatype = 'textbook';
+ }
+ my $disk_quota = &Apache::loncommon::get_user_quota($coursenum,$coursedom,
+ 'course',$quotatype); # expressed in MB
+ my $current_disk_usage = 0;
+ foreach my $subdir ('docs','supplemental') {
+ $current_disk_usage += &Apache::lonnet::diskusage($coursedom,$coursenum,
+ "userfiles/$subdir",1); # expressed in kB
+ }
+ my $free_space = 1024 * ((1024 * $disk_quota) - $current_disk_usage);
+ my $usage = $current_disk_usage/1024; # in MB
+ my $quota = $disk_quota;
+ my $percent;
+ if ($disk_quota == 0) {
+ $percent = 100.0;
+ } else {
+ $percent = 100*($current_disk_usage/$disk_quota);
+ }
+ $usage = sprintf("%.2f",$usage);
+ $quota = sprintf("%.2f",$quota);
+ $percent = sprintf("%.0f",$percent);
+ my $quotainfo = ''.&mt('Currently using [_1] of the [_2] available.',
+ $percent.'%',$quota.' MB').'
';
+
my $fileupload=(<
-
+
+
FIUP
my $checkbox=(<
-
-
-
-
+
+
+
+
@@ -4864,7 +5392,7 @@ IMSFORM