--- loncom/interface/courseprefs.pm 2020/02/12 16:25:48 1.89
+++ loncom/interface/courseprefs.pm 2022/02/21 15:44:57 1.105
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set configuration settings for a course
#
-# $Id: courseprefs.pm,v 1.89 2020/02/12 16:25:48 raeburn Exp $
+# $Id: courseprefs.pm,v 1.105 2022/02/21 15:44:57 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -52,12 +52,16 @@ This module is used for configuration of
=item process_changes()
+=item process_linkprot()
+
=item get_sec_str()
=item check_clone()
=item store_changes()
+=item store_linkprot()
+
=item update_env()
=item display_disallowed()
@@ -220,6 +224,7 @@ use Apache::lonparmset;
use Apache::courseclassifier;
use Apache::lonlocal;
use LONCAPA qw(:DEFAULT :match);
+use Crypt::CBC;
my $registered_cleanup;
my $modified_courses;
@@ -365,9 +370,29 @@ sub handler {
}
my %values=&Apache::lonnet::dump('environment',$cdom,$cnum);
+ my %linkprot=&Apache::lonnet::dump('lti',$cdom,$cnum,undef,undef,undef,1);
+ my %ltienc = &Apache::lonnet::dump('nohist_ltienc',$cdom,$cnum,undef,undef,undef,1);
+ foreach my $id (keys(%linkprot)) {
+ if (ref($linkprot{$id}) eq 'HASH') {
+ if (ref($ltienc{$id}) eq 'HASH') {
+ $values{'linkprot'}{$id} = { %{$linkprot{$id}}, %{$ltienc{$id}} };
+ } else {
+ $values{'linkprot'}{$id} = $linkprot{$id};
+ }
+ }
+ unless ($phase eq 'process') {
+ if (ref($values{'linkprot'}{$id}) eq 'HASH') {
+ delete($values{'linkprot'}{$id}{'secret'});
+ }
+ }
+ }
+ if ($linkprot{'lock'}) {
+ delete($linkprot{'lock'});
+ }
my @prefs_order = ('courseinfo','localization','feedback','discussion',
'classlists','appearance','grading','printouts',
- 'spreadsheet','bridgetasks','lti','other');
+ 'menuitems','linkprot','spreadsheet','bridgetasks',
+ 'lti','other');
my %prefs = (
'courseinfo' =>
@@ -467,7 +492,7 @@ sub handler {
help => 'Course_Prefs_Display',
ordered => ['default_xml_style','pageseparators',
'disable_receipt_display','texengine',
- 'tthoptions','uselcmath','usejsme'],
+ 'tthoptions','uselcmath','usejsme','inline_chem'],
itemtext => {
default_xml_style => 'Default XML style file',
pageseparators => 'Visibly Separate Items on Pages',
@@ -476,6 +501,7 @@ sub handler {
tthoptions => 'Default set of options to pass to tth/m when converting TeX',
uselcmath => 'Student formula entry uses inline preview, not DragMath pop-up',
usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)',
+ inline_chem => 'Chemical reaction response uses inline preview, not pop-up',
},
},
'grading' =>
@@ -542,6 +568,29 @@ sub handler {
'lti.lcmenu' => 'Menu items',
},
},
+ 'menuitems' =>
+ {
+ text => 'Menu display',
+ help => 'Course_Prefs_Menus',
+ header => [{col1 => 'Default Menu',
+ col2 => 'Value',},
+ {col1 => 'Menu collections',
+ col2 => 'Settings',
+ }],
+ ordered => ['menudefault','menucollections'],
+ itemtext => {
+ menudefault => 'Choose default collection of menu items for course',
+ menucollections => 'Menu collections',
+ },
+ },
+ 'linkprot' =>
+ {
+ text => 'Link protection',
+ help => 'Course_Prefs_Linkprotection',
+ header => [{col1 => 'Item',
+ col2 => 'Settings',
+ }],
+ },
'other' =>
{ text => 'Other settings',
help => 'Course_Prefs_Other',
@@ -557,10 +606,16 @@ sub handler {
$cnum,undef,\@allitems,
'coursepref',$parm_permission);
} elsif (($phase eq 'display') && ($parm_permission->{'display'})) {
- my $jscript = &get_jscript($cid,$cdom,$phase,$crstype,\%values);
+ my $noedit;
+ if (ref($parm_permission) eq 'HASH') {
+ unless ($parm_permission->{'process'}) {
+ $noedit = 1;
+ }
+ }
+ my $jscript = &get_jscript($cid,$cdom,$phase,$crstype,\%values,$noedit);
my @allitems = &get_allitems(%prefs);
&Apache::lonconfigsettings::display_settings($r,$cdom,$phase,$context,
- \@prefs_order,\%prefs,\%values,undef,$jscript,\@allitems,$crstype,
+ \@prefs_order,\%prefs,\%values,$cnum,$jscript,\@allitems,$crstype,
'coursepref',$parm_permission);
} else {
&Apache::lonconfigsettings::display_choices($r,$phase,$context,
@@ -613,7 +668,7 @@ sub get_allitems {
}
sub print_config_box {
- my ($r,$cdom,$phase,$action,$item,$settings,$allitems,$crstype,$parm_permission) = @_;
+ my ($r,$cdom,$cnum,$phase,$action,$item,$settings,$allitems,$crstype,$parm_permission) = @_;
my $ordered = $item->{'ordered'};
my $itemtext = $item->{'itemtext'};
my $noedit;
@@ -634,7 +689,7 @@ sub print_config_box {
}
$output .= ''."\n".
'';
- if (($action eq 'feedback') || ($action eq 'classlists')) {
+ if (($action eq 'feedback') || ($action eq 'classlists') || ($action eq 'menuitems')) {
$output .= '
@@ -659,6 +714,8 @@ sub print_config_box {
$output .= &print_feedback('top',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
} elsif ($action eq 'classlists') {
$output .= &print_classlists('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
+ } elsif ($action eq 'menuitems') {
+ $output .= &print_menuitems('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
}
$output .= '
@@ -739,6 +796,10 @@ sub print_config_box {
$output .= &print_bridgetasks($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
} elsif ($action eq 'lti') {
$output .= &print_lti($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
+ } elsif ($action eq 'menuitems') {
+ $output .= &print_menuitems('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
+ } elsif ($action eq 'linkprot') {
+ $output .= &print_linkprotection($cdom,$cnum,$settings,\$rowtotal,$crstype,$noedit,'course');
} elsif ($action eq 'other') {
$output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype,$noedit);
}
@@ -751,8 +812,8 @@ sub print_config_box {
}
sub process_changes {
- my ($cdom,$action,$values,$item,$changes,$allitems,$disallowed,$crstype) = @_;
- my %newvalues;
+ my ($cdom,$cnum,$action,$values,$item,$changes,$allitems,$disallowed,$crstype) = @_;
+ my (%newvalues,$errors);
if (ref($item) eq 'HASH') {
if (ref($changes) eq 'HASH') {
my @ordered;
@@ -769,6 +830,18 @@ sub process_changes {
}
}
}
+ } elsif ($action eq 'linkprot') {
+ if (ref($values->{$action}) eq 'HASH') {
+ foreach my $id (keys(%{$values->{$action}})) {
+ if ($id =~ /^\d+$/) {
+ push(@ordered,$id);
+ }
+ }
+ }
+ @ordered = sort { $a <=> $b } @ordered;
+ if (($env{'form.linkprot_add'}) && ($env{'form.linkprot_maxnum'} =~ /^\d+$/)) {
+ push(@ordered,$env{'form.linkprot_maxnum'});
+ }
} elsif (ref($item->{'ordered'}) eq 'ARRAY') {
if ($action eq 'courseinfo') {
my ($can_toggle_cat,$can_categorize) =
@@ -831,6 +904,85 @@ sub process_changes {
$changes->{$ext_entry} = $newvalues{$ext_entry};
}
}
+ } elsif ($action eq 'menuitems') {
+ my (%current,@colls);
+ my $next = 1;
+ if ($values->{'menucollections'}) {
+ foreach my $item (split(/;/,$values->{'menucollections'})) {
+ my ($num,$value) = split(/\%/,$item);
+ if ($num =~ /^\d+$/) {
+ unless (grep(/^$num$/,@colls)) {
+ push(@colls,$num);
+ }
+ my @entries = split(/\&/,$value);
+ foreach my $entry (@entries) {
+ my ($name,$fields) = split(/=/,$entry);
+ $current{$num}{$name} = $fields;
+ }
+ }
+ }
+ }
+ if (@colls) {
+ @colls = sort { $a <=> $b } @colls;
+ $next += $colls[-1];
+ }
+ if ($env{'form.menucollections_add'} eq $next) {
+ push(@colls,$next);
+ }
+ my $currdef = $values->{'menudefault'};
+ my $possdef = $env{'form.menudefault'};
+ if (($possdef =~ /^\d+$/) && (grep(/^$possdef$/,@colls))) {
+ if ($currdef ne $possdef) {
+ $changes->{'menudefault'} = $possdef;
+ }
+ } elsif ($currdef) {
+ $changes->{'menudefault'} = '';
+ }
+ my $menucoll;
+ if (@colls) {
+ my ($ordered,$cats) = &menuitems_categories();
+ my %shortcats = &menuitems_abbreviations();
+ foreach my $num (@colls) {
+ my ($entry,%include);
+ map { $include{$_}= 1; } &Apache::loncommon::get_env_multiple('form.menucollections_'.$num);
+ foreach my $item (@{$ordered}) {
+ if ($item eq 'shown') {
+ foreach my $type (@{$cats->{$item}}) {
+ $entry .= $type.'=';
+ if ($include{$type}) {
+ $entry .= 'y';
+ } else {
+ $entry .= 'n';
+ }
+ $entry .= '&';
+ }
+ } else {
+ $entry .= $shortcats{$item}.'=';
+ foreach my $type (@{$cats->{$item}}) {
+ if ($include{$type}) {
+ $entry .= $type.',';
+ }
+ }
+ $entry =~ s/,$//;
+ $entry .= '&';
+ }
+ }
+ $entry =~ s/\&$//;
+ if ($menucoll) {
+ $menucoll .= ';';
+ }
+ $menucoll .= $num.'%'.$entry;
+ }
+ if ($menucoll ne $values->{'menucollections'}) {
+ $changes->{'menucollections'} = $menucoll;
+ }
+ } elsif ($values->{'menucollections'}) {
+ $changes->{'menucollections'} = '';
+ }
+ } elsif ($action eq 'linkprot') {
+ if (ref($values) eq 'HASH') {
+ $errors = &process_linkprot($cdom,$cnum,$values->{$action},$changes,'course');
+ }
} else {
foreach my $entry (@ordered) {
if ($entry eq 'cloners') {
@@ -871,7 +1023,7 @@ sub process_changes {
my $clonedom = $env{'form.cloners_newdom'};
if (&check_clone($clonedom,$disallowed) eq 'ok') {
my $newdom = '*:'.$env{'form.cloners_newdom'};
- if (@clonedoms) {
+ if (@clonedoms) {
if (!grep(/^\Q$newdom\E$/,@clonedoms)) {
$newvalues{$entry} .= ','.$newdom;
}
@@ -960,7 +1112,9 @@ sub process_changes {
$autocoowner = $domconf{'autoenroll'}{'co-owners'};
}
}
- unless ($autocoowner) {
+ if ($autocoowner) {
+ $newvalues{'co-owners'} = $values->{'internal.co-owners'};
+ } else {
my @keepcoowners = &Apache::loncommon::get_env_multiple('form.coowners');
my @pendingcoowners = &Apache::loncommon::get_env_multiple('form.pendingcoowners');
my @invitecoowners = &Apache::loncommon::get_env_multiple('form.invitecoowners');
@@ -984,19 +1138,19 @@ sub process_changes {
my $udom = $env{'user.domain'};
my $pendingcoowners = $values->{'internal.pendingco-owners'};
my @pendingcoown = split(',',$pendingcoowners);
- if ($env{'form.pending_coowoner'}) {
+ if ($env{'form.pending_coowner'}) {
foreach my $item (@pendingcoown) {
unless ($item eq $uname.':'.$udom) {
push(@newpending,$item);
}
}
@newcoown = @currcoown;
- if ($env{'form.pending_coowoner'} eq 'accept') {
+ if ($env{'form.pending_coowner'} eq 'accept') {
unless (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
push(@newcoown,$uname.':'.$udom);
}
}
- } elsif ($env{'form.remove_coowoner'}) {
+ } elsif ($env{'form.remove_coowner'}) {
foreach my $item (@currcoown) {
unless ($item eq $uname.':'.$udom) {
push(@newcoown,$item);
@@ -1005,6 +1159,8 @@ sub process_changes {
if ($pendingcoowners ne '') {
@newpending = @pendingcoown;
}
+ } else {
+ @newcoown = @currcoown;
}
$newvalues{'pendingco-owners'} = join(',',sort(@newpending));
$newvalues{'co-owners'} = join(',',sort(@newcoown));
@@ -1317,7 +1473,276 @@ sub process_changes {
}
}
}
- return;
+ return $errors;
+}
+
+sub process_linkprot {
+ my ($cdom,$cnum,$values,$changes,$context) = @_;
+ my ($home,$dest,$ltiauth,$privkey,$privnum,$cipher,$errors,%linkprot);
+ if (ref($values) eq 'HASH') {
+ foreach my $id (keys(%{$values})) {
+ if ($id =~ /^\d+$/) {
+ unless (ref($values->{$id}) eq 'HASH') {
+ $linkprot{$id} = '';
+ }
+ }
+ }
+ }
+ my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
+ my @ids=&Apache::lonnet::current_machine_ids();
+ if ($context eq 'domain') {
+ $home = &Apache::lonnet::domain($cdom,'primary');
+ } else {
+ $home = &Apache::lonnet::homeserver($cnum,$cdom);
+ }
+ if ((($context eq 'domain') && ($domdefs{'linkprotenc_dom'})) ||
+ (($context eq 'course') && ($domdefs{'linkprotenc_crs'}))) {
+ unless (($home eq 'no_host') || ($home eq '')) {
+ if (grep(/^\Q$home\E$/,@ids)) {
+ if (ref($domdefs{'privhosts'}) eq 'ARRAY') {
+ if (grep(/^\Q$home\E$/,@{$domdefs{'privhosts'}})) {
+ my %privhash = &Apache::lonnet::restore_dom('lti','private',$cdom,$home,1);
+ $privkey = $privhash{'key'};
+ $privnum = $privhash{'version'};
+ if (($privnum) && ($privkey ne '')) {
+ $cipher = Crypt::CBC->new({'key' => $privkey,
+ 'cipher' => 'DES'});
+ }
+ }
+ }
+ }
+ }
+ }
+ if ($context eq 'domain') {
+ $dest = '/adm/domainprefs';
+ $ltiauth = 1;
+ } else {
+ $dest = '/adm/courseprefs';
+ if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
+ $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
+ } else {
+ my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
+ $ltiauth = $domdefs{'crsltiauth'};
+ }
+ }
+ my $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
+ my (@items,%deletions,%itemids,%haschanges);
+ if ($env{'form.linkprot_add'}) {
+ my $name = $env{'form.linkprot_name_add'};
+ $name =~ s/(`)/'/g;
+ my ($newid,$error) = &get_linkprot_id($cdom,$cnum,$name,$context);
+ if ($newid) {
+ $itemids{'add'} = $newid;
+ push(@items,'add');
+ $haschanges{$newid} = 1;
+ } else {
+ $errors .= ''.
+ &mt('Failed to acquire unique ID for link protection').
+ '';
+ }
+ }
+ if (ref($values) eq 'HASH') {
+ my @todelete = &Apache::loncommon::get_env_multiple('form.linkprot_del');
+ my $maxnum = $env{'form.linkprot_maxnum'};
+ for (my $i=0; $i<=$maxnum; $i++) {
+ my $itemid = $env{'form.linkprot_id_'.$i};
+ $itemid =~ s/\D+//g;
+ if ($itemid) {
+ if (ref($values->{$itemid}) eq 'HASH') {
+ push(@items,$i);
+ $itemids{$i} = $itemid;
+ if ((@todelete > 0) && (grep(/^$i$/,@todelete))) {
+ $deletions{$itemid} = $values->{$itemid}->{'name'};
+ }
+ }
+ }
+ }
+ }
+ foreach my $idx (@items) {
+ my $itemid = $itemids{$idx};
+ next unless ($itemid);
+ if (exists($deletions{$itemid})) {
+ $linkprot{$itemid} = $deletions{$itemid};
+ $haschanges{$itemid} = 1;
+ next;
+ }
+ my %current;
+ if (ref($values) eq 'HASH') {
+ if (ref($values->{$itemid}) eq 'HASH') {
+ foreach my $key (keys(%{$values->{$itemid}})) {
+ $current{$key} = $values->{$itemid}->{$key};
+ }
+ }
+ }
+ foreach my $inner ('name','lifetime','version') {
+ my $formitem = 'form.linkprot_'.$inner.'_'.$idx;
+ $env{$formitem} =~ s/(`)/'/g;
+ if ($inner eq 'lifetime') {
+ $env{$formitem} =~ s/[^\d.]//g;
+ }
+ unless ($idx eq 'add') {
+ if ($current{$inner} ne $env{$formitem}) {
+ $haschanges{$itemid} = 1;
+ }
+ }
+ if ($env{$formitem} ne '') {
+ $linkprot{$itemid}{$inner} = $env{$formitem};
+ }
+ }
+ if ($ltiauth) {
+ my $reqitem = 'form.linkprot_requser_'.$idx;
+ $env{$reqitem} =~ s/(`)/'/g;
+ unless ($idx eq 'add') {
+ if ((!$current{'requser'} && $env{$reqitem}) ||
+ ($current{'requser'} && !$env{$reqitem})) {
+ $haschanges{$itemid} = 1;
+ }
+ }
+ if ($env{$reqitem} == 1) {
+ $linkprot{$itemid}{'requser'} = $env{$reqitem};
+ foreach my $inner ('mapuser','notstudent') {
+ my $formitem = 'form.linkprot_'.$inner.'_'.$idx;
+ $env{$formitem} =~ s/(`)/'/g;
+ if ($inner eq 'mapuser') {
+ if ($env{$formitem} eq 'other') {
+ my $mapuser = $env{'form.linkprot_customuser_'.$idx};
+ $mapuser =~ s/(`)/'/g;
+ $mapuser =~ s/^\s+|\s+$//g;
+ if ($mapuser ne '') {
+ $linkprot{$itemid}{$inner} = $mapuser;
+ } else {
+ delete($linkprot{$itemid}{'requser'});
+ last;
+ }
+ } elsif ($env{$formitem} eq 'sourcedid') {
+ $linkprot{$itemid}{$inner} = 'lis_person_sourcedid';
+ } elsif ($env{$formitem} eq 'email') {
+ $linkprot{$itemid}{$inner} = 'lis_person_contact_email_primary';
+ }
+ } else {
+ $linkprot{$itemid}{$inner} = $env{$formitem};
+ }
+ unless ($idx eq 'add') {
+ if ($current{$inner} ne $linkprot{$itemid}{$inner}) {
+ $haschanges{$itemid} = 1;
+ }
+ }
+ }
+ }
+ }
+ unless ($switchserver) {
+ my $keyitem = 'form.linkprot_key_'.$idx;
+ $env{$keyitem} =~ s/(`)/'/g;
+ unless ($idx eq 'add') {
+ if ($current{'key'} ne $env{$keyitem}) {
+ $haschanges{$itemid} = 1;
+ }
+ }
+ if ($env{$keyitem} ne '') {
+ $linkprot{$itemid}{'key'} = $env{$keyitem};
+ }
+ my $secretitem = 'form.linkprot_secret_'.$idx;
+ $env{$secretitem} =~ s/(`)/'/g;
+ if ($current{'usable'}) {
+ if ($env{'form.linkprot_changesecret_'.$idx}) {
+ if ($env{$secretitem} ne '') {
+ if ($privnum && $cipher) {
+ $linkprot{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
+ $linkprot{$itemid}{'cipher'} = $privnum;
+ } else {
+ $linkprot{$itemid}{'secret'} = $env{$secretitem};
+ }
+ $haschanges{$itemid} = 1;
+ }
+ } else {
+ $linkprot{$itemid}{'secret'} = $current{'secret'};
+ }
+ } elsif ($env{$secretitem} ne '') {
+ if ($privnum && $cipher) {
+ $linkprot{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
+ $linkprot{$itemid}{'cipher'} = $privnum;
+ } else {
+ $linkprot{$itemid}{'secret'} = $env{$secretitem};
+ }
+ $haschanges{$itemid} = 1;
+ }
+ }
+ }
+ if (keys(%haschanges)) {
+ foreach my $entry (keys(%haschanges)) {
+ $changes->{$entry} = $linkprot{$entry};
+ }
+ }
+ return $errors;
+}
+
+sub get_linkprot_id {
+ my ($cdom,$cnum,$name,$context) = @_;
+ # get lock on lti db in course or linkprot db in domain
+ my $lockhash = {
+ lock => $env{'user.name'}.
+ ':'.$env{'user.domain'},
+ };
+ my $tries = 0;
+ my $gotlock;
+ if ($context eq 'domain') {
+ $gotlock = &Apache::lonnet::newput_dom('linkprot',$lockhash,$cdom);
+ } else {
+ $gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum);
+ }
+ my ($id,$error);
+ while (($gotlock ne 'ok') && ($tries<10)) {
+ $tries ++;
+ sleep (0.1);
+ if ($context eq 'domain') {
+ $gotlock = &Apache::lonnet::newput_dom('linkprot',$lockhash,$cdom);
+ } else {
+ $gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum);
+ }
+ }
+ if ($gotlock eq 'ok') {
+ my %currids;
+ if ($context eq 'domain') {
+ %currids = &Apache::lonnet::dump_dom('linkprot',$cdom);
+ } else {
+ %currids = &Apache::lonnet::dump('lti',$cdom,$cnum,undef,undef,undef,1);
+ }
+ if ($currids{'lock'}) {
+ delete($currids{'lock'});
+ if (keys(%currids)) {
+ my @curr = sort { $a <=> $b } keys(%currids);
+ if ($curr[-1] =~ /^\d+$/) {
+ $id = 1 + $curr[-1];
+ } else {
+ $id = 1;
+ }
+ } else {
+ $id = 1;
+ }
+ if ($id) {
+ if ($context eq 'domain') {
+ unless (&Apache::lonnet::newput_dom('linkprot',{ $id => $name },$cdom) eq 'ok') {
+ $error = 'nostore';
+ }
+ } else {
+ unless (&Apache::lonnet::newput('lti',{ $id => $name },$cdom,$cnum) eq 'ok') {
+ $error = 'nostore';
+ }
+ }
+ } else {
+ $error = 'nonumber';
+ }
+ }
+ my $dellockoutcome;
+ if ($context eq 'domain') {
+ $dellockoutcome = &Apache::lonnet::del_dom('linkprot',['lock'],$cdom);
+ } else {
+ $dellockoutcome = &Apache::lonnet::del('lti',['lock'],$cdom,$cnum);
+ }
+ } else {
+ $error = 'nolock';
+ }
+ return ($id,$error);
}
sub get_sec_str {
@@ -1362,8 +1787,12 @@ sub check_clone {
sub store_changes {
my ($cdom,$cnum,$prefs_order,$actions,$prefs,$values,$changes,$crstype) = @_;
my ($chome,$output);
- my (%storehash,@delkeys,@need_env_update,@oldcloner);
+ my (%storehash,@delkeys,@need_env_update,@oldcloner,%oldlinkprot);
if ((ref($values) eq 'HASH') && (ref($changes) eq 'HASH')) {
+ if (ref($values->{'linkprot'}) eq 'HASH') {
+ %oldlinkprot = %{$values->{'linkprot'}};
+ }
+ delete($values->{'linkprot'});
%storehash = %{$values};
} else {
if ($crstype eq 'Community') {
@@ -1373,6 +1802,20 @@ sub store_changes {
}
return $output;
}
+ my ($numchanges,$skipstore);
+ if (ref($changes) eq 'HASH') {
+ $numchanges = scalar(keys(%{$changes}));
+ if (($numchanges == 1) && (exists($changes->{'linkprot'}))) {
+ $skipstore = 1;
+ } elsif (!$numchanges) {
+ if ($crstype eq 'Community') {
+ $output = &mt('No changes made to community settings.');
+ } else {
+ $output = &mt('No changes made to course settings.');
+ }
+ return $output;
+ }
+ }
my %yesno = (
hidefromcat => '1',
problem_stream_switch => '1',
@@ -1398,6 +1841,8 @@ sub store_changes {
"'$storehash{$key}'")).'';
}
}
+ } elsif ($item eq 'linkprot') {
+ $output .= &store_linkprot($cdom,$cnum,'course',$changes->{$item},\%oldlinkprot);
} else {
if (ref($prefs->{$item}->{'ordered'}) eq 'ARRAY') {
my @settings = @{$prefs->{$item}->{'ordered'}};
@@ -1530,6 +1975,16 @@ sub store_changes {
}
}
$displayname = &mt($text);
+ } elsif ($item eq 'menuitems') {
+ unless ($changes->{$item}{$key} eq '') {
+ if ($key eq 'menudefault') {
+ $displayname = &mt('Default collection of menu items');
+ $displayval = &mt('Collection: [_1]',
+ $changes->{$item}{$key});
+ } elsif ($key eq 'menucollections') {
+ $displayval = &menucollections_display($changes->{$item}{$key});
+ }
+ }
} else {
$displayname = &mt($text);
}
@@ -1542,7 +1997,8 @@ sub store_changes {
$displayval = &Apache::lonlocal::locallocaltime($displayval);
} elsif ($key eq 'categories') {
$displayval = $env{'form.categories_display'};
- } elsif (($key eq 'canuse_pdfforms') || ($key eq 'usejsme') || ($key eq 'uselcmath')) {
+ } elsif (($key eq 'canuse_pdfforms') || ($key eq 'usejsme') ||
+ ($key eq 'uselcmath') || ($key eq 'inline_chem')) {
if ($changes->{$item}{$key} eq '1') {
$displayval = &mt('Yes');
} elsif ($changes->{$item}{$key} eq '0') {
@@ -1574,12 +2030,12 @@ sub store_changes {
}
}
unless (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
- if ($env{'form.pending_coowoner'} eq 'accept') {
+ if ($env{'form.pending_coowner'} eq 'accept') {
$displayval = &mt('on');
- } elsif ($env{'form.pending_coowoner'} eq 'decline') {
+ } elsif ($env{'form.pending_coowner'} eq 'decline') {
$displayval = '';
$output .= ''.&Apache::lonhtmlcommon::confirm_success(&mt('Invitation to be co-owner declined')).'';
- } elsif ($env{'form.remove_coowoner'}) {
+ } elsif ($env{'form.remove_coowner'}) {
$displayval = &mt('off');
}
if ($displayval) {
@@ -1605,10 +2061,19 @@ sub store_changes {
} elsif (!exists($changes->{$item}{'lti.override'})) {
$output .= ''.&mt('LTI settings only saved if Override is set to "Yes"').'';
}
+ } elsif ($item eq 'menuitems') {
+ if ($key eq 'menudefault') {
+ $output .= ''.&mt("Default collection of menu items set to: 'Standard' (all menus shown)").'';
+ } elsif ($key eq 'menucollections') {
+ $output .= ''.&mt('Specific collections of menus no longer available').'';
+ }
} else {
$output .= ''.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
''.$displayname.'')).'';
}
+ } elsif ($key eq 'menucollections') {
+ $output .= ''.&Apache::lonhtmlcommon::confirm_success(&mt('Numbered menu collections:')).' '.
+ $displayval.'';
} else {
$output .= ''.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
''.$displayname.'',
@@ -1666,6 +2131,9 @@ sub store_changes {
}
}
}
+ if ($skipstore) {
+ return $output;
+ }
if (&Apache::lonnet::put('environment',\%storehash,$cdom,$cnum) eq 'ok') {
if (ref($changes) eq 'HASH') {
if (ref($changes->{'courseinfo'}) eq 'HASH') {
@@ -1708,6 +2176,157 @@ sub store_changes {
return $output;
}
+sub store_linkprot {
+ my ($cdom,$cnum,$context,$changes,$oldlinkprot) = @_;
+ my ($ltiauth,$home,$lti_save_error,$output,$error,%ltienc,@deletions);
+ if ($context eq 'domain') {
+ $ltiauth = 1;
+ $home = &Apache::lonnet::domain($cdom,'primary');
+ } else {
+ $home = &Apache::lonnet::homeserver($cnum,$cdom);
+ if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
+ $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
+ } else {
+ my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
+ $ltiauth = $domdefs{'crsltiauth'};
+ }
+ }
+ if (ref($changes) eq 'HASH') {
+ foreach my $id (sort { $a <=> $b } keys(%{$changes})) {
+ if (ref($changes->{$id}) eq 'HASH') {
+ if (exists($changes->{$id}->{'key'})) {
+ $ltienc{$id}{'key'} = $changes->{$id}->{'key'};
+ delete($changes->{$id}->{'key'});
+ }
+ if (exists($changes->{$id}->{'secret'})) {
+ $ltienc{$id}{'secret'} = $changes->{$id}->{'secret'};
+ delete($changes->{$id}->{'secret'});
+ } elsif (ref($oldlinkprot->{$id}) eq 'HASH') {
+ if (exists($oldlinkprot->{$id}{'usable'})) {
+ $changes->{$id}->{'usable'} = 1;
+ }
+ }
+ }
+ }
+ }
+ my @ids=&Apache::lonnet::current_machine_ids();
+ if (keys(%ltienc) > 0) {
+ if ($context eq 'domain') {
+ foreach my $id (keys(%ltienc)) {
+ if (exists($ltienc{$id}{'secret'})) {
+ $changes->{$id}->{'usable'} = 1;
+ }
+ }
+ } else {
+ unless (($home eq 'no_host') || ($home eq '')) {
+ my $allowed;
+ foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
+ if ($allowed) {
+ if (&Apache::lonnet::put('nohist_ltienc',\%ltienc,$cdom,$cnum,1) eq 'ok') {
+ foreach my $id (keys(%ltienc)) {
+ if (exists($ltienc{$id}{'secret'})) {
+ $changes->{$id}->{'usable'} = 1;
+ }
+ }
+ } else {
+ $lti_save_error = 1;
+ }
+ }
+ }
+ }
+ }
+ unless ($lti_save_error) {
+ if ($context eq 'course') {
+ if (&Apache::lonnet::put('lti',$changes,$cdom,$cnum,1) eq 'ok') {
+ my $hashid=$cdom.'_'.$cnum;
+ &Apache::lonnet::devalidate_cache_new('courselti',$hashid);
+ unless (($home eq 'no_host') || ($home eq '')) {
+ if (grep(/^\Q$home\E$/,@ids)) {
+ &Apache::lonnet::devalidate_cache_new('courseltienc',$hashid);
+ }
+ }
+ } else {
+ $lti_save_error = 1;
+ }
+ }
+ unless ($lti_save_error) {
+ foreach my $id (sort { $a <=> $b } %{$changes}) {
+ if (ref($changes->{$id}) eq 'HASH') {
+ my %values = %{$changes->{$id}};
+ my %desc = &linkprot_names();
+ my $display;
+ foreach my $title ('name','lifetime','version','key','secret') {
+ if (($title eq 'key') || ($title eq 'secret')) {
+ if (ref($ltienc{$id}) eq 'HASH') {
+ if (exists($ltienc{$id}{$title})) {
+ if ($title eq 'secret') {
+ my $length = length($ltienc{$id}{$title});
+ $display .= $desc{$title}.': ['.&mt('not shown').'], ';
+ } else {
+ $display .= $desc{$title}.': '.$ltienc{$id}{$title}.', ';
+ }
+ }
+ }
+ } elsif ($title eq 'version') {
+ if ($values{$title} eq 'LTI-1p0') {
+ $display .= $desc{$title}.': 1.1, ';
+ }
+ } else {
+ $display .= $desc{$title}.': '.$values{$title}.', ';
+ }
+ }
+ if ($ltiauth) {
+ if (($values{'requser'}) && ($values{'mapuser'} ne '')) {
+ if ($values{'mapuser'} eq 'lis_person_contact_email_primary') {
+ $display .= &mt('Source of username: Email address [_1]',
+ '(lis_person_contact_email_primary)').', ';
+ } elsif ($values{'mapuser'} eq 'lis_person_sourcedid') {
+ $display .= &mt('Source of username: User ID [_1]',
+ '(lis_person_sourcedid)').', ';
+ } else {
+ $display .= &mt('Source of username: [_1]',$values{'mapuser'}).', ';
+ }
+ if ($values{'notstudent'} eq 'auth') {
+ $display .= &mt('Display LON-CAPA login page if no match').', ';
+ } elsif ($values{'notstudent'} eq 'reject') {
+ $display .= &mt('Discontinue launch if no match').', ';
+ }
+ }
+ }
+ $display =~ s/, $//;
+ $output .= ''.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',''.$id.'',
+ "'$display'")).'';
+ } elsif (ref($oldlinkprot->{$id}) eq 'HASH') {
+ my $oldname = $oldlinkprot->{$id}{'name'};
+ $output .= ''.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',''."$id ($oldname)".'')).'';
+ }
+ }
+ } else {
+ $lti_save_error = 1;
+ }
+ }
+ unless ($lti_save_error) {
+ foreach my $id (sort { $a <=> $b } keys(%{$changes})) {
+ unless (ref($changes->{$id}) eq 'HASH') {
+ push(@deletions,$id);
+ }
+ }
+ if (@deletions) {
+ if ($context eq 'course') {
+ &Apache::lonnet::del('nohist_ltienc',\@deletions,$cdom,$cnum);
+ }
+ }
+ }
+ if ($lti_save_error) {
+ $output .= ''.
+ ''.
+ &mt('An error occurred when saving changes to link protection settings, which remain unchanged.').
+ ''.
+ '';
+ }
+ return $output;
+}
+
sub update_env {
my ($cnum,$cdom,$chome,$need_env_update,$storehash) = @_;
my $count = 0;
@@ -1838,7 +2457,7 @@ sub get_course {
}
sub get_jscript {
- my ($cid,$cdom,$phase,$crstype,$settings) = @_;
+ my ($cid,$cdom,$phase,$crstype,$settings,$noedit) = @_;
my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
my ($jscript,$categorize_js,$loncaparev_js,$instcode_js);
my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript();
@@ -1964,11 +2583,95 @@ function syllabusinfo() {
}
}
ENDSCRIPT
+ my $menuitems_js;
+ unless ($noedit) {
+ my $collections;
+ my $next = 1;
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'menucollections'} ne '') {
+ my @current;
+ foreach my $item (split(/;/,$settings->{'menucollections'})) {
+ my ($num) = split(/\%/,$item);
+ if ($num =~ /^\d+$/) {
+ push(@current,$num);
+ }
+ }
+ $collections = join("','",sort { $a <=> $b } @current);
+ if ($collections) {
+ $collections = "'$collections'";
+ }
+ $next += $current[-1];
+ }
+ }
+ my $deftext = &mt('Standard (all menus shown)');
+ $menuitems_js = <'."\n".
'// '."\n".
+ $syllabus_js."\n".$menuitems_js."\n".
+ &linkprot_javascript()."\n".'//]]>'."\n".
''."\n".$stubrowse_js."\n";
return $jscript;
}
@@ -2054,6 +2757,68 @@ function getIndexByName(item) {
ENDSCRIPT
}
+sub linkprot_javascript {
+ return <<"ENDSCRIPT";
+function toggleLinkProt(form,num,item) {
+ var radioname = '';
+ var currdivid = '';
+ var newdivid = '';
+ if ((document.getElementById('linkprot_divcurr'+item+'_'+num)) &&
+ (document.getElementById('linkprot_divchg'+item+'_'+num))) {
+ currdivid = document.getElementById('linkprot_divcurr'+item+'_'+num);
+ newdivid = document.getElementById('linkprot_divchg'+item+'_'+num);
+ radioname = form.elements['linkprot_change'+item+'_'+num];
+ if (radioname) {
+ if (radioname.length > 0) {
+ var setvis;
+ for (var i=0; i 0) {
+ var setvis;
+ for (var i=0; i'.&mt('Discontinue?').'';
+ $output .= &mt('You are currently a co-owner:').' ';
} else {
- $output .= &mt('The course owner has invited you to become a co-owner:').' '.(' 'x2).
- '';
+ $output .= &mt('The course owner has invited you to become a co-owner:').' '.(' 'x2).
+ '';
}
$output .= '';
if (@currcoown) {
@@ -3671,8 +4436,8 @@ sub print_feedback {
}
if ($position eq 'top') {
my $includeempty = 0;
- $datatable .= ' | '.
- &user_table($cdom,$item,\@sections,
+ $datatable .= ' | '.
+ &user_table($cdom,$item,\@sections,
$settings->{$item},\%lt,$noedit);
} else {
$datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
@@ -3895,8 +4660,8 @@ sub print_discussion {
''.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
' ';
} elsif ($item eq 'plc.users.denied') {
- $datatable .= ' | '.
- &user_table($cdom,$item,undef,
+ $datatable .= ' | '.
+ &user_table($cdom,$item,undef,
$settings->{$item},\%lt,$noedit);
} elsif ($item eq 'pch.roles.denied') {
$datatable .= ' | '.
@@ -4266,6 +5031,10 @@ sub print_appearance {
text => ''.&mt($itemtext->{'usejsme'}).'',
input => 'radio',
},
+ 'inline_chem' => {
+ text => ''.&mt($itemtext->{'inline_chem'}).'',
+ input => 'radio',
+ },
);
return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance',$noedit);
}
@@ -4595,6 +5364,563 @@ sub ltimenu_titles {
);
}
+sub print_menuitems {
+ my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_;
+ unless ((ref($settings) eq 'HASH') && (ref($itemtext) eq 'HASH')) {
+ return;
+ }
+ if ($position eq 'top') {
+ my (%defaultmenu_options,@defaultmenu_order,$addcollection);
+ if ($settings->{'menucollections'} ne '') {
+ foreach my $item (split(/;/,$settings->{'menucollections'})) {
+ my ($num,$value) = split(/\%/,$item);
+ if ($num =~ /^\d+$/) {
+ $defaultmenu_options{$num} = $num;
+ }
+ }
+ @defaultmenu_order = sort { $a <=> $b } keys(%defaultmenu_options);
+ $addcollection = $defaultmenu_order[-1] + 1;
+ } else {
+ $addcollection = 1;
+ }
+ $defaultmenu_options{$addcollection} = $addcollection;
+ my %items = (
+ 'menudefault' => {
+ text => ''.&mt($itemtext->{'menudefault'}).' '.
+ &mt("(can be overriden in deep-link context)"),
+ input => 'selectbox',
+ options => \%defaultmenu_options,
+ order => \@defaultmenu_order,
+ nullval => &mt('Standard (all menus shown)'),
+ },
+ );
+ return &make_item_rows($cdom,\%items,['menudefault'],$settings,$rowtotal,$crstype,'menuitems',$noedit);
+ } else {
+ my %menu;
+ my $count = 0;
+ my $next = 1;
+ my ($datatable,$disabled);
+ if ($noedit) {
+ $disabled = ' disabled="disabled"';
+ }
+
+ my ($ordered,$cats) = &menuitems_categories();
+ my @order = @{$ordered};
+ my %categories = %{$cats};
+ my %menutitles = &menuitems_titles();
+ my %menufields = &menuitems_fields();
+
+ if ($settings->{'menucollections'} ne '') {
+ foreach my $item (split(/;/,$settings->{'menucollections'})) {
+ my ($num,$value) = split(/\%/,$item);
+ if ($num =~ /^\d+$/) {
+ my @entries = split(/\&/,$value);
+ foreach my $entry (@entries) {
+ my ($name,$fields) = split(/=/,$entry);
+ $menu{$num}{$name} = $fields;
+ }
+ }
+ }
+ if (keys(%menu)) {
+ my @current = sort { $a <=> $b } keys(%menu);
+ $next += $current[-1];
+ foreach my $num (@current) {
+ my %checked;
+ my $on = ' checked="checked"';
+ foreach my $key (keys(%{$menu{$num}})) {
+ if (($key eq 'top') || ($key eq 'inline') || ($key eq 'foot') || ($key eq 'main')) {
+ if ($menu{$num}{$key} eq 'y') {
+ $checked{$key} = $on;
+ }
+ } else {
+ foreach my $field (split(/,/,$menu{$num}{$key})) {
+ if (exists($menufields{$field})) {
+ $checked{$field} = $on;
+ }
+ }
+ }
+ }
+ if (ref($menu{$num}) eq 'HASH') {
+ $datatable .= &item_table_row_start(''.$num.'',$count,'','','','LC_left_item');
+ foreach my $category (@order) {
+ if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
+ $datatable .= '';
+ }
+ }
+ $datatable .= &item_table_row_end();
+ $count ++;
+ }
+ }
+ }
+ } elsif ($noedit) {
+ my $text = &mt('No menu collections defined for this course.');
+ $datatable .= &item_table_row_start($text,$count);
+ }
+ unless ($noedit) {
+ my $add = '';
+ $datatable .= &item_table_row_start($add,$count,'','','','LC_left_item');
+ foreach my $category (@order) {
+ if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
+ $datatable .= '';
+ }
+ }
+ $datatable .= &item_table_row_end();
+ $count ++;
+ }
+ return $datatable;
+ }
+}
+
+sub menuitems_abbreviations {
+ my %briefcats = (
+ text => 'pt',
+ links => 'p',
+ list => 'ps',
+ inline => 's',
+ );
+ return %briefcats;
+}
+
+sub menuitems_categories {
+ my @order = ('shown','text','links','list','inline');
+ my %categories = (
+ shown => ['top','inline','foot','main'],
+ text => ['name','role','crs','disc','fdbk'],
+ links => ['pers','logo','menu','comm','roles','help','logout'],
+ list => ['about','prefs','port','wish','anno','rss'],
+ inline => ['cont','grades','chat','people','groups','resv','syll','feeds'],
+ );
+ return (\@order,\%categories);
+}
+
+sub menuitems_titles {
+ return &Apache::lonlocal::texthash (
+ shown => 'Hierarchy',
+ text => 'Text',
+ links => 'Header links',
+ list => 'Drop-down list',
+ inline => 'Inline links',
+ );
+}
+
+sub menuitems_fields {
+ return &Apache::lonlocal::texthash (
+ top => 'Display header',
+ inline => 'Display inline menu',
+ foot => 'Display footer',
+ main => 'Access to main menu',
+ pers => 'Personal',
+ logo => 'LON-CAPA',
+ menu => 'Home',
+ comm => 'Messages',
+ roles => 'Roles/Courses',
+ help => 'Help',
+ logout => 'Logout',
+ name => 'Fullname',
+ crs => 'Course Title',
+ role => 'Current Role',
+ disc => 'Discussion',
+ fdbk => 'Feedback',
+ about => 'Information',
+ prefs => 'Preferences',
+ port => 'Portfolio',
+ wish => 'Stored Links',
+ anno => 'Calendar',
+ rss => 'RSS Feeds',
+ cont => 'Contents',
+ grades => 'Grades',
+ chat => 'Chat',
+ people => 'People',
+ groups => 'Groups',
+ resv => 'Reservations',
+ syll => 'Syllabus',
+ feeds => 'Feeds',
+ );
+}
+
+sub menucollections_display {
+ my ($collections) = @_;
+ my %menu;
+ my ($ordered,$cats) = &menuitems_categories();
+ my @order = @{$ordered};
+ my %categories = %{$cats};
+ my %menutitles = &menuitems_titles();
+ my %menufields = &menuitems_fields();
+ foreach my $item (split(/;/,$collections)) {
+ my ($num,$value) = split(/\%/,$item);
+ if ($num =~ /^\d+$/) {
+ my @entries = split(/\&/,$value);
+ foreach my $entry (@entries) {
+ my ($name,$fields) = split(/=/,$entry);
+ $menu{$num}{$name} = $fields;
+ }
+ }
+ }
+ my $output = '';
+ if (keys(%menu)) {
+ my @current = sort { $a <=> $b } keys(%menu);
+ foreach my $num (@current) {
+ my %checked;
+ foreach my $key (keys(%{$menu{$num}})) {
+ if (($key eq 'top') || ($key eq 'inline') || ($key eq 'foot') || ($key eq 'main')) {
+ if ($menu{$num}{$key} eq 'y') {
+ $checked{$key} = 1;
+ }
+ } else {
+ foreach my $field (split(/,/,$menu{$num}{$key})) {
+ if (exists($menufields{$field})) {
+ $checked{$field} = 1;
+ }
+ }
+ }
+ }
+ if (ref($menu{$num}) eq 'HASH') {
+ $output .= '';
+ }
+ }
+ }
+ return $output;
+}
+
+sub print_linkprotection {
+ my ($cdom,$cnum,$settings,$rowtotal,$crstype,$noedit,$context) = @_;
+
+ my %linkprotection;
+ my $count = 0;
+ my $next = 1;
+ my ($datatable,$disabled,$css_class,$dest);
+ if ($noedit) {
+ $disabled = ' disabled="disabled"';
+ }
+ my %desc = &linkprot_names();
+ my %lt = &Apache::lonlocal::texthash (
+ 'requ' => 'Required settings',
+ 'opti' => 'Optional settings',
+ );
+ my $itemcount = 0;
+
+ my $ltiauth;
+ if ($context eq 'domain') {
+ $ltiauth = 1;
+ } else {
+ if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
+ $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
+ } else {
+ my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
+ $ltiauth = $domdefs{'crsltiauth'};
+ }
+ }
+ if ($context eq 'domain') {
+ $dest = '/adm/domainprefs';
+ } else {
+ $dest = '/adm/courseprefs';
+ }
+
+ my ($switchserver,$switchmessage);
+ $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
+ if ($switchserver) {
+ if ($context eq 'domain') {
+ $switchmessage = &mt("submit from domain's primary library server: [_1].",$switchserver);
+ } elsif ($crstype eq 'Community') {
+ $switchmessage = &mt("submit from community's home server: [_1].",$switchserver);
+ } else {
+ $switchmessage = &mt("submit from course's home server: [_1].",$switchserver);
+ }
+ }
+
+ if ((ref($settings) eq 'HASH') && (ref($settings->{'linkprot'}) eq 'HASH')) {
+ if (keys(%{$settings->{'linkprot'}})) {
+ my @current = sort { $a <=> $b } keys(%{$settings->{'linkprot'}});
+ $next += $current[-1];
+ for (my $i=0; $i<@current; $i++) {
+ my $num = $current[$i];
+ my %values;
+ if (ref($settings->{'linkprot'}->{$num}) eq 'HASH') {
+ %values = %{$settings->{'linkprot'}->{$num}};
+ } else {
+ next;
+ }
+ my $selected;
+ if (($values{'version'} eq 'LTI-1p0') || ($values{'version'} eq '')) {
+ $selected = ' selected="selected"';
+ }
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .=
+ ' |