From raeburn at source.lon-capa.org Mon Jun 6 13:40:48 2016 From: raeburn at source.lon-capa.org (raeburn) Date: Mon, 06 Jun 2016 17:40:48 -0000 Subject: [LON-CAPA-cvs] cvs: loncom /interface domainprefs.pm londocs.pm lonextresedit.pm lonexttool.pm Message-ID: raeburn Mon Jun 6 17:40:48 2016 EDT Modified files: /loncom/interface domainprefs.pm londocs.pm lonextresedit.pm lonexttool.pm Log: - Bug 6754. Make LON-CAPA an LTI Tool Consumer (LTI 1.1). - Domain cofiguration to determine whether context_label, context_title, and launch_presentation_document_target LTI parameters can be configured for each instance of use of LTI Tool in a course. -------------- next part -------------- Index: loncom/interface/domainprefs.pm diff -u loncom/interface/domainprefs.pm:1.272 loncom/interface/domainprefs.pm:1.273 --- loncom/interface/domainprefs.pm:1.272 Mon Apr 4 01:09:47 2016 +++ loncom/interface/domainprefs.pm Mon Jun 6 17:40:47 2016 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.272 2016/04/04 01:09:47 raeburn Exp $ +# $Id: domainprefs.pm,v 1.273 2016/06/06 17:40:47 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3154,7 +3154,24 @@ } $datatable .= ''; } - $datatable .= ''. + $datatable .= ''; + my %courseconfig; + if (ref($settings->{$item}) eq 'HASH') { + if (ref($settings->{$item}->{'crsconf'}) eq 'HASH') { + %courseconfig = %{$settings->{$item}->{'crsconf'}}; + } + } + $datatable .= '
'.&mt('Configurable in course').''; + foreach my $item ('label','title','target') { + my $checked; + if ($courseconfig{$item}) { + $checked = ' checked="checked"'; + } + $datatable .= ''.(' ' x2)."\n"; + } + $datatable .= '
'. '
'.&mt('Custom items sent on launch').''. ''; if (ref($settings->{$item}->{'custom'}) eq 'HASH') { @@ -3260,6 +3277,13 @@ $datatable .= ''; } $datatable .= '
'.&mt('Action').''.&mt('Name').''.&mt('Value').'
'. + '
'.&mt('Configurable in course').''; + foreach my $item ('label','title','target') { + $datatable .= ''.(' ' x2)."\n"; + } + $datatable .= '
'. '
'.&mt('Custom items sent on launch').''. ''. '
'.&mt('Action').''.&mt('Name').''.&mt('Value').'
'. @@ -3294,6 +3318,9 @@ 'width' => 'Width', 'passback' => 'Tool can return grades:', 'roster' => 'Tool can retrieve roster:', + 'crstarget' => 'Display target', + 'crslabel' => 'Course label', + 'crstitle' => 'Course title', ); return %lt; } @@ -8435,6 +8462,10 @@ } } } + my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig'); + foreach my $item (@courseconfig) { + $confhash{$newid}{'crsconf'}{$item} = 1; + } if ($env{'form.ltitools_add_custom'}) { my $name = $env{'form.ltitools_add_custom_name'}; my $value = $env{'form.ltitools_add_custom_value'}; @@ -8522,6 +8553,19 @@ $changes{$itemid} = 1; } } + my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig_'.$i); + foreach my $item ('label','title','target') { + if (grep(/^\Q$item\E$/, at courseconfig)) { + $confhash{$itemid}{'crsconf'}{$item} = 1; + if (ref($domconfig{$action}{$itemid}{'crsconf'}) eq 'HASH') { + if ($domconfig{$action}{$itemid}{'crsconf'}{$item} ne $confhash{$itemid}{'crsconf'}{$item}) { + $changes{$itemid} = 1; + } + } else { + $changes{$itemid} = 1; + } + } + } my @fields = &Apache::loncommon::get_env_multiple('form.ltitools_fields_'.$i); foreach my $field (@fields) { if ($possfield{$field}) { @@ -8685,6 +8729,21 @@ my $num = length($confhash{$itemid}{'secret'}); $resulttext .= ('*'x$num).''; } + $resulttext .= '
  • '.&mt('Configurable in course:'); + my @possconfig = ('label','title','target'); + my $numconfig = 0; + if (ref($confhash{$itemid}{'crsconf'}) eq 'HASH') { + foreach my $item (@possconfig) { + if ($confhash{$itemid}{'crsconf'}{$item}) { + $numconfig ++; + $resulttext .= ' '.$lt{'crs'.$item}; + } + } + } + if (!$numconfig) { + $resulttext .= &mt('None'); + } + $resulttext .= '
  • '; foreach my $item ('passback','roster') { $resulttext .= '
  • '.$lt{$item}.' '; if ($confhash{$itemid}{$item}) { Index: loncom/interface/londocs.pm diff -u loncom/interface/londocs.pm:1.603 loncom/interface/londocs.pm:1.604 --- loncom/interface/londocs.pm:1.603 Mon May 9 02:25:33 2016 +++ loncom/interface/londocs.pm Mon Jun 6 17:40:48 2016 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.603 2016/05/09 02:25:33 raeburn Exp $ +# $Id: londocs.pm,v 1.604 2016/06/06 17:40:48 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -619,32 +619,82 @@ $url = $1; my $marker = $2; my $info = $3; - my ($toolid,%toolhash); + my ($toolid,%toolhash,%toolsettings); my @toolinfo = split(/:/,$info); if ($residx) { - my %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum); + %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum); $toolid = $toolsettings{'id'}; } else { - $toolid = shift(@toolinfo); + $toolid = shift(@toolinfo); } $toolid =~ s/\D//g; - ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'}) = @toolinfo; + ($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'}); - } elsif ($toolhash{'target'} eq 'window') { - foreach my $item ('width','height') { - $toolhash{$item} =~ s/^\s+//; - $toolhash{$item} =~ s/\s+$//; + 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); + } + } } } } @@ -4999,7 +5049,6 @@ my $tabidstr = join("','", at tabids); %ltitools = &Apache::lonnet::get_domain_ltitools($coursedom); my $posslti = keys(%ltitools); - my $exttoolurl = "/adm/$coursedom/$coursenum/new/exttool"; $script .= &editing_js($udom,$uname,$supplementalflag,$posslti). &history_tab_js(). &inject_data_js(). @@ -5451,7 +5500,7 @@ $help{'Web_Page'} NWEBFORM - + my $specialdocumentsform; my @specialdocumentsforma; @@ -6109,7 +6158,7 @@ p_msb => 'Title for the Problem', p_mdb => 'Title for the Drop Box', p_mbb => 'Title for the Discussion Board', - p_mwp => 'Title for Web Page', + p_mwp => 'Title for Web Page', p_mab => "Enter user:domain for User's Personal Information Page", p_mab2 => 'Personal Information Page of ', p_mab_alrt1 => 'Not a valid user:domain', Index: loncom/interface/lonextresedit.pm diff -u loncom/interface/lonextresedit.pm:1.9 loncom/interface/lonextresedit.pm:1.10 --- loncom/interface/lonextresedit.pm:1.9 Tue Jan 26 14:30:25 2016 +++ loncom/interface/lonextresedit.pm Mon Jun 6 17:40:48 2016 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: lonextresedit.pm,v 1.9 2016/01/26 14:30:25 raeburn Exp $ +# $Id: lonextresedit.pm,v 1.10 2016/06/06 17:40:48 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -259,32 +259,44 @@ sub update_exttool { my ($marker,$cdom,$cnum,$args) = @_; my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum); - my (%newhash,$changed,$errormsg); - ($newhash{'target'},$newhash{'width'},$newhash{'height'}) = split(/:/,$args); + my (%newhash,$changed, at deleted,$errormsg); + ($newhash{'target'},$newhash{'width'},$newhash{'height'},$newhash{'crslabel'},$newhash{'crstitle'}) = split(/:/,$args); + $newhash{'crslabel'} = &unescape($newhash{'crslabel'}); + $newhash{'crstitle'} = &unescape($newhash{'crstitle'}); my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum); - foreach my $item ('target','width','height') { + foreach my $item ('target','width','height','crslabel','crstitle') { $newhash{$item} =~ s/^\s+//; $newhash{$item} =~ s/\s+$//; - unless ($item eq 'target') { + if (($item eq 'width') || ($item eq 'height')) { if ($newhash{'target'} eq 'iframe') { $newhash{$item} = ''; } } if ($toolhash{$item} ne $newhash{$item}) { if ($newhash{$item} eq '') { - delete($toolhash{$item}); + unless (($item eq 'target') || + ((($item eq 'width') || ($item eq 'height')) && + (($newhash{'target'} eq 'window') || + (($newhash{'target'} eq '') && ($toolhash{'target'} eq 'window'))))) { + delete($toolhash{$item}); + push(@deleted,$item); + $changed = 1; + } } else { $toolhash{$item} = $newhash{$item}; + $changed = 1; } - $changed = 1; } } if ($changed) { my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$cdom,$cnum); unless ($putres eq 'ok') { - $errormsg = &mt('Failed to save updated settings.').' '.&mt('Error: [_1].',$putres); + $errormsg = &mt('Failed to save updated settings.').' '.&mt('Error: [_1].',$putres); } } + if (@deleted) { + &Apache::lonnet::del('exttool_'.$marker,\@deleted,$cdom,$cnum); + } return ($changed,$errormsg); } @@ -313,14 +325,17 @@ $tabid = 'ee'; } my ($formname,$formid,$toggle,$fieldsetid,$urlid,$dispdivstyle,$dimendivstyle, - $legend,$urlelem,$toolelem,%toolattr); + $labelstyle,$titlestyle,$legend,$urlelem,$toolelem,%toolattr); $formname = 'new'.$type; $toggle = $type; $fieldsetid = 'upload'.$type.'form'; $urlid = $type.'url'; - map { $toolattr{$_} = $type.$_; } ('dispdiv','dimendiv','dimenwidth','dimenheight'); + map { $toolattr{$_} = $type.$_; } ('dispdiv','dimendiv','dimenwidth','dimenheight', + 'crstitlediv','crslabeldiv','crstitle','crslabel'); $dispdivstyle = 'display:none'; $dimendivstyle = 'display:none'; + $labelstyle = 'display:none'; + $titlestyle = 'display:none'; if ($supplementalflag) { $formname = 'newsupp'.$type; $toggle = 'supp'.$type; @@ -328,7 +343,7 @@ $urlid = 'supp'.$type.'url'; map { $toolattr{$_} = 'supp'.$toolattr{$_}; } (keys(%toolattr)); } - my ($link,$legend,$active,$srcclass,$extsrc,$preview,$title,$save, + my ($link,$legend,$active,$srcclass,$extsrc,$preview,$title,$save,$crstitle,$crslabel, $fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget,%chkstate); $fieldsetstyle = 'display: none;'; $action = '/adm/coursedocs'; @@ -404,7 +419,6 @@ my $marker = $1; my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum); if ($toolhash{'id'}) { - $dispdivstyle = 'display:block'; if (ref($ltitools) eq 'HASH') { if (keys(%{$ltitools})) { if (ref($ltitools->{$toolhash{'id'}}) eq 'HASH') { @@ -423,6 +437,19 @@ } $width = $toolhash{'width'}; $height = $toolhash{'height'}; + if (ref($ltitools->{$toolhash{'id'}}->{'crsconf'}) eq 'HASH') { + if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'title'}) { + $crstitle = $toolhash{'crstitle'}; + $titlestyle = 'display:inline'; + } + if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'label'}) { + $crslabel = $toolhash{'crslabel'}; + $labelstyle = 'display:inline'; + } + if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'target'}) { + $dispdivstyle = 'display:block'; + } + } $toolelem = ''.$image.' '.$tooltitle.'
    '; } } @@ -452,7 +479,9 @@ } } } - $toolelem .= ''; + $toolelem .= '
    '; + $crslabel = $env{'course.'.$cdom.'_'.$cnum.'.internal.coursecode'}; + $crstitle = $env{'course.'.$cdom.'_'.$cnum.'.description'}; } $toolelem .= '
    '. ''.&mt('Display target:').' '. @@ -464,7 +493,15 @@ ''. &mt('Width').''.(' 'x2). &mt('Height').''."\n". - '
    '; + ''. + '
    '. + ''.&mt('Course label:').' '. + '
    '. + '
    '. + '
    '. + ''.&mt('Course title:').' '. + '
    '. + '
    '; } my $chooser = $toolelem; if ($type eq 'ext') { @@ -491,7 +528,7 @@ $pathitem $hiddenelem - + @@ -545,7 +582,10 @@ $toolsjs = " var ltitools = new Array($num);\n". " var ltitoolsTarget = new Array($num);\n". " var ltitoolsWidth = new Array($num);\n". - " var ltitoolsHeight = new Array($num);\n"; + " var ltitoolsHeight = new Array($num);\n". + " var ltitoolsDisplay = new Array($num);\n". + " var ltitoolsLabel = new Array($num);\n". + " var ltitoolsTitle = new Array($num);\n"; my $i = 0; foreach my $key (sort { $a <=> $b } keys(%{$toolsref})) { if (ref($toolsref->{$key})) { @@ -556,6 +596,15 @@ ' ltitoolsTarget['.$i.'] = '."'$target';\n". ' ltitoolsWidth['.$i.'] = '."'$width';\n". ' ltitoolsHeight['.$i.'] = '."'$height';\n"; + my %courseconfig; + if (ref($toolsref->{$key}->{'crsconf'}) eq 'HASH') { + my $display = $toolsref->{$key}->{'crsconf'}->{'target'}; + $toolsjs .= ' ltitoolsDisplay['.$i.'] = '."'$display';\n"; + my $label = $toolsref->{$key}->{'crsconf'}->{'label'}; + $toolsjs .= ' ltitoolsLabel['.$i.'] = '."'$label';\n"; + my $title = $toolsref->{$key}->{'crsconf'}->{'title'}; + $toolsjs .= ' ltitoolsTitle['.$i.'] = '."'$title';\n"; + } $i++; } } @@ -575,7 +624,7 @@ var regexp = $urlregexp; -function setExternal(extform,residx,type,exttoolurl) { +function setExternal(extform,residx,type,exttoolurl,supplementalflag) { var title=extform.exttitle.value; if (!String.trim) { String.prototype.trim = function() {return this.replace(\/^\\s+|\\s+$\/g, "");}; } @@ -610,20 +659,56 @@ } info += ':'+toolid; } - if (extform.exttooltarget.length) { - for (var i=0; i 0) { + dispdiv += '_'+residx; + } + if (document.getElementById(dispdiv)) { + if (document.getElementById(dispdiv).style.display == 'block') { + if (extform.exttooltarget.length) { + for (var i=0; i 0) { + labelinput += '_'+residx; + titleinput += '_'+residx; + } + if (document.getElementById(labelinput)) { + var crslabel = document.getElementById(labelinput).value; + crslabel.trim(); + info += ':'+escape(crslabel); + } else { + info += ':'; + } + if (document.getElementById(titleinput)) { + var crstitle = document.getElementById(titleinput).value; + crstitle.trim(); + info += ':'+escape(crstitle); + } else { + info += ':'; } info=escape(info); if (residx > 0) { @@ -668,6 +753,10 @@ dimendiv = prefix+'tooldimendiv'; widthinput = prefix+'toolwidth'; heightinput = prefix+'toolheight'; + labeldiv = prefix+'toolcrslabeldiv'; + titlediv = prefix+'toolcrstitlediv'; + labelinput = prefix+'toolcrslabel'; + titleinput = prefix+'toolcrstitle'; if (document.getElementById(dispdiv)) { var toolpick = caller.options[caller.selectedIndex].value; $toolsjs @@ -678,41 +767,63 @@ if (document.getElementById(dimendiv)) { document.getElementById(dimendiv).style.display = 'none'; } - } else { - if (document.getElementById(dispdiv)) { - document.getElementById(dispdiv).style.display = 'block'; + if (document.getElementById(labeldiv)) { + document.getElementById(labeldiv).style.display = 'none'; + } + if (document.getElementById(titlediv)) { + document.getElementById(titlediv).style.display = 'none'; } + } else { if (ltitools.length > 0) { for (var j=0; j $toolsettings{'width'}, height => $toolsettings{'height'}, }; + $toolhash{'crslabel'} = $toolsettings{'crslabel'}; + $toolhash{'crstitle'} = $toolsettings{'crstitle'}; $is_tool = 1; if ($target eq 'tex') { $r->print(&mt('External Tool')); } else { my $submittext = &mt('Launch [_1]',$toolhash{'title'}); if (($toolhash{'key'} ne '') && ($toolhash{'secret'} ne '') && ($toolhash{'url'} ne '')) { - my %lti = <i_params($r,$submittext,\%toolhash); + my %lti = <i_params($r,$cnum,$cdom,$submittext,\%toolhash); $r->print(&launch_html($toolhash{'url'},$toolhash{'key'}, $toolhash{'secret'},$submittext,\%lti)); } else { @@ -129,9 +131,9 @@ } sub lti_params { - my ($r,$submittext,$toolsref) = @_; + my ($r,$cnum,$cdom,$submittext,$toolsref) = @_; my ($version,$context_type,$msgtype,$toolname,$passback,$roster,$locale, - %fields,%rolesmap,%display,%custom, at userlangs); + $crslabel,$crstitle,%fields,%rolesmap,%display,%custom, at userlangs); if (ref($toolsref) eq 'HASH') { $version = $toolsref->{'version'}; $toolname = $toolsref->{'title'}; @@ -150,6 +152,8 @@ if (ref($toolsref->{'custom'}) eq 'HASH') { %custom = %{$toolsref->{'custom'}}; } + $crslabel = $toolsref->{'crslabel'}; + $crstitle = $toolsref->{'crstitle'}; } if ($version eq '') { $version = 'LTI-1p0'; @@ -160,6 +164,12 @@ if ($msgtype eq '') { $msgtype = 'basic-lti-launch-request'; } + if ($crslabel eq '') { + $crslabel = $env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}, + } + if ($crstitle eq '') { + $crstitle = $env{'course.'.$env{'request.course.id'}.'.description'},; + } my $lonhost = $r->dir_config('lonHostID'); my $loncaparev = $r->dir_config('lonVersion'); my $uname = $env{'user.name'}; @@ -202,21 +212,28 @@ } } } + my $domdesc = &Apache::lonnet::domain($cdom); + my $primary_id = &Apache::lonnet::domain($cdom,'primary'); + my $int_dom = &Apache::lonnet::internet_dom($primary_id); + my $portal_url = &Apache::lonnet::course_portal_url($cnum,$cdom); + my %ltiparams = ( lti_version => $version, lti_message_type => $msgtype, resource_link_title => $title, resource_link_id => $digest_symb, tool_consumer_instance_guid => $lonhost, + tool_consumer_instance_description => $domdesc, tool_consumer_info_product_family_code => 'loncapa', + tool_consumer_instance_name => $int_dom, + tool_consumer_instance_url => $portal_url, tool_consumer_info_version => $loncaparev, user_id => $digest_user, - lis_person_sourcedid => $uname.':'.$udom, roles => $ltirole, context_id => $env{'request.course.id'}, context_type => $context_type, - context_label => $env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}, - context_title => $env{'course.'.$env{'request.course.id'}.'.description'}, + context_label => $crslabel, + context_title => $crstitle, launch_presentation_locale => $locale, ); my $crshome = $env{'course.'.$env{'request.course.id'}.'.home'}; @@ -269,6 +286,9 @@ } $ltiparams{'lis_person_contact_email_primary'} = $contact_email; } + if ($fields{'user'}) { + $ltiparams{'lis_person_sourcedid'} = $uname.':'.$udom; + } if (keys(%custom)) { foreach my $key (keys(%custom)) { $ltiparams{'custom_'.$key} = $custom{$key}; From raeburn at source.lon-capa.org Fri Jun 10 18:31:35 2016 From: raeburn at source.lon-capa.org (raeburn) Date: Fri, 10 Jun 2016 22:31:35 -0000 Subject: [LON-CAPA-cvs] cvs: loncom /interface londocs.pm lonhtmlcommon.pm portfolio.pm /publisher lonpubdir.pm Message-ID: raeburn Fri Jun 10 22:31:35 2016 EDT Modified files: /loncom/interface londocs.pm lonhtmlcommon.pm portfolio.pm /loncom/publisher lonpubdir.pm Log: - Display course's quota usage in file upload section in Course Editor - Consistent conversion for kB -> MB - div style for disk usage: inline in Authoring Space; block in portfolio. Index: loncom/interface/londocs.pm diff -u loncom/interface/londocs.pm:1.604 loncom/interface/londocs.pm:1.605 --- loncom/interface/londocs.pm:1.604 Mon Jun 6 17:40:48 2016 +++ loncom/interface/londocs.pm Fri Jun 10 22:31:27 2016 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.604 2016/06/06 17:40:48 raeburn Exp $ +# $Id: londocs.pm,v 1.605 2016/06/10 22:31:27 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -5224,8 +5224,22 @@ "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=(< Index: loncom/interface/lonhtmlcommon.pm diff -u loncom/interface/lonhtmlcommon.pm:1.371 loncom/interface/lonhtmlcommon.pm:1.372 --- loncom/interface/lonhtmlcommon.pm:1.371 Sat Apr 2 04:30:20 2016 +++ loncom/interface/lonhtmlcommon.pm Fri Jun 10 22:31:27 2016 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.371 2016/04/02 04:30:20 raeburn Exp $ +# $Id: lonhtmlcommon.pm,v 1.372 2016/06/10 22:31:27 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2673,9 +2673,9 @@ # sub display_usage { - my ($current_disk_usage,$disk_quota) = @_; - my $usage = $current_disk_usage/1000; - my $quota = $disk_quota/1000; + my ($current_disk_usage,$disk_quota,$context) = @_; + my $usage = $current_disk_usage/1024; + my $quota = $disk_quota/1024; my $percent; if ($disk_quota == 0) { $percent = 100.0; @@ -2699,9 +2699,13 @@ if ($prog_width > 100) { $prog_width = 100; } + my $display = 'block'; + if ($context eq 'authoring') { + $display = 'inline'; + } return ' -
    '.&mt('Currently using [_1] of the [_2] available.',$usage.' MB ('.$percent.'%)',$quota.' MB')."\n". -'
    '."\n". +
    '.&mt('Currently using [_1] of the [_2] available.',$usage.' MB ('.$percent.'%)',$quota.' MB')."\n". +'
    '."\n". '
    '."\n". '
    '."\n". '
    '; Index: loncom/interface/portfolio.pm diff -u loncom/interface/portfolio.pm:1.256 loncom/interface/portfolio.pm:1.257 --- loncom/interface/portfolio.pm:1.256 Thu Jun 18 20:19:06 2015 +++ loncom/interface/portfolio.pm Fri Jun 10 22:31:27 2016 @@ -1,7 +1,7 @@ # The LearningOnline Network # portfolio browser # -# $Id: portfolio.pm,v 1.256 2015/06/18 20:19:06 musolffc Exp $ +# $Id: portfolio.pm,v 1.257 2016/06/10 22:31:27 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -203,7 +203,8 @@ .$helpitem .'
    ' .'
    ' - .&Apache::lonhtmlcommon::display_usage($current_disk_usage,$disk_quota) + .&Apache::lonhtmlcommon::display_usage($current_disk_usage, + $disk_quota,'portfolio') .'
    '); } @@ -2571,7 +2572,7 @@ } else { $disk_quota = &Apache::loncommon::get_user_quota($env{'user.name'}, $env{'user.domain'}); #expressed in MB - $disk_quota = 1000 * $disk_quota; # convert from MB to kB + $disk_quota = 1024 * $disk_quota; # convert from MB to kB } return $disk_quota; } Index: loncom/publisher/lonpubdir.pm diff -u loncom/publisher/lonpubdir.pm:1.167 loncom/publisher/lonpubdir.pm:1.168 --- loncom/publisher/lonpubdir.pm:1.167 Wed Jan 6 16:44:35 2016 +++ loncom/publisher/lonpubdir.pm Fri Jun 10 22:31:34 2016 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Authoring Space Directory Lister # -# $Id: lonpubdir.pm,v 1.167 2016/01/06 16:44:35 damieng Exp $ +# $Id: lonpubdir.pm,v 1.168 2016/06/10 22:31:34 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -375,7 +375,8 @@ $r->print(&Apache::loncommon::head_subbox( '
    ' - .&Apache::lonhtmlcommon::display_usage($current_disk_usage,$disk_quota) + .&Apache::lonhtmlcommon::display_usage($current_disk_usage, + $disk_quota,'authoring') .'
    ' .&Apache::loncommon::CSTR_pageheader()));