--- loncom/interface/lonextresedit.pm 2016/11/22 00:43:12 1.11
+++ loncom/interface/lonextresedit.pm 2023/07/12 00:05:02 1.34
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: lonextresedit.pm,v 1.11 2016/11/22 00:43:12 raeburn Exp $
+# $Id: lonextresedit.pm,v 1.34 2023/07/12 00:05:02 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -60,7 +60,7 @@ sub handler {
$symb,$type);
if (($env{'form.folderpath'} =~ /^supplemental/) && ($env{'form.suppurl'})) {
$supplementalflag = 1;
- if (&unescape($env{'form.suppurl'}) =~ m{^/adm/$cdom/$cnum/\d+/exttools?$}) {
+ if (&unescape($env{'form.suppurl'}) =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) {
$type = 'tool';
}
}
@@ -79,7 +79,7 @@ sub handler {
if ($symb ne $env{'form.symb'}) {
$env{'form.symb'} = $symb;
}
- if ($url =~ m{/adm/$cdom/$cnum/\d+/exttools?$}) {
+ if ($url =~ m{/adm/$cdom/$cnum/\d+/ext\.tool$}) {
$type = 'tool';
}
}
@@ -98,7 +98,18 @@ sub handler {
}
my %ltitools;
if ($type eq 'tool') {
- %ltitools = &Apache::lonnet::get_domain_ltitools($cdom);
+ my (%domtools,%crstools);
+ my %tooltypes = &Apache::loncommon::usable_exttools();
+ if ($tooltypes{'dom'}) {
+ %domtools = &Apache::lonnet::get_domain_lti($cdom,'consumer');
+ }
+ if ($tooltypes{'crs'}) {
+ %crstools = &Apache::lonnet::get_course_lti($cnum,$cdom,'consumer');
+ }
+ %ltitools = (
+ dom => \%domtools,
+ crs => \%crstools,
+ );
}
my $js = &Apache::lonhtmlcommon::scripttag(&extedit_javascript());
my $pathitem = ' 'Title',
al => 'Add Link',
at => 'Add Tool',
+ dd => 'Defined in domain',
+ dc => 'Defined in course',
);
my $tabid = 'aa';
my $size = 60;
if ($supplementalflag) {
$tabid = 'ee';
}
- my ($formname,$formid,$toggle,$fieldsetid,$urlid,$dispdivstyle,$dimendivstyle,
- $labelstyle,$titlestyle,$legend,$urlelem,$toolelem,%toolattr);
+ my ($formname,$formid,$toggle,$fieldsetid,$urlid,$subdivid,$dispdivstyle,$dimendivstyle,
+ $windivstyle,$linktextstyle,$explanationstyle,$labelstyle,$titlestyle,
+ $appendstyle,$gradablestyle,$subdivstyle,$legend,$urlelem,$toolelem,%toolattr);
$formname = 'new'.$type;
$toggle = $type;
- $fieldsetid = 'upload'.$type.'form';
+ $fieldsetid = 'external'.$type.'form';
$urlid = $type.'url';
map { $toolattr{$_} = $type.$_; } ('dispdiv','dimendiv','dimenwidth','dimenheight',
- 'crstitlediv','crslabeldiv','crstitle','crslabel');
+ 'crstitlediv','crslabeldiv','crsappenddiv',
+ 'gradablediv','crstitle','crslabel','crsappend',
+ 'windiv','linktextdiv','explanationdiv',
+ 'linktext','explanation','providerurl');
$dispdivstyle = 'display:none';
$dimendivstyle = 'display:none';
+ $windivstyle = 'display:none';
+ $linktextstyle = 'display:none';
+ $explanationstyle = 'display:none';
$labelstyle = 'display:none';
$titlestyle = 'display:none';
+ $appendstyle = 'display:none';
+ $gradablestyle = 'display:none';
+ $subdivstyle = 'display:block';
if ($supplementalflag) {
$formname = 'newsupp'.$type;
$toggle = 'supp'.$type;
- $fieldsetid = 'uploadsupp'.$type.'form';
+ $fieldsetid = 'externalsupp'.$type.'form';
$urlid = 'supp'.$type.'url';
map { $toolattr{$_} = 'supp'.$toolattr{$_}; } (keys(%toolattr));
}
my ($link,$legend,$active,$srcclass,$extsrc,$preview,$title,$save,$crstitle,$crslabel,
- $fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget,%chkstate);
+ $crsappend,$fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget,
+ $linktext,$explanation,$providerurl,$chkgrd,$chknogrd,%chkstate);
$fieldsetstyle = 'display: none;';
$action = '/adm/coursedocs';
+ my $protocol = ($ENV{'SERVER_PORT'} == 443?'https':'http');
+ my $rows = 2;
+ my $cols = 20;
if ($residx) {
if ($caller eq 'direct') {
$fieldsetstyle = 'display: block;';
$action = '/adm/extresedit';
+ $rows = 10;
+ $cols = 45;
if ($type eq 'tool') {
- $legend = $lt{'ee'};
- } else {
$legend = $lt{'te'};
+ } else {
+ $legend = $lt{'ee'};
}
$legend = '';
if ($symb) {
@@ -371,13 +457,13 @@ sub extedit_form {
$active = '';
}
$formname = 'edit'.$type.'_'.$residx;
- $fieldsetid = 'upload'.$type.$residx;
+ $fieldsetid = 'external'.$type.$residx;
$urlid = $type.'url_'.$residx;
map { $toolattr{$_} .= '_'.$residx; } (keys(%toolattr));
$srcclass = ' class="LC_nobreak"';
if ($type eq 'ext') {
$extsrc = ''.$lt{'ul'}.' ';
- $preview = ' '.$lt{'pr'}.'';
+ $preview = ' '.$lt{'pr'}.'';
}
$title = ''.$lt{'ti'}.' ';
$save = $lt{'sv'};
@@ -386,7 +472,7 @@ sub extedit_form {
if ($type eq 'tool') {
$link = $lt{'et'};
}
- $link = ''.$helpitem;
+ $link = ''.$helpitem;
if ($type eq 'tool') {
$legend = $lt{'te'};
} else {
@@ -399,12 +485,12 @@ sub extedit_form {
$orig_url = 'http://';
$orig_title = $lt{'ex'};
$extsrc = $lt{'ul'}.':
';
- $preview = '';
+ $preview = '';
$save = $lt{'al'};
} else {
$orig_title = $lt{'et'};
$save = $lt{'at'};
- $orig_url = "/adm/$cdom/$cnum/new/exttool";
+ $orig_url = "/adm/$cdom/$cnum/new/ext\.tool";
}
$pathitem .= '
';
}
@@ -415,93 +501,208 @@ sub extedit_form {
my $class = 'LC_nobreak';
if ($residx) {
$class = 'LC_docs_ext_edit LC_nobreak';
- if ($orig_url =~ m{^/adm/$cdom/$cnum/(\d+)/exttools?$}) {
+ if ($orig_url =~ m{^/adm/$cdom/$cnum/(\d+)/ext\.tool$}) {
my $marker = $1;
my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
- if ($toolhash{'id'}) {
+ my ($tooltype,$tool,$ltihash);
+ if ($toolhash{'id'} =~/^c(\d+)$/) {
+ $tool = $1;
+ $tooltype = 'crs';
if (ref($ltitools) eq 'HASH') {
- if (keys(%{$ltitools})) {
- if (ref($ltitools->{$toolhash{'id'}}) eq 'HASH') {
- my $tooltitle = $ltitools->{$toolhash{'id'}}->{'title'};
- my $icon = $ltitools->{$toolhash{'id'}}->{'image'};
- my $image;
- if ($icon) {
- $image = '';
- }
- $tooltarget = $toolhash{'target'};
- if ($tooltarget eq 'window') {
- $dimendivstyle = 'display:block';
- $chkstate{'window'} = 'checked="checked" ';
- } else {
- $chkstate{'iframe'} = 'checked="checked" ';
- }
- $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.'
';
- }
+ if (ref($ltitools->{'crs'}) eq 'HASH') {
+ $ltihash = $ltitools->{'crs'}->{$tool};
+ }
+ }
+ } elsif ($toolhash{'id'} =~/^\d+$/) {
+ $tooltype = 'dom';
+ $tool = $toolhash{'id'};
+ if (ref($ltitools) eq 'HASH') {
+ if (ref($ltitools->{'dom'}) eq 'HASH') {
+ $ltihash = $ltitools->{'dom'}->{$tool};
+ }
+ }
+ }
+ if (($tool ne '') && (ref($ltihash) eq 'HASH')) {
+ my $tooltitle = $ltihash->{'title'};
+ my $icon = $ltihash->{'image'};
+ my $image;
+ if ($icon) {
+ $image = '';
+ }
+ if ($ltihash->{'url'} =~ m{://}) {
+ (my $prot,my $host,$providerurl) = ($ltihash->{'url'} =~ m{^([^/]+)://([^/]+)(|/.+)$});
+ } else {
+ $providerurl = $ltihash->{'url'};
+ }
+ $tooltarget = $toolhash{'target'};
+ if ($tooltarget eq 'window') {
+ $dimendivstyle = 'display:block';
+ $windivstyle = 'display:block';
+ $chkstate{'window'} = 'checked="checked" ';
+ } elsif ($tooltarget eq 'tab') {
+ $windivstyle = 'display:block';
+ $chkstate{'tab'} = 'checked="checked" ';
+ } else {
+ $chkstate{'iframe'} = 'checked="checked" ';
+ }
+ $width = $toolhash{'width'};
+ $height = $toolhash{'height'};
+ $linktext = $toolhash{'linktext'};
+ $explanation = $toolhash{'explanation'};
+ if ($toolhash{'gradable'}) {
+ $chkgrd = ' checked="checked"';
+ } else {
+ $chknogrd = ' checked="checked"';
+ }
+ if (ref($ltihash->{'crsconf'}) eq 'HASH') {
+ if ($ltihash->{'crsconf'}->{'title'}) {
+ $crstitle = $toolhash{'crstitle'};
+ $titlestyle = 'display:inline';
+ }
+ if ($ltihash->{'crsconf'}->{'label'}) {
+ $crslabel = $toolhash{'crslabel'};
+ $labelstyle = 'display:inline';
+ }
+ if ($ltihash->{'crsconf'}->{'append'}) {
+ $crsappend = $toolhash{'crsappend'};
+ $appendstyle = 'display:inline';
+ }
+ if ($ltihash->{'crsconf'}->{'target'}) {
+ $dispdivstyle = 'display:block';
+ }
+ if ($ltihash->{'crsconf'}->{'linktext'}) {
+ $linktextstyle = 'padding:0;display:inline';
+ }
+ if ($ltihash->{'crsconf'}->{'explanation'}) {
+ $explanationstyle = 'padding:0;display:inline';
}
}
+ $toolelem = ''.$image.' '.$tooltitle.'
';
+ $gradablestyle = 'display:inline';
}
}
} else {
- $toolelem = ''."\n".
- '
';
+ foreach my $type ('crs','dom') {
+ $toolelem .= ' '."\n";
+ }
+ $toolelem .= '
'.
+ '
'."\n".
+ ''.
+ $exttypeofftext.
+ '
'."\n";
$crslabel = $env{'course.'.$cdom.'_'.$cnum.'.internal.coursecode'};
$crstitle = $env{'course.'.$cdom.'_'.$cnum.'.description'};
+ $crsappend = '';
+ $chknogrd = ' checked="checked"';
}
$toolelem .= ''.
- '';
+ $toolelem .= '';
+ $toolelem .= ''.
''.&mt('Course label:').' '.
- '
'.
+ '
'.
'
'.
''.
''.&mt('Course title:').' '.
- '
'.
- '
';
+ '
'.
+ ''.
+ ''.
+ ''.&mt('Append to URL[_1]',
+ ' ('.$providerurl.')
').
+ '
'.
+ '
'.
+ ''.
+ ''.&mt('Gradable').' '.
+ ''.(' 'x2).
+ '
';
}
my $chooser = $toolelem;
if ($type eq 'ext') {
@@ -515,20 +716,24 @@ $preview
";
}
+ my $idattr;
+ unless ($subdivid eq '') {
+ $idattr = 'id="'.$subdivid.'"';
+ }
$form = <